Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Implement particle filtering for neuland simulation" #1086

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Labiche, Marc
Lagni, Andrea
Lihtar, Ivana
Loeher, Bastian
Lonzen, Simon
Milhomens da Fonseca, Leandro
Mozumdar, Nikhil
Panin, Valerii
Expand Down
7 changes: 3 additions & 4 deletions neuland/digitizing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set(SRCS
R3BDigitizingPaddleNeuland.cxx
R3BNeulandHitMon.cxx
R3BNeulandDigitizer.cxx
R3BNeulandHitMon.cxx
NeulandPointFilter.cxx)
R3BDigitizingPaddleMock.h
R3BDigitizingChannelMock.h)

set(HEADERS
R3BDigitizingChannel.h
Expand All @@ -31,8 +31,7 @@ set(HEADERS
R3BDigitizingTacQuila.h
R3BDigitizingTamex.h
R3BNeulandDigitizer.h
R3BNeulandHitMon.h
NeulandPointFilter.h)
R3BNeulandHitMon.h)

add_library_with_dictionary(
LIBNAME
Expand Down
18 changes: 0 additions & 18 deletions neuland/digitizing/NeulandPointFilter.cxx

This file was deleted.

94 changes: 0 additions & 94 deletions neuland/digitizing/NeulandPointFilter.h

This file was deleted.

105 changes: 52 additions & 53 deletions neuland/digitizing/R3BNeulandDigitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#include "FairRootManager.h"
#include "FairRunAna.h"
#include "FairRuntimeDb.h"
#include "NeulandPointFilter.h"
#include "R3BDataMonitor.h"
#include "TGeoManager.h"
#include "TGeoNode.h"
#include "TH1F.h"
Expand All @@ -28,25 +26,28 @@
#include <TFile.h>
#include <iostream>
#include <stdexcept>
#include <string_view>
#include <utility>

R3BNeulandDigitizer::R3BNeulandDigitizer()
: R3BNeulandDigitizer(Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<TacquilaChannel>())

)
R3BNeulandDigitizer::R3BNeulandDigitizer(TString input, TString output)
: R3BNeulandDigitizer(Digitizing::CreateEngine(UsePaddle<NeulandPaddle>(), UseChannel<TacquilaChannel>()),
std::move(input),
std::move(output))
{
}

R3BNeulandDigitizer::R3BNeulandDigitizer(std::unique_ptr<Digitizing::DigitizingEngineInterface> engine)
R3BNeulandDigitizer::R3BNeulandDigitizer(std::unique_ptr<Digitizing::DigitizingEngineInterface> engine,
TString input,
TString output)
: FairTask("R3BNeulandDigitizer")
, digitizing_engine_(std::move(engine))
, fPoints(std::move(input))
, fHits(std::move(output))
, fDigitizingEngine(std::move(engine))
{
}

void R3BNeulandDigitizer::SetEngine(std::unique_ptr<Digitizing::DigitizingEngineInterface> engine)
{
digitizing_engine_ = std::move(engine);
fDigitizingEngine = std::move(engine);
}

void R3BNeulandDigitizer::SetParContainers()
Expand All @@ -63,64 +64,48 @@ void R3BNeulandDigitizer::SetParContainers()
LOG(fatal) << "R3BNeulandDigitizer::SetParContainers: No runtime database";
}

neuland_geo_par_ = dynamic_cast<R3BNeulandGeoPar*>(rtdb->getContainer("R3BNeulandGeoPar"));
if (neuland_geo_par_ == nullptr)
fNeulandGeoPar = dynamic_cast<R3BNeulandGeoPar*>(rtdb->getContainer("R3BNeulandGeoPar"));
if (fNeulandGeoPar == nullptr)
{
LOG(fatal) << "R3BNeulandDigitizer::SetParContainers: No R3BNeulandGeoPar";
}

digitizing_engine_->Init();
fDigitizingEngine->Init();
}

void R3BNeulandDigitizer::SetNeulandPointFilter(R3B::Neuland::BitSetParticle particle)
{
neuland_point_filter_.SetFilter(particle);
}
void R3BNeulandDigitizer::SetNeulandPointFilter(R3B::Neuland::BitSetParticle particle,
double minimum_allowed_energy_gev)
InitStatus R3BNeulandDigitizer::Init()
{
neuland_point_filter_.SetFilter(particle, minimum_allowed_energy_gev);
}
fPoints.Init();
fHits.Init();

auto R3BNeulandDigitizer::Init() -> InitStatus
{
neuland_points_.init();
neuland_hits_.init();
// Initialize control histograms
auto const PaddleMulSize = 3000;
mult_one_ = data_monitor_.add_hist<TH1I>(
hMultOne = R3B::root_owned<TH1I>(
"MultiplicityOne", "Paddle multiplicity: only one PMT per paddle", PaddleMulSize, 0, PaddleMulSize);

mult_two_ = data_monitor_.add_hist<TH1I>(
hMultTwo = R3B::root_owned<TH1I>(
"MultiplicityTwo", "Paddle multiplicity: both PMTs of a paddle", PaddleMulSize, 0, PaddleMulSize);
auto const timeBinSize = 200;
rl_time_to_trig_ = data_monitor_.add_hist<TH1F>("hRLTimeToTrig", "R/Ltime-triggerTime", timeBinSize, -100., 100.);
hRLTimeToTrig = R3B::root_owned<TH1F>("hRLTimeToTrig", "R/Ltime-triggerTime", timeBinSize, -100., 100.);

return kSUCCESS;
}

void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
{
neuland_hits_.clear();
fHits.Reset();
const auto GeVToMeVFac = 1000.;

std::map<UInt_t, Double_t> paddleEnergyDeposit;
// Look at each Land Point, if it deposited energy in the scintillator, store it with reference to the bar
for (const auto& point : neuland_points_)
for (const auto& point : fPoints.Retrieve())
{
if (((neuland_point_filter_.GetFilter() != R3B::Neuland::BitSetParticle::none) or
(neuland_point_filter_.GetMinimumAllowedEnergy() != 0)) and
neuland_point_filter_.CheckFiltered(point))
if (point->GetEnergyLoss() > 0.)
{
continue;
}
if (point.GetEnergyLoss() > 0.)
{
const Int_t paddleID = point.GetPaddle();
const Int_t paddleID = point->GetPaddle();

// Convert position of point to paddle-coordinates, including any rotation or translation
const TVector3 position = point.GetPosition();
const TVector3 converted_position = neuland_geo_par_->ConvertToLocalCoordinates(position, paddleID);
const TVector3 position = point->GetPosition();
const TVector3 converted_position = fNeulandGeoPar->ConvertToLocalCoordinates(position, paddleID);
LOG(debug2) << "NeulandDigitizer: Point in paddle " << paddleID
<< " with global position XYZ: " << position.X() << " " << position.Y() << " " << position.Z();
LOG(debug2) << "NeulandDigitizer: Converted to local position XYZ: " << converted_position.X() << " "
Expand All @@ -129,22 +114,22 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
// Within the paddle frame, the relevant distance of the light from the pmt is always given by the
// X-Coordinate
const Double_t dist = converted_position.X();
digitizing_engine_->DepositLight(paddleID, point.GetTime(), point.GetLightYield() * GeVToMeVFac, dist);
paddleEnergyDeposit[paddleID] += point.GetEnergyLoss() * GeVToMeVFac;
fDigitizingEngine->DepositLight(paddleID, point->GetTime(), point->GetLightYield() * GeVToMeVFac, dist);
paddleEnergyDeposit[paddleID] += point->GetEnergyLoss() * GeVToMeVFac;
} // eloss
} // points

const Double_t triggerTime = digitizing_engine_->GetTriggerTime();
const auto paddles = digitizing_engine_->ExtractPaddles();
const Double_t triggerTime = fDigitizingEngine->GetTriggerTime();
const auto paddles = fDigitizingEngine->ExtractPaddles();

// Fill control histograms
mult_one_->Fill(static_cast<int>(std::count_if(
hMultOne->Fill(static_cast<int>(std::count_if(
paddles.begin(), paddles.end(), [](const auto& keyValue) { return keyValue.second->HasHalfFired(); })));

mult_two_->Fill(static_cast<int>(std::count_if(
hMultTwo->Fill(static_cast<int>(std::count_if(
paddles.begin(), paddles.end(), [](const auto& keyValue) { return keyValue.second->HasFired(); })));

rl_time_to_trig_->Fill(triggerTime);
hRLTimeToTrig->Fill(triggerTime);

// Create Hits
for (const auto& [paddleID, paddle] : paddles)
Expand All @@ -159,8 +144,8 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
for (const auto signal : signals)
{
const TVector3 hitPositionLocal = TVector3(signal.position, 0., 0.);
const TVector3 hitPositionGlobal = neuland_geo_par_->ConvertToGlobalCoordinates(hitPositionLocal, paddleID);
const TVector3 hitPixel = neuland_geo_par_->ConvertGlobalToPixel(hitPositionGlobal);
const TVector3 hitPositionGlobal = fNeulandGeoPar->ConvertToGlobalCoordinates(hitPositionLocal, paddleID);
const TVector3 hitPixel = fNeulandGeoPar->ConvertGlobalToPixel(hitPositionGlobal);

R3BNeulandHit hit(paddleID,
signal.leftChannel.tdc,
Expand All @@ -172,16 +157,30 @@ void R3BNeulandDigitizer::Exec(Option_t* /*option*/)
hitPositionGlobal,
hitPixel);

if (neuland_hit_filters_.IsValid(hit))
if (fHitFilters.IsValid(hit))
{
neuland_hits_.get().emplace_back(std::move(hit));
fHits.Insert(std::move(hit));
LOG(debug) << "Adding neuland hit with id = " << paddleID << ", time = " << signal.time
<< ", energy = " << signal.energy;
}
} // loop over all hits for each paddle
} // loop over paddles

LOG(debug) << "R3BNeulandDigitizer: produced " << neuland_hits_.get().size() << " hits";
LOG(debug) << "R3BNeulandDigitizer: produced " << fHits.Size() << " hits";
}

void R3BNeulandDigitizer::Finish()
{
TDirectory* tmp = gDirectory;
FairRootManager::Instance()->GetOutFile()->cd();

gDirectory->mkdir("R3BNeulandDigitizer");
gDirectory->cd("R3BNeulandDigitizer");

hMultOne->Write();
hMultTwo->Write();

gDirectory = tmp;
}

ClassImp(R3BNeulandDigitizer); // NOLINT
Loading