Skip to content

Commit bd7c613

Browse files
committed
O2 linter fixes
1 parent 5362ede commit bd7c613

1 file changed

Lines changed: 25 additions & 21 deletions

File tree

Common/TableProducer/eventSelection.cxx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,13 @@ struct BcSelectionTask {
266266

267267
if (run != lastRun) {
268268
lastRun = run;
269-
if (run >= 300000 && run < 500000) { // unanchored Run3 MC
269+
int run3min = 500000;
270+
if (run < run3min) { // unanchored Run3 MC
270271
auto runDuration = ccdb->getRunDuration(run, true); // fatalise if timestamps are not found
271272
// SOR and EOR timestamps
272273
sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms
273274
eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms
274-
auto ctp = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2);
275+
auto ctp = ccdb->getForTimeStamp<std::vector<int64_t>>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2);
275276
auto orbitResetMUS = (*ctp)[0];
276277
// first bc of the first orbit
277278
bcSOR = static_cast<int64_t>((sorTimestamp * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS) * nBCsPerOrbit;
@@ -350,8 +351,8 @@ struct BcSelectionTask {
350351
}
351352

352353
int triggerBcShift = confTriggerBcShift;
353-
if (confTriggerBcShift == 999) {
354-
triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294;
354+
if (confTriggerBcShift == 999) { // o2-linter: disable=magic-number (indeed, this is a magic number)
355+
triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294; // o2-linter: disable=magic-number (magic list of runs)
355356
}
356357

357358
// bc loop
@@ -407,12 +408,14 @@ struct BcSelectionTask {
407408
}
408409
--bc;
409410
backwardMoveCount++;
410-
if (bc.globalBC() + 1 == globalBC) {
411+
int bcDistanceToBeamGasForFT0 = 1;
412+
int bcDistanceToBeamGasForFDD = 5;
413+
if (bc.globalBC() + bcDistanceToBeamGasForFT0 == globalBC) {
411414
timeV0ABG = bc.has_fv0a() ? bc.fv0a().time() : -999.f;
412415
timeT0ABG = bc.has_ft0() ? bc.ft0().timeA() : -999.f;
413416
timeT0CBG = bc.has_ft0() ? bc.ft0().timeC() : -999.f;
414417
}
415-
if (bc.globalBC() + 5 == globalBC) {
418+
if (bc.globalBC() + bcDistanceToBeamGasForFDD == globalBC) {
416419
timeFDABG = bc.has_fdd() ? bc.fdd().timeA() : -999.f;
417420
timeFDCBG = bc.has_fdd() ? bc.fdd().timeC() : -999.f;
418421
}
@@ -467,7 +470,7 @@ struct BcSelectionTask {
467470
LOGP(debug, "prev inactive chips: {} {} {} {} {} {} {}", vPrevInactiveChips[0], vPrevInactiveChips[1], vPrevInactiveChips[2], vPrevInactiveChips[3], vPrevInactiveChips[4], vPrevInactiveChips[5], vPrevInactiveChips[6]);
468471
isGoodITSLayer3 = vPrevInactiveChips[3] <= maxInactiveChipsPerLayer->at(3) && vNextInactiveChips[3] <= maxInactiveChipsPerLayer->at(3);
469472
isGoodITSLayer0123 = true;
470-
for (int i = 0; i < 4; i++) {
473+
for (int i = 0; i < 4; i++) { // o2-linter: disable=magic-number (counting first 4 ITS layers)
471474
isGoodITSLayer0123 &= vPrevInactiveChips[i] <= maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= maxInactiveChipsPerLayer->at(i);
472475
}
473476
isGoodITSLayersAll = true;
@@ -490,13 +493,13 @@ struct BcSelectionTask {
490493
// Temporary workaround to get visible cross section. TODO: store run-by-run visible cross sections in CCDB
491494
const char* srun = Form("%d", run);
492495

493-
bool injectionEnergy = (run >= 500000 && run <= 520099) || (run >= 534133 && run <= 534468);
496+
bool injectionEnergy = (run >= 500000 && run <= 520099) || (run >= 534133 && run <= 534468); // o2-linter: disable=magic-number (todo: extract from ccdb)
494497
// Cross sections in ub. Using dummy -1 if lumi estimator is not reliable
495498
float csTVX = isPP ? (injectionEnergy ? 0.0355e6 : 0.0594e6) : -1.;
496499
float csTCE = isPP ? -1. : 10.36e6;
497500
float csZEM = isPP ? -1. : 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515
498501
float csZNC = isPP ? -1. : 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515
499-
if (run > 543437 && run < 543514) {
502+
if (run > 543437 && run < 543514) { // o2-linter: disable=magic-number (todo: store and extract cross sections from ccdb)
500503
csTCE = 8.3e6;
501504
}
502505
if (run >= 543514) {
@@ -717,7 +720,7 @@ struct EventSelectionTask {
717720
int spdClusters = bc.spdClustersL0() + bc.spdClustersL1();
718721

719722
selection |= (spdClusters < par->fSPDClsVsTklA + nTkl * par->fSPDClsVsTklB) ? BIT(kNoSPDClsVsTklBG) : 0;
720-
selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(kNoV0C012vsTklBG) : 0;
723+
selection |= !(nTkl < 6 && multV0C012 > par->fV0C012vsTklA + nTkl * par->fV0C012vsTklB) ? BIT(kNoV0C012vsTklBG) : 0; // o2-linter: disable=magic-number (nTkl dependent parameterization)
721724

722725
// copy rct flags from bcsel table
723726
uint32_t rct = bc.rct_raw();
@@ -737,7 +740,7 @@ struct EventSelectionTask {
737740
sel1 = sel1 && bc.selection_bit(kNoTPCHVdip);
738741

739742
// INT1 (SPDFO>0 | V0A | V0C) minimum bias trigger logic used in pp2010 and pp2011
740-
bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582);
743+
bool isINT1period = bc.runNumber() <= 136377 || (bc.runNumber() >= 144871 && bc.runNumber() <= 159582); // o2-linter: disable=magic-number (magic run numbers)
741744

742745
// fill counters
743746
if (isMC == 1 || (!isINT1period && bc.alias_bit(kINT7)) || (isINT1period && bc.alias_bit(kINT1))) {
@@ -756,7 +759,8 @@ struct EventSelectionTask {
756759
{
757760
int run = bcs.iteratorAt(0).runNumber();
758761
// extract bc pattern from CCDB for data or anchored MC only
759-
if (run != lastRun && run >= 500000) {
762+
int run3min = 500000;
763+
if (run != lastRun && run >= run3min) {
760764
lastRun = run;
761765
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
762766
// first bc of the first orbit
@@ -782,7 +786,7 @@ struct EventSelectionTask {
782786
for (const auto& bc : bcs) {
783787
int64_t globalBC = bc.globalBC();
784788
// skip non-colliding bcs for data and anchored runs
785-
if (run >= 500000 && bcPatternB[globalBC % nBCsPerOrbit] == 0) {
789+
if (run >= run3min && bcPatternB[globalBC % nBCsPerOrbit] == 0) {
786790
continue;
787791
}
788792
if (bc.selection_bit(kIsTriggerTVX)) {
@@ -851,7 +855,7 @@ struct EventSelectionTask {
851855
float sumTime = 0, sumW = 0, sumHighPtTime = 0, sumHighPtW = 0;
852856
for (const auto& track : colPvTracks) {
853857
float trackTime = track.trackTime();
854-
if (track.itsNCls() >= 5)
858+
if (track.itsNCls() >= 5) // o2-linter: disable=magic-number (indeed, this is a magic number, counting layers 5, 6, 7)
855859
vTracksITS567perColl[colIndex]++;
856860
if (track.hasTRD())
857861
vIsVertexTRDmatched[colIndex] = 1;
@@ -1123,16 +1127,16 @@ struct EventSelectionTask {
11231127
if (confUseWeightsForOccupancyVariable) {
11241128
// weighted occupancy
11251129
wOccup = 0;
1126-
if (dt >= -40 && dt < -5) // collisions in the past
1127-
wOccup = 1. / 1225 * (dt + 40) * (dt + 40);
1128-
else if (dt >= -5 && dt < 15) // collisions near a given one
1130+
if (dt >= -40 && dt < -5) // collisions in the past // o2-linter: disable=magic-number (to be checked by Igor)
1131+
wOccup = 1. / 1225 * (dt + 40) * (dt + 40); // o2-linter: disable=magic-number (to be checked by Igor)
1132+
else if (dt >= -5 && dt < 15) // collisions near a given one // o2-linter: disable=magic-number (to be checked by Igor)
11291133
wOccup = 1;
11301134
// else if (dt >= 15 && dt < 100) // collisions from the future
11311135
// wOccup = -1. / 85 * dt + 20. / 17;
1132-
else if (dt >= 15 && dt < 40) // collisions from the future
1133-
wOccup = -0.4 / 25 * dt + 1.24;
1134-
else if (dt >= 40 && dt < 100) // collisions from the distant future
1135-
wOccup = -0.4 / 60 * dt + 0.6 + 0.8 / 3;
1136+
else if (dt >= 15 && dt < 40) // collisions from the future // o2-linter: disable=magic-number (to be checked by Igor)
1137+
wOccup = -0.4 / 25 * dt + 1.24; // o2-linter: disable=magic-number (to be checked by Igor)
1138+
else if (dt >= 40 && dt < 100) // collisions from the distant future // o2-linter: disable=magic-number (to be checked by Igor)
1139+
wOccup = -0.4 / 60 * dt + 0.6 + 0.8 / 3; // o2-linter: disable=magic-number (to be checked by Igor)
11361140
}
11371141
nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex];
11381142
sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex];

0 commit comments

Comments
 (0)