ATLAS Offline Software
PostExec.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #
3 # This module contains postExec commands that can be used with the CA-based
4 # runHLT in athena(HLT).
5 #
6 # Assumptions:
7 # - the final ComponentAccumulator instance is called 'cfg'
8 # - the ConfigFlags instance is called 'flags'
9 #
10 # Example usage:
11 # athenaHLT -C 'from TriggerJobOpts import PostExec; PostExec.foo([args])' ... TriggerJobOpts.runHLT
12 # athena --postExec 'from TriggerJobOpts import PostExec; PostExec.foo([args])' TriggerJobOpts/runHLT.py
13 #
14 
15 from AthenaCommon.Logging import logging
16 log = logging.getLogger('TriggerJobOpts.PostExec')
17 
18 # For convenience we provide access to the globals of the calling frame.
19 # This is where the `exec` of the post-commmand happens in athena or athenaHLT.
20 import inspect
21 __postExec_frame = next(filter(lambda f : ('TrigPSCPythonCASetup.py' in f.filename or
22  'runHLT.py' in f.filename), inspect.stack()), None)
23 if __postExec_frame is not None:
24  __globals = dict(inspect.getmembers(__postExec_frame[0]))["f_globals"]
25 
26 
27 #
28 # PostExec functions
29 #
30 
31 def forceConditions(run, lb, iovDbSvc=None):
32  """Force all conditions (except prescales) to match the given run and LB number"""
33 
34  log.info(forceConditions.__doc__)
35 
36  if iovDbSvc is None:
37  iovDbSvc = __globals['cfg'].getService('IOVDbSvc')
38 
39  # Do not override these folders:
40  ignore = ['/TRIGGER/HLT/PrescaleKey'] # see ATR-22143
41 
42  # All time-based folders (from IOVDbSvc DEBUG message, see athena!38274)
43  timebased = ['/TDAQ/OLC/CALIBRATIONS',
44  '/TDAQ/Resources/ATLAS/SCT/Robins',
45  '/SCT/DAQ/Config/ChipSlim',
46  '/SCT/DAQ/Config/Geog',
47  '/SCT/DAQ/Config/MUR',
48  '/SCT/DAQ/Config/Module',
49  '/SCT/DAQ/Config/ROD',
50  '/SCT/DAQ/Config/RODMUR',
51  '/SCT/HLT/DCS/HV',
52  '/SCT/HLT/DCS/MODTEMP',
53  '/MUONALIGN/Onl/MDT/BARREL',
54  '/MUONALIGN/Onl/MDT/ENDCAP/SIDEA',
55  '/MUONALIGN/Onl/MDT/ENDCAP/SIDEC',
56  '/MUONALIGN/Onl/TGC/SIDEA',
57  '/MUONALIGN/Onl/TGC/SIDEC',
58  '/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts',
59  '/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib',
60  '/TRIGGER/L1Calo/V1/Calibration/JfexModuleSettings',
61  '/TRIGGER/L1Calo/V1/Calibration/JfexNoiseCuts',
62  '/TRIGGER/L1Calo/V1/Calibration/JfexSystemSettings']
63 
64  from TrigCommon.AthHLT import get_sor_params
65  sor = get_sor_params(run)
66  timestamp = sor['SORTime'] // int(1e9)
67 
68  for i,f in enumerate(iovDbSvc.Folders):
69  if any(name in f for name in ignore):
70  continue
71  if any(name in f for name in timebased):
72  iovDbSvc.Folders[i] += f'<forceTimestamp>{timestamp:d}</forceTimestamp>'
73  else:
74  iovDbSvc.Folders[i] += f'<forceRunNumber>{run:d}</forceRunNumber> <forceLumiblockNumber>{lb:d}</forceLumiblockNumber>'
75 
76 
78  """Process views in reverse order"""
79 
80  log.info(forceConditions.__doc__)
81 
82  from TriggerJobOpts.TriggerConfig import collectViewMakers
83  viewMakers = collectViewMakers( __globals['cfg'].getSequence() )
84  for alg in viewMakers:
85  alg.ReverseViewsDebug = True
86 
87 
88 def dbmod_BFieldAutoConfig(): # DB modifier for debug recovery when using an online SMK
89  """Use DCS currents to configure magnetic field"""
90 
91  log.info(dbmod_BFieldAutoConfig.__doc__)
92 
93  from GaudiPython.Bindings import iProperty
94  # Add the DCS folder
95  f = '<db>COOLOFL_DCS/CONDBR2</db> /EXT/DCS/MAGNETS/SENSORDATA'
96  iProperty('IOVDbSvc').Folders += [f]
97  iProperty('CondInputLoader').Load.add(('CondAttrListCollection','/EXT/DCS/MAGNETS/SENSORDATA'))
98  # Configure CondAlgs
99  iProperty('AtlasFieldCacheCondAlg').UseDCS = True
100  iProperty('AtlasFieldMapCondAlg').LoadMapOnStart = False
101  iProperty('AtlasFieldMapCondAlg').UseMapsFromCOOL = True
102  iProperty('HltEventLoopMgr').setMagFieldFromPtree = False
python.AthHLT.get_sor_params
def get_sor_params(run_number)
Definition: AthHLT.py:28
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.PostExec.reverseViews
def reverseViews()
Definition: PostExec.py:77
covarianceTool.filter
filter
Definition: covarianceTool.py:514
python.PostExec.dbmod_BFieldAutoConfig
def dbmod_BFieldAutoConfig()
Definition: PostExec.py:88
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
python.TriggerConfig.collectViewMakers
def collectViewMakers(steps)
Definition: TriggerConfig.py:67
python.PostExec.forceConditions
def forceConditions(run, lb, iovDbSvc=None)
Definition: PostExec.py:31