Skip to content

Commit

Permalink
Use run-wise timestamp to query the CCDB
Browse files Browse the repository at this point in the history
This avoids crashes due to bogus values of the timestamp of the first BC in the data frame
  • Loading branch information
mpuccio committed Sep 9, 2024
1 parent 722aab7 commit 3e15a42
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Common/TableProducer/eventSelection.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,25 @@ struct BcSelectionTask {

bcsel.reserve(bcs.size());
// extract ITS time frame parameters

int64_t ts = bcs.iteratorAt(0).timestamp();
int run = bcs.iteratorAt(0).runNumber();
auto timestamps = ccdb->getRunDuration(run, true); /// fatalise if timestamps are not found
int64_t sorTimestamp = timestamps.first; // timestamp of the SOR in ms
int64_t eorTimestamp = timestamps.second; // timestamp of the EOR in ms
int64_t ts = eorTimestamp / 2 + sorTimestamp / 2; // timestamp of the middle of the run
auto alppar = ccdb->getForTimeStamp<o2::itsmft::DPLAlpideParam<0>>("ITS/Config/AlpideParam", ts);

EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", ts);
TriggerAliases* aliases = ccdb->getForTimeStamp<TriggerAliases>("EventSelection/TriggerAliases", ts);
// map from GlobalBC to BcId needed to find triggerBc
std::map<uint64_t, int32_t> mapGlobalBCtoBcId;
for (auto& bc : bcs) {
mapGlobalBCtoBcId[bc.globalBC()] = bc.globalIndex();
}
int triggerBcShift = confTriggerBcShift;
if (confTriggerBcShift == 999) {
int run = bcs.iteratorAt(0).runNumber();
triggerBcShift = (run <= 526766 || (run >= 526886 && run <= 527237) || (run >= 527259 && run <= 527518) || run == 527523 || run == 527734 || run >= 534091) ? 0 : 294;
}

// extract run number and related information
int run = bcs.iteratorAt(0).runNumber();
if (run != lastRunNumber) {
lastRunNumber = run; // do it only once
if (run >= 500000) { // access CCDB for data or anchored MC only
Expand Down Expand Up @@ -278,8 +280,6 @@ struct BcSelectionTask {

// bc loop
for (auto bc : bcs) {
EventSelectionParams* par = ccdb->getForTimeStamp<EventSelectionParams>("EventSelection/EventSelectionParams", bc.timestamp());
TriggerAliases* aliases = ccdb->getForTimeStamp<TriggerAliases>("EventSelection/TriggerAliases", bc.timestamp());
uint32_t alias{0};
// workaround for pp2022 (trigger info is shifted by -294 bcs)
int32_t triggerBcId = mapGlobalBCtoBcId[bc.globalBC() + triggerBcShift];
Expand Down

0 comments on commit 3e15a42

Please sign in to comment.