Skip to content

Commit 0b6f3aa

Browse files
authored
[PWGUD] Avoid magic numbers and minor corrections (#12465)
1 parent 6328364 commit 0b6f3aa

File tree

3 files changed

+168
-81
lines changed

3 files changed

+168
-81
lines changed

PWGUD/Core/SGSelector.h

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,15 @@ struct SelectionResult {
3838
namespace o2::aod::sgselector
3939
{
4040
enum TrueGap : int {
41-
NoGap = -1,
42-
SingleGapA = 0,
43-
SingleGapC = 1,
44-
DoubleGap = 2
41+
NoGap = -1, // no gap due to change of threshold(s) in any of FV0, FT0A, ZNA, FT0C, ZNC
42+
SingleGapA = 0, // initially single gap at A side event
43+
SingleGapC = 1, // initially single gap at C side event
44+
DoubleGap = 2, // initially double gap event
45+
NoUpc = 3, // initially no UPC event with default thresholds (FT0A=150, FT0C=50)
46+
TrkOutOfRange = 4, // to many tracks (>100 default)
47+
BadDoubleGap = 5 // unknows status of double gap check with changed thresholds
4548
};
46-
}
49+
} // namespace o2::aod::sgselector
4750

4851
class SGSelector
4952
{
@@ -65,7 +68,7 @@ class SGSelector
6568
SelectionResult<BC> result;
6669
result.bc = &oldbc;
6770
if (collision.numContrib() < diffCuts.minNTracks() || collision.numContrib() > diffCuts.maxNTracks()) {
68-
result.value = 4;
71+
result.value = o2::aod::sgselector::TrkOutOfRange; // 4
6972
return result;
7073
}
7174
auto newbc = oldbc;
@@ -91,9 +94,9 @@ class SGSelector
9194
newbc = bc;
9295
gC = false;
9396
}
94-
}
97+
} // end of loop over bc range
9598
if (!gA && !gC) {
96-
result.value = 3;
99+
result.value = o2::aod::sgselector::NoUpc; // gap = 3
97100
return result;
98101
}
99102
if (gA && gC) { // loop once again for so-called DG events to get the most active FT0 BC
@@ -120,7 +123,8 @@ class SGSelector
120123
result.bc = &newbc;
121124
// LOGF(info, "Old BC: %i, New BC: %i",oldbc.globalBC(), newbc.globalBC());
122125
result.bc = &newbc;
123-
result.value = gA && gC ? 2 : (gA ? 0 : 1);
126+
// result.value = gA && gC ? 2 : (gA ? 0 : 1);
127+
result.value = gA && gC ? o2::aod::sgselector::DoubleGap : (gA ? o2::aod::sgselector::SingleGapA : o2::aod::sgselector::SingleGapC);
124128
return result;
125129
}
126130
template <typename TFwdTrack>
@@ -139,29 +143,31 @@ class SGSelector
139143
float fit_cut[3] = {fv0, ft0a, ft0c};
140144
int gap = collision.gapSide();
141145
int true_gap = gap;
142-
float FV0A, FT0A, FT0C, ZNA, ZNC;
143-
FV0A = collision.totalFV0AmplitudeA();
144-
FT0A = collision.totalFT0AmplitudeA();
145-
FT0C = collision.totalFT0AmplitudeC();
146-
ZNA = collision.energyCommonZNA();
147-
ZNC = collision.energyCommonZNC();
146+
// float FV0A, FT0A, FT0C, ZNA, ZNC;
147+
const float FV0A = collision.totalFV0AmplitudeA();
148+
const float FT0A = collision.totalFT0AmplitudeA();
149+
const float FT0C = collision.totalFT0AmplitudeC();
150+
const float ZNA = collision.energyCommonZNA();
151+
const float ZNC = collision.energyCommonZNC();
148152
if (gap == o2::aod::sgselector::SingleGapA) { // gap == 0
149153
if (FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut)
150154
true_gap = o2::aod::sgselector::NoGap; // -1
151155
} else if (gap == o2::aod::sgselector::SingleGapC) { // gap == 1
152156
if (FT0C > fit_cut[2] || ZNC > zdc_cut)
153157
true_gap = o2::aod::sgselector::NoGap; // -1
154158
} else if (gap == o2::aod::sgselector::DoubleGap) { // gap == 2
155-
if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut))
159+
if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut)) {
156160
true_gap = o2::aod::sgselector::NoGap; // -1
157-
else if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C <= fit_cut[2] && ZNC <= zdc_cut))
161+
} else if ((FV0A > fit_cut[0] || FT0A > fit_cut[1] || ZNA > zdc_cut) && (FT0C <= fit_cut[2] && ZNC <= zdc_cut)) {
158162
true_gap = o2::aod::sgselector::SingleGapC; // 1
159-
else if ((FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut))
163+
} else if ((FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut) && (FT0C > fit_cut[2] || ZNC > zdc_cut)) {
160164
true_gap = o2::aod::sgselector::SingleGapA; // 0
161-
else if (FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut && FT0C <= fit_cut[2] && ZNC <= zdc_cut)
165+
} else if (FV0A <= fit_cut[0] && FT0A <= fit_cut[1] && ZNA <= zdc_cut && FT0C <= fit_cut[2] && ZNC <= zdc_cut) {
162166
true_gap = o2::aod::sgselector::DoubleGap; // 2
163-
else
167+
} else {
164168
LOGF(info, "Something wrong with DG");
169+
true_gap = o2::aod::sgselector::BadDoubleGap; // 5
170+
}
165171
}
166172
return true_gap;
167173
}

PWGUD/TableProducer/SGCandProducer.cxx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ struct SGCandProducer {
217217

218218
// Cross sections in ub. Using dummy -1 if lumi estimator is not reliable
219219
float csTCE = 10.36e6;
220-
float csZEM = 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515
221-
float csZNC = 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515
220+
const float csZEM = 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515
221+
const float csZNC = 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515
222222
if (runNumber > 543437 && runNumber < 543514) {
223223
csTCE = 8.3e6;
224224
}
@@ -326,14 +326,14 @@ struct SGCandProducer {
326326
getHist(TH1, histdir + "/Stat")->Fill(8., 1.);
327327

328328
//
329-
int trs = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ? 1 : 0;
330-
int trofs = collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard) ? 1 : 0;
331-
int hmpr = collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof) ? 1 : 0;
332-
int tfb = collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) ? 1 : 0;
333-
int itsROFb = collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) ? 1 : 0;
334-
int sbp = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) ? 1 : 0;
335-
int zVtxFT0vPv = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) ? 1 : 0;
336-
int vtxITSTPC = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC) ? 1 : 0;
329+
const int trs = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard) ? 1 : 0;
330+
const int trofs = collision.selection_bit(o2::aod::evsel::kNoCollInRofStandard) ? 1 : 0;
331+
const int hmpr = collision.selection_bit(o2::aod::evsel::kNoHighMultCollInPrevRof) ? 1 : 0;
332+
const int tfb = collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder) ? 1 : 0;
333+
const int itsROFb = collision.selection_bit(o2::aod::evsel::kNoITSROFrameBorder) ? 1 : 0;
334+
const int sbp = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup) ? 1 : 0;
335+
const int zVtxFT0vPv = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV) ? 1 : 0;
336+
const int vtxITSTPC = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC) ? 1 : 0;
337337
auto bc = collision.template foundBC_as<BCs>();
338338
double ir = 0.;
339339
const uint64_t ts = bc.timestamp();
@@ -363,14 +363,14 @@ struct SGCandProducer {
363363
return;
364364
}
365365
upchelpers::FITInfo fitInfo{};
366-
uint8_t chFT0A = 0;
367-
uint8_t chFT0C = 0;
368-
uint8_t chFDDA = 0;
369-
uint8_t chFDDC = 0;
370-
uint8_t chFV0A = 0;
371-
int occ = collision.trackOccupancyInTimeRange();
366+
const uint8_t chFT0A = 0;
367+
const uint8_t chFT0C = 0;
368+
const uint8_t chFDDA = 0;
369+
const uint8_t chFDDC = 0;
370+
const uint8_t chFV0A = 0;
371+
const int occ = collision.trackOccupancyInTimeRange();
372372
udhelpers::getFITinfo(fitInfo, newbc, bcs, ft0s, fv0as, fdds);
373-
int upc_flag = (collision.flags() & dataformats::Vertex<o2::dataformats::TimeStamp<int>>::Flags::UPCMode) ? 1 : 0;
373+
const int upc_flag = (collision.flags() & dataformats::Vertex<o2::dataformats::TimeStamp<int>>::Flags::UPCMode) ? 1 : 0;
374374
// update SG candidates tables
375375
outputCollisions(bc.globalBC(), bc.runNumber(),
376376
collision.posX(), collision.posY(), collision.posZ(), upc_flag,

0 commit comments

Comments
 (0)