Skip to content

Commit 94c93ee

Browse files
committed
[PWGEM,PWGEM-36] Pi0Flow: Reduce CPU time for LUT
- changed `lookupTable1D` from `std::vector` to `std::array` and fill with all good values when MapLevel is >= 4 for same event and background set in the config
1 parent 8215385 commit 94c93ee

File tree

1 file changed

+33
-26
lines changed

1 file changed

+33
-26
lines changed

PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -220,14 +220,14 @@ struct TaskPi0FlowEMC {
220220
o2::emcal::Geometry* emcalGeom;
221221
o2::emcal::BadChannelMap* mBadChannels;
222222
TH1D* h1SPResolution = nullptr;
223-
// Constants for eta and phi ranges
224-
double etaMin = -0.75, etaMax = 0.75;
225-
int nBinsEta = 150; // 150 bins for eta
223+
// Constants for eta and phi ranges for the look up table
224+
static constexpr double etaMin = -0.75, etaMax = 0.75;
225+
static constexpr int nBinsEta = 150; // 150 bins for eta
226226

227-
double phiMin = 1.35, phiMax = 5.75;
228-
int nBinsPhi = 440; // (440 bins = 0.01 step size covering most regions)
227+
static constexpr double phiMin = 1.35, phiMax = 5.75;
228+
static constexpr int nBinsPhi = 440; // (440 bins = 0.01 step size covering most regions)
229229

230-
std::vector<int8_t> lookupTable1D;
230+
std::array<int8_t, nBinsEta * nBinsPhi> lookupTable1D;
231231
float epsilon = 1.e-8;
232232

233233
// static constexpr
@@ -437,7 +437,8 @@ struct TaskPi0FlowEMC {
437437
}
438438

439439
if (cfgDoM02.value) {
440-
registry.add("hSparseFlow", "THn for SP", HistType::kTHnSparseF, {thnAxisM02, thnAxisPt, thnAxisCent});
440+
registry.add("p3DM02Flow", "<v_n> vs M_{02} vs p_T vs cent", HistType::kTProfile3D, {thnAxisM02, thnAxisPt, thnAxisCent});
441+
registry.add("h3DSparsePi0", "M_{02} vs p_T vs cent", HistType::kTH3D, {thnAxisM02, thnAxisPt, thnAxisCent});
441442
}
442443

443444
ccdb->setURL(ccdbUrl);
@@ -663,28 +664,33 @@ struct TaskPi0FlowEMC {
663664
emcalGeom = o2::emcal::Geometry::GetInstanceFromRunNumber(collision.runNumber());
664665
// Load Bad Channel map
665666
mBadChannels = ccdb->getForTimeStamp<o2::emcal::BadChannelMap>("EMC/Calib/BadChannelMap", collision.timestamp());
666-
lookupTable1D = std::vector<int8_t>(nBinsEta * nBinsPhi, -1);
667+
lookupTable1D.fill(-1);
667668
double binWidthEta = (etaMax - etaMin) / nBinsEta;
668669
double binWidthPhi = (phiMax - phiMin) / nBinsPhi;
669670

670-
for (int iEta = 0; iEta < nBinsEta; ++iEta) {
671-
double etaCenter = etaMin + (iEta + 0.5) * binWidthEta;
672-
for (int iPhi = 0; iPhi < nBinsPhi; ++iPhi) {
673-
double phiCenter = phiMin + (iPhi + 0.5) * binWidthPhi;
674-
try {
675-
// Get the cell ID
676-
int cellID = emcalGeom->GetAbsCellIdFromEtaPhi(etaCenter, phiCenter);
677-
678-
// Check conditions for the cell
679-
if (isTooCloseToEdge(cellID, 1)) {
680-
lookupTable1D[getIndex(iEta, iPhi)] = 2; // Edge
681-
} else if (isCellMasked(cellID)) {
682-
lookupTable1D[getIndex(iEta, iPhi)] = 1; // Bad
683-
} else {
684-
lookupTable1D[getIndex(iEta, iPhi)] = 0; // Good
671+
if (cfgEMCalMapLevelBackground.value >= 4 && cfgEMCalMapLevelSameEvent >= 4) {
672+
// in this case we do not want to check the clusters, so just say thery are all good.
673+
lookupTable1D.fill(0); // good
674+
} else {
675+
for (int iEta = 0; iEta < nBinsEta; ++iEta) {
676+
double etaCenter = etaMin + (iEta + 0.5) * binWidthEta;
677+
for (int iPhi = 0; iPhi < nBinsPhi; ++iPhi) {
678+
double phiCenter = phiMin + (iPhi + 0.5) * binWidthPhi;
679+
try {
680+
// Get the cell ID
681+
int cellID = emcalGeom->GetAbsCellIdFromEtaPhi(etaCenter, phiCenter);
682+
683+
// Check conditions for the cell
684+
if (isTooCloseToEdge(cellID, 1)) {
685+
lookupTable1D[getIndex(iEta, iPhi)] = 2; // Edge
686+
} else if (isCellMasked(cellID)) {
687+
lookupTable1D[getIndex(iEta, iPhi)] = 1; // Bad
688+
} else {
689+
lookupTable1D[getIndex(iEta, iPhi)] = 0; // Good
690+
}
691+
} catch (o2::emcal::InvalidPositionException& e) {
692+
lookupTable1D[getIndex(iEta, iPhi)] = 3; // Outside geometry
685693
}
686-
} catch (o2::emcal::InvalidPositionException& e) {
687-
lookupTable1D[getIndex(iEta, iPhi)] = 3; // Outside geometry
688694
}
689695
}
690696
}
@@ -1433,7 +1439,8 @@ struct TaskPi0FlowEMC {
14331439
scalprodCand = scalprodCand / h1SPResolution->GetBinContent(h1SPResolution->FindBin(cent + epsilon));
14341440
}
14351441
if (cfgDoM02.value) {
1436-
registry.fill(HIST("hSparseFlow"), photon.m02(), photon.pt(), cent, scalprodCand);
1442+
registry.fill(HIST("p3DM02Flow"), photon.m02(), photon.pt(), cent, scalprodCand);
1443+
registry.fill(HIST("h3DSparsePi0"), photon.m02(), photon.pt(), cent);
14371444
}
14381445
return;
14391446
} // end of loop over single cluster

0 commit comments

Comments
 (0)