Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using AggregatedRunInfo to extract orbitSOR and nBCsPerTF #7984

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 13 additions & 37 deletions Common/TableProducer/eventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "DataFormatsParameters/GRPECSObject.h"
#include "ITSMFTBase/DPLAlpideParam.h"
#include "MetadataHelper.h"
#include "DataFormatsParameters/AggregatedRunInfo.h"

#include "TH1D.h"

Expand Down Expand Up @@ -260,24 +261,12 @@ struct BcSelectionTask {
mITSROFrameEndBorderMargin = confITSROFrameEndBorderMargin < 0 ? par->fITSROFrameEndBorderMargin : confITSROFrameEndBorderMargin;
mTimeFrameStartBorderMargin = confTimeFrameStartBorderMargin < 0 ? par->fTimeFrameStartBorderMargin : confTimeFrameStartBorderMargin;
mTimeFrameEndBorderMargin = confTimeFrameEndBorderMargin < 0 ? par->fTimeFrameEndBorderMargin : confTimeFrameEndBorderMargin;
// access orbit-reset timestamp
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
int64_t tsOrbitReset = (*ctpx)[0]; // us
// access TF duration, start-of-run and end-of-run timestamps from ECS GRP
std::map<std::string, std::string> metadata;
metadata["runNumber"] = Form("%d", run);
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
int64_t tsSOR = grpecs->getTimeStart(); // ms
// calculate SOR orbit
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
// adjust to the nearest TF edge
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
// first bc of the first orbit (should coincide with TF start)
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;

auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
// first bc of the first orbit
bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
// duration of TF in bcs
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
LOGP(info, "tsOrbitReset={} us, SOR = {} ms, orbitSOR = {}, nBCsPerTF = {}", tsOrbitReset, tsSOR, orbitSOR, nBCsPerTF);
nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches;
}
}

Expand Down Expand Up @@ -631,28 +620,15 @@ struct EventSelectionTask {
// extract bc pattern from CCDB for data or anchored MC only
if (run != lastRun && run >= 500000) {
lastRun = run;
auto runInfo = o2::parameters::AggregatedRunInfo::buildAggregatedRunInfo(o2::ccdb::BasicCCDBManager::instance(), run);
// first bc of the first orbit
bcSOR = runInfo.orbitSOR * o2::constants::lhc::LHCMaxBunches;
// duration of TF in bcs
nBCsPerTF = runInfo.orbitsPerTF * o2::constants::lhc::LHCMaxBunches;
// colliding bc pattern
int64_t ts = bcs.iteratorAt(0).timestamp();
auto grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", ts);
bcPatternB = grplhcif->getBunchFilling().getBCPattern();

EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
// access orbit-reset timestamp
auto ctpx = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", ts);
int64_t tsOrbitReset = (*ctpx)[0]; // us
// access TF duration, start-of-run timestamp from ECS GRP
std::map<std::string, std::string> metadata;
metadata["runNumber"] = Form("%d", run);
auto grpecs = ccdb->getSpecific<o2::parameters::GRPECSObject>("GLO/Config/GRPECS", ts, metadata);
uint32_t nOrbitsPerTF = grpecs->getNHBFPerTF(); // assuming 1 orbit = 1 HBF; nOrbitsPerTF=128 in 2022, 32 in 2023
int64_t tsSOR = grpecs->getTimeStart(); // ms
// calculate SOR orbit
int64_t orbitSOR = (tsSOR * 1000 - tsOrbitReset) / o2::constants::lhc::LHCOrbitMUS;
// adjust to the nearest TF edge
orbitSOR = orbitSOR / nOrbitsPerTF * nOrbitsPerTF + par->fTimeFrameOrbitShift;
// first bc of the first orbit (should coincide with TF start)
bcSOR = orbitSOR * o2::constants::lhc::LHCMaxBunches;
// duration of TF in bcs
nBCsPerTF = nOrbitsPerTF * o2::constants::lhc::LHCMaxBunches;
}

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