Skip to content

Commit d2b8df4

Browse files
author
Sawan Sawan
committed
optimising code
1 parent 0d88ba4 commit d2b8df4

File tree

2 files changed

+37
-25
lines changed

2 files changed

+37
-25
lines changed

PWGLF/Tasks/Resonances/higherMassResonances.cxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,9 @@ struct HigherMassResonances {
173173

174174
// fixed variables
175175
float rapidityMotherData = 0.5;
176-
std::array<int, 6> numbers = {0, 1, 2, 3, 4, 5};
177-
double beamMomentum = std::sqrt(13600 * 13600 / 4 - o2::constants::physics::MassProton * o2::constants::physics::MassProton); // GeV
176+
float beamEnergy = 13600.0;
177+
double beamMomentum = std::sqrt(beamEnergy * beamEnergy / 4 - o2::constants::physics::MassProton * o2::constants::physics::MassProton); // GeV
178+
int noOfDaughters = 2;
178179
} config;
179180

180181
// Service<o2::framework::O2DatabasePDG> PDGdatabase;
@@ -859,7 +860,7 @@ struct HigherMassResonances {
859860
}
860861
int sizeofv0indexes = v0indexes.size();
861862
rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes);
862-
if (config.selectTWOKsOnly && sizeofv0indexes == config.numbers[2] && allConditionsMet) {
863+
if (config.selectTWOKsOnly && sizeofv0indexes == config.noOfDaughters && allConditionsMet) {
863864
fillInvMass(mother, multiplicity, daughter1, daughter2, false);
864865
}
865866
v0indexes.clear();
@@ -980,7 +981,7 @@ struct HigherMassResonances {
980981
}
981982
int sizeofv0indexes = v0indexes.size();
982983
rKzeroShort.fill(HIST("NksProduced"), sizeofv0indexes);
983-
if (config.selectTWOKsOnly && sizeofv0indexes == config.numbers[2] && allConditionsMet) {
984+
if (config.selectTWOKsOnly && sizeofv0indexes == config.noOfDaughters && allConditionsMet) {
984985
fillInvMass(mother, multiplicity, daughter1, daughter2, false);
985986
}
986987
v0indexes.clear();
@@ -1363,7 +1364,7 @@ struct HigherMassResonances {
13631364
// counter++;
13641365

13651366
auto kDaughters = mcParticle.daughters_as<aod::McParticles>();
1366-
if (kDaughters.size() != config.numbers[2]) {
1367+
if (kDaughters.size() != config.noOfDaughters) {
13671368
continue;
13681369
}
13691370
hMChists.fill(HIST("events_check"), 7.5);
@@ -1380,12 +1381,12 @@ struct HigherMassResonances {
13801381
hMChists.fill(HIST("events_check"), 9.5);
13811382
if (passKs.size() == 1) {
13821383
daughter1 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassK0Short);
1383-
} else if (passKs.size() == config.numbers[2]) {
1384+
} else if (static_cast<int>(passKs.size()) == config.noOfDaughters) {
13841385
daughter2 = ROOT::Math::PxPyPzMVector(kCurrentDaughter.px(), kCurrentDaughter.py(), kCurrentDaughter.pz(), o2::constants::physics::MassK0Short);
13851386
}
13861387
}
13871388
}
1388-
if (passKs.size() == config.numbers[2]) {
1389+
if (static_cast<int>(passKs.size()) == config.noOfDaughters) {
13891390
lResonanceGen = ROOT::Math::PxPyPzEVector(mcParticle.pt(), mcParticle.eta(), mcParticle.phi(), mcParticle.e());
13901391
lResonanceGen1 = daughter1 + daughter2;
13911392

PWGLF/Tasks/Resonances/kstarqa.cxx

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,22 @@ struct Kstarqa {
104104
Configurable<float> cfgTPCChi2NCl{"cfgTPCChi2NCl", 4.0, "TPC Chi2/NCl"};
105105

106106
// Other fixed variables
107-
float lowpTcutinpTdepPID = 0.5;
108-
std::array<int, 6> numbers = {0, 1, 2, 3, 4, 5};
107+
float lowPtCutPID = 0.5;
108+
int noOfDaughters = 2;
109109
float rapidityMotherData = 0.5;
110110

111111
} selectionConfig;
112112

113+
enum MultEstimator {
114+
kFT0M,
115+
kFT0A,
116+
kFT0C,
117+
kFV0A,
118+
kFV0C,
119+
kFV0M,
120+
kNEstimators // useful if you want to iterate or size things
121+
};
122+
113123
// Histograms are defined with HistogramRegistry
114124
HistogramRegistry rEventSelection{"eventSelection", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
115125
HistogramRegistry hInvMass{"hInvMass", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
@@ -498,23 +508,23 @@ struct Kstarqa {
498508
bool selectionPIDNew(const T& candidate, int PID)
499509
{
500510
if (PID == 0) {
501-
if (candidate.pt() < selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi) {
511+
if (candidate.pt() < selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi) {
502512
return true;
503513
}
504-
if (candidate.pt() >= selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOFPi) {
514+
if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && candidate.hasTOF() && std::abs(candidate.tofNSigmaPi()) < nsigmaCutTOFPi) {
505515
return true;
506516
}
507-
if (candidate.pt() >= selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && !candidate.hasTOF()) {
517+
if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaPi()) < nsigmaCutTPCPi && !candidate.hasTOF()) {
508518
return true;
509519
}
510520
} else if (PID == 1) {
511-
if (candidate.pt() < selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa) {
521+
if (candidate.pt() < selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa) {
512522
return true;
513523
}
514-
if (candidate.pt() >= selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < nsigmaCutTOFKa) {
524+
if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && candidate.hasTOF() && std::abs(candidate.tofNSigmaKa()) < nsigmaCutTOFKa) {
515525
return true;
516526
}
517-
if (candidate.pt() >= selectionConfig.lowpTcutinpTdepPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && !candidate.hasTOF()) {
527+
if (candidate.pt() >= selectionConfig.lowPtCutPID && std::abs(candidate.tpcNSigmaKa()) < nsigmaCutTPCKa && !candidate.hasTOF()) {
518528
return true;
519529
}
520530
}
@@ -799,17 +809,18 @@ struct Kstarqa {
799809

800810
multiplicity = -1;
801811

802-
if (cSelectMultEstimator == selectionConfig.numbers[0]) { // FT0M
812+
if (cSelectMultEstimator == kFT0M) {
803813
multiplicity = collision.centFT0M();
804-
} else if (cSelectMultEstimator == selectionConfig.numbers[1]) {
814+
} else if (cSelectMultEstimator == kFT0A) {
805815
multiplicity = collision.centFT0A();
806-
} else if (cSelectMultEstimator == selectionConfig.numbers[2]) {
816+
} else if (cSelectMultEstimator == kFT0C) {
807817
multiplicity = collision.centFT0C();
808-
} else if (cSelectMultEstimator == selectionConfig.numbers[3]) {
818+
} else if (cSelectMultEstimator == kFV0A) {
809819
multiplicity = collision.centFV0A();
810820
} else {
811-
multiplicity = collision.centFT0M();
821+
multiplicity = collision.centFT0M(); // default
812822
}
823+
813824
/* else if (cSelectMultEstimator == 4) {
814825
multiplicity = collision.centMFT();
815826
} */
@@ -998,13 +1009,13 @@ struct Kstarqa {
9981009
};
9991010

10001011
// Call mixing based on selected estimator
1001-
if (cSelectMultEstimator == selectionConfig.numbers[0]) { // FT0M
1012+
if (cSelectMultEstimator == kFT0M) {
10021013
runMixing(pair1, [](const auto& c) { return c.centFT0M(); });
1003-
} else if (cSelectMultEstimator == selectionConfig.numbers[1]) {
1014+
} else if (cSelectMultEstimator == kFT0A) {
10041015
runMixing(pair2, [](const auto& c) { return c.centFT0A(); });
1005-
} else if (cSelectMultEstimator == selectionConfig.numbers[2]) {
1016+
} else if (cSelectMultEstimator == kFT0C) {
10061017
runMixing(pair3, [](const auto& c) { return c.centFT0C(); });
1007-
} else if (cSelectMultEstimator == selectionConfig.numbers[3]) {
1018+
} else if (cSelectMultEstimator == kFV0A) {
10081019
runMixing(pair4, [](const auto& c) { return c.centFV0A(); });
10091020
}
10101021
}
@@ -1099,7 +1110,7 @@ struct Kstarqa {
10991110
hInvMass.fill(HIST("hAllKstarGenCollisisons1Rec"), multiplicity, mcParticle.pt());
11001111

11011112
auto kDaughters = mcParticle.daughters_as<aod::McParticles>();
1102-
if (kDaughters.size() != selectionConfig.numbers[2]) {
1113+
if (kDaughters.size() != selectionConfig.noOfDaughters) {
11031114
continue;
11041115
}
11051116

0 commit comments

Comments
 (0)