Skip to content

Commit cf90493

Browse files
sawenzelclaude
andcommitted
Align MC timeframes using FirstOrbitMC from MCProdInfo
This replaces the hardcoded list of MC productions in AggregatedRunInfo::adjust_from_MC by a per-run value from CCDB. - The correction now uses the key FirstOrbitMC of the MCProdInfo object of each run. - The shift is (FirstOrbitMC - orbitSOR) mod orbitsPerTF, so it holds for any TF length, anchor time and software version. - Without the key, no correction is applied. - New productions record FirstOrbitMC themselves (O2DPG). Existing ones are fixed with O2DPG's MC/prodinfo/mcprodinfo_firstorbit.py. - Publishing needs the aliprod role. If a production needs fixing, please open an O2 JIRA ticket and ask Sandro Wenzel. Recipe to fix a production: mcprodinfo_firstorbit.py scan --tag <TAG> -o <TAG>.json mcprodinfo_firstorbit.py rerun <TAG>.json --crosscheck 3 mcprodinfo_firstorbit.py apply <TAG>.json --comment "FirstOrbitMC added because of O2-XXXX" --yes scan reads the first orbit of each run from its GRID job logs, rerun fills runs without logs and cross-checks a sample (needs CVMFS), apply publishes (dry run without --yes). https://its.cern.ch/jira/browse/O2-7335 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5c6d39b commit cf90493

1 file changed

Lines changed: 10 additions & 65 deletions

File tree

‎DataFormats/Parameters/src/AggregatedRunInfo.cxx‎

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "DataFormatsParameters/GRPLHCIFData.h"
1919
#include "CommonConstants/LHCConstants.h"
2020
#include "Framework/Logger.h"
21-
#include <cmath>
21+
#include <charconv>
2222
#include <map>
2323

2424
using namespace o2::parameters;
@@ -133,71 +133,16 @@ void AggregatedRunInfo::adjust_from_MC(o2::ccdb::CCDBManagerInstance& ccdb,
133133
LOG(warn) << "No OrbitsPerTF information found for MC production " << lpm_prod_tag << " and run number " << run_number;
134134
}
135135

136-
// adjust SOR for some MC productions, where the ITS "ramp-up shift" of SOR was not a multiple of NOrbitsPerTF.
137-
// (several MC productions are affected (MC-prod-2026-v12 and v13), before the problem was fixed on Oct 4, 2026)
138-
static constexpr std::string_view validTags[] = {
139-
"LHC25f1c",
140-
"LHC26j18_G4list",
141-
"LHC26j18",
142-
"LHC26j17",
143-
"LHC26j16",
144-
"LHC26j14",
145-
"LHC26e9b",
146-
"LHC26i9_5",
147-
"LHC26i9_4",
148-
"LHC26i9_3",
149-
"LHC26i9_2",
150-
"LHC26i8_5",
151-
"LHC26i8_4",
152-
"LHC26i8_3",
153-
"LHC26i8_2",
154-
"LHC26j13",
155-
"LHC26j12_Plus10",
156-
"LHC26j12_Minus10",
157-
"LHC26j11",
158-
"LHC26j10",
159-
"LHC26j8",
160-
"LHC26j7",
161-
"LHC26j6",
162-
"LHC26j5",
163-
"LHC26j4_Plus10",
164-
"LHC26j4_Minus10",
165-
"LHC26j1",
166-
"LHC26i5_5",
167-
"LHC26i5_4",
168-
"LHC26i5_3",
169-
"LHC26i5_2",
170-
"LHC26i7",
171-
"LHC26i6",
172-
"LHC26i4",
173-
"LHC26h2",
174-
"LHC26g11",
175-
"LHC26i10_Plus10",
176-
"LHC26i10_Minus10",
177-
"LHC26h3_nodelta",
178-
"LHC26a5a_gp_v12",
179-
"LHC26h3",
180-
"LHC26e8",
181-
"LHC26f3",
182-
"EP26d1",
183-
"LHC26c12",
184-
"LHC26b10",
185-
"LHC26a7"};
186-
187-
if (std::ranges::find(validTags, lpm_prod_tag) != std::end(validTags)) {
188-
// apply the SOR adjustment for this specific MC production
189-
int nOrbitsCorrection = 4; // a shift (number of orbits for correction) if orbitsPerTF=32 or 8
190-
if (orbitsPerTF == 6) {
191-
nOrbitsCorrection = 2; // correction if orbitsPerTF=6, e.g. Pb-Pb MC LHC26h3
192-
} else if (orbitsPerTF == 128) {
193-
nOrbitsCorrection = 36; // correction if orbitsPerTF=128, e.g. MB gap trigger PbPb 2024 apass3 LHC26a7
136+
// align the TF borders with the MC, whose TFs start at FirstOrbitMC + k * orbitsPerTF (O2-7335)
137+
iter = header_data.find("FirstOrbitMC");
138+
int64_t firstOrbitMC = 0;
139+
if (iter != header_data.end() && std::from_chars(iter->second.data(), iter->second.data() + iter->second.size(), firstOrbitMC).ec == std::errc{}) {
140+
const int64_t shift = ((firstOrbitMC - orbitSOR) % orbitsPerTF + orbitsPerTF) % orbitsPerTF;
141+
if (shift != 0) {
142+
LOG(warn) << "AggregatedRunInfo.adjust_from_MC(): Shifting orbitSOR by " << shift << " orbits to align with the TFs of MC production " << lpm_prod_tag << " (run " << run_number << ", FirstOrbitMC " << firstOrbitMC << ")";
143+
orbitSOR += shift;
144+
sor += (int64_t)(shift * o2::constants::lhc::LHCOrbitMUS / 1000.);
194145
}
195-
if (lpm_prod_tag == "LHC26j17") {
196-
nOrbitsCorrection = 30; // special case: ITS ramp-up time of 90 s instead of 5 s (for orbitsPerTF=32)
197-
}
198-
orbitSOR += nOrbitsCorrection;
199-
sor += std::llround(nOrbitsCorrection * o2::constants::lhc::LHCOrbitMUS / 1000.);
200-
LOG(warn) << "AggregatedRunInfo.adjust_from_MC(): Applying SOR adjustment by " << nOrbitsCorrection << " orbits for MC production " << lpm_prod_tag << " and run number " << run_number;
201146
}
202147
}
203148

0 commit comments

Comments
 (0)