7 logger = logging.getLogger(
"PileUp")
8 customProfile = flags.Digitization.PU.CustomProfile
12 return int(scaleTaskLength * x)
15 logger.info(
'Setting-up custom pile-up range with user-selected run(s) %s', customProfile.get(
'run', -1))
16 except AttributeError:
17 logger.error(
"Set ConfigFlags.Digitization.PU.CustomProfile=\'{\"run\":1234,...}\' in preExec!")
18 raise ValueError(
"Invalid ConfigFlags.Digitization.PU.CustomProfile provided. Run number is missing.")
19 keys=[
'run',
'startmu',
'endmu',
'stepmu',
'startlb',
'timestamp']
20 for key
in customProfile.keys():
22 raise ValueError(
"Invalid ConfigFlags.Digitization.PU.CustomProfile provided, key: %s. Valid keys are: %s" % (key, keys))
24 startMu = customProfile.get(
'startmu', 0.0)
25 endMu = customProfile.get(
'endmu', 10.0)
26 stepMu = customProfile.get(
'stepmu', 1.0)
27 numberOfSteps =
int(((endMu - startMu) / stepMu) + 1.0)
29 raise RuntimeError(
"Step size too large!")
31 stepsWithExtraEvent = 5000 % numberOfSteps
32 eventsPerStep = (5000 - (5000 % numberOfSteps)) / numberOfSteps
33 if _evts(eventsPerStep) < 2:
raise RuntimeError(
"Step size too small!")
35 runList = customProfile.get(
'run', 195847)
36 if not isinstance(runList, list): runList = [runList]
37 timestampList = customProfile.get(
'timestamp', 1328039085)
38 if not isinstance(timestampList, list): timestampList = [timestampList]
39 startlbList = customProfile.get(
'startlb', 1)
40 if not isinstance(startlbList, list): startlbList = [startlbList]
43 for currentRun, currentTimestamp, currentStartlb
in zip(runList, timestampList, startlbList):
44 for step
in range(numberOfSteps):
45 events = eventsPerStep + 1
if step < stepsWithExtraEvent
else eventsPerStep
46 mu =
float(startMu + (step * stepMu))
47 profile += [{
'run': currentRun,
'lb': currentStartlb + step,
'starttstamp': currentTimestamp,
48 'evts': _evts(events),
'mu': mu}]