ATLAS Offline Software
Loading...
Searching...
No Matches
PostExec.py
Go to the documentation of this file.
1# Copyright (C) 2002-2026 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
15from AthenaCommon.Logging import logging
16log = 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.
20import inspect
21__postExec_frame = next(filter(lambda f : ('TrigPSCPythonCASetup.py' in f.filename or
22 'runHLT.py' in f.filename), inspect.stack()), None)
23if __postExec_frame is not None:
24 __globals = dict(inspect.getmembers(__postExec_frame[0]))["f_globals"]
25
26
27#
28# PostExec functions
29#
30
31def forceConditions(run, lb, timestamp=None, iovDbSvc=None):
32 """Force all conditions (except prescales) to match the given run and LB number, a timestamp can also be provided for MC"""
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 '/TRIGGER/L1Calo/V1/Calibration/GfexModuleSettings']
64
65 if timestamp is None:
66 from TrigCommon.AthHLT import get_sor_params
67 sor = get_sor_params(run)
68 timestamp = sor['SORTime'] // int(1e9)
69
70 for i,f in enumerate(iovDbSvc.Folders):
71 if any(name in f for name in ignore):
72 continue
73 if any(name in f for name in timebased):
74 iovDbSvc.Folders[i] += f'<forceTimestamp>{timestamp:d}</forceTimestamp>'
75 else:
76 iovDbSvc.Folders[i] += f'<forceRunNumber>{run:d}</forceRunNumber> <forceLumiblockNumber>{lb:d}</forceLumiblockNumber>'
77
78
80 """Process views in reverse order"""
81
82 log.info(forceConditions.__doc__)
83
84 from TriggerJobOpts.TriggerConfig import collectViewMakers
85 viewMakers = collectViewMakers( __globals['cfg'].getSequence() )
86 for alg in viewMakers:
87 alg.ReverseViewsDebug = True
88
89
90def dbmod_BFieldAutoConfig(): # DB modifier for debug recovery when using an online SMK
91 """Use DCS currents to configure magnetic field"""
92
93 log.info(dbmod_BFieldAutoConfig.__doc__)
94
95 from GaudiPython.Bindings import iProperty
96 # Add the DCS folder
97 f = '<db>COOLOFL_DCS/CONDBR2</db> /EXT/DCS/MAGNETS/SENSORDATA'
98 iProperty('IOVDbSvc').Folders += [f]
99 iProperty('CondInputLoader').Load.add(('CondAttrListCollection','/EXT/DCS/MAGNETS/SENSORDATA'))
100 # Configure CondAlgs
101 iProperty('AtlasFieldCacheCondAlg').UseDCS = True
102 iProperty('AtlasFieldMapCondAlg').LoadMapOnStart = False
103 iProperty('AtlasFieldMapCondAlg').UseMapsFromCOOL = True
104 iProperty('HltEventLoopMgr').setMagFieldFromPtree = False
forceConditions(run, lb, timestamp=None, iovDbSvc=None)
Definition PostExec.py:31