4 from AthenaCommon.Logging
import logging
5 from AthenaConfiguration.Enums
import BeamType, Format
7 log = logging.getLogger(
'OnlineRecoDefaults')
15 Set all input-dependent flags explicitly to avoid attempts to read an input
16 file when there is none
19 flags.Common.isOnline =
True
21 flags.Input.Files = []
22 flags.Input.isMC =
False
23 flags.Input.RunNumbers = [-1]
24 flags.Input.LumiBlockNumbers = [-1]
25 flags.Input.TimeStamps = [-1]
26 flags.Input.ProjectName =
'data_test'
27 flags.Input.Format = Format.BS
28 flags.Input.ProcessingTags = []
30 flags.Beam.Type = BeamType.Collisions
31 flags.Beam.Energy = 7*TeV
33 flags.IOVDb.GlobalTag =
'CONDBR2-HLTP-2018-01'
34 flags.GeoModel.AtlasVersion =
'ATLAS-R2-2016-01-00-01'
36 flags.Trigger.EDMVersion = 3
41 '''Attempt to fill in run metadata from IS if available'''
42 from PyUtils.moduleExists
import moduleExists
44 log.warning(
'TDAQ python modules to read from IS (ipc, ispy) are unavailable')
47 from ipc
import IPCPartition
48 from ispy
import ISObject
52 partition = os.getenv(
'TDAQ_PARTITION')
or 'ATLAS'
53 log.debug(
'Trying to read IS data for partition %s', partition)
55 def tryReadISObject(obj_name, type_name, part_name=partition):
57 obj = ISObject(IPCPartition(part_name), obj_name, type_name)
60 except Exception
as e:
61 log.warning(
'Cannot read %s from partition %s, exception: %s', obj_name, part_name, e)
64 def tryReadFromISObject(obj, attr, default=None):
66 return obj.getAttributeValue(attr)
67 except Exception
as e:
68 log.warning(
'Cannot read attribute %s from ISObject %s, exception: %s', attr, obj.name(), e)
72 runparams = tryReadISObject(
'RunParams.RunParams',
'RunParams')
75 run_number = tryReadFromISObject(runparams,
'run_number')
76 if run_number
is not None:
77 flags.Input.RunNumbers = [run_number]
79 project_name = tryReadFromISObject(runparams,
'T0_project_tag')
80 if project_name
is not None:
81 flags.Input.ProjectName = project_name
83 beam_type_num = tryReadFromISObject(runparams,
'beam_type')
84 if beam_type_num
is not None:
85 flags.Beam.Type = BeamType.Collisions
if beam_type_num > 0
else BeamType.Cosmics
87 beam_energy = tryReadFromISObject(runparams,
'beam_energy')
88 if beam_energy
is not None:
89 flags.Beam.Energy = beam_energy*GeV
92 smk_is = tryReadISObject(
'RunParams.TrigConfSmKey',
'TrigConfSmKey')
93 l1psk_is = tryReadISObject(
'RunParams.TrigConfL1PsKey',
'TrigConfL1PsKey')
94 hltpsk_is = tryReadISObject(
'RunParams.TrigConfHltPsKey',
'TrigConfHltPsKey')
95 bgk_is = tryReadISObject(
'RunParams.TrigConfL1BgKey',
'TrigConfL1BgKey')
96 if smk_is
and l1psk_is
and hltpsk_is
and bgk_is:
97 smk = tryReadFromISObject(smk_is,
'SuperMasterKey')
98 l1psk = tryReadFromISObject(l1psk_is,
'L1PrescaleKey')
99 hltpsk = tryReadFromISObject(hltpsk_is,
'HltPrescaleKey')
100 bgk = tryReadFromISObject(bgk_is,
'L1BunchGroupKey')
101 if all([v
is not None for v
in [smk, l1psk, hltpsk, bgk]]):
102 dbname =
'TRIGGERDB_RUN3'
103 flags.Trigger.triggerConfig =
'DB:{:s}:{:d},{:d},{:d},{:d}'.
format(
104 dbname, smk, l1psk, hltpsk, bgk)
107 lbinfo = tryReadISObject(
'RunParams.LumiBlock',
'LumiBlock')
110 lb_number = tryReadFromISObject(lbinfo,
'LumiBlockNumber')
111 if lb_number
is not None:
112 flags.Input.LumiBlockNumbers = [lb_number]
114 time_ns = tryReadFromISObject(lbinfo,
'Time')
115 if time_ns
is not None:
116 flags.Input.TimeStamps = [
int(time_ns / 1e9)]
119 solenoid_curr_is = tryReadISObject(
'DCS_GENERAL.MagnetSolenoidCurrent.value',
'DdcFloatInfo', part_name=
'initial')
121 solenoid_curr = tryReadFromISObject(solenoid_curr_is,
'value')
122 if solenoid_curr
is not None:
123 flags.BField.solenoidOn = (solenoid_curr > 70)
126 toroid_curr_is = tryReadISObject(
'DCS_GENERAL.MagnetToroidsCurrent.value',
'DdcFloatInfo', part_name=
'initial')
128 toroid_curr = tryReadFromISObject(toroid_curr_is,
'value')
129 if toroid_curr
is not None:
130 flags.BField.barrelToroidOn = (toroid_curr > 70)
131 flags.BField.endcapToroidOn = (toroid_curr > 70)