Skip to content

Commit ff2773b

Browse files
sawenzelalcaliva
authored andcommitted
Consistency fixes for SOR determination in unanchored MC (#1780)
* Set default firstOrbit to 256 just a preventive measure in case someone is using --early-orbits (avoid to get negative). In the worst case we skip few timeframes ... and in any case not a relevant change for anchored MC. * Better SOR determination Fixes a problem with wrong/inconsistent timestamps for some runs (when not using anchoring). Now consistent with other code in O2. (cherry picked from commit 5f6131a)
1 parent 0fd6fa0 commit ff2773b

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

MC/bin/o2dpg_sim_workflow.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
parser.add_argument('--no-tpc-digitchunking', action='store_true', help=argparse.SUPPRESS)
119119
parser.add_argument('--no-strangeness-tracking', action='store_true', default=False, help="Disable strangeness tracking")
120120
parser.add_argument('--combine-tpc-clusterization', action='store_true', help=argparse.SUPPRESS) #<--- useful for small productions (pp, low interaction rate, small number of events)
121-
parser.add_argument('--first-orbit', default=0, type=int, help=argparse.SUPPRESS) # to set the first orbit number of the run for HBFUtils (only used when anchoring)
121+
parser.add_argument('--first-orbit', default=256, type=int, help=argparse.SUPPRESS) # to set the first orbit number of the run for HBFUtils (only used when anchoring); default 256 for convenience to allow for some orbits-early
122122
# (consider doing this rather in O2 digitization code directly)
123123
parser.add_argument('--orbits-early', default=0, type=float, help=argparse.SUPPRESS) # number of orbits to start simulating earlier
124124
# to reduce start of timeframe effects in MC --> affects collision context
@@ -244,21 +244,44 @@ def retrieve_sor(run_number):
244244
"""
245245
retrieves start of run (sor)
246246
from the RCT/Info/RunInformation table with a simple http request
247-
in case of problems, 0 will be returned
247+
in case of problems, 0 will be returned. Simple http request has advantage
248+
of not needing to initialize a Ccdb object.
248249
"""
250+
249251
url="http://alice-ccdb.cern.ch/browse/RCT/Info/RunInformation/"+str(run_number)
250252
ansobject=requests.get(url)
251253
tokens=ansobject.text.split("\n")
252254

255+
# determine start of run, earlier values take precedence (see also implementation in BasicCCDBManager::getRunDuration)
256+
STF=0
257+
# extract SOR by pattern matching
258+
for t in tokens:
259+
match_object=re.match(r"\s*(STF\s*=\s*)([0-9]*)\s*", t)
260+
if match_object != None:
261+
STF=int(match_object[2])
262+
break
263+
if STF > 0:
264+
return STF
265+
266+
SOX=0
267+
# extract SOX by pattern matching
268+
for t in tokens:
269+
match_object=re.match(r"\s*(STF\s*=\s*)([0-9]*)\s*", t)
270+
if match_object != None:
271+
SOX=int(match_object[2])
272+
break
273+
if SOX > 0:
274+
return SOX
275+
253276
SOR=0
254277
# extract SOR by pattern matching
255278
for t in tokens:
256279
match_object=re.match("\s*(SOR\s*=\s*)([0-9]*)\s*", t)
257280
if match_object != None:
258-
SOR=match_object[2]
281+
SOR=int(match_object[2])
259282
break
260-
261-
return int(SOR)
283+
284+
return SOR
262285

263286

264287
# check and sanitize config-key values (extract and remove diamond vertex arguments into finalDiamondDict)

0 commit comments

Comments
 (0)