Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions MC/bin/o2dpg_sim_workflow_anchored.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import json
import math
import pandas as pd
import csv

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

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

# Function to detect the delimiter automatically
def detect_delimiter(file_path):
with open(file_path, 'r') as csvfile:
sample = csvfile.read(1024) # Read a small sample of the file
sniffer = csv.Sniffer()
delimiter = sniffer.sniff(sample).delimiter
return delimiter
return ',' # a reasonable default

# read txt file into a pandas dataframe ---> if this fails catch exception and return
df = pd.read_csv(filename, header=None, names=["Run", "From", "To", "Message"])
df = pd.read_csv(filename, header=None, names=["Run", "From", "To", "Message"], sep=detect_delimiter(filename))

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

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

print("Exclusion list has " + str(len(exclude_list)) + " entries")
print(exclude_list)

if len(exclude_list) == 0:
return False

Expand Down Expand Up @@ -354,6 +367,8 @@ def main():
parser.add_argument("--ccdb-IRate", type=bool, help="whether to try fetching IRate from CCDB/CTP", default=True)
parser.add_argument("--trig-eff", type=float, dest="trig_eff", help="Trigger eff needed for IR", default=-1.0)
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="")
parser.add_argument("--invert-irframe-selection", action='store_true', help="Inverts the logic of --run-time-span-file")
parser.add_argument("--orbitsPerTF", type=int, help="Force a certain orbits-per-timeframe number; Automatically taken from CCDB if not given.", default=-1)
parser.add_argument('forward', nargs=argparse.REMAINDER) # forward args passed to actual workflow creation
args = parser.parse_args()
print (args)
Expand All @@ -369,14 +384,21 @@ def main():
run_start = GLOparams["SOR"]
run_end = GLOparams["EOR"]

# overwrite with some external choices
if args.orbitsPerTF!=-1:
print("Adjusting orbitsPerTF from " + str(GLOparams["OrbitsPerTF"]) + " to " + str(args.orbitsPerTF))
GLOparams["OrbitsPerTF"] = args.orbitsPerTF

# determine timestamp, and production offset for the final MC job to run
timestamp, prod_offset = determine_timestamp(run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])
# determine orbit corresponding to timestamp
orbit = GLOparams["FirstOrbit"] + (timestamp - GLOparams["SOR"]) / LHCOrbitMUS

# check if timestamp is to be excluded
# what to do in case of
job_is_exluded = exclude_timestamp(timestamp, orbit, args.run_number, args.run_span_file)
# possibly invert the selection
if args.invert_irframe_selection:
job_is_exluded = not job_is_exluded

# this is anchored to
print ("Determined start-of-run to be: ", run_start)
Expand Down
5 changes: 3 additions & 2 deletions MC/run/ANCHOR/anchorMC.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ MODULES="--skipModules ZDC"
ALICEO2_CCDB_LOCALCACHE=${ALICEO2_CCDB_LOCALCACHE:-$(pwd)/ccdb}

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

# 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
remainingargs="-seed ${SEED} -ns ${NSIGEVENTS} --include-local-qc --pregenCollContext"
Expand Down
Loading