Skip to content

Commit c3b097d

Browse files
committed
[PWGEM,PWGEM-36] Pi0Flow: Reduce CPU time for LUT
- Fix linter error and warning
1 parent 94c93ee commit c3b097d

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

PWGEM/PhotonMeson/Tasks/taskPi0FlowEMC.cxx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,13 @@ enum Harmonics {
9999
kOctagonal = 8
100100
};
101101

102+
enum class MapLevel {
103+
kGood = 1,
104+
kNoBad = 2,
105+
kinEMC = 3,
106+
kAll = 4
107+
};
108+
102109
struct TaskPi0FlowEMC {
103110
static constexpr float MinEnergy = 0.7f;
104111

@@ -221,13 +228,13 @@ struct TaskPi0FlowEMC {
221228
o2::emcal::BadChannelMap* mBadChannels;
222229
TH1D* h1SPResolution = nullptr;
223230
// 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
231+
static constexpr double EtaMin = -0.75, etaMax = 0.75;
232+
static constexpr int NBinsEta = 150; // 150 bins for eta
226233

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)
234+
static constexpr double PhiMin = 1.35, phiMax = 5.75;
235+
static constexpr int NBinsPhi = 440; // (440 bins = 0.01 step size covering most regions)
229236

230-
std::array<int8_t, nBinsEta * nBinsPhi> lookupTable1D;
237+
std::array<int8_t, NBinsEta * NBinsPhi> lookupTable1D;
231238
float epsilon = 1.e-8;
232239

233240
// static constexpr
@@ -239,19 +246,19 @@ struct TaskPi0FlowEMC {
239246
// To access the 1D array
240247
inline int getIndex(int iEta, int iPhi)
241248
{
242-
return iEta * nBinsPhi + iPhi;
249+
return iEta * NBinsPhi + iPhi;
243250
}
244251

245252
// Function to access the lookup table
246253
inline int8_t checkEtaPhi1D(double eta, double phi)
247254
{
248-
if (eta < etaMin || eta > etaMax || phi < phiMin || phi > phiMax) {
255+
if (eta < EtaMin || eta > etaMax || phi < PhiMin || phi > phiMax) {
249256
return 3; // Out of bounds
250257
}
251258

252259
// Compute indices directly
253-
int iEta = static_cast<int>((eta - etaMin) / ((etaMax - etaMin) / nBinsEta));
254-
int iPhi = static_cast<int>((phi - phiMin) / ((phiMax - phiMin) / nBinsPhi));
260+
int iEta = static_cast<int>((eta - EtaMin) / ((etaMax - EtaMin) / NBinsEta));
261+
int iPhi = static_cast<int>((phi - PhiMin) / ((phiMax - PhiMin) / NBinsPhi));
255262

256263
return lookupTable1D[getIndex(iEta, iPhi)];
257264
}
@@ -665,17 +672,17 @@ struct TaskPi0FlowEMC {
665672
// Load Bad Channel map
666673
mBadChannels = ccdb->getForTimeStamp<o2::emcal::BadChannelMap>("EMC/Calib/BadChannelMap", collision.timestamp());
667674
lookupTable1D.fill(-1);
668-
double binWidthEta = (etaMax - etaMin) / nBinsEta;
669-
double binWidthPhi = (phiMax - phiMin) / nBinsPhi;
675+
double binWidthEta = (etaMax - EtaMin) / NBinsEta;
676+
double binWidthPhi = (phiMax - PhiMin) / NBinsPhi;
670677

671-
if (cfgEMCalMapLevelBackground.value >= 4 && cfgEMCalMapLevelSameEvent >= 4) {
678+
if (cfgEMCalMapLevelBackground.value >= static_cast<int>(MapLevel::kAll) && cfgEMCalMapLevelSameEvent >= static_cast<int>(MapLevel::kAll)) {
672679
// in this case we do not want to check the clusters, so just say thery are all good.
673680
lookupTable1D.fill(0); // good
674681
} 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;
682+
for (int iEta = 0; iEta < NBinsEta; ++iEta) {
683+
double etaCenter = EtaMin + (iEta + 0.5) * binWidthEta;
684+
for (int iPhi = 0; iPhi < NBinsPhi; ++iPhi) {
685+
double phiCenter = PhiMin + (iPhi + 0.5) * binWidthPhi;
679686
try {
680687
// Get the cell ID
681688
int cellID = emcalGeom->GetAbsCellIdFromEtaPhi(etaCenter, phiCenter);

0 commit comments

Comments
 (0)