ATLAS Offline Software
TileTimingConfig.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 timing 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 TileTimingCondAlgCfg(flags, **kwargs):
10  """Return component accumulator with configured Tile timing conditions algorithm
11 
12  Arguments:
13  flags -- Athena configuration flags
14  Keyword arguments:
15  Source -- source of Tile timing conditions (COOL, FILE). Defaults to COOL.
16  TileTiming -- name of Tile timing conditions object. Defaults to TileTiming.
17  ForceOnline -- flag to use online timing in offline. Defaults to False.
18  """
19 
20  acc = ComponentAccumulator()
21 
22  source = kwargs.get('Source', 'COOL')
23  timing = kwargs.get('TileTiming', 'TileTiming')
24  forceOnline = kwargs.get('ForceOnline', False)
25 
26  runType = flags.Tile.RunType
27  timingType = runType.getTimingType().value
28 
29  name = timing + 'CondAlg'
30 
31  if source == 'COOL':
32  # Connect COOL Tile conditions proxies to the algorithm (default)
33 
34  from TileConditions.TileFolders import TileFolders
35  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
36 
37  if flags.IOVDb.DatabaseInstance == 'CONDBR2':
38  onlineTimingFolder = '/TILE/ONL01/TIME/CHANNELOFFSET/' + timingType
39  else:
40  if timingType == 'GAP/LAS':
41  raise(Exception("No Tile GAP/LAS timing in DB: %s" % flags.IOVDb.DatabaseInstance))
42 
43  onlineTimingFolder = '/TILE/OFL01/TIME/CHANNELOFFSET/' + timingType
44 
45  if forceOnline:
46  timingFolder = folders.add(onlineTimingFolder, 'TILE')
47  else:
48  timingFolder = folders.addSplitOnline(onlineTimingFolder, '/TILE/OFL02/TIME/CHANNELOFFSET/' + timingType)
49 
50  TileCondProxyCoolFlt=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerFlt>")
51  timingProxy = TileCondProxyCoolFlt('TileCondProxyCool_AdcOffset', Source = timingFolder)
52 
53  from IOVDbSvc.IOVDbSvcConfig import addFolderList
54  acc.merge( addFolderList(flags, folders.get()) )
55 
56  elif source == 'FILE':
57  # Connect FILE Tile conditions proxies to the algorithm
58  fileExtention = {'PHY' : 'tcphy', 'LAS' : 'tclas', 'CIS' : 'tccis'}
59 
60  TileCondProxyFileFlt=CompFactory.getComp("TileCondProxyFile<TileCalibDrawerFlt>")
61  timingProxy = TileCondProxyFileFlt('TileCondProxyFile_AdcOffset',
62  Source = 'TileDefault.' + fileExtention[timingType])
63  else:
64  raise(Exception("Invalid source: %s" % source))
65 
66  TileTimingCondAlg = CompFactory.getComp("TileCondAlg<TileTiming,TileCalibDrawerFlt>")
67  timingCondAlg = TileTimingCondAlg( name = name,
68  ConditionsProxy = timingProxy,
69  TileCondData = timing)
70 
71  acc.addCondAlgo(timingCondAlg)
72 
73  return acc
74 
75 
76 
77 def TileCondToolTimingCfg(flags, **kwargs):
78  """Return component accumulator with configured private Tile timing conditions tool
79 
80  Arguments:
81  flags -- Athena configuration flags
82  Keyword arguments:
83  Source -- source of Tile timing conditions (COOL, FILE). Defaults to COOL.
84  TileTiming -- name of Tile timing conditions object. Defaults to TileTiming (TileOnlineTiming if ForceOnline).
85  TimingType -- type of Tile timing. Defaults to run type (PED->PHY, BILAS->LAS, MONOCIS->CIS).
86  Possible Tile timing types: PHY, LAS, GAP/LAS, CIS.
87  ForceOnline -- flag to use online timing in offline. Defaults to False.
88  """
89 
90  acc = ComponentAccumulator()
91 
92  kwargs.setdefault('Source', 'COOL')
93  kwargs.setdefault('ForceOnline', False)
94 
95  forceOnline = kwargs['ForceOnline']
96  kwargs.setdefault('TileTiming', 'TileOnlineTiming' if forceOnline else 'TileTiming')
97 
98  timing = kwargs['TileTiming']
99 
100  name = 'TileCondToolTiming'
101 
102  acc.merge( TileTimingCondAlgCfg(flags, **kwargs) )
103 
104  TileCondToolTiming=CompFactory.TileCondToolTiming
105  acc.setPrivateTools( TileCondToolTiming(name, TileTiming = timing) )
106 
107  return acc
108 
109 
110 
111 def TileCondToolOnlineTimingCfg(flags, **kwargs):
112  return TileCondToolTimingCfg(flags, ForceOnline = True)
113 
114 if __name__ == "__main__":
115 
116  from AthenaConfiguration.AllConfigFlags import initConfigFlags
117  from AthenaConfiguration.TestDefaults import defaultTestFiles
118  from AthenaCommon.Logging import log
119  from AthenaCommon.Constants import DEBUG
120 
121  # Test setup
122  log.setLevel(DEBUG)
123 
124  flags = initConfigFlags()
125  flags.Input.Files = defaultTestFiles.RAW_RUN2
126  flags.Tile.RunType = TileRunType.PHY
127  flags.lock()
128 
130 
131  timingTool = acc.popToolsAndMerge( TileCondToolTimingCfg(flags) )
132  print(timingTool)
133 
134  onlineTimingTool = acc.popToolsAndMerge( TileCondToolOnlineTimingCfg(flags) )
135  print(onlineTimingTool)
136 
137  acc.printConfig(withDetails = True, summariseProps = True)
138  print(acc.getService('IOVDbSvc'))
139  acc.store( open('TileTiming.pkl','wb') )
140 
141  print('All OK')
142 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:90
python.TileTimingConfig.TileTimingCondAlgCfg
def TileTimingCondAlgCfg(flags, **kwargs)
Definition: TileTimingConfig.py:9
TileCondAlg
Condition algorithm to prepare Tile conditions object and put it into conditions store.
Definition: TileCondAlg.h:21
python.TileTimingConfig.TileCondToolTimingCfg
def TileCondToolTimingCfg(flags, **kwargs)
Definition: TileTimingConfig.py:77
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
python.TileTimingConfig.TileCondToolOnlineTimingCfg
def TileCondToolOnlineTimingCfg(flags, **kwargs)
Definition: TileTimingConfig.py:111
TileCondProxyFile
The tool to get Tile conditions data from file.
Definition: TileCondProxyFile.h:28
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileCondToolTiming
Definition: TileCondToolTiming.h:18