Skip to content

Commit f2f8950

Browse files
authored
[PWGCF] jEPFlowAnalysis.cxx: fix bug for initialization (#17583)
1 parent ff32f2d commit f2f8950

1 file changed

Lines changed: 82 additions & 51 deletions

File tree

PWGCF/JCorran/Tasks/jEPFlowAnalysis.cxx

Lines changed: 82 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <RtypesCore.h>
5353

5454
#include <algorithm>
55+
#include <array>
5556
#include <chrono>
5657
#include <cmath>
5758
#include <cstddef>
@@ -79,15 +80,15 @@ struct JEPFlowAnalysis {
7980
kHistsel
8081
};
8182

82-
Service<o2::framework::O2DatabasePDG> pdg;
83+
Service<o2::framework::O2DatabasePDG> pdg{};
8384

8485
HistogramRegistry epFlowHistograms{"EPFlow", {}, OutputObjHandlingPolicy::AnalysisObject, true, true};
8586
EventPlaneHelper helperEP;
8687
o2::ft0::Geometry ft0geom;
8788
o2::fv0::Geometry* fv0geom = nullptr;
8889
FlowJHistManager histManager;
8990
bool debug = kFALSE;
90-
Service<o2::ccdb::BasicCCDBManager> ccdb;
91+
Service<o2::ccdb::BasicCCDBManager> ccdb{};
9192
o2::ccdb::CcdbApi ccdbApi;
9293

9394
struct : ConfigurableGroup {
@@ -204,7 +205,7 @@ struct JEPFlowAnalysis {
204205
float subleadingPhi = -999.;
205206
float subleadingEta = -999.;
206207

207-
std::vector<TProfile3D*> shiftprofile{};
208+
std::vector<TProfile3D*> shiftprofile;
208209
std::string fullCCDBShiftCorrPath;
209210

210211
THn* effMap = nullptr;
@@ -215,8 +216,8 @@ struct JEPFlowAnalysis {
215216
int nHighPt = 0;
216217
int minnHighPt = 2;
217218

218-
std::vector<float> ft0RelGainConst{};
219-
std::vector<float> fv0RelGainConst{};
219+
std::vector<float> ft0RelGainConst;
220+
std::vector<float> fv0RelGainConst;
220221

221222
bool q2sel(float q2, bool isHigh)
222223
{
@@ -226,74 +227,89 @@ struct JEPFlowAnalysis {
226227
if (idx < 0) {
227228
idx = 0;
228229
}
230+
229231
if (isHigh) {
230232
if (idx >= static_cast<int>(cfgMultq2high->size())) {
231233
idx = cfgMultq2high->size() - 1;
232234
}
233235
float sel = cfgMultq2high->at(idx);
234236
return q2 > sel;
235-
} else {
236-
if (idx >= static_cast<int>(cfgMultq2low->size())) {
237-
idx = cfgMultq2low->size() - 1;
238-
}
239-
float sel = cfgMultq2low->at(idx);
240-
return q2 < sel;
241237
}
238+
239+
if (idx >= static_cast<int>(cfgMultq2low->size())) {
240+
idx = cfgMultq2low->size() - 1;
241+
}
242+
float sel = cfgMultq2low->at(idx);
243+
return q2 < sel;
242244
}
243245

244246
template <typename T>
245247
int getdetId(const T& name)
246248
{
247249
if (name.value == "FT0C") {
248250
return 0;
249-
} else if (name.value == "FT0A") {
251+
}
252+
if (name.value == "FT0A") {
250253
return 1;
251-
} else if (name.value == "FT0M") {
254+
}
255+
if (name.value == "FT0M") {
252256
return 2;
253-
} else if (name.value == "FV0A") {
257+
}
258+
if (name.value == "FV0A") {
254259
return 3;
255-
} else if (name.value == "TPCPos") {
260+
}
261+
if (name.value == "TPCPos") {
256262
return 4;
257-
} else if (name.value == "TPCNeg") {
263+
}
264+
if (name.value == "TPCNeg") {
258265
return 5;
259-
} else if (name.value == "TPCTot") {
266+
}
267+
if (name.value == "TPCTot") {
260268
return 6;
261-
} else {
262-
return 0;
263269
}
270+
return 0;
264271
}
265272

266273
template <typename Col>
267274
bool eventSel(const Col& coll)
268275
{
269-
if (std::abs(coll.posZ()) > cfgVertexZ)
276+
if (std::abs(coll.posZ()) > cfgVertexZ) {
270277
return false;
278+
}
279+
271280
switch (cfgEvtSel) {
272281
case 0: // Sel8
273-
if (!coll.sel8())
282+
if (!coll.sel8()) {
274283
return false;
284+
}
275285
break;
276286
case 1: // PbPb standard
277-
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
287+
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) {
278288
return false;
289+
}
279290
break;
280291
case 2: // PbPb with pileup
281292
if (!coll.sel8() || !coll.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ||
282-
!coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
293+
!coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) || !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) {
283294
return false;
295+
}
284296
break;
285297
case 3: // Small systems (OO, NeNe, pp)
286-
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kNoSameBunchPileup))
298+
if (!coll.sel8() || !coll.selection_bit(aod::evsel::kNoSameBunchPileup)) {
287299
return false;
300+
}
288301
break;
302+
303+
default:
304+
return false;
289305
}
290306
// Check occupancy
291-
if (coll.trackOccupancyInTimeRange() > cfgMaxOccupancy || coll.trackOccupancyInTimeRange() < cfgMinOccupancy)
307+
if (coll.trackOccupancyInTimeRange() > cfgMaxOccupancy || coll.trackOccupancyInTimeRange() < cfgMinOccupancy) {
292308
return false;
293-
294-
if (rctCut.requireRCTFlagChecker && !rctChecker(coll))
309+
}
310+
if (rctCut.requireRCTFlagChecker && !rctChecker(coll)) {
295311
return false;
296-
312+
}
297313
return true;
298314
}
299315

@@ -371,9 +387,9 @@ struct JEPFlowAnalysis {
371387
template <typename Col, typename Trk>
372388
void fillvn(const Col& coll, const Trk& tracks)
373389
{
374-
float eps[3] = {0.};
375-
float qx_shifted[3] = {0.};
376-
float qy_shifted[3] = {0.};
390+
std::array<float, 3> eps{};
391+
std::array<float, 3> qx_shifted{};
392+
std::array<float, 3> qy_shifted{};
377393

378394
for (int i = 0; i < cfgnMode; i++) { // loop over different harmonic orders
379395
harmInd = cfgnTotalSystem * 4 * (i) + 3; // harmonic index to access corresponding Q-vector as all Q-vectors are in same vector
@@ -431,7 +447,7 @@ struct JEPFlowAnalysis {
431447
q2selLow = q2Map->GetBinContent(q2Map->GetXaxis()->FindBin(i + 2), q2Map->GetYaxis()->FindBin(cent), q2Map->GetZaxis()->FindBin(1. - cfgQ2SelFrac));
432448
}
433449

434-
if (cfgSelEvtTwoHP && i == 0) {
450+
if (i == 0) {
435451
leadingPt = 0.0;
436452
leadingPhi = 0.0;
437453
leadingEta = 0.0;
@@ -441,9 +457,13 @@ struct JEPFlowAnalysis {
441457
subleadingEta = 0.0;
442458

443459
nHighPt = 0;
460+
}
461+
462+
if (cfgSelEvtTwoHP && i == 0) {
444463
for (const auto& track : tracks) {
445-
if (cfgTrkSelFlag && trackSel(track))
464+
if (cfgTrkSelFlag && trackSel(track) != 0) {
446465
continue;
466+
}
447467

448468
if (leadingPt < track.pt()) {
449469
subleadingPt = leadingPt;
@@ -459,19 +479,23 @@ struct JEPFlowAnalysis {
459479
subleadingEta = track.eta();
460480
}
461481

462-
if (track.pt() > cfgHighPtSel)
482+
if (track.pt() > cfgHighPtSel) {
463483
nHighPt++;
484+
}
464485
}
465486
}
466487

467-
if (cfgSelEvtTwoHP && nHighPt < minnHighPt)
488+
if (cfgSelEvtTwoHP && nHighPt < minnHighPt) {
468489
continue;
490+
}
469491

470-
if (std::abs(RecoDecay::constrainAngle(leadingPhi - subleadingPhi, 0) - constants::math::PI) > cfgTwoLPAngle)
492+
if (cfgSelEvtTwoHP && std::abs(RecoDecay::constrainAngle(leadingPhi - subleadingPhi, 0) - constants::math::PI) > cfgTwoLPAngle) {
471493
continue;
494+
}
472495

473-
if (std::abs(leadingEta + subleadingEta) > cfgEtaBalancing)
496+
if (cfgSelEvtTwoHP && std::abs(leadingEta + subleadingEta) > cfgEtaBalancing) {
474497
continue;
498+
}
475499

476500
epFlowHistograms.fill(HIST("EpDet"), i + 2, cent, eps[0]);
477501
epFlowHistograms.fill(HIST("EpRefA"), i + 2, cent, eps[1]);
@@ -526,8 +550,9 @@ struct JEPFlowAnalysis {
526550
leadingPhi = 0.0;
527551
leadingEta = 0.0;
528552
for (const auto& track : tracks) {
529-
if (cfgTrkSelFlag && trackSel(track))
553+
if (cfgTrkSelFlag && trackSel(track) != 0) {
530554
continue;
555+
}
531556

532557
if (cfgEffCor) {
533558
weight = getEfficiencyCorrection(effMap, track.eta(), track.pt(), cent, coll.posZ());
@@ -571,13 +596,13 @@ struct JEPFlowAnalysis {
571596

572597
double getEfficiencyCorrection(THn* eff, float eta, float pt, float multiplicity, float posZ)
573598
{
574-
int effVars[4];
599+
std::array<int, 4> effVars{};
575600
effVars[0] = eff->GetAxis(0)->FindBin(eta);
576601
effVars[1] = eff->GetAxis(1)->FindBin(pt);
577602
effVars[2] = eff->GetAxis(2)->FindBin(multiplicity);
578603
effVars[3] = eff->GetAxis(3)->FindBin(posZ);
579604

580-
return eff->GetBinContent(effVars);
605+
return eff->GetBinContent(effVars.data());
581606
}
582607

583608
void init(InitContext const&)
@@ -652,7 +677,7 @@ struct JEPFlowAnalysis {
652677
epFlowHistograms.add("EpResQvecEvslDetRefBxx", "", {HistType::kTH3F, {axisMod, axisCent, axisQvec}});
653678
epFlowHistograms.add("EpResQvecEvslRefARefBxx", "", {HistType::kTH3F, {axisMod, axisCent, axisQvec}});
654679

655-
if (cfgq2analysis) {
680+
if (cfgq2analysis != 0) {
656681
epFlowHistograms.add("EpResQvecDetRefAxx_q2high", "", {HistType::kTH3F, {axisMod, axisCent, axisQvec}});
657682
epFlowHistograms.add("EpResQvecDetRefBxx_q2high", "", {HistType::kTH3F, {axisMod, axisCent, axisQvec}});
658683
epFlowHistograms.add("EpResQvecRefARefBxx_q2high", "", {HistType::kTH3F, {axisMod, axisCent, axisQvec}});
@@ -663,7 +688,7 @@ struct JEPFlowAnalysis {
663688

664689
epFlowHistograms.add("SPvnxx", "", {HistType::kTHnSparseF, {axisMod, axisCent, axisPt, axisEta, axisQvec}});
665690
epFlowHistograms.add("SPvnxy", "", {HistType::kTHnSparseF, {axisMod, axisCent, axisPt, axisEta, axisQvec}});
666-
if (cfgq2analysis) {
691+
if (cfgq2analysis != 0) {
667692
epFlowHistograms.add("SPvnxx_q2high", "", {HistType::kTHnSparseF, {axisMod, axisCent, axisPt, axisEta, axisQvec}});
668693
epFlowHistograms.add("SPvnxx_q2low", "", {HistType::kTHnSparseF, {axisMod, axisCent, axisPt, axisEta, axisQvec}});
669694
}
@@ -679,8 +704,9 @@ struct JEPFlowAnalysis {
679704
void processDefault(MyCollisions::iterator const& coll, soa::Filtered<MyTracks> const& tracks, aod::BCsWithTimestamps const&, aod::FT0s const&)
680705
{
681706
if (cfgAddEvtSel) {
682-
if (!eventSel(coll))
707+
if (!eventSel(coll)) {
683708
return;
709+
}
684710
}
685711

686712
if (cfgEffCor) {
@@ -762,21 +788,22 @@ struct JEPFlowAnalysis {
762788
}
763789
}
764790

765-
if (coll.qvecAmp()[detId] < minQvecAmp || coll.qvecAmp()[refAId] < minQvecAmp || coll.qvecAmp()[refBId] < minQvecAmp)
791+
if (coll.qvecAmp()[detId] < minQvecAmp || coll.qvecAmp()[refAId] < minQvecAmp || coll.qvecAmp()[refBId] < minQvecAmp) {
766792
return;
793+
}
767794

768795
qOvecM = calcFT0CRawQVecMag(coll, 2) / coll.qvecAmp()[detId]; // second order
769796
activity = calcFT0CLocalActivity(coll);
770797

771798
epFlowHistograms.fill(HIST("hQoverMCnt"), cent, qOvecM);
772799
epFlowHistograms.fill(HIST("hActivityCnt"), cent, activity);
773800

774-
if (cfgJetSubEvtSel & 1) {
801+
if ((cfgJetSubEvtSel & 1) != 0) {
775802
if (cfgJetSubEvlSelVar->at(0) < qOvecM) {
776803
return;
777804
}
778805
}
779-
if (cfgJetSubEvtSel & 2) {
806+
if ((cfgJetSubEvtSel & 2) != 0) {
780807
if (cfgJetSubEvlSelVar->at(1) < activity) {
781808
return;
782809
}
@@ -792,8 +819,9 @@ struct JEPFlowAnalysis {
792819
}
793820

794821
if (cfgAddEvtSel) {
795-
if (!eventSel(coll))
822+
if (!eventSel(coll)) {
796823
return;
824+
}
797825
}
798826

799827
cent = coll.centFT0C();
@@ -812,7 +840,7 @@ struct JEPFlowAnalysis {
812840
continue;
813841
}
814842

815-
if (trackSel(trk)) {
843+
if (trackSel(trk) != 0) {
816844
continue;
817845
}
818846

@@ -827,8 +855,9 @@ struct JEPFlowAnalysis {
827855

828856
void processMCGen(MyCollisionsMC::iterator const& coll, aod::McParticles const& mcParticles, aod::McCollisions const&)
829857
{
830-
if (!coll.has_mcCollision())
858+
if (!coll.has_mcCollision()) {
831859
return;
860+
}
832861
const auto mcColl = coll.mcCollision();
833862

834863
if (cfgAddEvtSel) {
@@ -840,8 +869,9 @@ struct JEPFlowAnalysis {
840869
cent = coll.centFT0C();
841870

842871
for (const auto& mcParticle : mcParticles) {
843-
if (std::abs(mcParticle.eta()) > cfgTrackCuts.cfgEtaMax)
872+
if (std::abs(mcParticle.eta()) > cfgTrackCuts.cfgEtaMax) {
844873
continue;
874+
}
845875

846876
auto p = pdg->GetParticle(mcParticle.pdgCode());
847877
if (p != nullptr) {
@@ -850,8 +880,9 @@ struct JEPFlowAnalysis {
850880
}
851881
}
852882

853-
if (!mcParticle.isPhysicalPrimary())
883+
if (!mcParticle.isPhysicalPrimary()) {
854884
continue;
885+
}
855886

856887
epFlowHistograms.fill(HIST("MC/hPartGen"), cent, mcColl.posZ(), mcParticle.eta(), mcParticle.phi(), mcParticle.pt());
857888
}

0 commit comments

Comments
 (0)