Skip to content

Commit 022eca8

Browse files
authored
[PWGEM/PhotonMeson] update TaggingPi0 (#12882)
1 parent 3b43850 commit 022eca8

File tree

2 files changed

+103
-35
lines changed

2 files changed

+103
-35
lines changed

PWGEM/PhotonMeson/Core/TaggingPi0.h

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ using namespace o2::aod::pwgem::photon;
6464
using namespace o2::aod::pwgem::dilepton::utils::emtrackutil;
6565
using namespace o2::aod::pwgem::dilepton::utils;
6666

67-
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec, aod::EMEventsWeight>;
67+
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMEventsQvec>;
6868
using MyCollision = MyCollisions::iterator;
6969

70+
using MyCollisionsWithJJMC = soa::Join<MyCollisions, aod::EMEventsWeight>;
71+
using MyCollisionWithJJMC = MyCollisionsWithJJMC::iterator;
72+
7073
using MyV0Photons = soa::Join<aod::V0PhotonsKF, aod::V0KFEMEventIds>;
7174
using MyV0Photon = MyV0Photons::iterator;
7275

@@ -465,7 +468,12 @@ struct TaggingPi0 {
465468
initCCDB(collision);
466469
int ndiphoton = 0;
467470

468-
if (eventcuts.onlyKeepWeightedEvents && std::fabs(collision.weight() - 1.f) < 1e-10) {
471+
float weight = 1.f;
472+
if constexpr (std::is_same_v<std::decay_t<TCollisions>, FilteredMyCollisionsWithJJMC>) {
473+
weight = collision.weight();
474+
}
475+
476+
if (eventcuts.onlyKeepWeightedEvents && std::fabs(weight - 1.f) < 1e-10) {
469477
continue;
470478
}
471479

@@ -474,13 +482,13 @@ struct TaggingPi0 {
474482
continue;
475483
}
476484

477-
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, collision.weight());
485+
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, weight);
478486
if (!fEMEventCut.IsSelected(collision)) {
479487
continue;
480488
}
481-
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, collision.weight());
482-
fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, collision.weight()); // accepted
483-
fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, collision.weight()); // accepted
489+
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, weight);
490+
fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, weight); // accepted
491+
fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, weight); // accepted
484492

485493
int zbin = lower_bound(zvtx_bin_edges.begin(), zvtx_bin_edges.end(), collision.posZ()) - zvtx_bin_edges.begin() - 1;
486494
if (zbin < 0) {
@@ -537,8 +545,8 @@ struct TaggingPi0 {
537545
auto pos1 = g1.template posTrack_as<TSubInfos1>();
538546
auto ele1 = g1.template negTrack_as<TSubInfos1>();
539547
ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.);
540-
fRegistry.fill(HIST("Photon/hPt"), v_gamma.Pt(), collision.weight());
541-
fRegistry.fill(HIST("Photon/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight());
548+
fRegistry.fill(HIST("Photon/hPt"), v_gamma.Pt(), weight);
549+
fRegistry.fill(HIST("Photon/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight);
542550

543551
for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) {
544552

@@ -561,7 +569,7 @@ struct TaggingPi0 {
561569
ROOT::Math::PtEtaPhiMVector v_ele(ele2.pt(), ele2.eta(), ele2.phi(), o2::constants::physics::MassElectron);
562570
ROOT::Math::PtEtaPhiMVector v_ee = v_pos + v_ele;
563571
ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele;
564-
fRegistry.fill(HIST("Pair/same/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight());
572+
fRegistry.fill(HIST("Pair/same/hMvsPt"), veeg.M(), v_gamma.Pt(), weight);
565573

566574
std::pair<int, int> pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex());
567575
std::tuple<int, int, int, int> tuple_tmp_id2 = std::make_tuple(ndf, collision.globalIndex(), pos2.trackId(), ele2.trackId());
@@ -588,7 +596,7 @@ struct TaggingPi0 {
588596
ROOT::Math::PtEtaPhiMVector v2(g2.pt(), g2.eta(), g2.phi(), 0.);
589597
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
590598

591-
fRegistry.fill(HIST("Pair/same/hMvsPt"), v12.M(), v1.Pt(), collision.weight());
599+
fRegistry.fill(HIST("Pair/same/hMvsPt"), v12.M(), v1.Pt(), weight);
592600

593601
std::pair<int, int> pair_tmp_id1 = std::make_pair(ndf, g1.globalIndex());
594602
std::pair<int, int> pair_tmp_id2 = std::make_pair(ndf, g2.globalIndex());
@@ -643,7 +651,7 @@ struct TaggingPi0 {
643651
v2.SetM(g2.mass());
644652
}
645653
ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
646-
fRegistry.fill(HIST("Pair/mix/hMvsPt"), v12.M(), v1.Pt(), collision.weight());
654+
fRegistry.fill(HIST("Pair/mix/hMvsPt"), v12.M(), v1.Pt(), weight);
647655
}
648656
}
649657
} // end of loop over mixed event pool
@@ -687,9 +695,36 @@ struct TaggingPi0 {
687695
// }
688696
ndf++;
689697
}
690-
PROCESS_SWITCH(TaggingPi0, processAnalysis, "process pair analysis", false);
698+
PROCESS_SWITCH(TaggingPi0, processAnalysis, "process pair analysis", true);
699+
700+
using FilteredMyCollisionsWithJJMC = soa::Filtered<MyCollisionsWithJJMC>;
701+
void processAnalysisJJMC(FilteredMyCollisionsWithJJMC const& collisions, Types const&... args)
702+
{
703+
// LOGF(info, "ndf = %d", ndf);
704+
if constexpr (pairtype == PairType::kPCMDalitzEE) {
705+
auto v0photons = std::get<0>(std::tie(args...));
706+
auto v0legs = std::get<1>(std::tie(args...));
707+
auto emprimaryelectrons = std::get<2>(std::tie(args...));
708+
// LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size());
709+
runPairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut);
710+
}
711+
// else if constexpr (pairtype == PairType::kPCMEMC) {
712+
// auto v0photons = std::get<0>(std::tie(args...));
713+
// auto v0legs = std::get<1>(std::tie(args...));
714+
// auto emcclusters = std::get<2>(std::tie(args...));
715+
// auto emcmatchedtracks = std::get<3>(std::tie(args...));
716+
// runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr);
717+
// } else if constexpr (pairtype == PairType::kPCMPHOS) {
718+
// auto v0photons = std::get<0>(std::tie(args...));
719+
// auto v0legs = std::get<1>(std::tie(args...));
720+
// auto phosclusters = std::get<2>(std::tie(args...));
721+
// runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr);
722+
// }
723+
ndf++;
724+
}
725+
PROCESS_SWITCH(TaggingPi0, processAnalysisJJMC, "process pair analysis", false);
691726

692727
void processDummy(MyCollisions const&) {}
693-
PROCESS_SWITCH(TaggingPi0, processDummy, "Dummy function", true);
728+
PROCESS_SWITCH(TaggingPi0, processDummy, "Dummy function", false);
694729
};
695730
#endif // PWGEM_PHOTONMESON_CORE_TAGGINGPI0_H_

PWGEM/PhotonMeson/Core/TaggingPi0MC.h

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ using namespace o2::aod::pwgem::photonmeson::photonpair;
5656
using namespace o2::aod::pwgem::photonmeson::utils::mcutil;
5757
using namespace o2::aod::pwgem::dilepton::utils::mcutil;
5858

59-
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMMCEventLabels, aod::EMEventsWeight>;
59+
using MyCollisions = soa::Join<aod::EMEvents, aod::EMEventsMult, aod::EMEventsCent, aod::EMMCEventLabels>;
6060
using MyCollision = MyCollisions::iterator;
6161

62+
using MyCollisionsWithJJMC = soa::Join<MyCollisions, aod::EMEventsWeight>;
63+
using MyCollisionWithJJMC = MyCollisionsWithJJMC::iterator;
64+
6265
using MyMCCollisions = soa::Join<aod::EMMCEvents, aod::BinnedGenPts>;
6366
using MyMCCollision = MyMCCollisions::iterator;
6467

@@ -429,7 +432,12 @@ struct TaggingPi0MC {
429432
for (const auto& collision : collisions) {
430433
initCCDB(collision);
431434

432-
if (eventcuts.onlyKeepWeightedEvents && std::fabs(collision.weight() - 1.f) < 1e-10) {
435+
float weight = 1.f;
436+
if constexpr (std::is_same_v<std::decay_t<TCollisions>, FilteredMyCollisionsWithJJMC>) {
437+
weight = collision.weight();
438+
}
439+
440+
if (eventcuts.onlyKeepWeightedEvents && std::fabs(weight - 1.f) < 1e-10) {
433441
continue;
434442
}
435443

@@ -438,13 +446,13 @@ struct TaggingPi0MC {
438446
continue;
439447
}
440448

441-
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, collision.weight());
449+
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<0>(&fRegistry, collision, weight);
442450
if (!fEMEventCut.IsSelected(collision)) {
443451
continue;
444452
}
445-
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, collision.weight());
446-
fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, collision.weight()); // accepted
447-
fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, collision.weight()); // accepted
453+
o2::aod::pwgem::photonmeson::utils::eventhistogram::fillEventInfo<1>(&fRegistry, collision, weight);
454+
fRegistry.fill(HIST("Event/before/hCollisionCounter"), 12.0, weight); // accepted
455+
fRegistry.fill(HIST("Event/after/hCollisionCounter"), 12.0, weight); // accepted
448456

449457
if constexpr (pairtype == PairType::kPCMDalitzEE) {
450458
auto photons1_per_collision = photons1.sliceBy(perCollision1, collision.globalIndex());
@@ -457,8 +465,8 @@ struct TaggingPi0MC {
457465
}
458466

459467
ROOT::Math::PtEtaPhiMVector v_gamma(g1.pt(), g1.eta(), g1.phi(), 0.f);
460-
fRegistry.fill(HIST("Photon/candidate/hPt"), v_gamma.Pt(), collision.weight());
461-
fRegistry.fill(HIST("Photon/candidate/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight());
468+
fRegistry.fill(HIST("Photon/candidate/hPt"), v_gamma.Pt(), weight);
469+
fRegistry.fill(HIST("Photon/candidate/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight);
462470

463471
auto pos1 = g1.template posTrack_as<TSubInfos1>();
464472
auto ele1 = g1.template negTrack_as<TSubInfos1>();
@@ -475,13 +483,13 @@ struct TaggingPi0MC {
475483
}
476484

477485
if (g1mc.isPhysicalPrimary() || g1mc.producedByGenerator()) {
478-
fRegistry.fill(HIST("Photon/primary/hPt"), v_gamma.Pt(), collision.weight());
479-
fRegistry.fill(HIST("Photon/primary/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight());
486+
fRegistry.fill(HIST("Photon/primary/hPt"), v_gamma.Pt(), weight);
487+
fRegistry.fill(HIST("Photon/primary/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight);
480488
if (g1mc.has_mothers()) {
481489
auto mp = g1mc.template mothers_first_as<TMCParticles>();
482490
if (std::abs(mp.pdgCode()) == 111) {
483-
fRegistry.fill(HIST("Photon/fromPi0/hPt"), v_gamma.Pt(), collision.weight());
484-
fRegistry.fill(HIST("Photon/fromPi0/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight());
491+
fRegistry.fill(HIST("Photon/fromPi0/hPt"), v_gamma.Pt(), weight);
492+
fRegistry.fill(HIST("Photon/fromPi0/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight);
485493
}
486494
}
487495
} else if (IsFromWD(g1mc.template emmcevent_as<TMCCollisions>(), g1mc, mcparticles) > 0) {
@@ -491,11 +499,11 @@ struct TaggingPi0MC {
491499
if (std::abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) {
492500
weight = f1fd_k0s_to_pi0->Eval(str_had.pt());
493501
}
494-
fRegistry.fill(HIST("Photon/fromWD/hPt"), v_gamma.Pt(), collision.weight() * weight);
495-
fRegistry.fill(HIST("Photon/fromWD/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight() * weight);
502+
fRegistry.fill(HIST("Photon/fromWD/hPt"), v_gamma.Pt(), weight * weight);
503+
fRegistry.fill(HIST("Photon/fromWD/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight * weight);
496504
} else {
497-
fRegistry.fill(HIST("Photon/fromHS/hPt"), v_gamma.Pt(), collision.weight());
498-
fRegistry.fill(HIST("Photon/fromHS/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), collision.weight());
505+
fRegistry.fill(HIST("Photon/fromHS/hPt"), v_gamma.Pt(), weight);
506+
fRegistry.fill(HIST("Photon/fromHS/hEtaPhi"), v_gamma.Phi() > 0 ? v_gamma.Phi() : v_gamma.Phi() + 2 * M_PI, v_gamma.Eta(), weight);
499507
}
500508

501509
for (const auto& [pos2, ele2] : combinations(CombinationsFullIndexPolicy(positrons_per_collision, electrons_per_collision))) { // ULS
@@ -529,17 +537,17 @@ struct TaggingPi0MC {
529537
ROOT::Math::PtEtaPhiMVector veeg = v_gamma + v_pos + v_ele;
530538

531539
if (pi0mc.isPhysicalPrimary() || pi0mc.producedByGenerator()) {
532-
fRegistry.fill(HIST("Pair/primary/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight());
540+
fRegistry.fill(HIST("Pair/primary/hMvsPt"), veeg.M(), v_gamma.Pt(), weight);
533541
} else if (IsFromWD(pi0mc.template emmcevent_as<TMCCollisions>(), pi0mc, mcparticles) > 0) {
534542
int motherid_strhad = IsFromWD(pi0mc.template emmcevent_as<TMCCollisions>(), pi0mc, mcparticles);
535543
auto str_had = mcparticles.iteratorAt(motherid_strhad);
536544
float weight = 1.f;
537545
if (std::abs(str_had.pdgCode()) == 310 && f1fd_k0s_to_pi0 != nullptr) {
538546
weight = f1fd_k0s_to_pi0->Eval(str_had.pt());
539547
}
540-
fRegistry.fill(HIST("Pair/fromWD/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight() * weight);
548+
fRegistry.fill(HIST("Pair/fromWD/hMvsPt"), veeg.M(), v_gamma.Pt(), weight * weight);
541549
} else {
542-
fRegistry.fill(HIST("Pair/fromHS/hMvsPt"), veeg.M(), v_gamma.Pt(), collision.weight());
550+
fRegistry.fill(HIST("Pair/fromHS/hMvsPt"), veeg.M(), v_gamma.Pt(), weight);
543551
}
544552

545553
} // end of dielectron loop
@@ -557,7 +565,7 @@ struct TaggingPi0MC {
557565
// ROOT::Math::PtEtaPhiMVector v12 = v1 + v2;
558566
// if (pi0id > 0) {
559567
// auto pi0mc = mcparticles.iteratorAt(pi0id);
560-
// o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, collision.weight());
568+
// o2::aod::pwgem::photonmeson::utils::nmhistogram::fillTruePairInfo(&fRegistry, v12, pi0mc, mcparticles, mccollisions, f1fd_k0s_to_pi0, weight);
561569
// }
562570
} // end of pairing loop
563571
} // end of pairing in same event
@@ -591,9 +599,34 @@ struct TaggingPi0MC {
591599
// runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr);
592600
// }
593601
}
594-
PROCESS_SWITCH(TaggingPi0MC, processAnalysis, "process pair analysis", false);
602+
PROCESS_SWITCH(TaggingPi0MC, processAnalysis, "process pair analysis", true);
603+
604+
using FilteredMyCollisionsWithJJMC = soa::Filtered<MyCollisionsWithJJMC>;
605+
void processAnalysisJJMC(FilteredMyCollisionsWithJJMC const& collisions, MyMCCollisions const& mccollisions, aod::EMMCParticles const& mcparticles, Types const&... args)
606+
{
607+
if constexpr (pairtype == PairType::kPCMDalitzEE) {
608+
auto v0photons = std::get<0>(std::tie(args...));
609+
auto v0legs = std::get<1>(std::tie(args...));
610+
auto emprimaryelectrons = std::get<2>(std::tie(args...));
611+
// LOGF(info, "electrons.size() = %d, positrons.size() = %d", electrons.size(), positrons.size());
612+
runTruePairing(collisions, v0photons, emprimaryelectrons, v0legs, emprimaryelectrons, perCollision_pcm, perCollision_electron, fV0PhotonCut, fDileptonCut, mccollisions, mcparticles);
613+
}
614+
// else if constexpr (pairtype == PairType::kPCMEMC) {
615+
// auto v0photons = std::get<0>(std::tie(args...));
616+
// auto v0legs = std::get<1>(std::tie(args...));
617+
// auto emcclusters = std::get<2>(std::tie(args...));
618+
// auto emcmatchedtracks = std::get<3>(std::tie(args...));
619+
// runPairing(collisions, v0photons, emcclusters, v0legs, nullptr, perCollision_pcm, perCollision_emc, fV0PhotonCut, fEMCCut, emcmatchedtracks, nullptr);
620+
// } else if constexpr (pairtype == PairType::kPCMPHOS) {
621+
// auto v0photons = std::get<0>(std::tie(args...));
622+
// auto v0legs = std::get<1>(std::tie(args...));
623+
// auto phosclusters = std::get<2>(std::tie(args...));
624+
// runPairing(collisions, v0photons, phosclusters, v0legs, nullptr, perCollision_pcm, perCollision_phos, fV0PhotonCut, fPHOSCut, nullptr, nullptr);
625+
// }
626+
}
627+
PROCESS_SWITCH(TaggingPi0MC, processAnalysisJJMC, "process pair analysis", false);
595628

596629
void processDummy(MyCollisions const&) {}
597-
PROCESS_SWITCH(TaggingPi0MC, processDummy, "Dummy function", true);
630+
PROCESS_SWITCH(TaggingPi0MC, processDummy, "Dummy function", false);
598631
};
599632
#endif // PWGEM_PHOTONMESON_CORE_TAGGINGPI0MC_H_

0 commit comments

Comments
 (0)