Skip to content

Commit 53dde2b

Browse files
authored
properly define gmother in MC Gen
1 parent 3a0e9f1 commit 53dde2b

File tree

1 file changed

+75
-64
lines changed

1 file changed

+75
-64
lines changed

PWGHF/HFL/TableProducer/electronSelectionWithTpcEmcal.cxx

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ struct HfElectronSelectionWithTpcEmcal {
539539
{
540540
fillElectronTrack<false>(collision, tracks, emcClusters, matchedTracks, 0);
541541
}
542-
PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processData, "process Data info only", true);
542+
PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processData, "process Data info only", false);
543543
/// Electron selection - for MC reco-level analysis
544544
void processMcRec(McTableCollision const& mcCollision,
545545
McTableTracks const& mcTracks,
@@ -567,89 +567,99 @@ struct HfElectronSelectionWithTpcEmcal {
567567
bool isEmbPi0 = false;
568568

569569
// Check first mother
570-
auto const& mother = particleMc.mothers_first_as<aod::McParticles>();
571-
572-
if (std::abs(mother.pdgCode()) == kEta || std::abs(mother.pdgCode()) == kPi0 || std::abs(mother.pdgCode()) == kGamma) {
573-
registry.fill(HIST("hMcgenAllNonHfeElectron"), particleMc.pt());
574-
auto const& gmother = mother.mothers_first_as<aod::McParticles>();
575-
auto const& ggmother = gmother.mothers_first_as<aod::McParticles>();
576-
auto const& gggmother = ggmother.mothers_first_as<aod::McParticles>();
577-
578-
// cases to consider: eta->e, eta->pi0->e, eta->gamma->e, eta->pi0->gamma->e, pi0->e, pi0->gamma->e
579-
580-
//================= eta->e ======================================
581-
if (std::abs(mother.pdgCode()) == kEta) {
582-
if (mother.isPhysicalPrimary()) {
583-
if ((std::abs(gmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gmother.pdgCode()) < pdgCodeCharmMax) ||
584-
(std::abs(gmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gmother.pdgCode()) < pdgCodeBeautyMax)) {
585-
continue;
586-
}
587-
isEmbEta = true;
588-
}
589-
}
590-
//================= eta->pi0->e ======================================
570+
if (particleMc.has_mothers()) {
571+
auto const& mother = particleMc.mothers_first_as<aod::McParticles>();
591572

592-
if (std::abs(mother.pdgCode()) == kPi0) {
593-
if (mother.isPhysicalPrimary()) {
594-
if ((std::abs(gmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gmother.pdgCode()) < pdgCodeCharmMax) ||
595-
(std::abs(gmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gmother.pdgCode()) < pdgCodeBeautyMax)) {
596-
continue;
597-
}
598-
isEmbPi0 = true; // pi0 -> e
599-
}
573+
if (std::abs(mother.pdgCode()) == kEta || std::abs(mother.pdgCode()) == kPi0 || std::abs(mother.pdgCode()) == kGamma) {
574+
575+
registry.fill(HIST("hMcgenAllNonHfeElectron"), particleMc.pt());
576+
577+
auto const& gmother = mother.mothers_first_as<aod::McParticles>();
578+
// cases to consider: eta->e, eta->pi0->e, eta->gamma->e, eta->pi0->gamma->e, pi0->e, pi0->gamma->e
600579

601-
if (std::abs(gmother.pdgCode()) == kEta) {
602-
if (gmother.isPhysicalPrimary()) {
603-
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
604-
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
580+
//================= eta->e ======================================
581+
if (std::abs(mother.pdgCode()) == kEta) {
582+
583+
if (mother.isPhysicalPrimary()) {
584+
if ((std::abs(gmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gmother.pdgCode()) < pdgCodeCharmMax) ||
585+
(std::abs(gmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gmother.pdgCode()) < pdgCodeBeautyMax)) {
605586
continue;
606587
}
607-
isEmbEta = true; // eta->pi0-> e
588+
isEmbEta = true;
608589
}
609590
}
610-
}
611591

612-
/// ==================================== eta->gamma->e and eta->pi0->gamma->e============
613-
if (std::abs(mother.pdgCode()) == kGamma) {
614-
if (std::abs(gmother.pdgCode()) == kEta) {
615-
if (gmother.isPhysicalPrimary()) {
616-
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
617-
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
592+
//================= eta->pi0->e ======================================
593+
594+
if (std::abs(mother.pdgCode()) == kPi0) {
595+
if (mother.isPhysicalPrimary()) {
596+
if ((std::abs(gmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gmother.pdgCode()) < pdgCodeCharmMax) ||
597+
(std::abs(gmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gmother.pdgCode()) < pdgCodeBeautyMax)) {
618598
continue;
619599
}
620-
isEmbEta = true; // eta->gamma-> e
600+
isEmbPi0 = true; // pi0 -> e
601+
}
602+
if (std::abs(gmother.pdgCode()) == kEta) {
603+
if (gmother.isPhysicalPrimary() || gmother.has_mothers()) {
604+
auto const& ggmother = gmother.mothers_first_as<aod::McParticles>();
605+
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
606+
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
607+
continue;
608+
}
609+
isEmbEta = true; // eta->pi0-> e
610+
}
621611
}
622612
}
623613

624-
if (std::abs(gmother.pdgCode()) == kPi0) {
625-
if (gmother.isPhysicalPrimary()) {
626-
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
627-
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
628-
continue;
614+
/// ==================================== eta->gamma->e and eta->pi0->gamma->e============
615+
if (std::abs(mother.pdgCode()) == kGamma) {
616+
617+
if (std::abs(gmother.pdgCode()) == kEta) {
618+
if (gmother.isPhysicalPrimary() || gmother.has_mothers()) {
619+
auto const& ggmother = gmother.mothers_first_as<aod::McParticles>();
620+
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
621+
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
622+
continue;
623+
}
624+
isEmbEta = true; // eta->gamma-> e
629625
}
630-
isEmbPi0 = true; // pi0-> gamma-> e
631626
}
632627

633-
if (std::abs(ggmother.pdgCode()) == kEta) {
634-
if (ggmother.isPhysicalPrimary()) {
635-
if ((std::abs(gggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gggmother.pdgCode()) < pdgCodeCharmMax) ||
636-
(std::abs(gggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gggmother.pdgCode()) < pdgCodeBeautyMax)) {
628+
if (std::abs(gmother.pdgCode()) == kPi0) {
629+
if (gmother.isPhysicalPrimary() || gmother.has_mothers()) {
630+
auto const& ggmother = gmother.mothers_first_as<aod::McParticles>();
631+
if ((std::abs(ggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(ggmother.pdgCode()) < pdgCodeCharmMax) ||
632+
(std::abs(ggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(ggmother.pdgCode()) < pdgCodeBeautyMax)) {
637633
continue;
638634
}
639-
isEmbEta = true; // eta->pi0->gamma-> e
635+
isEmbPi0 = true; // pi0-> gamma-> e
636+
}
637+
if (gmother.has_mothers()) {
638+
auto const& ggmother = gmother.mothers_first_as<aod::McParticles>();
639+
if (std::abs(ggmother.pdgCode()) == kEta) {
640+
if (ggmother.isPhysicalPrimary() || ggmother.has_mothers()) {
641+
auto const& gggmother = ggmother.mothers_first_as<aod::McParticles>();
642+
if ((std::abs(gggmother.pdgCode()) >= pdgCodeCharmMin && std::abs(gggmother.pdgCode()) < pdgCodeCharmMax) ||
643+
(std::abs(gggmother.pdgCode()) >= pdgCodeBeautyMin && std::abs(gggmother.pdgCode()) < pdgCodeBeautyMax)) {
644+
continue;
645+
}
646+
isEmbEta = true; // eta->pi0->gamma-> e
647+
}
648+
}
640649
}
641650
}
642651
}
643-
}
644-
if (isEmbPi0 || isEmbEta) {
645-
registry.fill(HIST("hMcgenNonHfeElectron"), particleMc.pt());
646-
isNonHfe = true;
647-
if (isEmbPi0) {
648652

649-
registry.fill(HIST("hPi0eEmbTrkPt"), particleMc.pt());
650-
}
651-
if (isEmbEta) {
652-
registry.fill(HIST("hEtaeEmbTrkPt"), particleMc.pt());
653+
if (isEmbPi0 || isEmbEta) {
654+
registry.fill(HIST("hMcgenNonHfeElectron"), particleMc.pt());
655+
isNonHfe = true;
656+
if (isEmbPi0) {
657+
658+
registry.fill(HIST("hPi0eEmbTrkPt"), particleMc.pt());
659+
}
660+
if (isEmbEta) {
661+
registry.fill(HIST("hEtaeEmbTrkPt"), particleMc.pt());
662+
}
653663
}
654664
}
655665
}
@@ -659,8 +669,9 @@ struct HfElectronSelectionWithTpcEmcal {
659669
}
660670
}
661671

662-
PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processMcGen, "Process MC Gen mode", false);
672+
PROCESS_SWITCH(HfElectronSelectionWithTpcEmcal, processMcGen, "Process MC Gen mode", true);
663673
};
674+
664675
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
665676
{
666677
return WorkflowSpec{adaptAnalysisTask<HfElectronSelectionWithTpcEmcal>(cfgc)};

0 commit comments

Comments
 (0)