Skip to content

Commit 88719d7

Browse files
authored
Update strangenessInJets.cxx
1 parent 886a5b5 commit 88719d7

File tree

1 file changed

+45
-96
lines changed

1 file changed

+45
-96
lines changed

PWGLF/Tasks/Strangeness/strangenessInJets.cxx

Lines changed: 45 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,10 @@
6767
#include <string>
6868
#include <vector>
6969

70-
using namespace std;
7170
using namespace o2;
72-
using namespace o2::soa;
73-
using namespace o2::aod;
7471
using namespace o2::framework;
7572
using namespace o2::framework::expressions;
7673
using namespace o2::constants::math;
77-
using std::array;
7874

7975
// Define convenient aliases for joined AOD tables
8076
using SelCollisions = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Ms>;
@@ -197,7 +193,7 @@ struct StrangenessInJets {
197193
enabled += checkEnabled(ParticleOfInterest::kKaons);
198194
enabled += checkEnabled(ParticleOfInterest::kProtons);
199195
if (enabled == 0) {
200-
LOG(fatal) << "At least one particle species must be enabled for the analysis. Please check the configuration of the task." << endl;
196+
LOG(fatal) << "At least one particle species must be enabled for the analysis. Please check the configuration of the task.";
201197
}
202198

203199
// Define binning and axis specifications for multiplicity, eta, pT, PID, and invariant mass histograms
@@ -319,7 +315,7 @@ struct StrangenessInJets {
319315
const AxisSpec axisInJetOutOfJet = AxisSpec{2, -2., 2., "In jet / Out of jet"};
320316
const AxisSpec axisCharge = AxisSpec{2, -2., 2., "Charge"};
321317
const AxisSpec axisParticleType = AxisSpec{3, -0.5, 2.5, "Particle Type"};
322-
registryData.add("LongLivedGenerated", "LongLivedGenerated", HistType::kTHnSparseF, {axisInJetOutOfJet, axisParticleType, axisCharge, ptAxisLongLived, multAxis});
318+
registryMC.add("LongLivedGenerated", "LongLivedGenerated", HistType::kTHnSparseF, {axisInJetOutOfJet, axisParticleType, axisCharge, ptAxisLongLived, multAxis});
323319
}
324320
}
325321

@@ -385,11 +381,31 @@ struct StrangenessInJets {
385381
const AxisSpec axisCharge = AxisSpec{2, -2., 2., "Charge"};
386382
const AxisSpec axisParticleType = AxisSpec{3, -0.5, 2.5, "Particle Type"};
387383
const AxisSpec axisDetector = AxisSpec{2, -0.5, 1.5, "TPC / TOF"};
388-
registryData.add("LongLivedReconstructed", "LongLivedReconstructed", HistType::kTHnSparseF, {axisInJetOutOfJet, axisParticleType, axisCharge, ptAxisLongLived, multAxis, axisDetector});
384+
registryMC.add("LongLivedReconstructed", "LongLivedReconstructed", HistType::kTHnSparseF, {axisInJetOutOfJet, axisParticleType, axisCharge, ptAxisLongLived, multAxis, axisDetector});
389385
}
390386
}
391387
}
392388

389+
bool pdgToLongLivedIndex(const int pdg, float& particle, float& charge)
390+
{
391+
switch (std::abs(pdg)) {
392+
case PDG_t::kPiPlus:
393+
particle = 0; // pion
394+
charge = (pdg > 0) ? 1 : -1;
395+
return enabledSignals.value[ParticleOfInterest::kPions];
396+
case PDG_t::kKPlus:
397+
particle = 1; // kaon
398+
charge = (pdg > 0) ? 1 : -1;
399+
return enabledSignals.value[ParticleOfInterest::kKaons];
400+
case PDG_t::kProton:
401+
particle = 2; // proton
402+
charge = (pdg > 0) ? 1 : -1;
403+
return enabledSignals.value[ParticleOfInterest::kProtons];
404+
default:
405+
return false;
406+
}
407+
}
408+
393409
// Delta phi calculation
394410
double getDeltaPhi(double a1, double a2)
395411
{
@@ -1129,7 +1145,9 @@ struct StrangenessInJets {
11291145
}
11301146
}
11311147
}
1132-
if (enabledSignals.value[ParticleOfInterest::kPions] || enabledSignals.value[ParticleOfInterest::kKaons] || enabledSignals.value[ParticleOfInterest::kProtons]) {
1148+
if (enabledSignals.value[ParticleOfInterest::kPions] ||
1149+
enabledSignals.value[ParticleOfInterest::kKaons] ||
1150+
enabledSignals.value[ParticleOfInterest::kProtons]) {
11331151
for (const auto& trk : tracks) {
11341152

11351153
if (!passedSingleTrackSelection(trk)) {
@@ -1424,33 +1442,14 @@ struct StrangenessInJets {
14241442
}
14251443
break;
14261444
case kPiPlus:
1427-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1428-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 0.f, 1.f, hadron.first.Pt(), genMultiplicity);
1429-
}
1430-
break;
1431-
case kKPlus:
1432-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
1433-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 1.f, 1.f, hadron.first.Pt(), genMultiplicity);
1434-
}
1435-
break;
1436-
case kProton:
1437-
if (enabledSignals.value[ParticleOfInterest::kProtons]) {
1438-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 2.f, 1.f, hadron.first.Pt(), genMultiplicity);
1439-
}
1440-
break;
14411445
case kPiMinus:
1442-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1443-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 0.f, -1.f, hadron.first.Pt(), genMultiplicity);
1444-
}
1445-
break;
1446+
case kKPlus:
14461447
case kKMinus:
1447-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
1448-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 1.f, -1.f, hadron.first.Pt(), genMultiplicity);
1449-
}
1450-
break;
1448+
case kProton:
14511449
case kProtonBar:
1452-
if (enabledSignals.value[ParticleOfInterest::kProtons]) {
1453-
registryMC.fill(HIST("LongLivedGenerated"), -1.f, 2.f, -1.f, hadron.first.Pt(), genMultiplicity);
1450+
float particleId, chargeId;
1451+
if (pdgToLongLivedIndex(hadron.second, particleId, chargeId)) {
1452+
registryMC.fill(HIST("LongLivedGenerated"), -1.f, particleId, chargeId, hadron.first.Pt(), genMultiplicity);
14541453
}
14551454
break;
14561455
default:
@@ -1497,33 +1496,14 @@ struct StrangenessInJets {
14971496
}
14981497
break;
14991498
case kPiPlus:
1500-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1501-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 0.f, 1.f, hadron.first.Pt(), genMultiplicity);
1502-
}
1503-
break;
1504-
case kKPlus:
1505-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
1506-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 1.f, 1.f, hadron.first.Pt(), genMultiplicity);
1507-
}
1508-
break;
1509-
case kProton:
1510-
if (enabledSignals.value[ParticleOfInterest::kProtons]) {
1511-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 2.f, 1.f, hadron.first.Pt(), genMultiplicity);
1512-
}
1513-
break;
15141499
case kPiMinus:
1515-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1516-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 0.f, -1.f, hadron.first.Pt(), genMultiplicity);
1517-
}
1518-
break;
1500+
case kKPlus:
15191501
case kKMinus:
1520-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
1521-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 1.f, -1.f, hadron.first.Pt(), genMultiplicity);
1522-
}
1523-
break;
1502+
case kProton:
15241503
case kProtonBar:
1525-
if (enabledSignals.value[ParticleOfInterest::kProtons]) {
1526-
registryMC.fill(HIST("LongLivedGenerated"), 1.f, 2.f, -1.f, hadron.first.Pt(), genMultiplicity);
1504+
float particleId, chargeId;
1505+
if (pdgToLongLivedIndex(hadron.second, particleId, chargeId)) {
1506+
registryMC.fill(HIST("LongLivedGenerated"), 1.f, particleId, chargeId, hadron.first.Pt(), genMultiplicity);
15271507
}
15281508
break;
15291509
default:
@@ -1692,6 +1672,7 @@ struct StrangenessInJets {
16921672
if (enabledSignals.value[ParticleOfInterest::kPions]) {
16931673
registryMC.fill(HIST("Pion_Plus_reconstructed_fullevent"), multiplicity, trk.pt());
16941674
}
1675+
break;
16951676
case kPiMinus:
16961677
if (enabledSignals.value[ParticleOfInterest::kPions]) {
16971678
registryMC.fill(HIST("Pion_Minus_reconstructed_fullevent"), multiplicity, trk.pt());
@@ -1984,46 +1965,14 @@ struct StrangenessInJets {
19841965
const double deltaPhiUe2 = getDeltaPhi(trackDir.Phi(), ue2[i].Phi());
19851966
const double deltaRue2 = std::sqrt(deltaEtaUe2 * deltaEtaUe2 + deltaPhiUe2 * deltaPhiUe2);
19861967

1987-
float indexParticle = -1;
1988-
float indexCharge = 0;
1989-
switch (mcParticle.pdgCode()) {
1990-
case kPiPlus:
1991-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1992-
indexParticle = 0;
1993-
indexCharge = 1;
1994-
}
1995-
break;
1996-
case kPiMinus:
1997-
if (enabledSignals.value[ParticleOfInterest::kPions]) {
1998-
indexParticle = 0;
1999-
indexCharge = -1;
2000-
}
2001-
break;
2002-
case kKPlus:
2003-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
2004-
indexParticle = 1;
2005-
indexCharge = 1;
2006-
}
2007-
case kKMinus:
2008-
if (enabledSignals.value[ParticleOfInterest::kKaons]) {
2009-
indexParticle = 1;
2010-
indexCharge = -1;
2011-
}
2012-
break;
2013-
case kProton:
2014-
if (enabledSignals.value[ParticleOfInterest::kProtons]) {
2015-
indexParticle = 2;
2016-
indexCharge = 1;
2017-
}
2018-
}
2019-
if (indexParticle <= -0.5f) {
2020-
continue;
2021-
}
2022-
if (deltaRjet < rJet) {
2023-
registryMC.fill(HIST("LongLivedReconstructed"), -1.f, indexParticle, indexCharge, trk.pt(), multiplicity, (trk.hasTOF() ? 1 : 0));
2024-
}
2025-
if (deltaRue1 < rJet || deltaRue2 < rJet) {
2026-
registryMC.fill(HIST("LongLivedReconstructed"), 1.f, indexParticle, indexCharge, trk.pt(), multiplicity, (trk.hasTOF() ? 1 : 0));
1968+
float particleId, chargeId;
1969+
if (pdgToLongLivedIndex(mcParticle.pdgCode(), particleId, chargeId)) {
1970+
if (deltaRjet < rJet) {
1971+
registryMC.fill(HIST("LongLivedReconstructed"), -1.f, indexParticle, indexCharge, trk.pt(), multiplicity, (trk.hasTOF() ? 1 : 0));
1972+
}
1973+
if (deltaRue1 < rJet || deltaRue2 < rJet) {
1974+
registryMC.fill(HIST("LongLivedReconstructed"), 1.f, indexParticle, indexCharge, trk.pt(), multiplicity, (trk.hasTOF() ? 1 : 0));
1975+
}
20271976
}
20281977
}
20291978
}

0 commit comments

Comments
 (0)