From 3d1240fc8e0e7b1378ed8720ac76b2ea22b289ac Mon Sep 17 00:00:00 2001 From: SuJeong Ji <120470463+SuJeong-Ji@users.noreply.github.com> Date: Sat, 25 Oct 2025 17:15:37 +0900 Subject: [PATCH 1/4] Add histograms and functions for calculating correction factors --- PWGLF/Tasks/Resonances/chk892pp.cxx | 603 ++++++++++++++++++---------- 1 file changed, 386 insertions(+), 217 deletions(-) diff --git a/PWGLF/Tasks/Resonances/chk892pp.cxx b/PWGLF/Tasks/Resonances/chk892pp.cxx index e888723a6b3..cc7b3e60730 100644 --- a/PWGLF/Tasks/Resonances/chk892pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892pp.cxx @@ -25,6 +25,7 @@ #include // #include // FIXME #include "PWGLF/DataModel/LFStrangenessTables.h" +#include "PWGLF/DataModel/mcCentrality.h" #include "PWGLF/Utils/collisionCuts.h" #include "PWGLF/Utils/inelGt.h" @@ -63,6 +64,7 @@ #include "TVector2.h" #include #include // FIXME +#include "TParticlePDG.h" #include #include @@ -82,19 +84,19 @@ using namespace o2::aod::rctsel; namespace { -template -inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) -{ - if (!v0.has_mcParticle()) - return false; - auto mcPart = v0.template mcParticle_as(); - if (mcPart.pdgCode() != kK0Short) - return false; - ptgen = mcPart.pt(); - ygen = mcPart.y(); - return true; -} -} // namespace + template + inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) + { + if (!v0.has_mcParticle()) + return false; + auto mcPart = v0.template mcParticle_as(); + if (mcPart.pdgCode() != kK0Short) + return false; + ptgen = mcPart.pt(); + ygen = mcPart.y(); + return true; + } +}// namespace struct Chk892pp { enum BinType : unsigned int { @@ -107,9 +109,18 @@ struct Chk892pp { kTYEnd }; + enum EvtStep { + kAll=0, + kZvtx, + kINELgt0, + kAssocReco, + kNSteps + }; + SliceCache cache; Preslice perCollision = aod::track::collisionId; - Preslice perCollisionV0 = aod::v0data::collisionId; + Preslice perCollisionV0 = aod::v0data::collisionId; + Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; using EventCandidates = soa::Join; using TrackCandidates = soa::Join; @@ -164,7 +175,7 @@ struct Chk892pp { Configurable cfgincludeCentralityMC{"cfgincludeCentralityMC", false, "Include centrality in MC"}; Configurable cfgEvtCollInTimeRangeStandard{"cfgEvtCollInTimeRangeStandard", false, "Evt sel: apply NoCollInTimeRangeStandard"}; Configurable cfgEventCentralityMin{"cfgEventCentralityMin", 0.0f, "Event sel: minimum centrality"}; - Configurable cfgEventCentralityMax{"cfgEventCentralityMax", 80.0f, "Event sel: maximum centrality"}; + Configurable cfgEventCentralityMax{"cfgEventCentralityMax", 100.0f, "Event sel: maximum centrality"}; Configurable cfgEvtUseRCTFlagChecker{"cfgEvtUseRCTFlagChecker", false, "Evt sel: use RCT flag checker"}; Configurable cfgEvtRCTFlagCheckerLabel{"cfgEvtRCTFlagCheckerLabel", "CBT_hadronPID", "Evt sel: RCT flag checker label"}; Configurable cfgEvtRCTFlagCheckerZDCCheck{"cfgEvtRCTFlagCheckerZDCCheck", false, "Evt sel: RCT flag checker ZDC check"}; @@ -172,7 +183,7 @@ struct Chk892pp { } EventCuts; RCTFlagsChecker rctChecker; - Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; + Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; /// PID Selections, pion @@ -250,6 +261,9 @@ struct Chk892pp { Configurable cfgNrotBkg{"cfgNrotBkg", 4, "Number of rotated copies (background) per each original candidate"}; } BkgEstimationConfig; + Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; + Configurable cfgTruthIncludeZvtx{"cfgTruthIncludeZvtx", true, "Truth denominator: also require |vtxz|(HIST("Correction/setSizes")); + hset->GetXaxis()->SetBinLabel(1, "refClassIds"); + hset->GetXaxis()->SetBinLabel(2, "allowedMcIds"); + hset->GetXaxis()->SetBinLabel(3, "intersection"); + hset->GetXaxis()->SetBinLabel(4, "allowed-only"); + + histos.add("Correction/hNEventsMCTruth", "hNEventsMCTruth", HistType::kTH1F, {AxisSpec{kNSteps, 0.5, kNSteps + 0.5, ""}}); + auto hstep = histos.get(HIST("Correction/hNEventsMCTruth")); + hstep->GetXaxis()->SetBinLabel(1, "All"); + hstep->GetXaxis()->SetBinLabel(2, "zvtx"); + hstep->GetXaxis()->SetBinLabel(3, "INEL>0"); + hstep->GetXaxis()->SetBinLabel(4, "Assoc with reco coll"); } ccdb->setURL(CCDBConfig.cfgURL); @@ -453,27 +489,6 @@ struct Chk892pp { } } - template - int getlDetId(DetNameType const& name) - { - LOGF(info, "GetDetID running"); - if (name.value == "FT0C") { - return 0; - } else if (name.value == "FT0A") { - return 1; - } else if (name.value == "FT0M") { - return 2; - } else if (name.value == "FV0A") { - return 3; - } else if (name.value == "TPCpos") { - return 4; - } else if (name.value == "TPCneg") { - return 5; - } else { - return false; - } - } - // Track selection template bool trackCut(TrackType const& track) @@ -689,62 +704,103 @@ struct Chk892pp { } std::unordered_set allowedMcIds; - std::unordered_map centByMcIds; + std::unordered_map centTruthByAllowed; + std::unordered_set refClassIds; + std::unordered_map refCentByMcId; - void buildAllowedMcIds(MCEventCandidates const& events) + template + void buildAllowedMcIds(RecoEventsT const& events) { allowedMcIds.clear(); - centByMcIds.clear(); + centTruthByAllowed.clear(); for (const auto& coll : events) { - lCentrality = getCentrality(coll); - histos.fill(HIST("QACent_woCut"), lCentrality); - histos.fill(HIST("QAvtxz_woCut"), coll.posZ()); + //lCentrality = getCentrality(coll); + + if (!coll.has_mcCollision()) + continue; + + const auto mcid = coll.mcCollisionId(); + const auto mccoll = coll.template mcCollision_as>(); + + const float lCentrality = mccoll.centFT0M(); + + if (doprocessMC){ + histos.fill(HIST("QACent_woCut"), lCentrality); + histos.fill(HIST("QAvtxz_woCut"), coll.posZ()); + } if (!colCuts.isSelected(coll)) continue; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(coll)) + continue; if (!coll.isInelGt0()) continue; - histos.fill(HIST("QACent_woCentCut"), lCentrality); - histos.fill(HIST("QAvtxz_wVtxzCut"), coll.posZ()); + if (doprocessMC){ + histos.fill(HIST("QACent_woCentCut"), lCentrality); + histos.fill(HIST("QAvtxz_wVtxzCut"), coll.posZ()); + } if (lCentrality < EventCuts.cfgEventCentralityMin || lCentrality > EventCuts.cfgEventCentralityMax) continue; - histos.fill(HIST("QACent_wCentCut"), lCentrality); - if (!coll.has_mcCollision()) - continue; - const auto mcid = coll.mcCollisionId(); - if (mcid < 0) - continue; + + if (doprocessMC){ + histos.fill(HIST("QACent_wCentCut"), lCentrality); + } allowedMcIds.insert(mcid); - centByMcIds[mcid] = lCentrality; + centTruthByAllowed.emplace(mcid, lCentrality); + } + } + + template + void buildReferenceMcIds(McCollsT const &mccolls, McPartsT const &mcparts) + { + refClassIds.clear(); + refCentByMcId.clear(); + + for (const auto& coll : mccolls) { + bool pass = true; + + if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) pass = false; + + if (pass && cfgTruthUseInelGt0) + { + auto partsThisMc = mcparts.sliceBy(perMCCollision, coll.globalIndex()); + if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) pass = false; + } + + if (!pass) continue; + + const auto mcid = coll.globalIndex(); + refClassIds.insert(mcid); + const float lCentrality = coll.centFT0M(); + refCentByMcId.emplace(mcid, lCentrality); } } void effK0sProcessGen(MCTrueTrackCandidates const& mcparts) { for (const auto& part : mcparts) { - const auto mcid = part.mcCollisionId(); - if (!part.has_mcCollision()) continue; if (part.pdgCode() != kPDGK0s) continue; if (!part.isPhysicalPrimary()) continue; - if (allowedMcIds.find(mcid) == allowedMcIds.end()) + if (std::abs(part.y()) > SecondaryCuts.cfgSecondaryRapidityMax) continue; - auto iter = centByMcIds.find(mcid); - if (iter == centByMcIds.end()) + const auto mcid = part.mcCollisionId(); + if (allowedMcIds.count(mcid) == 0) continue; - const float lCentrality = iter->second; - - if (std::abs(part.y()) > SecondaryCuts.cfgSecondaryRapidityMax) + auto iter = centTruthByAllowed.find(mcid); + if (iter == centTruthByAllowed.end()) continue; + const float lCentrality = iter->second; + histos.fill(HIST("EffK0s/genK0s"), part.pt(), lCentrality); } } @@ -759,14 +815,11 @@ struct Chk892pp { const auto mcid = coll.mcCollisionId(); - if (allowedMcIds.find(mcid) == allowedMcIds.end()) + if (allowedMcIds.count(mcid) == 0) continue; - auto iter = centByMcIds.find(mcid); - if (iter == centByMcIds.end()) - continue; - - const float lCentrality = iter->second; + const auto mccoll = coll.template mcCollision_as>(); + const float lCentrality = mccoll.centFT0M(); const double ptreco = v0.pt(); const double yreco = v0.yK0Short(); @@ -844,24 +897,25 @@ struct Chk892pp { void effKstarProcessGen(MCTrueTrackCandidates const& mcparts) { - for (const auto& part : mcparts) { - const auto mcid = part.mcCollisionId(); + for (const auto& part : mcparts) + { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; - if (allowedMcIds.find(mcid) == allowedMcIds.end()) + if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - auto iter = centByMcIds.find(mcid); - if (iter == centByMcIds.end()) + const auto mcid = part.mcCollisionId(); + if (allowedMcIds.count(mcid) == 0) continue; - const float lCentrality = iter->second; - - if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) + auto iter = centTruthByAllowed.find(mcid); + if (iter == centTruthByAllowed.end()) continue; + const float lCentrality = iter->second; + histos.fill(HIST("EffKstar/genKstar"), part.pt(), lCentrality); } } // effKstarProcessGen @@ -877,14 +931,11 @@ struct Chk892pp { const auto mcid = coll.mcCollisionId(); - if (allowedMcIds.find(mcid) == allowedMcIds.end()) + if (allowedMcIds.count(mcid) == 0) continue; - auto iter = centByMcIds.find(mcid); - if (iter == centByMcIds.end()) - continue; - - const float lCentrality = iter->second; + const auto mccoll = coll.template mcCollision_as>(); + const float lCentrality = mccoll.centFT0M(); if (!SecondaryCuts.cfgByPassDauPIDSelection) { auto posDauTrack = v0.template posTrack_as(); @@ -901,7 +952,6 @@ struct Chk892pp { for (const auto& bTrack : trks) { if (bTrack.collisionId() != v0.collisionId()) continue; - if (!trackCut(bTrack)) continue; if (!selectionPIDPion(bTrack)) @@ -923,10 +973,61 @@ struct Chk892pp { if (std::abs(yreco) > KstarCuts.cfgKstarMaxRap) continue; histos.fill(HIST("EffKstar/recoKstar"), ptreco, lCentrality); - } + } } } // effKstarProcessReco + void fillSigLossNum(MCTrueTrackCandidates const& mcparts) + { + for (auto const& part : mcparts) + { + if (!part.has_mcCollision()) + continue; + if (std::abs(part.pdgCode()) != kKstarPlus) + continue; + if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) + continue; + + const auto mcid = part.mcCollisionId(); + if (allowedMcIds.count(mcid) == 0) + continue; + + auto iter = centTruthByAllowed.find(mcid); + if (iter == centTruthByAllowed.end()) + continue; + + const float lCentrality = iter->second; + + histos.fill(HIST("Correction/sigLoss_num"), part.pt(), lCentrality); + } + }//fillSigLossNum + + void fillSigLossDen(MCTrueTrackCandidates const& mcparts) + { + for (auto const& part : mcparts) + { + if (!part.has_mcCollision()) + continue; + if (std::abs(part.pdgCode()) != kKstarPlus) + continue; + if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) + continue; + + const auto mcid = part.mcCollisionId(); + if (refClassIds.count(mcid) == 0) + continue; + + auto iter = refCentByMcId.find(mcid); + if (iter == refCentByMcId.end()) + continue; + + const float lCentrality = iter->second; + + histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); + } + }//fillSigLossDen + + int count = 0; template @@ -947,18 +1048,18 @@ struct Chk892pp { auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots - histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } + } if (!trackCut(bTrack)) continue; @@ -966,18 +1067,18 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots after applying cuts - histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + } trackIndicies.push_back(bTrack.index()); } @@ -1013,39 +1114,39 @@ struct Chk892pp { lResoSecondary = LorentzVectorSetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots - histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkppionpT"), trkppt); - histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trknpionpT"), trknpt); - histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/before/hy_Secondary"), trkky); - histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); - } - } + if (cfgFillQAPlots) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + } + } if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) continue; @@ -1055,46 +1156,46 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots after applying cuts - - histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkppionpT"), trkppt); - histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trknpionpT"), trknpt); - histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/after/hy_Secondary"), trkky); - histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); - } - histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); - } - k0sIndicies.push_back(k0sCand.index()); - } + if (cfgFillQAPlots) { + // Seconddary QA plots after applying cuts + + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/after/hy_Secondary"), trkky); + histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + } + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); + } + k0sIndicies.push_back(k0sCand.index()); + } for (const auto& trackIndex : trackIndicies) { - auto bTrack = dTracks1.rawIteratorAt(trackIndex); + auto bTrack = dTracks1.rawIteratorAt(trackIndex); for (const auto& k0sIndex : k0sIndicies) { auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); @@ -1106,30 +1207,30 @@ struct Chk892pp { // QA plots if constexpr (!IsMix) { - if (cfgFillQAPlots) { - histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); - } - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); + } + } if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) continue; if constexpr (!IsMix) { unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; - if (cfgFillQAPlots) { + if (cfgFillQAPlots) { - histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - } - histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + } + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); if (BkgEstimationConfig.cfgFillRotBkg) { for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); - if (cfgFillQAPlots) { - histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + } if (BkgEstimationConfig.cfgRotPion) { lDaughterRot = lDecayDaughter_bach; // lDaughterRot.RotateZ(lRotAngle); @@ -1149,15 +1250,14 @@ struct Chk892pp { histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M()); } } - } // IsMix - } // K0scand - } // bTrack + }// IsMix + }// K0scand + }// bTrack count++; - } // fillHistograms + }// fillHistograms - // process data void processData(EventCandidates::iterator const& collision, TrackCandidates const& tracks, V0Candidates const& v0s, @@ -1179,40 +1279,109 @@ struct Chk892pp { } PROCESS_SWITCH(Chk892pp, processData, "Process Event for data without Partitioning", false); - // process MC reconstructed level void processMC(MCTrueTrackCandidates const& mcpart, MCTrackCandidates const& tracks, MCV0Candidates const& v0s, - MCEventCandidates const& events) + MCEventCandidates const& events, + soa::Join const& mccolls) { buildAllowedMcIds(events); - effK0sProcessGen(mcpart); - effK0sProcessReco(v0s); - effKstarProcessGen(mcpart); - effKstarProcessReco(v0s, tracks); - } - PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", false); + buildReferenceMcIds(mccolls, mcpart); + effK0sProcessGen(mcpart); + effK0sProcessReco(v0s); + effKstarProcessGen(mcpart); + effKstarProcessReco(v0s, tracks); + fillSigLossNum(mcpart); + fillSigLossDen(mcpart); + + for (const auto& mcid : refClassIds) + { + histos.fill(HIST("Correction/EF_den"), refCentByMcId[mcid]); + } + for (const auto& mcid : allowedMcIds) + { + auto iter = centTruthByAllowed.find(mcid); + if (iter == centTruthByAllowed.end()) + continue; - void processMCQA(MCEventCandidates::iterator const& collision, - MCTrackCandidates const& tracks, - MCV0Candidates const& v0s, - aod::BCsWithTimestamps const&) - { - if (!colCuts.isSelected(collision)) + const float lCentrality = iter->second; + histos.fill(HIST("Correction/EF_num"), lCentrality); + } + + size_t nIntersect = 0; + for (const auto& mcid : allowedMcIds) if (refClassIds.count(mcid)) nIntersect++; + histos.fill(HIST("Correction/setSizes"), 0.0, refClassIds.size()); + histos.fill(HIST("Correction/setSizes"), 1.0, allowedMcIds.size()); + histos.fill(HIST("Correction/setSizes"), 2.0, nIntersect); + histos.fill(HIST("Correction/setSizes"), 3.0, allowedMcIds.size() - nIntersect); + + for (const auto& mcc : mccolls) + { + histos.fill(HIST("Correction/MCTruthCent_all"), mcc.centFT0M()); + } + + for (const auto& mcid : refClassIds) + { + auto iter = refCentByMcId.find(mcid); + if (iter == refCentByMcId.end()) + continue; + lCentrality = iter->second; + histos.fill(HIST("Correction/MCTruthCent_cut"), lCentrality); + } + + for (auto const& mcc : mccolls) + { + const auto mcid = mcc.globalIndex(); + + histos.fill(HIST("Correction/hNEventsMCTruth"), 1.0); + + bool passZvtx = true; + if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) + { + passZvtx = false; + } + if (passZvtx) + { + histos.fill(HIST("Correction/hNEventsMCTruth"), 2.0); + + auto partsThisMc = mcpart.sliceBy(perMCCollision, mcid); + if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) + { + histos.fill(HIST("Correction/hNEventsMCTruth"), 3.0); + } + } + if (allowedMcIds.count(mcid)) + { + histos.fill(HIST("Correction/hNEventsMCTruth"), 4.0); + } + } + } + PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", true); + + void processMCQA(MCEventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s, + aod::BCsWithTimestamps const&) + { + if (!colCuts.isSelected(collision)) + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; + if (!collision.isInelGt0()) return; - if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + + if (!collision.has_mcCollision()) return; + auto mccoll = collision.template mcCollision_as>(); + const float lCentrality = mccoll.centFT0M(); - lCentrality = getCentrality(collision); if (lCentrality < EventCuts.cfgEventCentralityMin || lCentrality > EventCuts.cfgEventCentralityMax) return; - if (!collision.isInelGt0()) - return; colCuts.fillQA(collision); fillHistograms(collision, tracks, v0s); - } - PROCESS_SWITCH(Chk892pp, processMCQA, "Process Event for MC and fill QA plots", true); + } + PROCESS_SWITCH(Chk892pp, processMCQA, "Process Event for MC and fill QA plots", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 5085703a771ed8a6f8ebe9a0d37722b058306457 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Sat, 25 Oct 2025 08:18:09 +0000 Subject: [PATCH 2/4] Please consider the following formatting changes --- PWGLF/Tasks/Resonances/chk892pp.cxx | 375 ++++++++++++++-------------- 1 file changed, 183 insertions(+), 192 deletions(-) diff --git a/PWGLF/Tasks/Resonances/chk892pp.cxx b/PWGLF/Tasks/Resonances/chk892pp.cxx index cc7b3e60730..6af391f81ea 100644 --- a/PWGLF/Tasks/Resonances/chk892pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892pp.cxx @@ -60,11 +60,11 @@ #include "Math/Vector3D.h" #include "Math/Vector4D.h" #include "TF1.h" +#include "TParticlePDG.h" #include "TRandom3.h" #include "TVector2.h" #include #include // FIXME -#include "TParticlePDG.h" #include #include @@ -84,19 +84,19 @@ using namespace o2::aod::rctsel; namespace { - template - inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) - { - if (!v0.has_mcParticle()) - return false; - auto mcPart = v0.template mcParticle_as(); - if (mcPart.pdgCode() != kK0Short) - return false; - ptgen = mcPart.pt(); - ygen = mcPart.y(); - return true; - } -}// namespace +template +inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) +{ + if (!v0.has_mcParticle()) + return false; + auto mcPart = v0.template mcParticle_as(); + if (mcPart.pdgCode() != kK0Short) + return false; + ptgen = mcPart.pt(); + ygen = mcPart.y(); + return true; +} +} // namespace struct Chk892pp { enum BinType : unsigned int { @@ -110,7 +110,7 @@ struct Chk892pp { }; enum EvtStep { - kAll=0, + kAll = 0, kZvtx, kINELgt0, kAssocReco, @@ -119,7 +119,7 @@ struct Chk892pp { SliceCache cache; Preslice perCollision = aod::track::collisionId; - Preslice perCollisionV0 = aod::v0data::collisionId; + Preslice perCollisionV0 = aod::v0data::collisionId; Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; using EventCandidates = soa::Join; @@ -183,7 +183,7 @@ struct Chk892pp { } EventCuts; RCTFlagsChecker rctChecker; - Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; + Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; /// PID Selections, pion @@ -261,7 +261,7 @@ struct Chk892pp { Configurable cfgNrotBkg{"cfgNrotBkg", 4, "Number of rotated copies (background) per each original candidate"}; } BkgEstimationConfig; - Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; + Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; Configurable cfgTruthIncludeZvtx{"cfgTruthIncludeZvtx", true, "Truth denominator: also require |vtxz| EventCuts.cfgEventCentralityMax) continue; - - if (doprocessMC){ + + if (doprocessMC) { histos.fill(HIST("QACent_wCentCut"), lCentrality); } allowedMcIds.insert(mcid); @@ -754,7 +754,7 @@ struct Chk892pp { } template - void buildReferenceMcIds(McCollsT const &mccolls, McPartsT const &mcparts) + void buildReferenceMcIds(McCollsT const& mccolls, McPartsT const& mcparts) { refClassIds.clear(); refCentByMcId.clear(); @@ -762,16 +762,18 @@ struct Chk892pp { for (const auto& coll : mccolls) { bool pass = true; - if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) pass = false; + if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) + pass = false; - if (pass && cfgTruthUseInelGt0) - { + if (pass && cfgTruthUseInelGt0) { auto partsThisMc = mcparts.sliceBy(perMCCollision, coll.globalIndex()); - if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) pass = false; + if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) + pass = false; } - if (!pass) continue; - + if (!pass) + continue; + const auto mcid = coll.globalIndex(); refClassIds.insert(mcid); const float lCentrality = coll.centFT0M(); @@ -897,8 +899,7 @@ struct Chk892pp { void effKstarProcessGen(MCTrueTrackCandidates const& mcparts) { - for (const auto& part : mcparts) - { + for (const auto& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) @@ -973,60 +974,57 @@ struct Chk892pp { if (std::abs(yreco) > KstarCuts.cfgKstarMaxRap) continue; histos.fill(HIST("EffKstar/recoKstar"), ptreco, lCentrality); - } + } } } // effKstarProcessReco void fillSigLossNum(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) - { + for (auto const& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (allowedMcIds.count(mcid) == 0) continue; - + auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_num"), part.pt(), lCentrality); } - }//fillSigLossNum + } // fillSigLossNum void fillSigLossDen(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) - { + for (auto const& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (refClassIds.count(mcid) == 0) continue; - + auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); } - }//fillSigLossDen - + } // fillSigLossDen int count = 0; @@ -1048,18 +1046,18 @@ struct Chk892pp { auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots - histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } + } if (!trackCut(bTrack)) continue; @@ -1067,18 +1065,18 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots after applying cuts - histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + } trackIndicies.push_back(bTrack.index()); } @@ -1114,39 +1112,39 @@ struct Chk892pp { lResoSecondary = LorentzVectorSetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots - histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkppionpT"), trkppt); - histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trknpionpT"), trknpt); - histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/before/hy_Secondary"), trkky); - histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); - } - } + if (cfgFillQAPlots) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + } + } if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) continue; @@ -1156,46 +1154,46 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots after applying cuts - - histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkppionpT"), trkppt); - histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trknpionpT"), trknpt); - histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/after/hy_Secondary"), trkky); - histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); - } - histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); - } - k0sIndicies.push_back(k0sCand.index()); - } + if (cfgFillQAPlots) { + // Seconddary QA plots after applying cuts + + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/after/hy_Secondary"), trkky); + histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + } + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); + } + k0sIndicies.push_back(k0sCand.index()); + } for (const auto& trackIndex : trackIndicies) { - auto bTrack = dTracks1.rawIteratorAt(trackIndex); + auto bTrack = dTracks1.rawIteratorAt(trackIndex); for (const auto& k0sIndex : k0sIndicies) { auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); @@ -1207,30 +1205,30 @@ struct Chk892pp { // QA plots if constexpr (!IsMix) { - if (cfgFillQAPlots) { - histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); - } - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); + } + } if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) continue; if constexpr (!IsMix) { unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; - if (cfgFillQAPlots) { + if (cfgFillQAPlots) { - histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - } - histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + } + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); if (BkgEstimationConfig.cfgFillRotBkg) { for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); - if (cfgFillQAPlots) { - histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + } if (BkgEstimationConfig.cfgRotPion) { lDaughterRot = lDecayDaughter_bach; // lDaughterRot.RotateZ(lRotAngle); @@ -1250,13 +1248,13 @@ struct Chk892pp { histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M()); } } - }// IsMix - }// K0scand - }// bTrack + } // IsMix + } // K0scand + } // bTrack count++; - }// fillHistograms + } // fillHistograms void processData(EventCandidates::iterator const& collision, TrackCandidates const& tracks, @@ -1287,19 +1285,17 @@ struct Chk892pp { { buildAllowedMcIds(events); buildReferenceMcIds(mccolls, mcpart); - effK0sProcessGen(mcpart); - effK0sProcessReco(v0s); - effKstarProcessGen(mcpart); - effKstarProcessReco(v0s, tracks); + effK0sProcessGen(mcpart); + effK0sProcessReco(v0s); + effKstarProcessGen(mcpart); + effKstarProcessReco(v0s, tracks); fillSigLossNum(mcpart); fillSigLossDen(mcpart); - for (const auto& mcid : refClassIds) - { + for (const auto& mcid : refClassIds) { histos.fill(HIST("Correction/EF_den"), refCentByMcId[mcid]); } - for (const auto& mcid : allowedMcIds) - { + for (const auto& mcid : allowedMcIds) { auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; @@ -1309,19 +1305,19 @@ struct Chk892pp { } size_t nIntersect = 0; - for (const auto& mcid : allowedMcIds) if (refClassIds.count(mcid)) nIntersect++; + for (const auto& mcid : allowedMcIds) + if (refClassIds.count(mcid)) + nIntersect++; histos.fill(HIST("Correction/setSizes"), 0.0, refClassIds.size()); histos.fill(HIST("Correction/setSizes"), 1.0, allowedMcIds.size()); histos.fill(HIST("Correction/setSizes"), 2.0, nIntersect); histos.fill(HIST("Correction/setSizes"), 3.0, allowedMcIds.size() - nIntersect); - for (const auto& mcc : mccolls) - { + for (const auto& mcc : mccolls) { histos.fill(HIST("Correction/MCTruthCent_all"), mcc.centFT0M()); } - for (const auto& mcid : refClassIds) - { + for (const auto& mcid : refClassIds) { auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; @@ -1329,44 +1325,39 @@ struct Chk892pp { histos.fill(HIST("Correction/MCTruthCent_cut"), lCentrality); } - for (auto const& mcc : mccolls) - { + for (auto const& mcc : mccolls) { const auto mcid = mcc.globalIndex(); histos.fill(HIST("Correction/hNEventsMCTruth"), 1.0); bool passZvtx = true; - if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) - { + if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) { passZvtx = false; } - if (passZvtx) - { + if (passZvtx) { histos.fill(HIST("Correction/hNEventsMCTruth"), 2.0); auto partsThisMc = mcpart.sliceBy(perMCCollision, mcid); - if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) - { + if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) { histos.fill(HIST("Correction/hNEventsMCTruth"), 3.0); } } - if (allowedMcIds.count(mcid)) - { + if (allowedMcIds.count(mcid)) { histos.fill(HIST("Correction/hNEventsMCTruth"), 4.0); } } } PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", true); - void processMCQA(MCEventCandidates::iterator const& collision, - MCTrackCandidates const& tracks, - MCV0Candidates const& v0s, - aod::BCsWithTimestamps const&) - { - if (!colCuts.isSelected(collision)) - return; - if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) - return; + void processMCQA(MCEventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s, + aod::BCsWithTimestamps const&) + { + if (!colCuts.isSelected(collision)) + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; if (!collision.isInelGt0()) return; @@ -1380,7 +1371,7 @@ struct Chk892pp { colCuts.fillQA(collision); fillHistograms(collision, tracks, v0s); - } + } PROCESS_SWITCH(Chk892pp, processMCQA, "Process Event for MC and fill QA plots", false); }; From 99029f9c539e5dd49410b4c04df0daff96a8cb6d Mon Sep 17 00:00:00 2001 From: SuJeong Ji <120470463+SuJeong-Ji@users.noreply.github.com> Date: Sun, 26 Oct 2025 19:14:08 +0900 Subject: [PATCH 3/4] Update: fixed o2 build error --- PWGLF/Tasks/Resonances/chk892pp.cxx | 379 ++++++++++++++-------------- 1 file changed, 195 insertions(+), 184 deletions(-) diff --git a/PWGLF/Tasks/Resonances/chk892pp.cxx b/PWGLF/Tasks/Resonances/chk892pp.cxx index 6af391f81ea..82b286c3854 100644 --- a/PWGLF/Tasks/Resonances/chk892pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892pp.cxx @@ -60,11 +60,11 @@ #include "Math/Vector3D.h" #include "Math/Vector4D.h" #include "TF1.h" -#include "TParticlePDG.h" #include "TRandom3.h" #include "TVector2.h" #include #include // FIXME +#include "TParticlePDG.h" #include #include @@ -84,19 +84,19 @@ using namespace o2::aod::rctsel; namespace { -template -inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) -{ - if (!v0.has_mcParticle()) - return false; - auto mcPart = v0.template mcParticle_as(); - if (mcPart.pdgCode() != kK0Short) - return false; - ptgen = mcPart.pt(); - ygen = mcPart.y(); - return true; -} -} // namespace + template + inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) + { + if (!v0.has_mcParticle()) + return false; + auto mcPart = v0.template mcParticle_as(); + if (mcPart.pdgCode() != kK0Short) + return false; + ptgen = mcPart.pt(); + ygen = mcPart.y(); + return true; + } +}// namespace struct Chk892pp { enum BinType : unsigned int { @@ -110,16 +110,18 @@ struct Chk892pp { }; enum EvtStep { - kAll = 0, + kAll=0, kZvtx, kINELgt0, kAssocReco, kNSteps }; + const int nSteps = static_cast(EvtStep::kNSteps); + SliceCache cache; Preslice perCollision = aod::track::collisionId; - Preslice perCollisionV0 = aod::v0data::collisionId; + Preslice perCollisionV0 = aod::v0data::collisionId; Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; using EventCandidates = soa::Join; @@ -183,7 +185,7 @@ struct Chk892pp { } EventCuts; RCTFlagsChecker rctChecker; - Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; + Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; /// PID Selections, pion @@ -261,7 +263,7 @@ struct Chk892pp { Configurable cfgNrotBkg{"cfgNrotBkg", 4, "Number of rotated copies (background) per each original candidate"}; } BkgEstimationConfig; - Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; + Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; Configurable cfgTruthIncludeZvtx{"cfgTruthIncludeZvtx", true, "Truth denominator: also require |vtxz|GetXaxis()->SetBinLabel(3, "intersection"); hset->GetXaxis()->SetBinLabel(4, "allowed-only"); - histos.add("Correction/hNEventsMCTruth", "hNEventsMCTruth", HistType::kTH1F, {AxisSpec{kNSteps, 0.5, kNSteps + 0.5, ""}}); + histos.add("Correction/hNEventsMCTruth", "hNEventsMCTruth", HistType::kTH1F, {AxisSpec{nSteps, 0.5, nSteps + 0.5, ""}}); auto hstep = histos.get(HIST("Correction/hNEventsMCTruth")); hstep->GetXaxis()->SetBinLabel(1, "All"); hstep->GetXaxis()->SetBinLabel(2, "zvtx"); @@ -715,7 +717,7 @@ struct Chk892pp { centTruthByAllowed.clear(); for (const auto& coll : events) { - // lCentrality = getCentrality(coll); + //lCentrality = getCentrality(coll); if (!coll.has_mcCollision()) continue; @@ -725,7 +727,7 @@ struct Chk892pp { const float lCentrality = mccoll.centFT0M(); - if (doprocessMC) { + if (doprocessMC){ histos.fill(HIST("QACent_woCut"), lCentrality); histos.fill(HIST("QAvtxz_woCut"), coll.posZ()); } @@ -737,15 +739,15 @@ struct Chk892pp { if (!coll.isInelGt0()) continue; - if (doprocessMC) { + if (doprocessMC){ histos.fill(HIST("QACent_woCentCut"), lCentrality); histos.fill(HIST("QAvtxz_wVtxzCut"), coll.posZ()); } if (lCentrality < EventCuts.cfgEventCentralityMin || lCentrality > EventCuts.cfgEventCentralityMax) continue; - - if (doprocessMC) { + + if (doprocessMC){ histos.fill(HIST("QACent_wCentCut"), lCentrality); } allowedMcIds.insert(mcid); @@ -754,7 +756,7 @@ struct Chk892pp { } template - void buildReferenceMcIds(McCollsT const& mccolls, McPartsT const& mcparts) + void buildReferenceMcIds(McCollsT const &mccolls, McPartsT const &mcparts) { refClassIds.clear(); refCentByMcId.clear(); @@ -762,18 +764,16 @@ struct Chk892pp { for (const auto& coll : mccolls) { bool pass = true; - if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) - pass = false; + if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) pass = false; - if (pass && cfgTruthUseInelGt0) { + if (pass && cfgTruthUseInelGt0) + { auto partsThisMc = mcparts.sliceBy(perMCCollision, coll.globalIndex()); - if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) - pass = false; + if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) pass = false; } - if (!pass) - continue; - + if (!pass) continue; + const auto mcid = coll.globalIndex(); refClassIds.insert(mcid); const float lCentrality = coll.centFT0M(); @@ -899,7 +899,8 @@ struct Chk892pp { void effKstarProcessGen(MCTrueTrackCandidates const& mcparts) { - for (const auto& part : mcparts) { + for (const auto& part : mcparts) + { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) @@ -974,57 +975,60 @@ struct Chk892pp { if (std::abs(yreco) > KstarCuts.cfgKstarMaxRap) continue; histos.fill(HIST("EffKstar/recoKstar"), ptreco, lCentrality); - } + } } } // effKstarProcessReco void fillSigLossNum(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) { + for (auto const& part : mcparts) + { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (allowedMcIds.count(mcid) == 0) continue; - + auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_num"), part.pt(), lCentrality); } - } // fillSigLossNum + }//fillSigLossNum void fillSigLossDen(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) { + for (auto const& part : mcparts) + { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (refClassIds.count(mcid) == 0) continue; - + auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); } - } // fillSigLossDen + }//fillSigLossDen + int count = 0; @@ -1046,18 +1050,18 @@ struct Chk892pp { auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots - histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } + } if (!trackCut(bTrack)) continue; @@ -1065,18 +1069,18 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots after applying cuts - histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + } trackIndicies.push_back(bTrack.index()); } @@ -1112,39 +1116,39 @@ struct Chk892pp { lResoSecondary = LorentzVectorSetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots - histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkppionpT"), trkppt); - histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trknpionpT"), trknpt); - histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/before/hy_Secondary"), trkky); - histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); - } - } + if (cfgFillQAPlots) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + } + } if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) continue; @@ -1154,46 +1158,46 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots after applying cuts - - histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkppionpT"), trkppt); - histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trknpionpT"), trknpt); - histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/after/hy_Secondary"), trkky); - histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); - } - histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); - } - k0sIndicies.push_back(k0sCand.index()); - } + if (cfgFillQAPlots) { + // Seconddary QA plots after applying cuts + + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/after/hy_Secondary"), trkky); + histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + } + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); + } + k0sIndicies.push_back(k0sCand.index()); + } for (const auto& trackIndex : trackIndicies) { - auto bTrack = dTracks1.rawIteratorAt(trackIndex); + auto bTrack = dTracks1.rawIteratorAt(trackIndex); for (const auto& k0sIndex : k0sIndicies) { auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); @@ -1205,30 +1209,30 @@ struct Chk892pp { // QA plots if constexpr (!IsMix) { - if (cfgFillQAPlots) { - histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); - } - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); + } + } if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) continue; if constexpr (!IsMix) { unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; - if (cfgFillQAPlots) { + if (cfgFillQAPlots) { - histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - } - histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + } + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); if (BkgEstimationConfig.cfgFillRotBkg) { for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); - if (cfgFillQAPlots) { - histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + } if (BkgEstimationConfig.cfgRotPion) { lDaughterRot = lDecayDaughter_bach; // lDaughterRot.RotateZ(lRotAngle); @@ -1248,13 +1252,13 @@ struct Chk892pp { histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M()); } } - } // IsMix - } // K0scand - } // bTrack + }// IsMix + }// K0scand + }// bTrack count++; - } // fillHistograms + }// fillHistograms void processData(EventCandidates::iterator const& collision, TrackCandidates const& tracks, @@ -1285,17 +1289,19 @@ struct Chk892pp { { buildAllowedMcIds(events); buildReferenceMcIds(mccolls, mcpart); - effK0sProcessGen(mcpart); - effK0sProcessReco(v0s); - effKstarProcessGen(mcpart); - effKstarProcessReco(v0s, tracks); + effK0sProcessGen(mcpart); + effK0sProcessReco(v0s); + effKstarProcessGen(mcpart); + effKstarProcessReco(v0s, tracks); fillSigLossNum(mcpart); fillSigLossDen(mcpart); - for (const auto& mcid : refClassIds) { + for (const auto& mcid : refClassIds) + { histos.fill(HIST("Correction/EF_den"), refCentByMcId[mcid]); } - for (const auto& mcid : allowedMcIds) { + for (const auto& mcid : allowedMcIds) + { auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; @@ -1305,19 +1311,19 @@ struct Chk892pp { } size_t nIntersect = 0; - for (const auto& mcid : allowedMcIds) - if (refClassIds.count(mcid)) - nIntersect++; + for (const auto& mcid : allowedMcIds) if (refClassIds.count(mcid)) nIntersect++; histos.fill(HIST("Correction/setSizes"), 0.0, refClassIds.size()); histos.fill(HIST("Correction/setSizes"), 1.0, allowedMcIds.size()); histos.fill(HIST("Correction/setSizes"), 2.0, nIntersect); histos.fill(HIST("Correction/setSizes"), 3.0, allowedMcIds.size() - nIntersect); - for (const auto& mcc : mccolls) { + for (const auto& mcc : mccolls) + { histos.fill(HIST("Correction/MCTruthCent_all"), mcc.centFT0M()); } - for (const auto& mcid : refClassIds) { + for (const auto& mcid : refClassIds) + { auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; @@ -1325,39 +1331,44 @@ struct Chk892pp { histos.fill(HIST("Correction/MCTruthCent_cut"), lCentrality); } - for (auto const& mcc : mccolls) { + for (auto const& mcc : mccolls) + { const auto mcid = mcc.globalIndex(); histos.fill(HIST("Correction/hNEventsMCTruth"), 1.0); bool passZvtx = true; - if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) { + if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) + { passZvtx = false; } - if (passZvtx) { + if (passZvtx) + { histos.fill(HIST("Correction/hNEventsMCTruth"), 2.0); auto partsThisMc = mcpart.sliceBy(perMCCollision, mcid); - if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) { + if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) + { histos.fill(HIST("Correction/hNEventsMCTruth"), 3.0); } } - if (allowedMcIds.count(mcid)) { + if (allowedMcIds.count(mcid)) + { histos.fill(HIST("Correction/hNEventsMCTruth"), 4.0); } } } PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", true); - void processMCQA(MCEventCandidates::iterator const& collision, - MCTrackCandidates const& tracks, - MCV0Candidates const& v0s, - aod::BCsWithTimestamps const&) - { - if (!colCuts.isSelected(collision)) - return; - if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) - return; + void processMCQA(MCEventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s, + aod::BCsWithTimestamps const&) + { + if (!colCuts.isSelected(collision)) + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; if (!collision.isInelGt0()) return; @@ -1371,7 +1382,7 @@ struct Chk892pp { colCuts.fillQA(collision); fillHistograms(collision, tracks, v0s); - } + } PROCESS_SWITCH(Chk892pp, processMCQA, "Process Event for MC and fill QA plots", false); }; From 9fa23cb3fd86924f31bb8e9ab7cc9916af28df19 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Sun, 26 Oct 2025 10:16:14 +0000 Subject: [PATCH 4/4] Please consider the following formatting changes --- PWGLF/Tasks/Resonances/chk892pp.cxx | 377 ++++++++++++++-------------- 1 file changed, 184 insertions(+), 193 deletions(-) diff --git a/PWGLF/Tasks/Resonances/chk892pp.cxx b/PWGLF/Tasks/Resonances/chk892pp.cxx index 82b286c3854..e0986eb7cbe 100644 --- a/PWGLF/Tasks/Resonances/chk892pp.cxx +++ b/PWGLF/Tasks/Resonances/chk892pp.cxx @@ -60,11 +60,11 @@ #include "Math/Vector3D.h" #include "Math/Vector4D.h" #include "TF1.h" +#include "TParticlePDG.h" #include "TRandom3.h" #include "TVector2.h" #include #include // FIXME -#include "TParticlePDG.h" #include #include @@ -84,19 +84,19 @@ using namespace o2::aod::rctsel; namespace { - template - inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) - { - if (!v0.has_mcParticle()) - return false; - auto mcPart = v0.template mcParticle_as(); - if (mcPart.pdgCode() != kK0Short) - return false; - ptgen = mcPart.pt(); - ygen = mcPart.y(); - return true; - } -}// namespace +template +inline bool getTruthK0sAndGenKinematics(V0T const& v0, double& ptgen, double& ygen) +{ + if (!v0.has_mcParticle()) + return false; + auto mcPart = v0.template mcParticle_as(); + if (mcPart.pdgCode() != kK0Short) + return false; + ptgen = mcPart.pt(); + ygen = mcPart.y(); + return true; +} +} // namespace struct Chk892pp { enum BinType : unsigned int { @@ -110,18 +110,18 @@ struct Chk892pp { }; enum EvtStep { - kAll=0, + kAll = 0, kZvtx, kINELgt0, kAssocReco, kNSteps }; - const int nSteps = static_cast(EvtStep::kNSteps); + const int nSteps = static_cast(EvtStep::kNSteps); SliceCache cache; Preslice perCollision = aod::track::collisionId; - Preslice perCollisionV0 = aod::v0data::collisionId; + Preslice perCollisionV0 = aod::v0data::collisionId; Preslice perMCCollision = o2::aod::mcparticle::mcCollisionId; using EventCandidates = soa::Join; @@ -185,7 +185,7 @@ struct Chk892pp { } EventCuts; RCTFlagsChecker rctChecker; - Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; + Configurable cfgFillQAPlots{"cfgFillQAPlots", false, "Fill QA plots"}; Configurable cfgCentEst{"cfgCentEst", 2, "Centrality estimator, 1: FT0C, 2: FT0M"}; /// PID Selections, pion @@ -263,7 +263,7 @@ struct Chk892pp { Configurable cfgNrotBkg{"cfgNrotBkg", 4, "Number of rotated copies (background) per each original candidate"}; } BkgEstimationConfig; - Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; + Configurable cfgTruthUseInelGt0{"cfgTruthUseInelGt0", true, "Truth denominator: require INEL>0"}; Configurable cfgTruthIncludeZvtx{"cfgTruthIncludeZvtx", true, "Truth denominator: also require |vtxz| EventCuts.cfgEventCentralityMax) continue; - - if (doprocessMC){ + + if (doprocessMC) { histos.fill(HIST("QACent_wCentCut"), lCentrality); } allowedMcIds.insert(mcid); @@ -756,7 +756,7 @@ struct Chk892pp { } template - void buildReferenceMcIds(McCollsT const &mccolls, McPartsT const &mcparts) + void buildReferenceMcIds(McCollsT const& mccolls, McPartsT const& mcparts) { refClassIds.clear(); refCentByMcId.clear(); @@ -764,16 +764,18 @@ struct Chk892pp { for (const auto& coll : mccolls) { bool pass = true; - if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) pass = false; + if (cfgTruthIncludeZvtx && std::abs(coll.posZ()) >= EventCuts.cfgEvtZvtx) + pass = false; - if (pass && cfgTruthUseInelGt0) - { + if (pass && cfgTruthUseInelGt0) { auto partsThisMc = mcparts.sliceBy(perMCCollision, coll.globalIndex()); - if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) pass = false; + if (!pwglf::isINELgtNmc(partsThisMc, 0, pdg)) + pass = false; } - if (!pass) continue; - + if (!pass) + continue; + const auto mcid = coll.globalIndex(); refClassIds.insert(mcid); const float lCentrality = coll.centFT0M(); @@ -899,8 +901,7 @@ struct Chk892pp { void effKstarProcessGen(MCTrueTrackCandidates const& mcparts) { - for (const auto& part : mcparts) - { + for (const auto& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) @@ -975,60 +976,57 @@ struct Chk892pp { if (std::abs(yreco) > KstarCuts.cfgKstarMaxRap) continue; histos.fill(HIST("EffKstar/recoKstar"), ptreco, lCentrality); - } + } } } // effKstarProcessReco void fillSigLossNum(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) - { + for (auto const& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (allowedMcIds.count(mcid) == 0) continue; - + auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_num"), part.pt(), lCentrality); } - }//fillSigLossNum + } // fillSigLossNum void fillSigLossDen(MCTrueTrackCandidates const& mcparts) { - for (auto const& part : mcparts) - { + for (auto const& part : mcparts) { if (!part.has_mcCollision()) continue; if (std::abs(part.pdgCode()) != kKstarPlus) continue; if (std::abs(part.y()) > KstarCuts.cfgKstarMaxRap) continue; - + const auto mcid = part.mcCollisionId(); if (refClassIds.count(mcid) == 0) continue; - + auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; - + const float lCentrality = iter->second; histos.fill(HIST("Correction/sigLoss_den"), part.pt(), lCentrality); } - }//fillSigLossDen - + } // fillSigLossDen int count = 0; @@ -1050,18 +1048,18 @@ struct Chk892pp { auto trkbNSigmaPiTOF = (istrkbhasTOF) ? bTrack.tofNSigmaPi() : -999.; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots - histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots + histos.fill(HIST("QA/before/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/before/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/before/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/before/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/before/trkbpionDCAz"), bTrack.dcaZ()); + } + } if (!trackCut(bTrack)) continue; @@ -1069,18 +1067,18 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Bachelor pion QA plots after applying cuts - histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); - if (istrkbhasTOF) { - histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); - histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); - histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); - histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); - } - } + if (cfgFillQAPlots) { + // Bachelor pion QA plots after applying cuts + histos.fill(HIST("QA/after/trkbpionTPCPID"), trkbpt, trkbNSigmaPiTPC); + if (istrkbhasTOF) { + histos.fill(HIST("QA/after/trkbpionTOFPID"), trkbpt, trkbNSigmaPiTOF); + histos.fill(HIST("QA/after/trkbpionTPCTOFPID"), trkbNSigmaPiTPC, trkbNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkbpionpT"), trkbpt); + histos.fill(HIST("QA/after/trkbpionDCAxy"), bTrack.dcaXY()); + histos.fill(HIST("QA/after/trkbpionDCAz"), bTrack.dcaZ()); + } + } trackIndicies.push_back(bTrack.index()); } @@ -1116,39 +1114,39 @@ struct Chk892pp { lResoSecondary = LorentzVectorSetXYZM(k0sCand.px(), k0sCand.py(), k0sCand.pz(), trkkMass); if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots - histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trkppionpT"), trkppt); - histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/before/trknpionpT"), trknpt); - histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/before/hy_Secondary"), trkky); - histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); - } - } + if (cfgFillQAPlots) { + // Seconddary QA plots + histos.fill(HIST("QA/before/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/before/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/before/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trkppionpT"), trkppt); + histos.fill(HIST("QA/before/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/before/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/before/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/before/trknpionpT"), trknpt); + histos.fill(HIST("QA/before/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/before/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/before/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/before/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/before/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/before/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/before/hy_Secondary"), trkky); + histos.fill(HIST("QA/before/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/before/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/before/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/before/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/before/hInvmassSecondary"), trkkMass); + } + } if (!SecondaryCuts.cfgByPassDauPIDSelection && !selectionPIDPion(posDauTrack)) continue; @@ -1158,46 +1156,46 @@ struct Chk892pp { continue; if constexpr (!IsMix) { - if (cfgFillQAPlots) { - // Seconddary QA plots after applying cuts - - histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); - if (istrkphasTOF) { - histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); - histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trkppionpT"), trkppt); - histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); - if (istrknhasTOF) { - histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); - histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); - } - histos.fill(HIST("QA/after/trknpionpT"), trknpt); - histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); - histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); - - histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); - histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); - histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); - - histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); - histos.fill(HIST("QA/after/hy_Secondary"), trkky); - histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); - histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); - histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); - histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); - histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); - } - histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); - } - k0sIndicies.push_back(k0sCand.index()); - } + if (cfgFillQAPlots) { + // Seconddary QA plots after applying cuts + + histos.fill(HIST("QA/after/trkppionTPCPID"), trkppt, trkpNSigmaPiTPC); + if (istrkphasTOF) { + histos.fill(HIST("QA/after/trkppionTOFPID"), trkppt, trkpNSigmaPiTOF); + histos.fill(HIST("QA/after/trkppionTPCTOFPID"), trkpNSigmaPiTPC, trkpNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trkppionpT"), trkppt); + histos.fill(HIST("QA/after/trkppionDCAxy"), posDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trkppionDCAz"), posDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/trknpionTPCPID"), trknpt, trknNSigmaPiTPC); + if (istrknhasTOF) { + histos.fill(HIST("QA/after/trknpionTOFPID"), trknpt, trknNSigmaPiTOF); + histos.fill(HIST("QA/after/trknpionTPCTOFPID"), trknNSigmaPiTPC, trknNSigmaPiTOF); + } + histos.fill(HIST("QA/after/trknpionpT"), trknpt); + histos.fill(HIST("QA/after/trknpionDCAxy"), negDauTrack.dcaXY()); + histos.fill(HIST("QA/after/trknpionDCAz"), negDauTrack.dcaZ()); + + histos.fill(HIST("QA/after/hDauDCASecondary"), trkkDauDCA); + histos.fill(HIST("QA/after/hDauPosDCAtoPVSecondary"), trkkDauDCAPostoPV); + histos.fill(HIST("QA/after/hDauNegDCAtoPVSecondary"), trkkDauDCANegtoPV); + + histos.fill(HIST("QA/after/hpT_Secondary"), trkkpt); + histos.fill(HIST("QA/after/hy_Secondary"), trkky); + histos.fill(HIST("QA/after/hRadiusSecondary"), trkkRadius); + histos.fill(HIST("QA/after/hDCAtoPVSecondary"), trkkDCAtoPV); + histos.fill(HIST("QA/after/hCPASecondary"), trkkCPA); + histos.fill(HIST("QA/after/hPropTauSecondary"), trkkPropTau); + histos.fill(HIST("QA/after/hInvmassSecondary"), trkkMass); + } + histos.fill(HIST("hInvmass_K0s"), lCentrality, lResoSecondary.Pt(), lResoSecondary.M()); + } + k0sIndicies.push_back(k0sCand.index()); + } for (const auto& trackIndex : trackIndicies) { - auto bTrack = dTracks1.rawIteratorAt(trackIndex); + auto bTrack = dTracks1.rawIteratorAt(trackIndex); for (const auto& k0sIndex : k0sIndicies) { auto k0sCand = dTracks2.rawIteratorAt(k0sIndex); @@ -1209,30 +1207,30 @@ struct Chk892pp { // QA plots if constexpr (!IsMix) { - if (cfgFillQAPlots) { - histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); - } - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/before/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/before/kstarinvmass"), lResoKstar.M()); + } + } if (lResoKstar.Rapidity() > KstarCuts.cfgKstarMaxRap || lResoKstar.Rapidity() < KstarCuts.cfgKstarMinRap) continue; if constexpr (!IsMix) { unsigned int typeKstar = bTrack.sign() > 0 ? BinType::kKstarP : BinType::kKstarN; - if (cfgFillQAPlots) { + if (cfgFillQAPlots) { - histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); - histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); - } - histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); + histos.fill(HIST("QA/after/KstarRapidity"), lResoKstar.Rapidity()); + histos.fill(HIST("QA/after/kstarinvmass"), lResoKstar.M()); + } + histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResoKstar.Pt(), lResoKstar.M()); if (BkgEstimationConfig.cfgFillRotBkg) { for (int i = 0; i < BkgEstimationConfig.cfgNrotBkg; i++) { auto lRotAngle = BkgEstimationConfig.cfgMinRot + i * ((BkgEstimationConfig.cfgMaxRot - BkgEstimationConfig.cfgMinRot) / (BkgEstimationConfig.cfgNrotBkg - 1)); - if (cfgFillQAPlots) { - histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); - } + if (cfgFillQAPlots) { + histos.fill(HIST("QA/RotBkg/hRotBkg"), lRotAngle); + } if (BkgEstimationConfig.cfgRotPion) { lDaughterRot = lDecayDaughter_bach; // lDaughterRot.RotateZ(lRotAngle); @@ -1252,13 +1250,13 @@ struct Chk892pp { histos.fill(HIST("hInvmass_Kstar"), typeKstar, lCentrality, lResonanceRot.Pt(), lResonanceRot.M()); } } - }// IsMix - }// K0scand - }// bTrack + } // IsMix + } // K0scand + } // bTrack count++; - }// fillHistograms + } // fillHistograms void processData(EventCandidates::iterator const& collision, TrackCandidates const& tracks, @@ -1289,19 +1287,17 @@ struct Chk892pp { { buildAllowedMcIds(events); buildReferenceMcIds(mccolls, mcpart); - effK0sProcessGen(mcpart); - effK0sProcessReco(v0s); - effKstarProcessGen(mcpart); - effKstarProcessReco(v0s, tracks); + effK0sProcessGen(mcpart); + effK0sProcessReco(v0s); + effKstarProcessGen(mcpart); + effKstarProcessReco(v0s, tracks); fillSigLossNum(mcpart); fillSigLossDen(mcpart); - for (const auto& mcid : refClassIds) - { + for (const auto& mcid : refClassIds) { histos.fill(HIST("Correction/EF_den"), refCentByMcId[mcid]); } - for (const auto& mcid : allowedMcIds) - { + for (const auto& mcid : allowedMcIds) { auto iter = centTruthByAllowed.find(mcid); if (iter == centTruthByAllowed.end()) continue; @@ -1311,19 +1307,19 @@ struct Chk892pp { } size_t nIntersect = 0; - for (const auto& mcid : allowedMcIds) if (refClassIds.count(mcid)) nIntersect++; + for (const auto& mcid : allowedMcIds) + if (refClassIds.count(mcid)) + nIntersect++; histos.fill(HIST("Correction/setSizes"), 0.0, refClassIds.size()); histos.fill(HIST("Correction/setSizes"), 1.0, allowedMcIds.size()); histos.fill(HIST("Correction/setSizes"), 2.0, nIntersect); histos.fill(HIST("Correction/setSizes"), 3.0, allowedMcIds.size() - nIntersect); - for (const auto& mcc : mccolls) - { + for (const auto& mcc : mccolls) { histos.fill(HIST("Correction/MCTruthCent_all"), mcc.centFT0M()); } - for (const auto& mcid : refClassIds) - { + for (const auto& mcid : refClassIds) { auto iter = refCentByMcId.find(mcid); if (iter == refCentByMcId.end()) continue; @@ -1331,44 +1327,39 @@ struct Chk892pp { histos.fill(HIST("Correction/MCTruthCent_cut"), lCentrality); } - for (auto const& mcc : mccolls) - { + for (auto const& mcc : mccolls) { const auto mcid = mcc.globalIndex(); histos.fill(HIST("Correction/hNEventsMCTruth"), 1.0); bool passZvtx = true; - if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) - { + if (cfgTruthIncludeZvtx && std::abs(mcc.posZ()) > EventCuts.cfgEvtZvtx) { passZvtx = false; } - if (passZvtx) - { + if (passZvtx) { histos.fill(HIST("Correction/hNEventsMCTruth"), 2.0); auto partsThisMc = mcpart.sliceBy(perMCCollision, mcid); - if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) - { + if (pwglf::isINELgtNmc(partsThisMc, 0, pdg)) { histos.fill(HIST("Correction/hNEventsMCTruth"), 3.0); } } - if (allowedMcIds.count(mcid)) - { + if (allowedMcIds.count(mcid)) { histos.fill(HIST("Correction/hNEventsMCTruth"), 4.0); } } } PROCESS_SWITCH(Chk892pp, processMC, "Process Event for MC", true); - void processMCQA(MCEventCandidates::iterator const& collision, - MCTrackCandidates const& tracks, - MCV0Candidates const& v0s, - aod::BCsWithTimestamps const&) - { - if (!colCuts.isSelected(collision)) - return; - if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) - return; + void processMCQA(MCEventCandidates::iterator const& collision, + MCTrackCandidates const& tracks, + MCV0Candidates const& v0s, + aod::BCsWithTimestamps const&) + { + if (!colCuts.isSelected(collision)) + return; + if (EventCuts.cfgEvtUseRCTFlagChecker && !rctChecker(collision)) + return; if (!collision.isInelGt0()) return; @@ -1382,7 +1373,7 @@ struct Chk892pp { colCuts.fillQA(collision); fillHistograms(collision, tracks, v0s); - } + } PROCESS_SWITCH(Chk892pp, processMCQA, "Process Event for MC and fill QA plots", false); };