Skip to content

Commit f9651ed

Browse files
committed
refactoring for efficiency improvement
1 parent f8be077 commit f9651ed

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

PWGLF/Tasks/Nuspex/antinucleiInJets.cxx

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,7 @@ struct AntinucleiInJets {
13851385

13861386
// Loop over all MC particles
13871387
std::vector<fastjet::PseudoJet> fjParticles;
1388+
std::vector<TVector3> protonMomentum;
13881389
for (const auto& particle : mcParticles) {
13891390

13901391
// Select physical primaries within acceptance
@@ -1394,6 +1395,12 @@ struct AntinucleiInJets {
13941395
if (particle.eta() < minEta || particle.eta() > maxEta || particle.pt() < MinPtParticle)
13951396
continue;
13961397

1398+
// Store 3-momentum vectors of antiprotons for further analysis
1399+
if (particle.pdgCode() == PDG_t::kProtonBar) {
1400+
TVector3 pVec(particle.px(), particle.py(), particle.pz());
1401+
protonMomentum.push_back(pVec);
1402+
}
1403+
13971404
// 4-momentum representation of a particle
13981405
double energy = std::sqrt(particle.p() * particle.p() + MassPionCharged * MassPionCharged);
13991406
fastjet::PseudoJet fourMomentum(particle.px(), particle.py(), particle.pz(), energy);
@@ -1454,23 +1461,14 @@ struct AntinucleiInJets {
14541461
getPerpendicularAxis(jetAxis, ueAxis2, -1);
14551462

14561463
// Loop over MC particles to analyze underlying event region
1457-
for (const auto& particle : mcParticles) {
1458-
1459-
// Antiproton selection based on the pdg
1460-
if (particle.user_index() != PDG_t::kProtonBar)
1461-
continue;
1462-
1463-
// Select physical primaries within the acceptance
1464-
static constexpr double MinPtParticle = 0.1;
1465-
if (particle.eta() < minEta || particle.eta() > maxEta || particle.pt() < MinPtParticle)
1466-
continue;
1464+
for (const auto& protonVec : protonMomentum) {
14671465

14681466
// Compute distance of particle from both perpendicular cone axes
1469-
double deltaEtaUe1 = particle.eta() - ueAxis1.Eta();
1470-
double deltaPhiUe1 = getDeltaPhi(particle.phi(), ueAxis1.Phi());
1467+
double deltaEtaUe1 = protonVec.Eta() - ueAxis1.Eta();
1468+
double deltaPhiUe1 = getDeltaPhi(protonVec.Phi(), ueAxis1.Phi());
14711469
double deltaRUe1 = std::sqrt(deltaEtaUe1 * deltaEtaUe1 + deltaPhiUe1 * deltaPhiUe1);
1472-
double deltaEtaUe2 = particle.eta() - ueAxis2.Eta();
1473-
double deltaPhiUe2 = getDeltaPhi(particle.phi(), ueAxis2.Phi());
1470+
double deltaEtaUe2 = protonVec.Eta() - ueAxis2.Eta();
1471+
double deltaPhiUe2 = getDeltaPhi(protonVec.Phi(), ueAxis2.Phi());
14741472
double deltaRUe2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2);
14751473

14761474
// Determine the maximum allowed distance from UE axes for particle selection
@@ -1484,7 +1482,7 @@ struct AntinucleiInJets {
14841482
continue;
14851483

14861484
// Fill histogram for antiprotons in the UE
1487-
registryMC.fill(HIST("antiproton_gen_ue"), particle.pt());
1485+
registryMC.fill(HIST("antiproton_gen_ue"), protonVec.Pt());
14881486
}
14891487
}
14901488
if (isAtLeastOneJetSelected) {

0 commit comments

Comments
 (0)