Skip to content

Commit e5ca551

Browse files
authored
Refactor hResonanceCorrelation.cxx for clarity and safety
1 parent 3a3e005 commit e5ca551

1 file changed

Lines changed: 41 additions & 39 deletions

File tree

‎PWGLF/Tasks/Resonances/hResonanceCorrelation.cxx‎

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,17 @@ struct HResonanceCorrelation {
256256
int region;
257257
float efficiency;
258258
float efficiencyError;
259-
int type;
259+
// no species tag stored here: the `type` argument to addValidParticle
260+
// below (-1 = trigger, else Phi/K*0) only decides which vector this
261+
// particle goes into; once stored, nothing reads it back.
260262
};
261-
float pvz;
262-
float mult;
263+
float pvz = 0.f;
264+
float mult = 0.f;
263265
std::vector<ValidParticle> trigParticles;
264266
std::vector<ValidParticle> assocParticles;
265267
void addValidParticle(float eta, float phi, float pt, int region, float efficiency, float efficiencyError, int type)
266268
{
267-
ValidParticle particle{eta, phi, pt, region, efficiency, efficiencyError, type};
269+
ValidParticle particle{eta, phi, pt, region, efficiency, efficiencyError};
268270

269271
if (type == -1) {
270272
trigParticles.push_back(particle);
@@ -278,29 +280,29 @@ struct HResonanceCorrelation {
278280
ValidCollisions validCollisions;
279281

280282
// objects to use for efficiency corrections
281-
TH2F* hEfficiencyTrigger;
282-
TH3F* hEfficiencyTriggerMult;
283-
THnF* hEfficiencyTriggerMultVsPhi;
284-
TH2F* hEfficiencyPion;
285-
TH2F* hEfficiencyPhi;
286-
THnF* hEfficiencyPhiMultVsPhi;
287-
TH2F* hEfficiencyKstar;
288-
THnF* hEfficiencyKstarMultVsPhi;
289-
TH2F* hEfficiencyHadron;
290-
TH3F* hEfficiencyHadronMult;
291-
TH1F* hPurityHadron;
292-
TH2F* hPurityHadronMult;
283+
TH2F* hEfficiencyTrigger = nullptr;
284+
TH3F* hEfficiencyTriggerMult = nullptr;
285+
THnF* hEfficiencyTriggerMultVsPhi = nullptr;
286+
TH2F* hEfficiencyPion = nullptr;
287+
TH2F* hEfficiencyPhi = nullptr;
288+
THnF* hEfficiencyPhiMultVsPhi = nullptr;
289+
TH2F* hEfficiencyKstar = nullptr;
290+
THnF* hEfficiencyKstarMultVsPhi = nullptr;
291+
TH2F* hEfficiencyHadron = nullptr;
292+
TH3F* hEfficiencyHadronMult = nullptr;
293+
TH1F* hPurityHadron = nullptr;
294+
TH2F* hPurityHadronMult = nullptr;
293295

294296
// objects to propagate the efficiency uncertainty
295-
TH2F* hEfficiencyUncertaintyTrigger;
296-
TH3F* hEfficiencyUncertaintyTriggerMult;
297-
TH2F* hEfficiencyUncertaintyPion;
298-
TH2F* hEfficiencyUncertaintyPhi;
299-
TH2F* hEfficiencyUncertaintyKstar;
300-
TH2F* hEfficiencyUncertaintyHadron;
301-
TH3F* hEfficiencyUncertaintyHadronMult;
302-
TH1F* hPurityUncertaintyHadron;
303-
TH2F* hPurityUncertaintyHadronMult;
297+
TH2F* hEfficiencyUncertaintyTrigger = nullptr;
298+
TH3F* hEfficiencyUncertaintyTriggerMult = nullptr;
299+
TH2F* hEfficiencyUncertaintyPion = nullptr;
300+
TH2F* hEfficiencyUncertaintyPhi = nullptr;
301+
TH2F* hEfficiencyUncertaintyKstar = nullptr;
302+
TH2F* hEfficiencyUncertaintyHadron = nullptr;
303+
TH3F* hEfficiencyUncertaintyHadronMult = nullptr;
304+
TH1F* hPurityUncertaintyHadron = nullptr;
305+
TH2F* hPurityUncertaintyHadronMult = nullptr;
304306

305307
using BinningTypePP = ColumnBinningPolicy<aod::collision::PosZ, aod::cent::CentFT0M>;
306308
using BinningTypePbPb = ColumnBinningPolicy<aod::collision::PosZ, aod::cent::CentFT0C>;
@@ -320,9 +322,9 @@ struct HResonanceCorrelation {
320322
static constexpr int IndexKstar = 1;
321323
static constexpr int IndexPion = 2;
322324

323-
uint16_t doCorrelation;
324-
int mRunNumber;
325-
int mRunNumberZorro;
325+
uint16_t doCorrelation = 0;
326+
int mRunNumber = 0;
327+
int mRunNumberZorro = 0;
326328

327329
std::vector<std::vector<float>> axisRanges;
328330

@@ -1075,7 +1077,7 @@ struct HResonanceCorrelation {
10751077
return true;
10761078
}
10771079

1078-
double calculateAverageDeltaPhiStar(double* trigg, double* assoc, double B)
1080+
double calculateAverageDeltaPhiStar(const double* trigg, const double* assoc, double B)
10791081
{
10801082
double dPhiStar = 0;
10811083
double dPhiStarMean = 0;
@@ -1361,7 +1363,7 @@ struct HResonanceCorrelation {
13611363
c.isRightBg = (massWindowConfigurationsPhi.minBgNSigma * sig < delta && delta < massWindowConfigurationsPhi.maxBgNSigma * sig);
13621364

13631365
c.passesMcSelection = (!masterConfigurations.doMCassociation || assocCandidate.mcTruePhi()) &&
1364-
(!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary());
1366+
(!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary());
13651367

13661368
// Candidate-level kinematic/spectrum QA, ported from the equivalent
13671369
// block in hStrangeCorrelation.cxx (h3d<Species>Spectrum[Y],
@@ -1712,7 +1714,7 @@ struct HResonanceCorrelation {
17121714
c.isRightBg = (massWindowConfigurationsKstar.minBgNSigma * sig < delta && delta < massWindowConfigurationsKstar.maxBgNSigma * sig);
17131715

17141716
c.passesMcSelection = (!masterConfigurations.doMCassociation || assocCandidate.mcTrueKstar()) &&
1715-
(!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary());
1717+
(!doAssocPhysicalPrimary || assocCandidate.mcPhysicalPrimary());
17161718

17171719
// Same candidate-level Spectrum/EtaVsPtVsPhi QA as fillCorrelationsPhi
17181720
// above -- see the comment there for rationale.
@@ -2717,7 +2719,7 @@ struct HResonanceCorrelation {
27172719
std::vector<uint32_t> piIndices;
27182720
std::vector<uint32_t> phiIndices;
27192721
std::vector<uint32_t> kstarIndices; // intentionally left unpopulated: Kstar0 is not
2720-
// extended to this process function in this version
2722+
// extended to this process function in this version
27212723

27222724
for (auto const& mcParticle : mcParticles) {
27232725
double geta = mcParticle.eta();
@@ -2830,9 +2832,9 @@ struct HResonanceCorrelation {
28302832
}
28312833
}
28322834

2833-
associatedIndices.emplace_back(phiIndices); // IndexPhi = 0
2834-
associatedIndices.emplace_back(kstarIndices); // IndexKstar = 1 (always empty here)
2835-
associatedIndices.emplace_back(piIndices); // IndexPion = 2
2835+
associatedIndices.emplace_back(phiIndices); // IndexPhi = 0
2836+
associatedIndices.emplace_back(kstarIndices); // IndexKstar = 1 (always empty here)
2837+
associatedIndices.emplace_back(piIndices); // IndexPion = 2
28362838
associatedIndices.emplace_back(assocHadronIndices); // Hadron = 3
28372839

28382840
for (std::size_t iTrigger = 0; iTrigger < triggerIndices.size(); iTrigger++) {
@@ -2914,7 +2916,7 @@ struct HResonanceCorrelation {
29142916
std::vector<uint32_t> piIndices;
29152917
std::vector<uint32_t> phiIndices;
29162918
std::vector<uint32_t> kstarIndices; // intentionally left unpopulated: Kstar0 is not
2917-
// extended to this process function in this version
2919+
// extended to this process function in this version
29182920
float centMultFT0M = -1;
29192921
float centMultFT0A = -1;
29202922
float centMultFT0C = -1;
@@ -2998,9 +3000,9 @@ struct HResonanceCorrelation {
29983000
}
29993001
}
30003002

3001-
associatedIndices.emplace_back(phiIndices); // IndexPhi = 0
3002-
associatedIndices.emplace_back(kstarIndices); // IndexKstar = 1 (always empty here)
3003-
associatedIndices.emplace_back(piIndices); // IndexPion = 2
3003+
associatedIndices.emplace_back(phiIndices); // IndexPhi = 0
3004+
associatedIndices.emplace_back(kstarIndices); // IndexKstar = 1 (always empty here)
3005+
associatedIndices.emplace_back(piIndices); // IndexPion = 2
30043006
associatedIndices.emplace_back(assocHadronIndices); // Hadron = 3
30053007
for (std::size_t iTrigger = 0; iTrigger < triggerIndices.size(); iTrigger++) {
30063008
auto triggerParticle = mcParticles.iteratorAt(triggerIndices[iTrigger]);

0 commit comments

Comments
 (0)