@@ -87,14 +87,15 @@ struct Alice3HfTask3Prong {
8787 HistogramRegistry registry{" registry" , {}};
8888
8989 // Names of folders and suffixes for MC signal histograms
90- constexpr static std::string_view SignalFolders[] = {" signal" , " prompt" , " nonprompt" };
91- constexpr static std::string_view SignalSuffixes[] = {" " , " Prompt" , " NonPrompt" };
92-
9390 enum SignalClasses : int {
9491 Signal = 0 ,
9592 Prompt,
96- NonPrompt
93+ NonPrompt,
94+ Bkg,
95+ NSignalClasses
9796 };
97+ constexpr static std::string_view SignalFolders[SignalClasses::NSignalClasses] = {" signal" , " prompt" , " nonprompt" , " background" };
98+ constexpr static std::string_view SignalSuffixes[SignalClasses::NSignalClasses] = {" " , " Prompt" , " NonPrompt" , " Bkg" };
9899
99100 void init (InitContext&)
100101 {
@@ -109,9 +110,11 @@ struct Alice3HfTask3Prong {
109110 }
110111
111112 auto addHistogramsRec = [&](const std::string& histoName, const std::string& xAxisTitle, const std::string& yAxisTitle, const HistogramConfigSpec& configSpec) {
112- registry.add ((" MC/rec/signal/" + histoName + " RecSig" ).c_str (), (" 3-prong cands (matched);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
113- registry.add ((" MC/rec/prompt/" + histoName + " RecSigPrompt" ).c_str (), (" 3-prong cands (matched, prompt);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
114- registry.add ((" MC/rec/nonprompt/" + histoName + " RecSigNonPrompt" ).c_str (), (" 3-prong cands (matched, non-prompt);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
113+ const char * basePath = " MC/rec" ;
114+ registry.add (Form (" %s/signal/%sRecSig%s" ,basePath, histoName.c_str (), SignalSuffixes[SignalClasses::Signal].data ()), (" 3-prong cands (matched);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
115+ registry.add (Form (" %s/prompt/%sRecSig%s" , basePath, histoName.c_str (), SignalSuffixes[SignalClasses::Prompt].data ()), (" 3-prong cands (matched, prompt);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
116+ registry.add (Form (" %s/nonprompt/%sRecSig%s" , basePath, histoName.c_str (), SignalSuffixes[SignalClasses::NonPrompt].data ()), (" 3-prong cands (matched, non-prompt);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
117+ registry.add (Form (" %s/background/%sRecSig%s" , basePath, histoName.c_str (), SignalSuffixes[SignalClasses::Bkg].data ()), (" 3-prong cands (unmatched);" + xAxisTitle + " ;" + yAxisTitle).c_str (), configSpec);
115118 };
116119
117120 auto addHistogramsGen = [&](const std::string& histoName, const std::string& xAxisTitle, const std::string& yAxisTitle, const HistogramConfigSpec& configSpec) {
@@ -174,9 +177,16 @@ struct Alice3HfTask3Prong {
174177 auto h2 = registry.add <TH2>(" hSelectionStatus" , " 3-prong cands;selection status;entries" , {HistType::kTH2F , {{5 , -0.5 , 4.5 }, {vbins, " #it{p}_{T} (GeV/#it{c})" }}});
175178 h2->GetXaxis ()->SetBinLabel (1 , " mass hypo 0" );
176179 h2->GetXaxis ()->SetBinLabel (2 , " mass hypo 1" );
177- auto h = registry.add <TH1>(" MC/rec/hCandidateCounter" , " Candidate counter;entries" , {HistType::kTH1D , {{2 , -0.5 , 1 .5 }}});
180+ auto h = registry.add <TH1>(" MC/rec/hCandidateCounter" , " Candidate counter;entries" , {HistType::kTH1D , {{4 , -0.5 , 3 .5 }}});
178181 h->GetXaxis ()->SetBinLabel (1 , " Calls" );
179182 h->GetXaxis ()->SetBinLabel (2 , " Candidates" );
183+ h->GetXaxis ()->SetBinLabel (3 , " Passed Y cut" );
184+ h->GetXaxis ()->SetBinLabel (4 , " Has MC match" );
185+
186+ registry.add (" MC/rec/hPtDeltaProng0" , " ;prong 0 (#it{p}_{T}-#it{p}_{T, gen}) (GeV/#it{c});entries" , {HistType::kTH1F , {{100 , -5 , 5 .}}});
187+ registry.add (" MC/rec/hPtDeltaProng1" , " ;prong 1 (#it{p}_{T}-#it{p}_{T, gen}) (GeV/#it{c});entries" , {HistType::kTH1F , {{100 , -5 , 5 .}}});
188+ registry.add (" MC/rec/hPtDeltaProng2" , " ;prong 2 (#it{p}_{T}-#it{p}_{T, gen}) (GeV/#it{c});entries" , {HistType::kTH1F , {{100 , -5 , 5 .}}});
189+
180190 // Number of events processed
181191 h = registry.add <TH1>(" hNEventsProcessed" , " number of events processed;entries;" , {HistType::kTH1F , {{2 , 0.5 , 2.5 }}});
182192 h->GetXaxis ()->SetBinLabel (1 , " Generated" );
@@ -207,7 +217,7 @@ struct Alice3HfTask3Prong {
207217 // / Helper function for filling MC reconstructed histograms for prompt, nonpromt and common (signal)
208218 // / \param candidate is a reconstructed candidate
209219 // / \tparam SignalType is an enum defining which histogram in which folder (signal, prompt or nonpromt) to fill
210- template <CharmHadAlice3 CharmHad, int SignalType, typename CandidateType>
220+ template <CharmHadAlice3 CharmHad, SignalClasses SignalType, typename CandidateType>
211221 void fillHistogramsRecSig (CandidateType const & candidate, float mass, bool isSwapped = false )
212222 {
213223 static constexpr auto histoPrefix = HIST (" MC/rec/" ) + HIST (SignalFolders[SignalType]) + HIST (" /" );
@@ -268,33 +278,50 @@ struct Alice3HfTask3Prong {
268278 if (yCandRecoMax >= 0 . && std::abs (hfHelper.getCandY <CharmHad>(candidate)) > yCandRecoMax) {
269279 continue ;
270280 }
271- auto mcParticle = allParticles.iteratorAt (candidate.particleMcRec ());
272- if (candidate.particleMcRec () > 0 ) {
281+ registry.fill (HIST (" MC/rec/hCandidateCounter" ), 2 .);
282+ if (candidate.particleMcRec () >= 0 ) {
283+ registry.fill (HIST (" MC/rec/hCandidateCounter" ), 3 .);
284+ auto mcParticle = allParticles.iteratorAt (candidate.particleMcRec ());
273285 if (mcParticle.has_daughters ()) {
274286 auto daughters = mcParticle.daughtersIds ();
275- LOG (info) << " Reco candidate matched to MC particle with PDG " << mcParticle.pdgCode () << " daughters: " << daughters.size ();
276- for (auto dauId : daughters) {
287+ LOG (debug) << " Reco candidate matched to MC particle with PDG " << mcParticle.pdgCode () << " daughters: " << daughters.size ();
288+ int prongIdx = 0 ;
289+ for (int dauId = daughters[0 ]; dauId <= daughters[1 ]; dauId++) {
277290 auto dau = allParticles.iteratorAt (dauId);
278- LOG (info) << " dauId: " << dauId << " PDG: " << dau.pdgCode ();
291+ LOG (debug) << " dauId: " << dauId << " PDG: " << dau.pdgCode () << " with pT: " << dau.pt ();
292+ switch (prongIdx) {
293+ case 0 :
294+ registry.fill (HIST (" MC/rec/hPtDeltaProng0" ), candidate.ptProng0 () - dau.pt ());
295+ break ;
296+ case 1 :
297+ registry.fill (HIST (" MC/rec/hPtDeltaProng1" ), candidate.ptProng1 () - dau.pt ());
298+ break ;
299+ case 2 :
300+ registry.fill (HIST (" MC/rec/hPtDeltaProng2" ), candidate.ptProng2 () - dau.pt ());
301+ break ;
302+ default :
303+ break ;
304+ }
305+ prongIdx++;
279306 }
280307 }
281308 }
282309
283- if (candidate.flagMcRec () != 0 ) {
284- // Get the corresponding MC particle.
310+ if (candidate.flagMcRec () != 0 ) { // Particle is matched to MC truth
285311
312+ // Get the corresponding MC particle.
286313 const auto pt = candidate.pt ();
287314 const auto originType = candidate.originMcRec ();
288315
289316 if (candidate.isSelMassHypo0 ()) {
290317 registry.fill (HIST (" hSelectionStatus" ), 0 ., pt);
291318 double mass = hfHelper.getCandMass <CharmHad, false >(candidate);
292319 // / Fill histograms
293- fillHistogramsRecSig<CharmHad, Signal>(candidate, mass, false );
320+ fillHistogramsRecSig<CharmHad, SignalClasses:: Signal>(candidate, mass, false );
294321 if (originType == RecoDecay::OriginType::Prompt) {
295- fillHistogramsRecSig<CharmHad, Prompt>(candidate, mass, false );
322+ fillHistogramsRecSig<CharmHad, SignalClasses:: Prompt>(candidate, mass, false );
296323 } else if (originType == RecoDecay::OriginType::NonPrompt) {
297- fillHistogramsRecSig<CharmHad, NonPrompt>(candidate, mass, false );
324+ fillHistogramsRecSig<CharmHad, SignalClasses:: NonPrompt>(candidate, mass, false );
298325 }
299326 if (fillThn) {
300327 std::vector<double > valuesToFill{mass, pt};
@@ -312,11 +339,11 @@ struct Alice3HfTask3Prong {
312339 registry.fill (HIST (" hSelectionStatus" ), 1 ., pt);
313340 double mass = hfHelper.getCandMass <CharmHad, true >(candidate);
314341 // / Fill histograms
315- fillHistogramsRecSig<CharmHad, Signal>(candidate, mass, true );
342+ fillHistogramsRecSig<CharmHad, SignalClasses:: Signal>(candidate, mass, true );
316343 if (originType == RecoDecay::OriginType::Prompt) {
317- fillHistogramsRecSig<CharmHad, Prompt>(candidate, mass, true );
344+ fillHistogramsRecSig<CharmHad, SignalClasses:: Prompt>(candidate, mass, true );
318345 } else if (originType == RecoDecay::OriginType::NonPrompt) {
319- fillHistogramsRecSig<CharmHad, NonPrompt>(candidate, mass, true );
346+ fillHistogramsRecSig<CharmHad, SignalClasses:: NonPrompt>(candidate, mass, true );
320347 }
321348 if (fillThn) {
322349 std::vector<double > valuesToFill{mass, pt};
@@ -330,6 +357,15 @@ struct Alice3HfTask3Prong {
330357 registry.get <THnSparse>(HIST (" hSparseRec" ))->Fill (valuesToFill.data ());
331358 }
332359 }
360+ } else { // Background
361+ if (candidate.isSelMassHypo0 ()) {
362+ double mass = hfHelper.getCandMass <CharmHad, false >(candidate);
363+ fillHistogramsRecSig<CharmHad, SignalClasses::Bkg>(candidate, mass, false );
364+ }
365+ if (candidate.isSelMassHypo1 ()) {
366+ double mass = hfHelper.getCandMass <CharmHad, true >(candidate);
367+ fillHistogramsRecSig<CharmHad, SignalClasses::Bkg>(candidate, mass, true );
368+ }
333369 }
334370 }
335371 }
0 commit comments