ATLAS Offline Software
TileEMScaleConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to construct configured Tile EM scale"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 _validSources = ['COOL','FILE']
9 
10 def TileEMScaleCondAlgCfg(flags, **kwargs):
11  """Return component accumulator with configured Tile EM scale conditions algorithm
12 
13  Arguments:
14  flags -- Athena configuration flags
15  Keyword arguments:
16  Source -- source of EM scale conditions (COOL, FILE). Defaults to COOL.
17  TileEMScale -- name of Tile EM scale conditions object. Defaults to TileEMScale.
18  """
19 
20  acc = ComponentAccumulator()
21  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
22 
23  acc.merge( TileCablingSvcCfg(flags) )
24 
25  source = kwargs.get('Source', 'COOL')
26  emScale = kwargs.get('TileEMScale', 'TileEMScale')
27 
28  if source not in _validSources:
29  raise(Exception("Invalid source: %s" % source))
30 
31  name = emScale + 'CondAlg'
32  onlCacheUnit = "Invalid"
33 
34  if source == 'COOL':
35  # Connect COOL Tile conditions proxies to the tool
36  from TileConditions.TileFolders import TileFolders
37  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
38 
39  if not flags.Input.isMC:
40  onlCacheUnit = 'OnlineMegaElectronVolts'
41 
42  oflLasLinFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/LAS/LIN', '/TILE/OFL02/CALIB/LAS/LIN')
43  oflCesFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/CES', '/TILE/OFL02/CALIB/CES')
44  oflEmsFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/EMS', '/TILE/OFL02/CALIB/EMS')
45 
46  onlCisLinFolder = folders.addSplitMC('/TILE/ONL01/CALIB/CIS/LIN', '/TILE/OFL02/CALIB/CIS/FIT/LIN')
47  onlLasLinFolder = folders.addSplitMC('/TILE/ONL01/CALIB/LAS/LIN', '/TILE/OFL02/CALIB/LAS/LIN')
48  onlCesFolder = folders.addSplitMC('/TILE/ONL01/CALIB/CES', '/TILE/OFL02/CALIB/CES')
49  onlEmsFolder = folders.addSplitMC('/TILE/ONL01/CALIB/EMS', '/TILE/OFL02/CALIB/EMS')
50 
51 
52  if flags.IOVDb.DatabaseInstance == 'CONDBR2':
53  oflCisLinFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/CIS/LIN', '/TILE/OFL02/CALIB/CIS/LIN')
54  oflCisNlnFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/CIS/NLN', '/TILE/OFL02/CALIB/CIS/NLN')
55  oflLasNlnFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/LAS/NLN', '/TILE/OFL02/CALIB/LAS/NLN')
56  if not flags.Common.isOnline:
57  oflLasFibFolder = folders.add('/TILE/OFL02/CALIB/LAS/FIBER', 'TILE_OFL')
58  else:
59  oflLasFibFolder = None
60  else:
61  oflCisLinFolder = folders.addSplitOnline('/TILE/ONL01/CALIB/CIS/LIN', '/TILE/OFL02/CALIB/CIS/FIT/LIN')
62  oflCisNlnFolder = folders.addSplitOnline('/TILE/OFL01/CALIB/CIS/FIT/NLN', '/TILE/OFL02/CALIB/CIS/FIT/NLN')
63  oflLasNlnFolder = folders.addSplitOnline('/TILE/OFL01/CALIB/LAS/NLN', '/TILE/OFL02/CALIB/LAS/NLN')
64  oflLasFibFolder = folders.addSplitOnline('/TILE/OFL01/CALIB/LAS/FIBER', '/TILE/OFL02/CALIB/LAS/FIBER')
65 
66  from IOVDbSvc.IOVDbSvcConfig import addFolderList
67  acc.merge( addFolderList(flags, folders.get()) )
68 
69  TileCondProxyCoolFlt = CompFactory.getComp("TileCondProxyCool<TileCalibDrawerFlt>")
70  if not oflLasFibFolder:
71  oflLasFibProxy = None
72  else:
73  oflLasFibProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflLasFib', Source = oflLasFibFolder)
74  oflCisLinProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflCisLin', Source = oflCisLinFolder)
75  oflCisNlnProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflCisNln', Source = oflCisNlnFolder)
76  oflLasLinProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflLasLin', Source = oflLasLinFolder)
77  oflLasNlnProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflLasNln', Source = oflLasNlnFolder)
78  oflCesProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflCes', Source = oflCesFolder)
79  oflEmsProxy = TileCondProxyCoolFlt('TileCondProxyCool_OflEms', Source = oflEmsFolder)
80  onlCisProxy = TileCondProxyCoolFlt('TileCondProxyCool_OnlCis', Source = onlCisLinFolder)
81  onlLasProxy = TileCondProxyCoolFlt('TileCondProxyCool_OnlLas', Source = onlLasLinFolder)
82  onlCesProxy = TileCondProxyCoolFlt('TileCondProxyCool_OnlCes', Source = onlCesFolder)
83  onlEmsProxy = TileCondProxyCoolFlt('TileCondProxyCool_OnlEms', Source = onlEmsFolder)
84 
85  else:
86  # Connect FILE Tile conditions proxies to the tool
87  # Undoing "online" calibrations makes no sense here and is disabled
88  TileCondProxyFileFlt = CompFactory.getComp("TileCondProxyFile<TileCalibDrawerFlt>")
89  oflCisLinProxy = TileCondProxyFileFlt('TileCondProxyFile_OflCisLin', Source = 'TileDefault.cisFitLin')
90  oflCisNlnProxy = TileCondProxyFileFlt('TileCondProxyFile_OflCisNln', Source = 'TileDefault.cisFitNln')
91  oflLasLinProxy = TileCondProxyFileFlt('TileCondProxyFile_OflLasLin', Source = 'TileDefault.lasLin')
92  oflLasNlnProxy = TileCondProxyFileFlt('TileCondProxyFile_OflLasNln', Source = 'TileDefault.lasNln')
93  oflLasFibProxy = TileCondProxyFileFlt('TileCondProxyFile_OflLasFib', Source = 'TileDefault.lasFib')
94  oflCesProxy = TileCondProxyFileFlt('TileCondProxyFile_OflCes', Source = 'TileDefault.ces')
95  oflEmsProxy = TileCondProxyFileFlt('TileCondProxyFile_OflEms', Source = 'TileDefault.ems')
96  onlCisProxy = TileCondProxyFileFlt('TileCondProxyFile_OflCisLin', Source = 'TileDefault.cisFitLin')
97  onlLasProxy = TileCondProxyFileFlt('TileCondProxyFile_OflLasLin', Source = 'TileDefault.lasLin')
98  onlCesProxy = TileCondProxyFileFlt('TileCondProxyFile_OflCes', Source = 'TileDefault.ces')
99  onlEmsProxy = TileCondProxyFileFlt('TileCondProxyFile_OflEms', Source = 'TileDefault.ems')
100 
101 
102  TileEMScaleCondAlg=CompFactory.TileEMScaleCondAlg
103  emScaleCondAlg = TileEMScaleCondAlg(name = name,
104  OnlCacheUnit = onlCacheUnit,
105  OflCisLinProxy = oflCisLinProxy,
106  OflCisNlnProxy = oflCisNlnProxy,
107  OflLasLinProxy = oflLasLinProxy,
108  OflLasNlnProxy = oflLasNlnProxy,
109  OflLasFibProxy = oflLasFibProxy,
110  OflCesProxy = oflCesProxy,
111  OflEmsProxy = oflEmsProxy,
112  OnlCisProxy = onlCisProxy,
113  OnlLasProxy = onlLasProxy,
114  OnlCesProxy = onlCesProxy,
115  OnlEmsProxy = onlEmsProxy,
116  TileEMScale = emScale)
117 
118 
119 
120  acc.addCondAlgo(emScaleCondAlg)
121 
122  return acc
123 
124 
125 def TileCondToolEmscaleCfg(flags, **kwargs):
126  """Return component accumulator with configured private Tile EM scale tool
127 
128  Arguments:
129  flags -- Athena configuration flags
130  Keyword arguments:
131  Source -- source of EM scale conditions (COOL, FILE). Defaults to COOL.
132  TileEMScale -- name of Tile EM scale conditions object. Defaults to TileEMScale.
133  """
134 
135  acc = ComponentAccumulator()
136 
137  kwargs.setdefault('Source', 'COOL')
138  kwargs.setdefault('TileEMScale', 'TileEMScale')
139 
140  source = kwargs['Source']
141  if source not in _validSources:
142  raise(Exception("Invalid source: %s" % source))
143 
144  emScale = kwargs['TileEMScale']
145  name = 'TileCondToolEmscale'
146 
147  acc.merge( TileEMScaleCondAlgCfg(flags, **kwargs) )
148 
149  TileCondToolEmscale=CompFactory.TileCondToolEmscale
150  acc.setPrivateTools( TileCondToolEmscale(name, TileEMScale = emScale) )
151 
152  return acc
153 
154 
155 def TileExpertToolEmscaleCfg(flags, **kwargs):
156  """Return component accumulator with configured private Tile expert EM scale tool
157 
158  Arguments:
159  flags -- Athena configuration flags
160  Keyword arguments:
161  Source -- source of EM scale conditions (COOL, FILE). Defaults to COOL.
162  TileEMScale -- name of Tile EM scale conditions object. Defaults to TileEMScale.
163  """
164 
165  acc = ComponentAccumulator()
166 
167  kwargs.setdefault('Source', 'COOL')
168  kwargs.setdefault('TileEMScale', 'TileEMScale')
169 
170  source = kwargs['Source']
171  if source not in _validSources:
172  raise(Exception("Invalid source: %s" % source))
173 
174  emScale = kwargs['TileEMScale']
175  name = 'TileExpertToolEmscale'
176 
177  acc.merge( TileEMScaleCondAlgCfg(flags, **kwargs) )
178 
179  TileExpertToolEmscale=CompFactory.TileExpertToolEmscale
180  acc.setPrivateTools( TileExpertToolEmscale(name, TileEMScale = emScale) )
181 
182  return acc
183 
184 
185 if __name__ == "__main__":
186 
187  from AthenaConfiguration.AllConfigFlags import initConfigFlags
188  from AthenaConfiguration.TestDefaults import defaultTestFiles
189  from AthenaCommon.Logging import log
190  from AthenaCommon.Constants import DEBUG
191 
192  # test setup
193  log.setLevel(DEBUG)
194 
195  flags = initConfigFlags()
196  flags.Input.Files = defaultTestFiles.RAW_RUN2
197  flags.lock()
198 
200 
201  emScaleTool = acc.popToolsAndMerge( TileCondToolEmscaleCfg(flags) )
202  print(emScaleTool)
203 
204  emScaleExpertTool = acc.popToolsAndMerge( TileExpertToolEmscaleCfg(flags) )
205  print(emScaleExpertTool)
206 
207  acc.printConfig(withDetails = True, summariseProps = True)
208  print(acc.getService('IOVDbSvc'))
209  acc.store( open('TileEMScale.pkl','wb') )
210 
211  print('All OK')
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
TileCondProxyFile
The tool to get Tile conditions data from file.
Definition: TileCondProxyFile.h:28
Constants
some useful constants -------------------------------------------------—
python.TileEMScaleConfig.TileExpertToolEmscaleCfg
def TileExpertToolEmscaleCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:155
TileEMScaleCondAlg
Condition algorithm to produce TileEMScale and put it into condition store.
Definition: TileEMScaleCondAlg.h:25
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
python.TileEMScaleConfig.TileCondToolEmscaleCfg
def TileCondToolEmscaleCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:125
TileCondToolEmscale
Calibration of TileCal channels and access to calibration factors.
Definition: TileCondToolEmscale.h:58
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
TileExpertToolEmscale
(For experts only) Calibration of TileCal channels and access to calibration factors.
Definition: TileExpertToolEmscale.h:26
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11