Skip to content

Commit b200892

Browse files
committed
Implemented ITS ramp-up shift in start-of-run
1 parent 2e31d1b commit b200892

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

MC/bin/o2dpg_sim_workflow_anchored.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,21 @@ def retrieve_CTPScalers(ccdbreader, run_number, timestamp=None):
266266
return ctpscaler
267267
return None
268268

269+
def retrieve_ITS_RampDuration(ccdbreader, timestamp):
270+
"""
271+
Retrieves the ITS ramp-up duration for a given timestamp and
272+
returns it in milliseconds.
273+
ITS does not deliver digits during a certain ramp-up period so
274+
the start of run is adjusted accordingly using this value.
275+
"""
276+
_, ramp_duration = ccdbreader.fetch("ITS/Calib/RampDuration", "vector<float>", timestamp=timestamp)
277+
if ramp_duration and len(ramp_duration) > 0:
278+
# The vector contains the duration in seconds, convert to milliseconds
279+
duration_ms = int(ramp_duration[0] * 1000)
280+
return duration_ms
281+
print("WARNING: ITS ramp duration vector is empty, using 0")
282+
return 0
283+
269284
def retrieve_MinBias_CTPScaler_Rate(ctpscaler, finaltime, trig_eff_arg, NBunches, ColSystem, eCM):
270285
"""
271286
retrieves the CTP scalers object for a given timestamp
@@ -520,7 +535,11 @@ def main():
520535
run_start = GLOparams["SOR"]
521536
run_end = GLOparams["EOR"]
522537

523-
mid_run_timestamp = (run_start + run_end) // 2
538+
# Adjust start of run using ITS ramp-up period
539+
ITS_rampup = retrieve_ITS_RampDuration(ccdbreader, run_start)
540+
print(f"ITS ramp-up time: {ITS_rampup} ms")
541+
effective_run_start = run_start + ITS_rampup
542+
mid_run_timestamp = (effective_run_start + run_end) // 2
524543

525544
# --------
526545
# fetch other important global properties needed further below
@@ -580,16 +599,16 @@ def main():
580599
timestamp = 0
581600
prod_offset = 0
582601
if args.timeframeID != -1:
583-
timestamp = determine_timestamp_from_timeframeID(run_start, run_end, args.timeframeID, GLOparams["OrbitsPerTF"])
602+
timestamp = determine_timestamp_from_timeframeID(effective_run_start, run_end, args.timeframeID, GLOparams["OrbitsPerTF"])
584603
prod_offset = args.timeframeID
585604
else:
586-
timestamp, prod_offset = determine_timestamp(run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])
605+
timestamp, prod_offset = determine_timestamp(effective_run_start, run_end, [args.split_id - 1, args.prod_split], args.cycle, args.tf, GLOparams["OrbitsPerTF"])
587606

588607
# determine orbit corresponding to timestamp (mainly used in exclude_timestamp function)
589608
orbit = GLOparams["FirstOrbit"] + int((timestamp - GLOparams["SOR"]) / ( LHCOrbitMUS / 1000))
590609

591610
# this is anchored to
592-
print ("Determined start-of-run to be: ", run_start)
611+
print ("Determined start-of-run to be: ", effective_run_start)
593612
print ("Determined end-of-run to be: ", run_end)
594613
print ("Determined timestamp to be : ", timestamp)
595614
print ("Determined offset to be : ", prod_offset)
@@ -630,7 +649,7 @@ def main():
630649
# However, the last passed argument wins, so they would be overwritten. If this should not happen, the option
631650
# needs to be handled as further below:
632651
energyarg = (" -eCM " + str(eCM)) if A1 == A2 else (" -eA " + str(eA) + " -eB " + str(eB))
633-
forwardargs += " -tf " + str(args.tf) + " --sor " + str(run_start) + " --timestamp " + str(timestamp) + " --production-offset " + str(prod_offset) + " -run " + str(args.run_number) + " --run-anchored --first-orbit " \
652+
forwardargs += " -tf " + str(args.tf) + " --sor " + str(effective_run_start) + " --timestamp " + str(timestamp) + " --production-offset " + str(prod_offset) + " -run " + str(args.run_number) + " --run-anchored --first-orbit " \
634653
+ str(GLOparams["FirstOrbit"]) + " --orbitsPerTF " + str(GLOparams["OrbitsPerTF"]) + " -col " + str(ColSystem) + str(energyarg)
635654
# the following options can be overwritten/influence from the outside
636655
if not '--readoutDets' in forwardargs:

0 commit comments

Comments
 (0)