From 212630cf7cf8c434e2cfc2396ededf736c0ac192 Mon Sep 17 00:00:00 2001 From: Omar Vazquez Date: Mon, 30 Jun 2025 14:05:09 -0600 Subject: [PATCH 1/2] Select MC charged particles --- PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx | 106 +++++++++++++++---- 1 file changed, 87 insertions(+), 19 deletions(-) diff --git a/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx index 261a5a0284e..d61778e98aa 100644 --- a/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx +++ b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx @@ -69,6 +69,7 @@ struct UccZdc { static constexpr float kCollEnergy{2.68}; static constexpr float kZero{0.}; + static constexpr float minCharge{3.f}; // Configurables Event Selection Configurable isNoCollInTimeRangeStrict{"isNoCollInTimeRangeStrict", true, "use isNoCollInTimeRangeStrict?"}; @@ -819,6 +820,7 @@ struct UccZdc { // Preslice perMCCollision = aod::mcparticle::mcCollisionId; Preslice perCollision = aod::track::collisionId; + Service pdg; TRandom* randPointer = new TRandom(); void processMCclosure(aod::McCollisions::iterator const& mccollision, soa::SmallGroups const& collisions, o2::aod::BCsRun3 const& /*bcs*/, aod::FT0s const& /*ft0s*/, aod::McParticles const& mcParticles, TheFilteredSimTracks const& simTracks) { @@ -879,9 +881,10 @@ struct UccZdc { return; } - std::vector pTs; - std::vector vecFD; - std::vector vecOneOverEff; + std::vector pTs; + std::vector vecFD; + std::vector vecEff; + std::vector vecOneOverEffXFD; // std::vector wIs; const auto& groupedTracks{simTracks.sliceBy(perCollision, collision.globalIndex())}; @@ -901,6 +904,8 @@ struct UccZdc { } // Calculates the event weight, W_k + const int foundNchBin{efficiency->GetXaxis()->FindBin(nchRaw)}; + for (const auto& track : groupedTracks) { // Track Selection if (track.eta() < minEta || track.eta() > maxEta) { @@ -912,12 +917,31 @@ struct UccZdc { if (!track.isGlobalTrack()) { continue; } + if (!track.has_mcParticle()) { + continue; + } + const auto& particle{track.mcParticle()}; + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } - float pt{track.pt()}; - int foundNchBin{efficiency->GetXaxis()->FindBin(nchRaw)}; - int foundPtBin{efficiency->GetYaxis()->FindBin(pt)}; - float effValue{1.}; - float fdValue{1.}; + // Is it a charged particle? + if (std::abs(charge) < minCharge) { + continue; + } + // Is it a primary particle? + // if (!particle.isPhysicalPrimary()) { continue; } + + const double pt{static_cast(track.pt())}; + const int foundPtBin{efficiency->GetYaxis()->FindBin(pt)}; + double effValue{1.}; + double fdValue{1.}; if (applyEff) { effValue = efficiency->GetBinContent(foundNchBin, foundPtBin); @@ -925,19 +949,19 @@ struct UccZdc { } if ((effValue > 0.) && (fdValue > 0.)) { pTs.emplace_back(pt); - vecOneOverEff.emplace_back(1. / effValue); + vecEff.emplace_back(effValue); vecFD.emplace_back(fdValue); + vecOneOverEffXFD.emplace_back(fdValue / effValue); } } - - nchMult = std::accumulate(vecOneOverEff.begin(), vecOneOverEff.end(), 0); + nchMult = std::accumulate(vecOneOverEffXFD.begin(), vecOneOverEffXFD.end(), 0); if (nchMult < minNchSel) { return; } double p1, p2, p3, p4, w1, w2, w3, w4; p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; - getPTpowers(pTs, vecOneOverEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); const double denTwoParCorr{std::pow(w1, 2.) - w2}; const double numTwoParCorr{std::pow(p1, 2.) - p2}; @@ -971,6 +995,21 @@ struct UccZdc { if (particle.pt() < minPt || particle.pt() > maxPt) { continue; } + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < minCharge) { + continue; + } + // Is it a primary particle? if (!particle.isPhysicalPrimary()) { continue; } @@ -1044,9 +1083,23 @@ struct UccZdc { if (!track.has_mcParticle()) { continue; } - registry.fill(HIST("Pt_all_ch"), nchRaw, track.pt()); - + // Get the MC particle const auto& particle{track.mcParticle()}; + auto charge{0.}; + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < minCharge) { + continue; + } + // All charged particles + registry.fill(HIST("Pt_all_ch"), nchRaw, track.pt()); + // Is it a primary particle? if (!particle.isPhysicalPrimary()) { continue; } @@ -1075,6 +1128,21 @@ struct UccZdc { if (particle.pt() < minPt || particle.pt() > maxPt) { continue; } + + auto charge{0.}; + // Get the MC particle + auto* pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (pdgParticle != nullptr) { + charge = pdgParticle->Charge(); + } else { + continue; + } + + // Is it a charged particle? + if (std::abs(charge) < minCharge) { + continue; + } + // Is it a primary particle? if (!particle.isPhysicalPrimary()) { continue; } @@ -1101,14 +1169,14 @@ struct UccZdc { PROCESS_SWITCH(UccZdc, processMCclosure, "Process MC closure", false); template - void getPTpowers(const T& pTs, const T& vecOneOverEff, const T& vecFD, U& pOne, U& wOne, U& pTwo, U& wTwo, U& pThree, U& wThree, U& pFour, U& wFour) + void getPTpowers(const T& pTs, const T& vecEff, const T& vecFD, U& pOne, U& wOne, U& pTwo, U& wTwo, U& pThree, U& wThree, U& pFour, U& wFour) { pOne = wOne = pTwo = wTwo = pThree = wThree = pFour = wFour = 0.; for (std::size_t i = 0; i < pTs.size(); ++i) { - const float pTi{pTs.at(i)}; - const float eFFi{vecOneOverEff.at(i)}; - const float fDi{vecFD.at(i)}; - const float wEighti{eFFi * fDi}; + const double pTi{pTs.at(i)}; + const double eFFi{vecEff.at(i)}; + const double fDi{vecFD.at(i)}; + const double wEighti{pow(eFFi, -1.) * fDi}; pOne += wEighti * pTi; wOne += wEighti; pTwo += std::pow(wEighti * pTi, 2.); From e391675e350a468715eb4ea3cc0d62574e1909c8 Mon Sep 17 00:00:00 2001 From: Omar Vazquez Date: Mon, 30 Jun 2025 14:29:15 -0600 Subject: [PATCH 2/2] Select MC charged particles v2 --- PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx index d61778e98aa..c00bd607966 100644 --- a/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx +++ b/PWGLF/Tasks/GlobalEventProperties/uccZdc.cxx @@ -69,7 +69,7 @@ struct UccZdc { static constexpr float kCollEnergy{2.68}; static constexpr float kZero{0.}; - static constexpr float minCharge{3.f}; + static constexpr float kMinCharge{3.f}; // Configurables Event Selection Configurable isNoCollInTimeRangeStrict{"isNoCollInTimeRangeStrict", true, "use isNoCollInTimeRangeStrict?"}; @@ -711,6 +711,7 @@ struct UccZdc { std::vector pTs; std::vector vecFD; + std::vector vecEff; std::vector vecOneOverEff; // Calculates the Nch multiplicity @@ -748,7 +749,7 @@ struct UccZdc { // Fill vectors for [pT] measurement pTs.clear(); vecFD.clear(); - vecOneOverEff.clear(); + vecEff.clear(); for (const auto& track : tracks) { // Track Selection if (!track.isGlobalTrack()) { @@ -772,7 +773,7 @@ struct UccZdc { } if ((effValue > 0.) && (fdValue > 0.)) { pTs.emplace_back(pt); - vecOneOverEff.emplace_back(1. / effValue); + vecEff.emplace_back(effValue); vecFD.emplace_back(fdValue); } // To calculate event-averaged @@ -781,7 +782,7 @@ struct UccZdc { double p1, p2, p3, p4, w1, w2, w3, w4; p1 = p2 = p3 = p4 = w1 = w2 = w3 = w4 = 0.0; - getPTpowers(pTs, vecOneOverEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); + getPTpowers(pTs, vecEff, vecFD, p1, w1, p2, w2, p3, w3, p4, w4); // EbE one-particle pT correlation double oneParCorr{p1 / w1}; @@ -932,7 +933,7 @@ struct UccZdc { } // Is it a charged particle? - if (std::abs(charge) < minCharge) { + if (std::abs(charge) < kMinCharge) { continue; } // Is it a primary particle? @@ -1006,7 +1007,7 @@ struct UccZdc { } // Is it a charged particle? - if (std::abs(charge) < minCharge) { + if (std::abs(charge) < kMinCharge) { continue; } // Is it a primary particle? @@ -1094,7 +1095,7 @@ struct UccZdc { } // Is it a charged particle? - if (std::abs(charge) < minCharge) { + if (std::abs(charge) < kMinCharge) { continue; } // All charged particles @@ -1139,7 +1140,7 @@ struct UccZdc { } // Is it a charged particle? - if (std::abs(charge) < minCharge) { + if (std::abs(charge) < kMinCharge) { continue; } // Is it a primary particle? @@ -1176,7 +1177,7 @@ struct UccZdc { const double pTi{pTs.at(i)}; const double eFFi{vecEff.at(i)}; const double fDi{vecFD.at(i)}; - const double wEighti{pow(eFFi, -1.) * fDi}; + const double wEighti{std::pow(eFFi, -1.) * fDi}; pOne += wEighti * pTi; wOne += wEighti; pTwo += std::pow(wEighti * pTi, 2.);