ATLAS Offline Software
TileTMDBConfig.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 Tile TMDB conditions tool and algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from TileConfiguration.TileConfigFlags import TileRunType
8 
9 def TileTMDBCondAlgCfg(flags, **kwargs):
10  """Return component accumulator with configured Tile TMDB conditions algorithms
11 
12  Arguments:
13  flags -- Athena configuration flags
14  Keyword arguments:
15  Source -- source of Tile TMDB conditions (COOL, FILE). Defaults to COOL.
16  TileTMDBThreshold -- name of Tile TMDB threshold conditions object. Defaults to TileTMDBThreshold.
17  TileTMDBDelay -- name of Tile TMDB dealy conditions object. Defaults to TileTMDBDelay.
18  TileTMDBTMF -- name of Tile TMDB TMF conditions object. Defaults to TileTMDBTMF.
19  TileTMDBCalib -- name of Tile TMDB calibration conditions object. Defaults to TileTMDBCalib.
20  """
21 
22  acc = ComponentAccumulator()
23 
24  source = kwargs.get('Source', 'COOL')
25  threshod = kwargs.get('TileTMDBThreshold', 'TileTMDBThreshold')
26  delay = kwargs.get('TileTMDBDelay', 'TileTMDBDelay')
27  tmf = kwargs.get('TileTMDBTMF', 'TileTMDBTMF')
28  calib = kwargs.get('TileTMDBCalib', 'TileTMDBCalib')
29 
30  TileCalibFltCondAlg=CompFactory.getComp("TileCalibCondAlg<TileCalibDrawerFlt>")
31  def __addCondAlg(calibData, proxy):
32  condAlg = TileCalibFltCondAlg( name = calibData + 'CondAlg',
33  ConditionsProxy = proxy,
34  TileCalibData = calibData)
35  acc.addCondAlgo(condAlg)
36 
37  if source == 'COOL':
38  # Connect COOL Tile conditions proxies to the algorithm (default)
39 
40  from TileConditions.TileFolders import TileFolders
41  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
42 
43  runType = flags.Tile.RunType
44  run = runType.getCommonType().value
45 
46  if flags.IOVDb.DatabaseInstance == 'CONDBR2':
47  thrFolder = folders.addSplitMC('/TILE/ONL01/TMDB/THRESHOLD/' + run, '/TILE/ONL01/TMDB/THRESHOLD/' + run)
48  delayFolder = folders.addSplitMC('/TILE/ONL01/TMDB/DELAY/' + run, '/TILE/ONL01/TMDB/DELAY/' + run)
49  tmfFolder = folders.addSplitMC('/TILE/ONL01/TMDB/TMF/' + run, '/TILE/ONL01/TMDB/TMF/' + run)
50  calibFolder = folders.addSplitMC('/TILE/ONL01/TMDB/CALIB/' + run, '/TILE/ONL01/TMDB/CALIB/' + run)
51  else:
52  raise(Exception("No Tile TMDB folders in %s" % flags.IOVDb.DatabaseInstancea))
53 
54  TileCondProxyCoolFlt=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerFlt>")
55  thrProxy = TileCondProxyCoolFlt('TileCondProxyCool_TMDBThreshold', Source = thrFolder)
56  delayProxy = TileCondProxyCoolFlt('TileCondProxyCool_TMDBDelay', Source = delayFolder)
57  tmfProxy = TileCondProxyCoolFlt('TileCondProxyCool_TMDBTmf', Source = tmfFolder)
58  calibProxy = TileCondProxyCoolFlt('TileCondProxyCool_TMDBCalib', Source = calibFolder)
59 
60  from IOVDbSvc.IOVDbSvcConfig import addFolderList
61  acc.merge( addFolderList(flags, folders.get()) )
62 
63  else:
64  # Connect FILE Tile conditions proxies to the algorithm
65  raise(Exception("Not implemented source %s" % source))
66 
67 
68  __addCondAlg(threshod, thrProxy)
69  __addCondAlg(delay, delayProxy)
70  __addCondAlg(tmf, tmfProxy)
71  __addCondAlg(calib, calibProxy)
72 
73  return acc
74 
75 
76 def TileCondToolTMDBCfg(flags, **kwargs):
77  """Return component accumulator with configured private Tile TMDB conditions tool
78 
79  Arguments:
80  flags -- Athena configuration flags
81  Keyword arguments:
82  Source -- source of Tile TMDB conditions (COOL, FILE). Defaults to COOL.
83  TileTMDBThreshold -- name of Tile TMDB threshold conditions object. Defaults to TileTMDBThreshold.
84  TileTMDBDelay -- name of Tile TMDB dealy conditions object. Defaults to TileTMDBDelay.
85  TileTMDBTMF -- name of Tile TMDB TMF conditions object. Defaults to TileTMDBTMF.
86  TileTMDBCalib -- name of Tile TMDB calibration conditions object. Defaults to TileTMDBCalib.
87  """
88 
89  acc = ComponentAccumulator()
90 
91  kwargs.setdefault('Source', 'COOL')
92  kwargs.setdefault('TileTMDBThreshold', 'TileTMDBThreshold')
93  kwargs.setdefault('TileTMDBDelay', 'TileTMDBDelay')
94  kwargs.setdefault('TileTMDBTMF', 'TileTMDBTMF')
95  kwargs.setdefault('TileTMDBCalib', 'TileTMDBCalib')
96 
97  threshod = kwargs['TileTMDBThreshold']
98  delay = kwargs['TileTMDBDelay']
99  tmf = kwargs['TileTMDBTMF']
100  calib = kwargs['TileTMDBCalib']
101 
102  acc.merge( TileTMDBCondAlgCfg(flags, **kwargs) )
103 
104  TileCondToolTMDB=CompFactory.TileCondToolTMDB
105  acc.setPrivateTools( TileCondToolTMDB(TileTMDBThreshold = threshod,
106  TileTMDBDelay = delay,
107  TileTMDBTMF = tmf,
108  TileTMDBCalib = calib) )
109 
110  return acc
111 
112 
113 if __name__ == "__main__":
114 
115  from AthenaConfiguration.AllConfigFlags import initConfigFlags
116  from AthenaConfiguration.TestDefaults import defaultTestFiles
117  from AthenaCommon.Logging import log
118  from AthenaCommon.Constants import DEBUG
119 
120  # Test setup
121  log.setLevel(DEBUG)
122 
123  flags = initConfigFlags()
124  flags.Input.Files = defaultTestFiles.RAW_RUN2
125  flags.Tile.RunType = TileRunType.PHY
126  flags.lock()
127 
129 
130  tmdbTool = acc.popToolsAndMerge( TileCondToolTMDBCfg(flags) )
131  print(tmdbTool)
132 
133  acc.printConfig(withDetails = True, summariseProps = True)
134  print(acc.getService('IOVDbSvc'))
135  acc.store( open('TileTMDB.pkl','wb') )
136 
137  print('All OK')
138 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:90
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
python.TileTMDBConfig.TileCondToolTMDBCfg
def TileCondToolTMDBCfg(flags, **kwargs)
Definition: TileTMDBConfig.py:76
Constants
some useful constants -------------------------------------------------—
Trk::open
@ open
Definition: BinningType.h:40
python.TileTMDBConfig.TileTMDBCondAlgCfg
def TileTMDBCondAlgCfg(flags, **kwargs)
Definition: TileTMDBConfig.py:9
TileCalibCondAlg
Condition algorithm to prepare TileCalibData object and put it into condition store.
Definition: TileCalibCondAlg.h:24
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
TileCondToolTMDB
Definition: TileCondToolTMDB.h:16