Skip to content

Commit d141b09

Browse files
committed
fixing O2 linter issues
1 parent f6dc2ff commit d141b09

File tree

1 file changed

+85
-83
lines changed

1 file changed

+85
-83
lines changed

PWGMM/Lumi/Tasks/lumiStability.cxx

Lines changed: 85 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ struct LumiStabilityTask {
6464
int64_t currentTFid = -1;
6565
int nOrbits = nOrbitsConf;
6666
double minOrbit = minOrbitConf;
67+
int minTimeFDD = 30;
6768
int64_t bcSOR = 0; // global bc of the start of the first orbit, setting 0 by default for unanchored MC
6869
int64_t tsSOR;
6970
int64_t tsEOR;
@@ -273,78 +274,77 @@ struct LumiStabilityTask {
273274
lastRunNumber = runNumber; // do it only once
274275
executionCounter++;
275276

276-
if (runNumber >= 500000) { // access CCDB for data or anchored MC only
277-
int64_t ts = bcs.iteratorAt(0).timestamp();
278-
279-
// access colliding and beam-gas bc patterns
280-
grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
281-
beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0);
282-
beamPatternC = grplhcif->getBunchFilling().getBeamPattern(1);
283-
bcPatternA = beamPatternA & ~beamPatternC;
284-
bcPatternC = ~beamPatternA & beamPatternC;
285-
bcPatternB = beamPatternA & beamPatternC;
286-
bcPatternE = ~beamPatternA & ~beamPatternC;
287-
288-
for (int i = 0; i < nBCsPerOrbit; i++) {
289-
if (bcPatternA[i]) {
290-
histos.fill(HIST("hBcA"), i);
291-
}
292-
if (bcPatternC[i]) {
293-
histos.fill(HIST("hBcC"), i);
294-
}
295-
if (bcPatternB[i]) {
296-
histos.fill(HIST("hBcB"), i);
297-
bool isLeadBC = true;
298-
for (int jbit = i - minEmpty; jbit < i; jbit++) {
299-
int kbit = jbit;
300-
if (kbit < 0)
301-
kbit += nbin;
302-
if (bcPatternB[kbit]) {
303-
isLeadBC = false;
304-
break;
305-
}
277+
// access CCDB for data or anchored MC only
278+
int64_t ts = bcs.iteratorAt(0).timestamp();
279+
280+
// access colliding and beam-gas bc patterns
281+
grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
282+
beamPatternA = grplhcif->getBunchFilling().getBeamPattern(0);
283+
beamPatternC = grplhcif->getBunchFilling().getBeamPattern(1);
284+
bcPatternA = beamPatternA & ~beamPatternC;
285+
bcPatternC = ~beamPatternA & beamPatternC;
286+
bcPatternB = beamPatternA & beamPatternC;
287+
bcPatternE = ~beamPatternA & ~beamPatternC;
288+
289+
for (int i = 0; i < nBCsPerOrbit; i++) {
290+
if (bcPatternA[i]) {
291+
histos.fill(HIST("hBcA"), i);
292+
}
293+
if (bcPatternC[i]) {
294+
histos.fill(HIST("hBcC"), i);
295+
}
296+
if (bcPatternB[i]) {
297+
histos.fill(HIST("hBcB"), i);
298+
bool isLeadBC = true;
299+
for (int jbit = i - minEmpty; jbit < i; jbit++) {
300+
int kbit = jbit;
301+
if (kbit < 0)
302+
kbit += nbin;
303+
if (bcPatternB[kbit]) {
304+
isLeadBC = false;
305+
break;
306306
}
307-
if (isLeadBC)
308-
histos.fill(HIST("hBcBL"), i);
309-
}
310-
if (bcPatternE[i]) {
311-
histos.fill(HIST("hBcE"), i);
312307
}
308+
if (isLeadBC)
309+
histos.fill(HIST("hBcBL"), i);
310+
}
311+
if (bcPatternE[i]) {
312+
histos.fill(HIST("hBcE"), i);
313313
}
314-
315-
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
316-
// access orbit-reset timestamp
317-
auto ctpx = ccdb->getForTimeStamp<std::vector<int64_t>>("CTP/Calib/OrbitReset", ts);
318-
int64_t tsOrbitReset = (*ctpx)[0]; // us
319-
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
320-
std::map<std::string, std::string> metadata;
321-
metadata["runNumber"] = Form("%d", runNumber);
322-
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
323-
nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
324-
tsSOR = grpecs->getTimeStart(); // ms
325-
tsEOR = grpecs->getTimeEnd(); // ms
326-
// calculate SOR and EOR orbits
327-
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
328-
int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
329-
// adjust to the nearest TF edge
330-
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
331-
orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
332-
// set nOrbits and minOrbit used for orbit-axis binning
333-
nOrbits = orbitEOR - orbitSOR;
334-
minOrbit = orbitSOR;
335-
// first bc of the first orbit (should coincide with TF start)
336-
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
337-
// duration of TF in bcs
338-
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
339-
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, EOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, tsEOR, orbitSOR, nBCsPerTF);
340-
341-
auto hTsValues = histos.get<TH1>(HIST("tsValues"));
342-
hTsValues->GetXaxis()->SetBinLabel(1, "tsSOR");
343-
hTsValues->GetXaxis()->SetBinLabel(2, "tsEOR");
344-
hTsValues->SetBinContent(1, tsSOR / 1000); // seconds
345-
hTsValues->SetBinContent(2, tsEOR / 1000); // seconds
346314
}
347315

316+
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
317+
// access orbit-reset timestamp
318+
auto ctpx = ccdb->getForTimeStamp<std::vector<int64_t>>("CTP/Calib/OrbitReset", ts);
319+
int64_t tsOrbitReset = (*ctpx)[0]; // us
320+
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
321+
std::map<std::string, std::string> metadata;
322+
metadata["runNumber"] = Form("%d", runNumber);
323+
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
324+
nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
325+
tsSOR = grpecs->getTimeStart(); // ms
326+
tsEOR = grpecs->getTimeEnd(); // ms
327+
// calculate SOR and EOR orbits
328+
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
329+
int64_t orbitEOR = (tsEOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
330+
// adjust to the nearest TF edge
331+
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
332+
orbitEOR = orbitEOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
333+
// set nOrbits and minOrbit used for orbit-axis binning
334+
nOrbits = orbitEOR - orbitSOR;
335+
minOrbit = orbitSOR;
336+
// first bc of the first orbit (should coincide with TF start)
337+
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
338+
// duration of TF in bcs
339+
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
340+
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, EOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, tsEOR, orbitSOR, nBCsPerTF);
341+
342+
auto hTsValues = histos.get<TH1>(HIST("tsValues"));
343+
hTsValues->GetXaxis()->SetBinLabel(1, "tsSOR");
344+
hTsValues->GetXaxis()->SetBinLabel(2, "tsEOR");
345+
hTsValues->SetBinContent(1, tsSOR / 1000); // seconds
346+
hTsValues->SetBinContent(2, tsEOR / 1000); // seconds
347+
348348
// create orbit-axis histograms on the fly with binning based on info from GRP if GRP is available
349349
// otherwise default minOrbit and nOrbits will be used
350350
// const AxisSpec axisOrbits{static_cast<int>(nOrbits / nOrbitsPerTF), 0., static_cast<double>(nOrbits), ""};
@@ -354,7 +354,7 @@ struct LumiStabilityTask {
354354
// histos.add("hOrbitFV0Central", "", kTH1F, {axisOrbits});
355355
}
356356

357-
for (auto& bc : bcs) {
357+
for (auto const& bc : bcs) {
358358
if (bc.timestamp() == 0) {
359359
continue;
360360
}
@@ -433,11 +433,12 @@ struct LumiStabilityTask {
433433
auto sideC = fdd.chargeC();
434434
std::vector<int> channelA;
435435
std::vector<int> channelC;
436+
int minLimit = 0;
436437
for (auto i = 0; i < 8; i++) {
437-
if (sideA[i] > 0) {
438+
if (sideA[i] > minLimit) {
438439
channelA.push_back(i);
439440
}
440-
if (sideC[i] > 0) {
441+
if (sideC[i] > minLimit) {
441442
channelC.push_back(i);
442443
}
443444
}
@@ -517,27 +518,27 @@ struct LumiStabilityTask {
517518
histos.fill(HIST("FDD/hTimeAVertex"), fdd.timeA());
518519
histos.fill(HIST("FDD/hTimeCVertex"), fdd.timeC());
519520
if (is2022Data) {
520-
if (fdd.timeA() > 30) {
521+
if (fdd.timeA() > minTimeFDD) {
521522
histos.fill(HIST("FDD/hCountsTimeA2022"), 0);
522523
histos.fill(HIST("FDD/hInvTimeAvsBC2022"), localBC);
523524
} else {
524525
histos.fill(HIST("FDD/hCountsTimeA2022"), 1);
525526
histos.fill(HIST("FDD/hValidTimeAvsBC2022"), localBC);
526527
}
527528

528-
if (fdd.timeC() > 30) {
529+
if (fdd.timeC() > minTimeFDD) {
529530
histos.fill(HIST("FDD/hCountsTimeC2022"), 0);
530531
histos.fill(HIST("FDD/hInvTimeCvsBC2022"), localBC);
531532
} else {
532533
histos.fill(HIST("FDD/hCountsTimeC2022"), 1);
533534
histos.fill(HIST("FDD/hValidTimeCvsBC2022"), localBC);
534535
}
535536

536-
if (fdd.timeA() > 30 || fdd.timeC() > 30) {
537+
if (fdd.timeA() > minTimeFDD || fdd.timeC() > minTimeFDD) {
537538
histos.fill(HIST("FDD/hCountsTime2022"), 0);
538539
histos.fill(HIST("FDD/hInvTimevsBC2022"), localBC);
539540
}
540-
if (fdd.timeA() < 30 && fdd.timeC() < 30) {
541+
if (fdd.timeA() < minTimeFDD && fdd.timeC() < minTimeFDD) {
541542
histos.fill(HIST("FDD/hCountsTime2022"), 1);
542543
histos.fill(HIST("FDD/hValidTimevsBC2022"), localBC);
543544
}
@@ -580,27 +581,27 @@ struct LumiStabilityTask {
580581
histos.fill(HIST("FDD/hTimeACoinc"), fdd.timeA());
581582
histos.fill(HIST("FDD/hTimeCCoinc"), fdd.timeC());
582583
if (!is2022Data) {
583-
if (fdd.timeA() > 30) {
584+
if (fdd.timeA() > minTimeFDD) {
584585
histos.fill(HIST("FDD/hCountsTimeA"), 0);
585586
histos.fill(HIST("FDD/hInvTimeAvsBC"), localBC);
586587
} else {
587588
histos.fill(HIST("FDD/hCountsTimeA"), 1);
588589
histos.fill(HIST("FDD/hValidTimeAvsBC"), localBC);
589590
}
590591

591-
if (fdd.timeC() > 30) {
592+
if (fdd.timeC() > minTimeFDD) {
592593
histos.fill(HIST("FDD/hCountsTimeC"), 0);
593594
histos.fill(HIST("FDD/hInvTimeCvsBC"), localBC);
594595
} else {
595596
histos.fill(HIST("FDD/hCountsTimeC"), 1);
596597
histos.fill(HIST("FDD/hValidTimeCvsBC"), localBC);
597598
}
598599

599-
if (fdd.timeA() > 30 || fdd.timeC() > 30) {
600+
if (fdd.timeA() > minTimeFDD || fdd.timeC() > minTimeFDD) {
600601
histos.fill(HIST("FDD/hCountsTime"), 0);
601602
histos.fill(HIST("FDD/hInvTimevsBC"), localBC);
602603
}
603-
if (fdd.timeA() < 30 && fdd.timeC() < 30) {
604+
if (fdd.timeA() < minTimeFDD && fdd.timeC() < minTimeFDD) {
604605
histos.fill(HIST("FDD/hCountsTime"), 1);
605606
histos.fill(HIST("FDD/hValidTimevsBC"), localBC);
606607
}
@@ -634,7 +635,8 @@ struct LumiStabilityTask {
634635
auto sideCPast = fddPast.chargeC();
635636
std::vector<int> channelAPast;
636637
std::vector<int> channelCPast;
637-
for (auto i = 0; i < 8; i++) {
638+
int maxNChanels = 8
639+
for (auto i = 0; i < maxNChanels; i++) {
638640
if (sideAPast[i] > 0) {
639641
channelAPast.push_back(i);
640642
}
@@ -742,27 +744,27 @@ struct LumiStabilityTask {
742744
histos.fill(HIST("FT0/hTimeA"), ft0.timeA());
743745
histos.fill(HIST("FT0/hTimeC"), ft0.timeC());
744746

745-
if (ft0.timeA() > 30) {
747+
if (ft0.timeA() > minTimeFDD) {
746748
histos.fill(HIST("FT0/hCountsTimeA"), 0);
747749
histos.fill(HIST("FT0/hInvTimeAvsBC"), localBC);
748750
} else {
749751
histos.fill(HIST("FT0/hCountsTimeA"), 1);
750752
histos.fill(HIST("FT0/hValidTimeAvsBC"), localBC);
751753
}
752754

753-
if (ft0.timeC() > 30) {
755+
if (ft0.timeC() > minTimeFDD) {
754756
histos.fill(HIST("FT0/hCountsTimeC"), 0);
755757
histos.fill(HIST("FT0/hInvTimeCvsBC"), localBC);
756758
} else {
757759
histos.fill(HIST("FT0/hCountsTimeC"), 1);
758760
histos.fill(HIST("FT0/hValidTimeCvsBC"), localBC);
759761
}
760762

761-
if (ft0.timeA() > 30 || ft0.timeC() > 30) {
763+
if (ft0.timeA() > minTimeFDD || ft0.timeC() > minTimeFDD) {
762764
histos.fill(HIST("FT0/hCountsTime"), 0);
763765
histos.fill(HIST("FT0/hInvTimevsBC"), localBC);
764766
}
765-
if (ft0.timeA() < 30 && ft0.timeC() < 30) {
767+
if (ft0.timeA() < minTimeFDD && ft0.timeC() < minTimeFDD) {
766768
histos.fill(HIST("FT0/hCountsTime"), 1);
767769
histos.fill(HIST("FT0/hValidTimevsBC"), localBC);
768770
}

0 commit comments

Comments
 (0)