Skip to content

Commit 2b045c9

Browse files
committed
Improvements for run_span treatment
* allow arbitrary deliminiters * allow to invert selection just like in async reco
1 parent 7b88f33 commit 2b045c9

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

MC/bin/o2dpg_sim_workflow_anchored.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import json
1515
import math
1616
import pandas as pd
17+
import csv
1718

1819
# Creates a time anchored MC workflow; positioned within a given run-number (as function of production size etc)
1920

@@ -317,15 +318,27 @@ def exclude_timestamp(ts, orbit, run, filename):
317318
if not os.path.isfile(filename):
318319
return False
319320

321+
# Function to detect the delimiter automatically
322+
def detect_delimiter(file_path):
323+
with open(file_path, 'r') as csvfile:
324+
sample = csvfile.read(1024) # Read a small sample of the file
325+
sniffer = csv.Sniffer()
326+
delimiter = sniffer.sniff(sample).delimiter
327+
return delimiter
328+
return ',' # a reasonable default
329+
320330
# read txt file into a pandas dataframe ---> if this fails catch exception and return
321-
df = pd.read_csv(filename, header=None, names=["Run", "From", "To", "Message"])
331+
df = pd.read_csv(filename, header=None, names=["Run", "From", "To", "Message"], sep=detect_delimiter(filename))
322332

323333
# extract data for this run number
324334
filtered = df[df['Run'] == run]
325335

326336
# now extract from and to lists
327337
exclude_list = list(zip(filtered["From"].to_list() , filtered["To"].to_list()))
328338

339+
print("Exclusion list has " + str(len(exclude_list)) + " entries")
340+
print(exclude_list)
341+
329342
if len(exclude_list) == 0:
330343
return False
331344

@@ -354,6 +367,7 @@ def main():
354367
parser.add_argument("--ccdb-IRate", type=bool, help="whether to try fetching IRate from CCDB/CTP", default=True)
355368
parser.add_argument("--trig-eff", type=float, dest="trig_eff", help="Trigger eff needed for IR", default=-1.0)
356369
parser.add_argument("--run-time-span-file", type=str, dest="run_span_file", help="Run-time-span-file for exclusions of timestamps (bad data periods etc.)", default="")
370+
parser.add_argument("--invert-irframe-selection", action='store_true', help="Inverts the logic of --run-time-span-file")
357371
parser.add_argument('forward', nargs=argparse.REMAINDER) # forward args passed to actual workflow creation
358372
args = parser.parse_args()
359373
print (args)
@@ -375,8 +389,10 @@ def main():
375389
orbit = GLOparams["FirstOrbit"] + (timestamp - GLOparams["SOR"]) / LHCOrbitMUS
376390

377391
# check if timestamp is to be excluded
378-
# what to do in case of
379392
job_is_exluded = exclude_timestamp(timestamp, orbit, args.run_number, args.run_span_file)
393+
# possibly invert the selection
394+
if args.invert_irframe_selection:
395+
job_is_exluded = not job_is_exluded
380396

381397
# this is anchored to
382398
print ("Determined start-of-run to be: ", run_start)

MC/run/ANCHOR/anchorMC.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ MODULES="--skipModules ZDC"
210210
ALICEO2_CCDB_LOCALCACHE=${ALICEO2_CCDB_LOCALCACHE:-$(pwd)/ccdb}
211211

212212
# these arguments will be digested by o2dpg_sim_workflow_anchored.py
213-
baseargs="-tf ${NTIMEFRAMES} --split-id ${SPLITID} --prod-split ${PRODSPLIT} --cycle ${CYCLE} --run-number ${ALIEN_JDL_LPMRUNNUMBER} \
214-
${ALIEN_JDL_RUN_TIME_SPAN_FILE:+--run-time-span-file ${ALIEN_JDL_RUN_TIME_SPAN_FILE}}"
213+
baseargs="-tf ${NTIMEFRAMES} --split-id ${SPLITID} --prod-split ${PRODSPLIT} --cycle ${CYCLE} --run-number ${ALIEN_JDL_LPMRUNNUMBER} \
214+
${ALIEN_JDL_RUN_TIME_SPAN_FILE:+--run-time-span-file ${ALIEN_JDL_RUN_TIME_SPAN_FILE} ${ALIEN_JDL_INVERT_IRFRAME_SELECTION:+--invert-irframe-selection}}"
215215

216216
# these arguments will be passed as well but only evetually be digested by o2dpg_sim_workflow.py which is called from o2dpg_sim_workflow_anchored.py
217217
remainingargs="-seed ${SEED} -ns ${NSIGEVENTS} --include-local-qc --pregenCollContext"

0 commit comments

Comments
 (0)