ATLAS Offline Software
TileHid2RESrcIDConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to construct configured TileHid2ReSrcIDCondAlg conditions algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from IOVDbSvc.IOVDbSvcConfig import addFolders
8 
9 def TileHid2RESrcIDCondAlg(ForHLT=False, **kwargs):
10  """Configure TileHid2ReSrcIDCondAlg conditions algorithm"""
11 
12  hid2RESrcID = 'TileHid2RESrcIDHLT' if ForHLT else 'TileHid2RESrcID'
13  hid2RESrcIDCondAlg = f'{hid2RESrcID}CondAlg'
14  from AthenaCommon.AlgSequence import AthSequencer
15  condSequence = AthSequencer("AthCondSeq")
16  if hasattr(condSequence, hid2RESrcIDCondAlg):
17  return #Already there....
18 
19  from TileByteStream.TileByteStreamConf import TileHid2RESrcIDCondAlg
20  condSequence += TileHid2RESrcIDCondAlg(name=hid2RESrcIDCondAlg, ForHLT=ForHLT, TileHid2RESrcID=hid2RESrcID, **kwargs)
21  return
22 
23 
24 def TileHid2RESrcIDCondAlgCfg(flags, source='COOL', **kwargs):
25  """Return component accumulator with configured TileHid2ReSrcIDCondAlg conditions algorithm"""
26 
27  forHLT = kwargs.get('ForHLT', False)
28  hid2RESrcID = 'TileHid2RESrcIDHLT' if forHLT else 'TileHid2RESrcID'
29  kwargs.setdefault('TileHid2RESrcID', hid2RESrcID)
30  kwargs.setdefault('name', f'{hid2RESrcID}CondAlg')
31 
32  acc = ComponentAccumulator()
33 
34  from TileGeoModel.TileGMConfig import TileGMCfg
35  acc.merge( TileGMCfg(flags) )
36 
37  if source == 'COOL':
38  rodFolder = None
39  # Connect COOL Tile conditions proxies to the tool
40  if flags.IOVDb.DatabaseInstance == 'COMP200':
41  # In the COMP200 DB there is no conditions with ROD status
42  kwargs['FullTileMode'] = 1 # Configure predifined mapping for Run1
43  elif flags.Input.isMC:
44  rodFolder = '/TILE/OFL02/STATUS/ROD'
45  # Temporary tag is hardcoded until it is connected to the global tags
46  acc.merge(addFolders(flags, rodFolder, 'TILE_OFL', tag='TileOfl02StatusRod-RUN3-00', className='CondAttrListCollection'))
47  else:
48  rodFolder = '/TILE/ONL01/STATUS/ROD'
49  acc.merge(addFolders(flags, rodFolder, 'TILE', className='CondAttrListCollection'))
50 
51  if rodFolder:
52  TileCondProxyCoolInt = CompFactory.getComp("TileCondProxyCool<TileCalibDrawerInt>")
53  rodStatusProxy = TileCondProxyCoolInt('TileCondProxyCool_ROD', Source=rodFolder)
54  kwargs['RODStatusProxy'] = rodStatusProxy
55 
56  elif source == 'FILE':
57  TileCondProxyFileInt = CompFactory.getComp("TileCondProxyFile<TileCalibDrawerInt>")
58  rodStatusProxy = TileCondProxyFileInt('TileCondProxyFile_ROD', Source='TileDefault.fullrod')
59  kwargs['RODStatusProxy'] = rodStatusProxy
60 
61  TileHid2ReSrcIDCondAlg = CompFactory.TileHid2RESrcIDCondAlg
62  acc.addCondAlgo( TileHid2ReSrcIDCondAlg(**kwargs) )
63 
64  return acc
65 
66 
67 
68 if __name__ == "__main__":
69 
70  from AthenaConfiguration.AllConfigFlags import initConfigFlags
71  from AthenaConfiguration.TestDefaults import defaultGeometryTags, defaultTestFiles
72  from AthenaCommon.Logging import log
73  from AthenaCommon.Constants import INFO
74 
75  # Test setup
76  log.setLevel(INFO)
77 
78  flags = initConfigFlags()
79  flags.Input.Files = defaultTestFiles.RAW_RUN2
80  flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN2
81  flags.lock()
82 
83  # Initialize configuration object, add accumulator, merge, and run.
84  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
85  cfg = MainServicesCfg(flags)
86 
87  from ByteStreamCnvSvc.ByteStreamConfig import ByteStreamReadCfg
88  cfg.merge( ByteStreamReadCfg(flags) )
89 
90  cfg.merge( TileHid2RESrcIDCondAlgCfg(flags, ForHLT=True) )
91 
92  cfg.printConfig(withDetails = True, summariseProps = True)
93  cfg.store( open('TileHid2ReSrcIDCondAlg.pkl','wb') )
94 
95  sc = cfg.run(3)
96 
97  import sys
98  # Success should be 0
99  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
AthSequencer
ClassName: AthSequencer.
Definition: AthSequencer.h:40
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
TileHid2RESrcIDCondAlg
Condition algorithm to prepare TileHid2RESrcID conditions object and put it into conditions store.
Definition: TileHid2RESrcIDCondAlg.h:27
TileCondProxyFile
The tool to get Tile conditions data from file.
Definition: TileCondProxyFile.h:28
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
Constants
some useful constants -------------------------------------------------—
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
TileHid2RESrcIDConfig.TileHid2RESrcIDCondAlg
def TileHid2RESrcIDCondAlg(ForHLT=False, **kwargs)
Definition: TileHid2RESrcIDConfig.py:9
TileHid2RESrcIDConfig.TileHid2RESrcIDCondAlgCfg
def TileHid2RESrcIDCondAlgCfg(flags, source='COOL', **kwargs)
Definition: TileHid2RESrcIDConfig.py:24
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7