ATLAS Offline Software
Loading...
Searching...
No Matches
python.AutoConfigOnlineRecoFlags Namespace Reference

Functions

 setDefaultOnlineRecoFlags (flags)
 trySetFlagsFromIS (flags, partition=None)
 autoConfigOnlineRecoFlags (flags, partition=None)

Variables

 log = logging.getLogger('OnlineRecoDefaults')

Function Documentation

◆ autoConfigOnlineRecoFlags()

python.AutoConfigOnlineRecoFlags.autoConfigOnlineRecoFlags ( flags,
partition = None )

Definition at line 134 of file AutoConfigOnlineRecoFlags.py.

134def autoConfigOnlineRecoFlags(flags, partition=None):
135 # Set the flags to default
136 setDefaultOnlineRecoFlags(flags)
137 # Try updating the flags from IS if the information is available
138 trySetFlagsFromIS(flags, partition)

◆ setDefaultOnlineRecoFlags()

python.AutoConfigOnlineRecoFlags.setDefaultOnlineRecoFlags ( flags)
Set all input-dependent flags explicitly to avoid attempts to read an input
file when there is none

Definition at line 13 of file AutoConfigOnlineRecoFlags.py.

13def setDefaultOnlineRecoFlags(flags):
14 '''
15 Set all input-dependent flags explicitly to avoid attempts to read an input
16 file when there is none
17 '''
18
19 flags.Common.isOnline = True
20
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 = []
29
30 flags.Beam.Type = BeamType.Collisions
31 flags.Beam.Energy = 7*TeV
32
33 flags.IOVDb.GlobalTag = 'CONDBR2-HLTP-2018-01'
34 flags.GeoModel.AtlasVersion = 'ATLAS-R2-2016-01-00-01'
35
36 flags.Trigger.EDMVersion = 3
37
38
39# When running the job at P1 while the partition is running, the metadata can be read from IS

◆ trySetFlagsFromIS()

python.AutoConfigOnlineRecoFlags.trySetFlagsFromIS ( flags,
partition = None )
Attempt to fill in run metadata from IS if available

Definition at line 40 of file AutoConfigOnlineRecoFlags.py.

40def trySetFlagsFromIS(flags, partition=None):
41 '''Attempt to fill in run metadata from IS if available'''
42 from PyUtils.moduleExists import moduleExists
43 if not moduleExists('ipc') or not moduleExists('ispy'):
44 log.warning('TDAQ python modules to read from IS (ipc, ispy) are unavailable')
45 return
46
47 from ipc import IPCPartition
48 from ispy import ISObject
49
50 if not partition:
51 import os
52 partition = os.getenv('TDAQ_PARTITION') or 'ATLAS'
53 log.debug('Trying to read IS data for partition %s', partition)
54
55 def tryReadISObject(obj_name, type_name, part_name=partition):
56 try:
57 obj = ISObject(IPCPartition(part_name), obj_name, type_name)
58 obj.checkout()
59 return obj
60 except Exception as e:
61 log.warning('Cannot read %s from partition %s, exception: %s', obj_name, part_name, e)
62 return None
63
64 def tryReadFromISObject(obj, attr, default=None):
65 try:
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)
69 return default
70
71 # Run parameters
72 runparams = tryReadISObject('RunParams.RunParams', 'RunParams')
73 if runparams:
74 # Run number
75 run_number = tryReadFromISObject(runparams, 'run_number')
76 if run_number is not None:
77 flags.Input.RunNumbers = [run_number]
78 # Tier-0 project name
79 project_name = tryReadFromISObject(runparams, 'T0_project_tag')
80 if project_name is not None:
81 flags.Input.ProjectName = project_name
82 # Beam type
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
86 # Beam energy
87 beam_energy = tryReadFromISObject(runparams, 'beam_energy')
88 if beam_energy is not None:
89 flags.Beam.Energy = beam_energy*GeV
90
91 # Trigger configuration
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' # Run3 DB name (not listed in IS)
103 flags.Trigger.triggerConfig = 'DB:{:s}:{:d},{:d},{:d},{:d}'.format(
104 dbname, smk, l1psk, hltpsk, bgk)
105
106 # LumiBlock information
107 lbinfo = tryReadISObject('RunParams.LumiBlock', 'LumiBlock')
108 if lbinfo:
109 # LB number
110 lb_number = tryReadFromISObject(lbinfo, 'LumiBlockNumber')
111 if lb_number is not None:
112 flags.Input.LumiBlockNumbers = [lb_number]
113 # Timestamp
114 time_ns = tryReadFromISObject(lbinfo, 'Time')
115 if time_ns is not None:
116 flags.Input.TimeStamps = [int(time_ns / 1e9)]
117
118 # Solenoid status
119 solenoid_curr_is = tryReadISObject('DCS_GENERAL.MagnetSolenoidCurrent.value', 'DdcFloatInfo', part_name='initial')
120 if solenoid_curr_is:
121 solenoid_curr = tryReadFromISObject(solenoid_curr_is, 'value')
122 if solenoid_curr is not None:
123 flags.BField.solenoidOn = (solenoid_curr > 70) # threshold of 70 copied from RecExOnline_globalconfig.py
124
125 # Toroid status
126 toroid_curr_is = tryReadISObject('DCS_GENERAL.MagnetToroidsCurrent.value', 'DdcFloatInfo', part_name='initial')
127 if toroid_curr_is:
128 toroid_curr = tryReadFromISObject(toroid_curr_is, 'value')
129 if toroid_curr is not None:
130 flags.BField.barrelToroidOn = (toroid_curr > 70) # threshold of 70 copied from RecExOnline_globalconfig.py
131 flags.BField.endcapToroidOn = (toroid_curr > 70) # threshold of 70 copied from RecExOnline_globalconfig.py
132
133

Variable Documentation

◆ log

python.AutoConfigOnlineRecoFlags.log = logging.getLogger('OnlineRecoDefaults')

Definition at line 7 of file AutoConfigOnlineRecoFlags.py.