Skip to content

Commit 66e5ed7

Browse files
authored
Using AggregatedRunInfo to extract orbitSOR and nBCsPerTF (AliceO2Group#7984)
1 parent 375f0f8 commit 66e5ed7

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

Common/TableProducer/eventSelection.cxx

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "DataFormatsParameters/GRPECSObject.h"
2525
#include "ITSMFTBase/DPLAlpideParam.h"
2626
#include "MetadataHelper.h"
27+
#include "DataFormatsParameters/AggregatedRunInfo.h"
2728

2829
#include "TH1D.h"
2930

@@ -260,24 +261,12 @@ struct BcSelectionTask {
260261
mITSROFrameEndBorderMargin = confITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : confITSROFrameEndBorderMargin;
261262
mTimeFrameStartBorderMargin = confTimeFrameStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : confTimeFrameStartBorderMargin;
262263
mTimeFrameEndBorderMargin = confTimeFrameEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : confTimeFrameEndBorderMargin;
263-
// access orbit-reset timestamp
264-
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
265-
int64_t tsOrbitReset = (*ctpx)[0]; // us
266-
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
267-
std::map<std::string, std::string> metadata;
268-
metadata["runNumber"] = Form("%d", run);
269-
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
270-
uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
271-
int64_t tsSOR = grpecs->getTimeStart(); // ms
272-
// calculate SOR orbit
273-
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
274-
// adjust to the nearest TF edge
275-
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
276-
// first bc of the first orbit (should coincide with TF start)
277-
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
264+
265+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
266+
// first bc of the first orbit
267+
bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
278268
// duration of TF in bcs
279-
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
280-
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, orbitSOR, nBCsPerTF);
269+
nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches;
281270
}
282271
}
283272

@@ -631,28 +620,15 @@ struct EventSelectionTask {
631620
// extract bc pattern from CCDB for data or anchored MC only
632621
if (run != lastRun && run >= 500000) {
633622
lastRun = run;
623+
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
624+
// first bc of the first orbit
625+
bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
626+
// duration of TF in bcs
627+
nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches;
628+
// colliding bc pattern
634629
int64_t ts = bcs.iteratorAt(0).timestamp();
635630
auto grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
636631
bcPatternB = grplhcif->getBunchFilling().getBCPattern();
637-
638-
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
639-
// access orbit-reset timestamp
640-
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
641-
int64_t tsOrbitReset = (*ctpx)[0]; // us
642-
// access TF duration, start-of-run timestamp from ECS GRP
643-
std::map<std::string, std::string> metadata;
644-
metadata["runNumber"] = Form("%d", run);
645-
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
646-
uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
647-
int64_t tsSOR = grpecs->getTimeStart(); // ms
648-
// calculate SOR orbit
649-
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
650-
// adjust to the nearest TF edge
651-
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
652-
// first bc of the first orbit (should coincide with TF start)
653-
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
654-
// duration of TF in bcs
655-
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
656632
}
657633

658634
// create maps from globalBC to bc index for TVX-fired bcs
@@ -806,7 +782,7 @@ struct EventSelectionTask {
806782
// second loop to match remaining low-pt TPCnoTOFnoTRD collisions
807783
for (auto& col : cols) {
808784
int32_t colIndex = col.globalIndex();
809-
if (vIsVertexTPC[colIndex] > 0 && vIsVertexHighPtTPC[colIndex] == 0) {
785+
if (vIsVertexTPC[colIndex] > 0 && vIsVertexTOF[colIndex] == 0 && vIsVertexHighPtTPC[colIndex] == 0) {
810786
float weightedTime = vWeightedTimesTPCnoTOFnoTRD[colIndex];
811787
float weightedSigma = vWeightedSigmaTPCnoTOFnoTRD[colIndex];
812788
auto bc = col.bc_as<BCsWithBcSelsRun3>();

0 commit comments

Comments
 (0)