From 5f6131abfb95a331646a5b23f84312b76364a2e0 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Tue, 5 Nov 2024 13:35:59 +0100 Subject: [PATCH] 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. --- MC/bin/o2dpg_sim_workflow.py | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/MC/bin/o2dpg_sim_workflow.py b/MC/bin/o2dpg_sim_workflow.py index d429af3a3..09e9ecd0b 100755 --- a/MC/bin/o2dpg_sim_workflow.py +++ b/MC/bin/o2dpg_sim_workflow.py @@ -118,7 +118,7 @@ parser.add_argument('--no-tpc-digitchunking', action='store_true', help=argparse.SUPPRESS) parser.add_argument('--no-strangeness-tracking', action='store_true', default=False, help="Disable strangeness tracking") parser.add_argument('--combine-tpc-clusterization', action='store_true', help=argparse.SUPPRESS) #<--- useful for small productions (pp, low interaction rate, small number of events) -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) +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 # (consider doing this rather in O2 digitization code directly) parser.add_argument('--orbits-early', default=0, type=float, help=argparse.SUPPRESS) # number of orbits to start simulating earlier # to reduce start of timeframe effects in MC --> affects collision context @@ -244,21 +244,44 @@ def retrieve_sor(run_number): """ retrieves start of run (sor) from the RCT/Info/RunInformation table with a simple http request - in case of problems, 0 will be returned + in case of problems, 0 will be returned. Simple http request has advantage + of not needing to initialize a Ccdb object. """ + url="http://alice-ccdb.cern.ch/browse/RCT/Info/RunInformation/"+str(run_number) ansobject=requests.get(url) tokens=ansobject.text.split("\n") + # determine start of run, earlier values take precedence (see also implementation in BasicCCDBManager::getRunDuration) + STF=0 + # extract SOR by pattern matching + for t in tokens: + match_object=re.match(r"\s*(STF\s*=\s*)([0-9]*)\s*", t) + if match_object != None: + STF=int(match_object[2]) + break + if STF > 0: + return STF + + SOX=0 + # extract SOX by pattern matching + for t in tokens: + match_object=re.match(r"\s*(STF\s*=\s*)([0-9]*)\s*", t) + if match_object != None: + SOX=int(match_object[2]) + break + if SOX > 0: + return SOX + SOR=0 # extract SOR by pattern matching for t in tokens: match_object=re.match(r"\s*(SOR\s*=\s*)([0-9]*)\s*", t) if match_object != None: - SOR=match_object[2] + SOR=int(match_object[2]) break - - return int(SOR) + + return SOR # check and sanitize config-key values (extract and remove diamond vertex arguments into finalDiamondDict)