86 if (++fEventNumber % 100000 == 0 && fVerbose)
88 const auto msg = TString::Format(
89 "R3BNeulandCal2HitPar::Exec : Event: %10d, accepted Events: %10d", fEventNumber, fAcceptedEventNumber);
90 std::cout << msg <<
"\r" << std::flush;
92 std::cout <<
" cnts " << fIgorcnt0 <<
" ---- " << fIgorcnt1 <<
" ---- " << fIgorcnt2 <<
" " << std::endl;
103 LOG(debug) <<
"R3BNeulandCal2HitPar::Exec: Event " << fEventNumber - 1;
104 const auto nItems = fCalNeuland->GetEntriesFast();
108 LOG(debug) <<
" Event cannot be used: too few signals : " << nItems <<
"!";
112 fHitCalEngine->Reset();
113 fCosmicTracker->Reset();
115 Int_t addedPoints = 0;
117 for (Int_t i = 0; i < nItems; i++)
121 const auto id = pmt->
GetBarId() - 1;
122 const auto side = pmt->GetSide() - 1;
124 if (std::isnan(pmt->GetTriggerTime()))
126 fHitCalEngine->Set(
id, side, pmt->GetTime(), pmt->GetQdc());
130 fHitCalEngine->Set(
id, side, pmt->GetTime() - pmt->GetTriggerTime(), pmt->GetQdc());
133 if (fHitCalEngine->IsValid(
id))
136 fCosmicTracker->AddPoint(
id, fHitCalEngine->GetPosition(
id));
144 LOG(debug) <<
" Event cannot be used: too few Points : " << addedPoints <<
" (" << nItems <<
")!";
150 const auto& cosmicTrack = fCosmicTracker->GetTrack();
152 if (cosmicTrack.Interactions.size() == 0)
154 LOG(debug) <<
" Getting Cosmic Track : Failure!";
158 LOG(debug) <<
" Getting Cosmic Track: Success!";
159 ++fAcceptedEventNumber;
161 LOG(debug) <<
" Adding data to calibration";
162 fHitCalEngine->Add(cosmicTrack, fEventNumber);
167 LOG(info) <<
"R3BNeulandCal2HitPar::FinishTask: " <<
"Saved " << fAcceptedEventNumber <<
" Events.";
169 LOG(info) <<
"R3BNeulandCal2HitPar::FinishTask: " <<
"Starting Neuland Hit Calibration with "
170 << fAcceptedEventNumber <<
" Events.";
172 const auto batchMode = gROOT->IsBatch();
173 gROOT->SetBatch(kTRUE);
174 const auto defdir = gDirectory;
176 TDirectory* neulandDir =
nullptr;
178 neulandDir = defdir->mkdir(
"NeuLAND");
180 auto parameters = fHitCalEngine->Calibrate(neulandDir);
183 gROOT->SetBatch(batchMode);
185 fNeulandHitPar->GetListOfModulePar()->Clear();
187 auto maxThreshold = 0.;
188 for (
auto& parameter : parameters)
192 for (
auto side = 1; side <= 2; ++side)
194 const auto threshold =
195 parameter.GetPMTThreshold(side) * exp(
TotalBarLength / parameter.GetLightAttenuationLength());
196 if (threshold > maxThreshold)
197 maxThreshold = threshold;
201 fNeulandHitPar->SetEnergyCutoff(maxThreshold);
202 LOG(info) << TString::Format(
"R3BNeulandCal2HitPar::FinishTask: Recommended Minimum Energy Cutoff : >%4.2f MeV\n",
205 fNeulandHitPar->setChanged();
207 LOG(info) <<
"R3BNeulandCal2HitPar::FinishTask: " <<
"Number of calibrated Bars: "
208 << fNeulandHitPar->GetNumModulePar();