Skip to content

Commit 503c638

Browse files
authored
[Common] Fix for unanchored Run 3 MC (#11223)
1 parent 3f2285f commit 503c638

File tree

1 file changed

+51
-33
lines changed

1 file changed

+51
-33
lines changed

Common/TableProducer/eventSelection.cxx

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,31 @@ struct BcSelectionTask {
266266

267267
if (run != lastRun) {
268268
lastRun = run;
269-
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
270-
// first bc of the first orbit
271-
bcSOR = runInfo.orbitSOR * nBCsPerOrbit;
272-
// duration of TF in bcs
273-
nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit;
274-
// SOR and EOR timestamps
275-
sorTimestamp = runInfo.sor;
276-
eorTimestamp = runInfo.eor;
269+
int run3min = 500000;
270+
if (run < run3min) { // unanchored Run3 MC
271+
auto runDuration = ccdb->getRunDuration(run, true); // fatalise if timestamps are not found
272+
// SOR and EOR timestamps
273+
sorTimestamp = runDuration.first; // timestamp of the SOR/SOX/STF in ms
274+
eorTimestamp = runDuration.second; // timestamp of the EOR/EOX/ETF in ms
275+
auto ctp = ccdb->getForTimeStamp<std::vector<int64_t>>("CTP/Calib/OrbitReset", sorTimestamp / 2 + eorTimestamp / 2);
276+
auto orbitResetMUS = (*ctp)[0];
277+
// first bc of the first orbit
278+
bcSOR = static_cast<int64_t>((sorTimestamp * 1000 - orbitResetMUS) / o2::constants::lhc::LHCOrbitMUS) * nBCsPerOrbit;
279+
// duration of TF in bcs
280+
nBCsPerTF = 32; // hard-coded for Run3 MC (no info from ccdb at the moment)
281+
} else {
282+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
283+
// SOR and EOR timestamps
284+
sorTimestamp = runInfo.sor;
285+
eorTimestamp = runInfo.eor;
286+
// first bc of the first orbit
287+
bcSOR = runInfo.orbitSOR * nBCsPerOrbit;
288+
// duration of TF in bcs
289+
nBCsPerTF = runInfo.orbitsPerTF * nBCsPerOrbit;
290+
}
291+
277292
// timestamp of the middle of the run used to access run-wise CCDB entries
278-
int64_t ts = runInfo.sor / 2 + runInfo.eor / 2;
293+
int64_t ts = sorTimestamp / 2 + eorTimestamp / 2;
279294
// access ITSROF and TF border margins
280295
par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
281296
mITSROFrameStartBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;
@@ -336,8 +351,8 @@ struct BcSelectionTask {
336351
}
337352

338353
int triggerBcShift = confTriggerBcShift;
339-
if (confTriggerBcShift == 999) {
340-
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 (special shift for early 2022 data)
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)
341356
}
342357

343358
// bc loop
@@ -393,12 +408,14 @@ struct BcSelectionTask {
393408
}
394409
--bc;
395410
backwardMoveCount++;
396-
if (bc.globalBC() + 1 == globalBC) {
411+
int bcDistanceToBeamGasForFT0 = 1;
412+
int bcDistanceToBeamGasForFDD = 5;
413+
if (bc.globalBC() + bcDistanceToBeamGasForFT0 == globalBC) {
397414
timeV0ABG = bc.has_fv0a() ? bc.fv0a().time() : -999.f;
398415
timeT0ABG = bc.has_ft0() ? bc.ft0().timeA() : -999.f;
399416
timeT0CBG = bc.has_ft0() ? bc.ft0().timeC() : -999.f;
400417
}
401-
if (bc.globalBC() + 5 == globalBC) {
418+
if (bc.globalBC() + bcDistanceToBeamGasForFDD == globalBC) {
402419
timeFDABG = bc.has_fdd() ? bc.fdd().timeA() : -999.f;
403420
timeFDCBG = bc.has_fdd() ? bc.fdd().timeC() : -999.f;
404421
}
@@ -453,7 +470,7 @@ struct BcSelectionTask {
453470
LOGP(debug, "prev inactive chips: {} {} {} {} {} {} {}", vPrevInactiveChips[0], vPrevInactiveChips[1], vPrevInactiveChips[2], vPrevInactiveChips[3], vPrevInactiveChips[4], vPrevInactiveChips[5], vPrevInactiveChips[6]);
454471
isGoodITSLayer3 = vPrevInactiveChips[3] <= maxInactiveChipsPerLayer->at(3) && vNextInactiveChips[3] <= maxInactiveChipsPerLayer->at(3);
455472
isGoodITSLayer0123 = true;
456-
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)
457474
isGoodITSLayer0123 &= vPrevInactiveChips[i] <= maxInactiveChipsPerLayer->at(i) && vNextInactiveChips[i] <= maxInactiveChipsPerLayer->at(i);
458475
}
459476
isGoodITSLayersAll = true;
@@ -476,17 +493,17 @@ struct BcSelectionTask {
476493
// Temporary workaround to get visible cross section. TODO: store run-by-run visible cross sections in CCDB
477494
const char* srun = Form("%d", run);
478495

479-
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)
480497
// Cross sections in ub. Using dummy -1 if lumi estimator is not reliable
481498
float csTVX = isPP ? (injectionEnergy ? 0.0355e6 : 0.0594e6) : -1.;
482499
float csTCE = isPP ? -1. : 10.36e6;
483500
float csZEM = isPP ? -1. : 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515
484501
float csZNC = isPP ? -1. : 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515
485-
if (run > 543437 && run < 543514) {
502+
if (run > 543437 && run < 543514) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb)
486503
csTCE = 8.3e6;
487504
}
488-
if (run >= 543514) {
489-
csTCE = 4.10e6; // see AN: https://alice-notes.web.cern.ch/node/1515
505+
if (run >= 543514) { // o2-linter: disable=magic-number (TODO store and extract cross sections from ccdb)
506+
csTCE = 4.10e6; // see AN: https://alice-notes.web.cern.ch/node/1515
490507
}
491508

492509
// Fill TVX (T0 vertex) counters
@@ -703,7 +720,7 @@ struct EventSelectionTask {
703720
int spdClusters = bc.spdClustersL0() + bc.spdClustersL1();
704721

705722
selection |= (spdClusters < par->fSPDClsVsTklA + nTkl * par->fSPDClsVsTklB) ? BIT(kNoSPDClsVsTklBG) : 0;
706-
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)
707724

708725
// copy rct flags from bcsel table
709726
uint32_t rct = bc.rct_raw();
@@ -723,7 +740,7 @@ struct EventSelectionTask {
723740
sel1 = sel1 && bc.selection_bit(kNoTPCHVdip);
724741

725742
// INT1 (SPDFO>0 | V0A | V0C) minimum bias trigger logic used in pp2010 and pp2011
726-
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)
727744

728745
// fill counters
729746
if (isMC == 1 || (!isINT1period && bc.alias_bit(kINT7)) || (isINT1period && bc.alias_bit(kINT1))) {
@@ -742,7 +759,8 @@ struct EventSelectionTask {
742759
{
743760
int run = bcs.iteratorAt(0).runNumber();
744761
// extract bc pattern from CCDB for data or anchored MC only
745-
if (run != lastRun && run >= 500000) {
762+
int run3min = 500000;
763+
if (run != lastRun && run >= run3min) {
746764
lastRun = run;
747765
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
748766
// first bc of the first orbit
@@ -768,7 +786,7 @@ struct EventSelectionTask {
768786
for (const auto& bc : bcs) {
769787
int64_t globalBC = bc.globalBC();
770788
// skip non-colliding bcs for data and anchored runs
771-
if (run >= 500000 && bcPatternB[globalBC % nBCsPerOrbit] == 0) {
789+
if (run >= run3min && bcPatternB[globalBC % nBCsPerOrbit] == 0) {
772790
continue;
773791
}
774792
if (bc.selection_bit(kIsTriggerTVX)) {
@@ -837,7 +855,7 @@ struct EventSelectionTask {
837855
float sumTime = 0, sumW = 0, sumHighPtTime = 0, sumHighPtW = 0;
838856
for (const auto& track : colPvTracks) {
839857
float trackTime = track.trackTime();
840-
if (track.itsNCls() >= 5)
858+
if (track.itsNCls() >= 5) // o2-linter: disable=magic-number (indeed counting layers 5 6 7)
841859
vTracksITS567perColl[colIndex]++;
842860
if (track.hasTRD())
843861
vIsVertexTRDmatched[colIndex] = 1;
@@ -1109,16 +1127,16 @@ struct EventSelectionTask {
11091127
if (confUseWeightsForOccupancyVariable) {
11101128
// weighted occupancy
11111129
wOccup = 0;
1112-
if (dt >= -40 && dt < -5) // collisions in the past
1113-
wOccup = 1. / 1225 * (dt + 40) * (dt + 40);
1114-
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)
11151133
wOccup = 1;
11161134
// else if (dt >= 15 && dt < 100) // collisions from the future
11171135
// wOccup = -1. / 85 * dt + 20. / 17;
1118-
else if (dt >= 15 && dt < 40) // collisions from the future
1119-
wOccup = -0.4 / 25 * dt + 1.24;
1120-
else if (dt >= 40 && dt < 100) // collisions from the distant future
1121-
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)
11221140
}
11231141
nITS567tracksInFullTimeWindow += wOccup * vTracksITS567perColl[thisColIndex];
11241142
sumAmpFT0CInFullTimeWindow += wOccup * vAmpFT0CperColl[thisColIndex];
@@ -1131,12 +1149,12 @@ struct EventSelectionTask {
11311149

11321150
// standard cut on other collisions vs delta-times
11331151
const float driftV = 2.5; // drift velocity in cm/us, TPC drift_length / drift_time = 250 cm / 100 us
1134-
if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions
1152+
if (std::fabs(dt) < 2.0) { // us, complete veto on other collisions // o2-linter: disable=magic-number (to be checked by Igor)
11351153
nCollsWithFT0CAboveVetoStandard++;
1136-
} else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more
1154+
} else if (dt > -4.0 && dt <= -2.0) { // us, strict veto to suppress fake ITS-TPC matches more // o2-linter: disable=magic-number (to be checked by Igor)
11371155
if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange / 5)
11381156
nCollsWithFT0CAboveVetoStandard++;
1139-
} else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm
1157+
} else if (std::fabs(dt) < 8 + std::fabs(vZ) / driftV) { // loose veto, 8 us corresponds to maximum possible |vZ|, which is ~20 cm // o2-linter: disable=magic-number (to be checked by Igor)
11401158
// counting number of other collisions with multiplicity above threshold
11411159
if (vAmpFT0CperColl[thisColIndex] > confFT0CamplCutVetoOnCollInTimeRange)
11421160
nCollsWithFT0CAboveVetoStandard++;

0 commit comments

Comments
 (0)