50Double_t
Score(
const std::vector<std::pair<R3BNeulandNeutron, FairMCPoint>>& combination)
52 return std::accumulate(combination.begin(),
55 [](
const Double_t sum,
const std::pair<R3BNeulandNeutron, FairMCPoint>&
pair)
56 { return sum + Distance(pair.first, pair.second); });
62 std::function<
bool(
const U&,
const U&)> comparator)
64 std::vector<std::vector<std::pair<T, U>>> out;
67 if (ts.size() < us.size())
71 if (us.size() < ts.size())
76 std::sort(us.begin(), us.end(), comparator);
79 std::vector<std::pair<T, U>> tmp;
80 for (
size_t i = 0; i < ts.size(); i++)
82 tmp.push_back({ ts.at(i), us.at(i) });
84 out.push_back(std::move(tmp));
85 }
while (std::next_permutation(us.begin(), us.end(), comparator));
102 FairRootManager* ioman = FairRootManager::Instance();
105 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init: No FairRootManager";
110 if (
dynamic_cast<TClonesArray*
>(ioman->GetObject(fInput)) ==
nullptr)
112 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init No " << fInput <<
"!";
115 if (!TString((
dynamic_cast<TClonesArray*
>(ioman->GetObject(fInput)))->GetClass()->GetName())
116 .EqualTo(
"R3BNeulandNeutron"))
118 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init Branch " << fInput
119 <<
" does not contain "
120 "R3BNeulandNeutrons!";
123 fReconstructedNeutrons =
dynamic_cast<TClonesArray*
>(ioman->GetObject(fInput));
126 if (
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"NeulandPrimaryPoints")) ==
nullptr)
128 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init No NeulandPrimaryPoints!";
131 if (!TString((
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"NeulandPrimaryPoints")))->GetClass()->GetName())
132 .EqualTo(
"R3BNeulandPoint"))
134 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init Branch NeulandPrimaryPoints "
135 "does not contain R3BNeulandPoint!";
138 fPrimaryNeutronInteractionPoints =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"NeulandPrimaryPoints"));
141 if (
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack")) ==
nullptr)
143 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init No MCTrack!";
146 if (!TString((
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack")))->GetClass()->GetName())
147 .EqualTo(
"R3BMCTrack"))
149 LOG(fatal) <<
"R3BNeulandNeutronReconstructionMon::Init Branch MCTrack "
150 "does not contain FairMCPoints!";
153 fMCTracks =
dynamic_cast<TClonesArray*
>(ioman->GetObject(
"MCTrack"));
155 TH1::AddDirectory(kFALSE);
157 fhScore =
new TH1D(
"fhScore",
"Neuland Neutron Reconstruction Score (lower is better)", 5000, 0, 5000);
158 fhCountN =
new TH1D(
"fhCountN",
"Number of reconstructed Neutrons", 11, -0.5, 10.5);
160 new TH1D(
"fhCountNdiff",
"Number of reacted primary Neutrons - Number of reconstructed Neutrons", 11, -5, 5);
161 fhEdiff =
new TH1D(
"fhEdiff",
"Energy of primary Neutron - Energy of reconstructed Neutron", 2001, -1000, 1000);
163 fhErel =
new TH1D(
"fhErel",
"fhErel", 5000, 0, 5000);
164 fhErelMC =
new TH1D(
"fhErelMC",
"fhErelMC", 5000, 0, 5000);
165 fhErelVSnNreco =
new TH2D(
"fhErelVSnNreco",
"fhErelVSnNreco", 5000, 0, 5000, 11, -0.5, 10.5);
167 fhErelVSnNrecoNPNIPs =
new TH2D(
"fhErelVSnNrecoNPNIPs",
"fhErelVSnNrecoNPNIPs", 5000, 0, 5000, 11, -0.5, 10.5);
169 fhNreacNreco =
new TH2D(
"fhNreacNreco",
"fhNreacNreco", 11, -0.5, 10.5, 11, -0.5, 10.5);
170 fhNreacNreco->GetXaxis()->SetTitle(
"nReac");
171 fhNreacNreco->GetYaxis()->SetTitle(
"nReco");
178 const Int_t nReconstructedNeutrons = fReconstructedNeutrons->GetEntries();
179 std::vector<R3BNeulandNeutron> neutrons;
180 neutrons.reserve(nReconstructedNeutrons);
181 for (Int_t i = 0; i < nReconstructedNeutrons; i++)
183 neutrons.push_back(*(
dynamic_cast<R3BNeulandNeutron*
>(fReconstructedNeutrons->At(i))));
186 const Int_t nNPNIPS = fPrimaryNeutronInteractionPoints->GetEntries();
187 std::vector<R3BNeulandPoint> npnips;
188 npnips.reserve(nReconstructedNeutrons);
189 for (Int_t i = 0; i < nNPNIPS; i++)
191 npnips.push_back(*(
dynamic_cast<R3BNeulandPoint*
>(fPrimaryNeutronInteractionPoints->At(i))));
193 fhCountN->Fill(nReconstructedNeutrons);
194 fhCountNdiff->Fill((Int_t)nNPNIPS - (Int_t)nReconstructedNeutrons);
195 fhNreacNreco->Fill(nNPNIPS, nReconstructedNeutrons);
238 TLorentzVector p4_reco;
239 Double_t m0_reco = 0;
241 TLorentzVector p4_mc;
244 TLorentzVector p4_npnips;
245 Double_t m0_npnips = 0;
247 for (
const auto& neutron : neutrons)
249 p4_reco += TLorentzVector(neutron.GetP(), neutron.GetEtot());
253 for (
const auto& npnip : npnips)
257 p4_npnips += TLorentzVector(MCTrack->
GetPx() * 1000.,
258 MCTrack->
GetPy() * 1000.,
259 MCTrack->
GetPz() * 1000.,
261 m0_npnips += MCTrack->
GetMass() * 1000.;
265 const Int_t nMCTracks = fMCTracks->GetEntries();
266 for (Int_t i = 0; i < nMCTracks; i++)
268 MCTrack =
dynamic_cast<R3BMCTrack*
>(fMCTracks->At(i));
281 p4_reco += TLorentzVector(MCTrack->
GetPx() * 1000.,
282 MCTrack->
GetPy() * 1000.,
283 MCTrack->
GetPz() * 1000.,
285 m0_reco += MCTrack->
GetMass() * 1000.;
287 p4_npnips += TLorentzVector(MCTrack->
GetPx() * 1000.,
288 MCTrack->
GetPy() * 1000.,
289 MCTrack->
GetPz() * 1000.,
291 m0_npnips += MCTrack->
GetMass() * 1000.;
295 p4_mc += TLorentzVector(MCTrack->
GetPx() * 1000.,
296 MCTrack->
GetPy() * 1000.,
297 MCTrack->
GetPz() * 1000.,
299 m0_mc += MCTrack->
GetMass() * 1000.;
302 const Double_t minv = p4_reco.Mag() - m0_reco;
303 fhErel->Fill(minv * 1000.);
304 fhErelVSnNreco->Fill(minv * 1000., nReconstructedNeutrons);
306 if (fhmErelnReco[nReconstructedNeutrons] ==
nullptr)
308 fhmErelnReco[nReconstructedNeutrons] =
new TH1D(
"fhErel" + TString::Itoa(nReconstructedNeutrons, 10),
309 "fhErel" + TString::Itoa(nReconstructedNeutrons, 10),
314 fhmErelnReco.at(nReconstructedNeutrons)->Fill(minv * 1000.);
316 const Double_t minv_mc = p4_mc.Mag() - m0_mc;
317 fhErelMC->Fill(minv_mc * 1000.);
319 const Double_t minv_npnips = p4_npnips.Mag() - m0_npnips;
320 fhErelVSnNrecoNPNIPs->Fill(minv_npnips * 1000., nNPNIPS);