Skip to content

Commit fdaac3e

Browse files
authored
kNoTimeFrameBorder and kNoITSROFrameBorder cuts added in the standard sel8 selection (#5547)
1 parent b47970e commit fdaac3e

File tree

1 file changed

+56
-34
lines changed

1 file changed

+56
-34
lines changed

Common/TableProducer/eventSelection.cxx

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,18 @@ struct BcSelectionTask {
4141
Service<o2::ccdb::BasicCCDBManager> ccdb;
4242
HistogramRegistry histos{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject};
4343
Configurable<int> confTriggerBcShift{"triggerBcShift", 999, "set to 294 for apass2/apass3 in LHC22o-t"};
44-
Configurable<int> confITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", 10, "Number of bcs at the start of ITS RO Frame border"};
45-
Configurable<int> confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", 20, "Number of bcs at the end of ITS RO Frame border"};
46-
Configurable<int> confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", 350, "Number of bcs to cut at the start of the Time Frame"};
47-
Configurable<int> confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", 4000, "Number of bcs to cut at the end of the Time Frame"};
44+
Configurable<int> confITSROFrameStartBorderMargin{"ITSROFrameStartBorderMargin", -1, "Number of bcs at the start of ITS RO Frame border. Take from CCDB if -1"};
45+
Configurable<int> confITSROFrameEndBorderMargin{"ITSROFrameEndBorderMargin", -1, "Number of bcs at the end of ITS RO Frame border. Take from CCDB if -1"};
46+
Configurable<int> confTimeFrameStartBorderMargin{"TimeFrameStartBorderMargin", -1, "Number of bcs to cut at the start of the Time Frame. Take from CCDB if -1"};
47+
Configurable<int> confTimeFrameEndBorderMargin{"TimeFrameEndBorderMargin", -1, "Number of bcs to cut at the end of the Time Frame. Take from CCDB if -1"};
4848

4949
int lastRunNumber = -1;
50-
int64_t bcSOR = -1; // global bc of the start of the first orbit
51-
int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564
50+
int64_t bcSOR = -1; // global bc of the start of the first orbit
51+
int64_t nBCsPerTF = -1; // duration of TF in bcs, should be 128*3564 or 32*3564
52+
int mITSROFrameStartBorderMargin = 10; // default value
53+
int mITSROFrameEndBorderMargin = 20; // default value
54+
int mTimeFrameStartBorderMargin = 300; // default value
55+
int mTimeFrameEndBorderMargin = 4000; // default value
5256

5357
void init(InitContext&)
5458
{
@@ -61,10 +65,18 @@ struct BcSelectionTask {
6165
histos.add("hCounterTCE", "", kTH1D, {{1, 0., 1.}});
6266
histos.add("hCounterZEM", "", kTH1D, {{1, 0., 1.}});
6367
histos.add("hCounterZNC", "", kTH1D, {{1, 0., 1.}});
68+
histos.add("hCounterTVXafterBCcuts", "", kTH1D, {{1, 0., 1.}});
69+
histos.add("hCounterTCEafterBCcuts", "", kTH1D, {{1, 0., 1.}});
70+
histos.add("hCounterZEMafterBCcuts", "", kTH1D, {{1, 0., 1.}});
71+
histos.add("hCounterZNCafterBCcuts", "", kTH1D, {{1, 0., 1.}});
6472
histos.add("hLumiTVX", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
6573
histos.add("hLumiTCE", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
6674
histos.add("hLumiZEM", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
6775
histos.add("hLumiZNC", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
76+
histos.add("hLumiTVXafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
77+
histos.add("hLumiTCEafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
78+
histos.add("hLumiZEMafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
79+
histos.add("hLumiZNCafterBCcuts", ";;Luminosity, 1/#mub", kTH1D, {{1, 0., 1.}});
6880
}
6981

7082
void processRun2(
@@ -223,42 +235,32 @@ struct BcSelectionTask {
223235
int run = bcs.iteratorAt(0).runNumber();
224236
if (run != lastRunNumber) {
225237
lastRunNumber = run; // do it only once
226-
int64_t tsSOR = 0;
227-
int64_t tsEOR = 0;
228-
229238
if (run >= 500000) { // access CCDB for data or anchored MC only
230239
int64_t ts = bcs.iteratorAt(0).timestamp();
231-
240+
// access orbitShift, ITSROF and TF border margins
241+
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
242+
mITSROFrameStartBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;
243+
mITSROFrameEndBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;
244+
mTimeFrameStartBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;
245+
mTimeFrameEndBorderMargin = confITSROFrameStartBorderMargin < 0 ? par->fITSROFrameStartBorderMargin : confITSROFrameStartBorderMargin;
232246
// access orbit-reset timestamp
233247
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
234248
int64_t tsOrbitReset = (*ctpx)[0]; // us
235-
LOGP(info, "tsOrbitReset={} us", tsOrbitReset);
236-
237249
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
238250
std::map<std::string, std::string> metadata;
239251
metadata["runNumber"] = Form("%d", run);
240252
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
241253
uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
242-
tsSOR = grpecs->getTimeStart(); // ms
243-
tsEOR = grpecs->getTimeEnd(); // ms
244-
245-
// calculate SOR and EOR orbits
254+
int64_t tsSOR = grpecs->getTimeStart(); // ms
255+
// calculate SOR orbit
246256
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
247-
int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
248-
249257
// adjust to the nearest TF edge
250-
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF; // was with - 1;
251-
orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF; // was with - 1;
252-
253-
// set nOrbits and minOrbit used for orbit-axis binning
254-
// nOrbits = orbitEOR - orbitSOR;
255-
// minOrbit = orbitSOR;
256-
257-
int nBCsPerOrbit = 3564;
258+
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
258259
// first bc of the first orbit (should coincide with TF start)
259-
bcSOR = orbitSOR * nBCsPerOrbit;
260+
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
260261
// duration of TF in bcs
261-
nBCsPerTF = nOrbitsPerTF * nBCsPerOrbit;
262+
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
263+
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, orbitSOR, nBCsPerTF);
262264
}
263265
}
264266

@@ -340,12 +342,12 @@ struct BcSelectionTask {
340342
// 2bc margin is also introduced at ehe beginning of ITS RO Frame to account for the uncertainty of the roFrameBiasInBC
341343
uint16_t bcInITSROF = (globalBC + 3564 - alppar->roFrameBiasInBC) % alppar->roFrameLengthInBC;
342344
LOGP(debug, "bcInITSROF={}", bcInITSROF);
343-
selection |= bcInITSROF > confITSROFrameStartBorderMargin && bcInITSROF < alppar->roFrameLengthInBC - confITSROFrameEndBorderMargin ? BIT(kNoITSROFrameBorder) : 0;
345+
selection |= bcInITSROF > mITSROFrameStartBorderMargin && bcInITSROF < alppar->roFrameLengthInBC - mITSROFrameEndBorderMargin ? BIT(kNoITSROFrameBorder) : 0;
344346

345347
// check if bc is far from the Time Frame borders
346348
int64_t bcInTF = (globalBC - bcSOR) % nBCsPerTF;
347349
LOGP(debug, "bcInTF={}", bcInTF);
348-
selection |= bcInTF > confTimeFrameStartBorderMargin && bcInTF < nBCsPerTF - confTimeFrameEndBorderMargin ? BIT(kNoTimeFrameBorder) : 0;
350+
selection |= bcInTF > mTimeFrameStartBorderMargin && bcInTF < nBCsPerTF - mTimeFrameEndBorderMargin ? BIT(kNoTimeFrameBorder) : 0;
349351

350352
int32_t foundFT0 = bc.has_ft0() ? bc.ft0().globalIndex() : -1;
351353
int32_t foundFV0 = bc.has_fv0a() ? bc.fv0a().globalIndex() : -1;
@@ -363,33 +365,49 @@ struct BcSelectionTask {
363365
// Cross sections in ub. Using dummy -1 if lumi estimator is not reliable
364366
float csTVX = isPP ? (injectionEnergy ? 0.0355e6 : 0.0594e6) : -1.;
365367
float csTCE = isPP ? -1. : 10.36e6;
366-
float csZEM = isPP ? -1. : 415.2e6;
367-
float csZNC = isPP ? -1. : 214.5e6;
368+
float csZEM = isPP ? -1. : 415.2e6; // see AN: https://alice-notes.web.cern.ch/node/1515
369+
float csZNC = isPP ? -1. : 214.5e6; // see AN: https://alice-notes.web.cern.ch/node/1515
368370
if (run > 543437 && run < 543514) {
369371
csTCE = 8.3e6;
370372
}
371373
if (run >= 543514) {
372-
csTCE = 3.97e6;
374+
csTCE = 4.10e6; // see AN: https://alice-notes.web.cern.ch/node/1515
373375
}
374376

375377
// Fill TVX (T0 vertex) counters
376378
if (TESTBIT(selection, kIsTriggerTVX)) {
377379
histos.get<TH1>(HIST("hCounterTVX"))->Fill(srun, 1);
378380
histos.get<TH1>(HIST("hLumiTVX"))->Fill(srun, 1. / csTVX);
381+
if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) {
382+
histos.get<TH1>(HIST("hCounterTVXafterBCcuts"))->Fill(srun, 1);
383+
histos.get<TH1>(HIST("hLumiTVXafterBCcuts"))->Fill(srun, 1. / csTVX);
384+
}
379385
}
380386
// Fill counters and lumi histograms for Pb-Pb lumi monitoring
381387
// TODO: introduce pileup correction
382388
if (bc.has_ft0() ? (TESTBIT(selection, kIsTriggerTVX) && TESTBIT(bc.ft0().triggerMask(), o2::ft0::Triggers::bitCen)) : 0) {
383389
histos.get<TH1>(HIST("hCounterTCE"))->Fill(srun, 1);
384390
histos.get<TH1>(HIST("hLumiTCE"))->Fill(srun, 1. / csTCE);
391+
if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) {
392+
histos.get<TH1>(HIST("hCounterTCEafterBCcuts"))->Fill(srun, 1);
393+
histos.get<TH1>(HIST("hLumiTCEafterBCcuts"))->Fill(srun, 1. / csTCE);
394+
}
385395
}
386396
if (TESTBIT(selection, kIsBBZNA) || TESTBIT(selection, kIsBBZNC)) {
387397
histos.get<TH1>(HIST("hCounterZEM"))->Fill(srun, 1);
388398
histos.get<TH1>(HIST("hLumiZEM"))->Fill(srun, 1. / csZEM);
399+
if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) {
400+
histos.get<TH1>(HIST("hCounterZEMafterBCcuts"))->Fill(srun, 1);
401+
histos.get<TH1>(HIST("hLumiZEMafterBCcuts"))->Fill(srun, 1. / csZEM);
402+
}
389403
}
390404
if (TESTBIT(selection, kIsBBZNC)) {
391405
histos.get<TH1>(HIST("hCounterZNC"))->Fill(srun, 1);
392406
histos.get<TH1>(HIST("hLumiZNC"))->Fill(srun, 1. / csZNC);
407+
if (TESTBIT(selection, kNoITSROFrameBorder) && TESTBIT(selection, kNoTimeFrameBorder)) {
408+
histos.get<TH1>(HIST("hCounterZNCafterBCcuts"))->Fill(srun, 1);
409+
histos.get<TH1>(HIST("hLumiZNCafterBCcuts"))->Fill(srun, 1. / csZNC);
410+
}
393411
}
394412

395413
// Fill bc selection columns
@@ -436,6 +454,7 @@ struct EventSelectionTask {
436454
ccdb->setLocalObjectValidityChecking();
437455

438456
histos.add("hColCounterAll", "", kTH1D, {{1, 0., 1.}});
457+
histos.add("hColCounterTVX", "", kTH1D, {{1, 0., 1.}});
439458
histos.add("hColCounterAcc", "", kTH1D, {{1, 0., 1.}});
440459
}
441460

@@ -661,10 +680,13 @@ struct EventSelectionTask {
661680
// TODO apply other cuts for sel8
662681
// TODO introduce sel1 etc?
663682
// TODO introduce array of sel[0]... sel[8] or similar?
664-
bool sel8 = bc.selection_bit(kIsTriggerTVX);
683+
bool sel8 = bc.selection_bit(kIsTriggerTVX) && bc.selection_bit(kNoTimeFrameBorder) && bc.selection_bit(kNoITSROFrameBorder);
665684

666685
// fill counters
667686
histos.get<TH1>(HIST("hColCounterAll"))->Fill(Form("%d", bc.runNumber()), 1);
687+
if (bc.selection_bit(kIsTriggerTVX)) {
688+
histos.get<TH1>(HIST("hColCounterTVX"))->Fill(Form("%d", bc.runNumber()), 1);
689+
}
668690
if (sel8) {
669691
histos.get<TH1>(HIST("hColCounterAcc"))->Fill(Form("%d", bc.runNumber()), 1);
670692
}

0 commit comments

Comments
 (0)