@@ -186,7 +186,7 @@ struct HfCorrelatorDplusHadrons {
186186
187187 Configurable<int > selectionFlagDplus{" selectionFlagDplus" , 7 , " Selection Flag for Dplus" }; // 7 corresponds to topo+PID cuts
188188 Configurable<int > numberEventsMixed{" numberEventsMixed" , 5 , " Number of events mixed in ME process" };
189- Configurable<bool > removeUnreconstructedGenCollisions{" removeUnreconstructedGenCollisions" ,true ," Remove generator-level collisions that were not reconstructed" };
189+ Configurable<bool > removeUnreconstructedGenCollisions{" removeUnreconstructedGenCollisions" , true , " Remove generator-level collisions that were not reconstructed" };
190190 Configurable<bool > removeCollWSplitVtx{" removeCollWSplitVtx" , true , " Flag for rejecting the splitted collisions" };
191191 Configurable<bool > useSel8{" useSel8" , true , " Flag for applying sel8 for collision selection" };
192192 Configurable<bool > selNoSameBunchPileUpColl{" selNoSameBunchPileUpColl" , true , " Flag for rejecting the collisions associated with the same bunch crossing" };
@@ -319,125 +319,124 @@ struct HfCorrelatorDplusHadrons {
319319 corrBinning = {{binsZVtx, binsMultiplicity}, true };
320320 }
321321
322- template <typename ParticleContainer, typename AssocContainer>
323- void runMcGenDplusHadronAnalysis (const ParticleContainer& particlesToLoop, const AssocContainer& groupedMcParticles, int poolBin, int & counterDplusHadron)
324- {
325- for (const auto & particle : particlesToLoop) {
322+ template <typename ParticleContainer, typename AssocContainer>
323+ void runMcGenDplusHadronAnalysis (const ParticleContainer& particlesToLoop, const AssocContainer& groupedMcParticles, int poolBin, int & counterDplusHadron)
324+ {
325+ for (const auto & particle : particlesToLoop) {
326326
327- if (std::abs (particle.pdgCode ()) != Pdg::kDPlus ) {
328- continue ;
329- }
327+ if (std::abs (particle.pdgCode ()) != Pdg::kDPlus ) {
328+ continue ;
329+ }
330330
331- if (std::abs (particle.flagMcMatchGen ()) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) {
332- continue ;
333- }
331+ if (std::abs (particle.flagMcMatchGen ()) != hf_decay::hf_cand_3prong::DecayChannelMain::DplusToPiKPi) {
332+ continue ;
333+ }
334334
335- double yD = RecoDecay::y (particle.pVector (), MassDPlus);
335+ double yD = RecoDecay::y (particle.pVector (), MassDPlus);
336336
337- if (std::abs (yD) > yCandGenMax ||
338- particle.pt () < ptCandMin ||
339- particle.pt () > ptCandMax) {
340- continue ;
341- }
337+ if (std::abs (yD) > yCandGenMax ||
338+ particle.pt () < ptCandMin ||
339+ particle.pt () > ptCandMax) {
340+ continue ;
341+ }
342342
343- std::vector<int > listDaughters{};
344- std::array<int , NDaughters> const arrDaughDplusPDG = {+kPiPlus , -kKPlus , kPiPlus };
345- std::array<int , NDaughters> prongsId{};
343+ std::vector<int > listDaughters{};
344+ std::array<int , NDaughters> const arrDaughDplusPDG = {+kPiPlus , -kKPlus , kPiPlus };
345+ std::array<int , NDaughters> prongsId{};
346346
347- RecoDecay::getDaughters (particle, &listDaughters, arrDaughDplusPDG, 2 );
347+ RecoDecay::getDaughters (particle, &listDaughters, arrDaughDplusPDG, 2 );
348348
349- if (listDaughters.size () != NDaughters) {
350- continue ;
351- }
349+ if (listDaughters.size () != NDaughters) {
350+ continue ;
351+ }
352352
353- bool isDaughtersOk = true ;
354- int counterDaughters = 0 ;
353+ bool isDaughtersOk = true ;
354+ int counterDaughters = 0 ;
355355
356- for (const auto & dauIdx : listDaughters) {
357- auto daughI = particlesToLoop.rawIteratorAt (dauIdx - particlesToLoop.offset ());
356+ for (const auto & dauIdx : listDaughters) {
357+ auto daughI = particlesToLoop.rawIteratorAt (dauIdx - particlesToLoop.offset ());
358358
359- if (std::abs (daughI.eta ()) >= EtaDaughtersMax) {
360- isDaughtersOk = false ;
361- break ;
359+ if (std::abs (daughI.eta ()) >= EtaDaughtersMax) {
360+ isDaughtersOk = false ;
361+ break ;
362+ }
363+
364+ prongsId[counterDaughters++] = daughI.globalIndex ();
362365 }
363366
364- prongsId[counterDaughters++] = daughI.globalIndex ();
365- }
367+ if (!isDaughtersOk) { // Skip this D+ candidate if any daughter fails eta cut
368+ continue ;
369+ }
370+ counterDplusHadron++;
371+
372+ registry.fill (HIST (" hDplusBin" ), poolBin);
373+ registry.fill (HIST (" hPtCandMCGen" ), particle.pt ());
374+ registry.fill (HIST (" hEtaMcGen" ), particle.eta ());
375+ registry.fill (HIST (" hPhiMcGen" ), RecoDecay::constrainAngle (particle.phi (), -PIHalf));
376+ registry.fill (HIST (" hYMCGen" ), yD);
377+
378+ // Prompt / Non-prompt separation
379+ bool isDplusPrompt = particle.originMcGen () == RecoDecay::OriginType::Prompt;
380+ bool isDplusNonPrompt = particle.originMcGen () == RecoDecay::OriginType::NonPrompt;
381+
382+ if (isDplusPrompt) {
383+ registry.fill (HIST (" hPtCandMcGenPrompt" ), particle.pt ());
384+ } else if (isDplusNonPrompt) {
385+ registry.fill (HIST (" hPtCandMcGenNonPrompt" ), particle.pt ());
386+ }
366387
367- if (!isDaughtersOk) { // Skip this D+ candidate if any daughter fails eta cut
368- continue ;
369- }
370- counterDplusHadron++;
371-
372- registry.fill (HIST (" hDplusBin" ), poolBin);
373- registry.fill (HIST (" hPtCandMCGen" ), particle.pt ());
374- registry.fill (HIST (" hEtaMcGen" ), particle.eta ());
375- registry.fill (HIST (" hPhiMcGen" ), RecoDecay::constrainAngle (particle.phi (), -PIHalf));
376- registry.fill (HIST (" hYMCGen" ), yD);
377-
378- // Prompt / Non-prompt separation
379- bool isDplusPrompt = particle.originMcGen () == RecoDecay::OriginType::Prompt;
380- bool isDplusNonPrompt = particle.originMcGen () == RecoDecay::OriginType::NonPrompt;
381-
382- if (isDplusPrompt) {
383- registry.fill (HIST (" hPtCandMcGenPrompt" ), particle.pt ());
384- } else if (isDplusNonPrompt) {
385- registry.fill (HIST (" hPtCandMcGenNonPrompt" ), particle.pt ());
386- }
388+ // Count triggers
389+ registry.fill (HIST (" hcountDplustriggersMCGen" ), 0 , particle.pt ());
387390
388- // Count triggers
389- registry.fill (HIST (" hcountDplustriggersMCGen" ), 0 , particle.pt ());
391+ for (const auto & particleAssoc : groupedMcParticles) {
390392
391- for (const auto & particleAssoc : groupedMcParticles) {
393+ if (std::abs (particleAssoc.eta ()) > etaTrackMax ||
394+ particleAssoc.pt () < ptTrackMin ||
395+ particleAssoc.pt () > ptTrackMax) {
396+ continue ;
397+ }
392398
393- if (std::abs (particleAssoc.eta ()) > etaTrackMax ||
394- particleAssoc.pt () < ptTrackMin ||
395- particleAssoc.pt () > ptTrackMax) {
396- continue ;
397- }
399+ // Remove daughters if requested
400+ if (removeDaughters) {
401+ if (particleAssoc.globalIndex () == prongsId[0 ] ||
402+ particleAssoc.globalIndex () == prongsId[1 ] ||
403+ particleAssoc.globalIndex () == prongsId[2 ]) {
404+ continue ;
405+ }
406+ }
398407
399- // Remove daughters if requested
400- if (removeDaughters) {
401- if (particleAssoc.globalIndex () == prongsId[0 ] ||
402- particleAssoc.globalIndex () == prongsId[1 ] ||
403- particleAssoc.globalIndex () == prongsId[2 ]) {
408+ // Particle species selection
409+ if ((std::abs (particleAssoc.pdgCode ()) != kElectron ) &&
410+ (std::abs (particleAssoc.pdgCode ()) != kMuonMinus ) &&
411+ (std::abs (particleAssoc.pdgCode ()) != kPiPlus ) &&
412+ (std::abs (particleAssoc.pdgCode ()) != kKPlus ) &&
413+ (std::abs (particleAssoc.pdgCode ()) != kProton )) {
404414 continue ;
405415 }
406- }
407416
408- // Particle species selection
409- if ((std::abs (particleAssoc.pdgCode ()) != kElectron ) &&
410- (std::abs (particleAssoc.pdgCode ()) != kMuonMinus ) &&
411- (std::abs (particleAssoc.pdgCode ()) != kPiPlus ) &&
412- (std::abs (particleAssoc.pdgCode ()) != kKPlus ) &&
413- (std::abs (particleAssoc.pdgCode ()) != kProton )) {
414- continue ;
415- }
417+ if (!particleAssoc.isPhysicalPrimary ()) {
418+ continue ;
419+ }
416420
417- if (!particleAssoc. isPhysicalPrimary ()) {
418- continue ;
419- }
421+ int trackOrigin = RecoDecay::getCharmHadronOrigin (groupedMcParticles,
422+ particleAssoc,
423+ true );
420424
421- int trackOrigin = RecoDecay::getCharmHadronOrigin (groupedMcParticles,
422- particleAssoc,
423- true );
424-
425- registry.fill (HIST (" hPtParticleAssocMcGen" ), particleAssoc.pt ());
426- entryDplusHadronPair (
427- getDeltaPhi (particleAssoc.phi (), particle.phi ()),
428- particleAssoc.eta () - particle.eta (),
429- particle.pt (),
430- particleAssoc.pt (),
431- poolBin
432- );
433-
434- entryDplusHadronRecoInfo (MassDPlus, true );
435- entryDplusHadronGenInfo (isDplusPrompt,
436- particleAssoc.isPhysicalPrimary (),
437- trackOrigin);
425+ registry.fill (HIST (" hPtParticleAssocMcGen" ), particleAssoc.pt ());
426+ entryDplusHadronPair (
427+ getDeltaPhi (particleAssoc.phi (), particle.phi ()),
428+ particleAssoc.eta () - particle.eta (),
429+ particle.pt (),
430+ particleAssoc.pt (),
431+ poolBin);
432+
433+ entryDplusHadronRecoInfo (MassDPlus, true );
434+ entryDplusHadronGenInfo (isDplusPrompt,
435+ particleAssoc.isPhysicalPrimary (),
436+ trackOrigin);
437+ }
438438 }
439439 }
440- }
441440
442441 // / Dplus-hadron correlation pair builder - for real data and data-like analysis (i.e. reco-level w/o matching request via MC truth)
443442 void processData (SelCollisionsWithDplus::iterator const & collision,
@@ -663,68 +662,67 @@ void runMcGenDplusHadronAnalysis(const ParticleContainer& particlesToLoop, const
663662 }
664663 PROCESS_SWITCH (HfCorrelatorDplusHadrons, processMcRec, " Process MC Reco mode" , true );
665664
666- // / Dplus-Hadron correlation pair builder - for MC gen-level analysis (no filter/selection, only true signal)
667- void processMcGen (CollisionsMc const & mcCollisions,
668- soa::Join<aod::Collisions, aod::FT0Mults, aod::EvSels, aod::McCollisionLabels> const & collisions,
669- CandDplusMcGen const & mcParticles)
670- {
671- BinningTypeMcGen const corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true };
672-
673- for (const auto & mcCollision : mcCollisions) {
665+ // / Dplus-Hadron correlation pair builder - for MC gen-level analysis (no filter/selection, only true signal)
666+ void processMcGen (CollisionsMc const & mcCollisions,
667+ soa::Join<aod::Collisions, aod::FT0Mults, aod::EvSels, aod::McCollisionLabels> const & collisions,
668+ CandDplusMcGen const & mcParticles)
669+ {
670+ BinningTypeMcGen const corrBinningMcGen{{binsZVtx, binsMultiplicityMc}, true };
674671
675- int counterDplusHadron = 0 ;
676- registry.fill (HIST (" hMCEvtCount" ), 0 );
672+ for (const auto & mcCollision : mcCollisions) {
677673
678- int poolBin = corrBinningMcGen. getBin ( std::make_tuple (mcCollision. posZ (), mcCollision. multMCFT0A ())) ;
679- registry.fill (HIST (" hMultFT0AMcGen " ), mcCollision. multMCFT0A () );
674+ int counterDplusHadron = 0 ;
675+ registry.fill (HIST (" hMCEvtCount " ), 0 );
680676
681- const auto groupedMcParticles = mcParticles. sliceBy (candMcGenPerMcCollision , mcCollision.globalIndex ( ));
682- const auto groupedCollisions = collisions. sliceBy (recoCollisionsPerMcCollision , mcCollision.globalIndex ());
677+ int poolBin = corrBinningMcGen. getBin ( std::make_tuple (mcCollision. posZ () , mcCollision.multMCFT0A () ));
678+ registry. fill ( HIST ( " hMultFT0AMcGen " ) , mcCollision.multMCFT0A ());
683679
684- if (removeUnreconstructedGenCollisions) {
680+ const auto groupedMcParticles = mcParticles.sliceBy (candMcGenPerMcCollision, mcCollision.globalIndex ());
681+ const auto groupedCollisions = collisions.sliceBy (recoCollisionsPerMcCollision, mcCollision.globalIndex ());
685682
686- if (groupedCollisions.size () < 1 ) {
687- continue ;
688- }
683+ if (removeUnreconstructedGenCollisions) {
689684
690- if (groupedCollisions.size () > 1 && removeCollWSplitVtx) {
691- continue ;
692- }
693-
694- for (const auto & collision : groupedCollisions) {
695-
696- if (useSel8 && !collision.sel8 ()) {
685+ if (groupedCollisions.size () < 1 ) {
697686 continue ;
698687 }
699688
700- if (std::abs (collision. posZ ()) > zVtxMax ) {
689+ if (groupedCollisions. size () > 1 && removeCollWSplitVtx ) {
701690 continue ;
702691 }
703692
704- if (selNoSameBunchPileUpColl &&
705- !(collision.selection_bit (o2::aod::evsel::kNoSameBunchPileup ))) {
706- continue ;
707- }
693+ for (const auto & collision : groupedCollisions) {
708694
709- if (!collision.has_mcCollision ()) {
710- registry.fill (HIST (" hFakeCollision" ), 0 .);
711- continue ;
695+ if (useSel8 && !collision.sel8 ()) {
696+ continue ;
697+ }
698+
699+ if (std::abs (collision.posZ ()) > zVtxMax) {
700+ continue ;
701+ }
702+
703+ if (selNoSameBunchPileUpColl &&
704+ !(collision.selection_bit (o2::aod::evsel::kNoSameBunchPileup ))) {
705+ continue ;
706+ }
707+
708+ if (!collision.has_mcCollision ()) {
709+ registry.fill (HIST (" hFakeCollision" ), 0 .);
710+ continue ;
711+ }
712+
713+ // MC particles with reconstructed-collision selection
714+ runMcGenDplusHadronAnalysis (groupedMcParticles, groupedMcParticles, poolBin, counterDplusHadron);
712715 }
713716
714- // MC particles with reconstructed-collision selection
717+ } else {
718+ // MC particles without reconstructed-collision selection (preliminary approval approach)
715719 runMcGenDplusHadronAnalysis (groupedMcParticles, groupedMcParticles, poolBin, counterDplusHadron);
716720 }
717721
718- }
719- else {
720- // MC particles without reconstructed-collision selection (preliminary approval approach)
721- runMcGenDplusHadronAnalysis (groupedMcParticles, groupedMcParticles, poolBin, counterDplusHadron);
722+ registry.fill (HIST (" hcountDplusHadronPerEvent" ), counterDplusHadron);
723+ registry.fill (HIST (" hZvtx" ), mcCollision.posZ ());
722724 }
723-
724- registry.fill (HIST (" hcountDplusHadronPerEvent" ), counterDplusHadron);
725- registry.fill (HIST (" hZvtx" ), mcCollision.posZ ());
726725 }
727- }
728726 PROCESS_SWITCH (HfCorrelatorDplusHadrons, processMcGen, " Process MC Gen mode" , false );
729727
730728 void processDataMixedEvent (SelCollisionsWithDplus const & collisions,
0 commit comments