ATLAS Offline Software
TileOFCConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 """Define methods to construct configured Tile OFC 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 TileOFCCondAlgCfg(flags, **kwargs):
10  """Return component accumulator with configured Tile OFC conditions algorithm
11 
12  Arguments:
13  flags -- Athena configuration flags
14  Keyword arguments:
15  Source -- source of Tile OFC conditions (COOL, FILE). Defaults to COOL.
16  TileOfc -- name of Tile OFC conditions object starts with. Defaults to TileOfc.
17  OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2.
18  """
19 
20  acc = ComponentAccumulator()
21 
22  runType = flags.Tile.RunType
23 
24  source = kwargs.get('Source', 'COOL')
25  ofc = kwargs.get('TileOfc', 'TileOfc')
26  ofcType = kwargs.get('OfcType', 'OF2')
27 
28  ofcType = ofcType.upper()
29  if ofcType not in ['OF1', 'OF2']:
30  raise(Exception("Invalid Tile OFC type: %s" % ofcType))
31 
32  name = ofc + 'CondAlg'
33 
34  if source == 'COOL':
35  # Connect COOL Tile conditions proxies to the algorithm (default)
36 
37  from TileConditions.TileFolders import TileFolders
38  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
39 
40  ofcType = ofcType + '/' + runType.getCommonType().value
41 
42  runNumber = flags.Input.RunNumbers[0]
43  runSplitMC = 470000 # Use OFC stored in OFL02 folder since this run for MC
44  runSplitOnline = 314449 #Use OFC stored in online folder for all runs before 2017
45  if flags.IOVDb.DatabaseInstance == 'CONDBR2' and runType.getCommonType() is TileRunType.PHY and runNumber > runSplitOnline:
46  ofcFolder = folders.addSplitOnline('/TILE/ONL01/FILTER/' + ofcType, '/TILE/OFL02/FILTER/' + ofcType)
47  elif runNumber >= runSplitMC:
48  ofcFolder = folders.addSplitMC('/TILE/ONL01/FILTER/' + ofcType, '/TILE/OFL02/FILTER/' + ofcType)
49  else:
50  ofcFolder = folders.addSplitMC('/TILE/ONL01/FILTER/' + ofcType, '/TILE/ONL01/FILTER/' + ofcType)
51 
52  TileCondProxyCoolOfc=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerOfc>")
53  ofcProxy = TileCondProxyCoolOfc('TileCondProxyCool_Ofc', Source = ofcFolder)
54 
55  from IOVDbSvc.IOVDbSvcConfig import addFolderList
56  acc.merge( addFolderList(flags, folders.get()) )
57 
58  else:
59  raise(Exception("Invalid source: %s" % source))
60 
61  TileCalibOfcCondAlg=CompFactory.getComp("TileCalibCondAlg<TileCalibDrawerOfc>")
62  ofcCondAlg = TileCalibOfcCondAlg( name = name, ConditionsProxy = ofcProxy, TileCalibData = ofc)
63 
64  acc.addCondAlgo(ofcCondAlg)
65 
66  return acc
67 
68 
69 def TileCondToolOfcCoolCfg(flags, **kwargs):
70  """Return component accumulator with configured Tile OFC conditions algorithm
71 
72  Arguments:
73  flags -- Athena configuration flags
74  Keyword arguments:
75  Source -- source of Tile OFC conditions (COOL, FILE). Defaults to COOL.
76  TileOfc -- name of Tile OFC conditions. Defaults to TileOfc + OfcType (capitalized).
77  OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2.
78  """
79 
80  acc = ComponentAccumulator()
81 
82  kwargs.setdefault('Source', 'COOL')
83  kwargs.setdefault('OfcType', 'OF2')
84 
85  ofcType = kwargs['OfcType']
86  ofc = 'TileOfc' + ofcType.capitalize()
87 
88  kwargs.setdefault('TileOfc', ofc)
89 
90  ofc = kwargs['TileOfc']
91  name = 'TileCondToolOfcCool'
92 
93  acc.merge( TileOFCCondAlgCfg(flags, **kwargs) )
94 
95  TileCondToolOfcCool=CompFactory.TileCondToolOfcCool
96  acc.setPrivateTools( TileCondToolOfcCool(name, TileOfc = ofc) )
97 
98  return acc
99 
100 
101 def TileCondToolOfcCfg(flags, **kwargs):
102  """Return component accumulator with configured Tile OFC conditions algorithm
103 
104  Arguments:
105  flags -- Athena configuration flags
106  Keyword arguments:
107  OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2.
108  OptFilterDeltaCorrelation -- flag to use delta correlation. Defaults to False.
109  If it is False auto correlation obtained from data will be used.
110  TileCondToolPulseShape - Tile conditions tool to get pulse shape.
111  Provided it will be used. By default new one will be configured.
112  TileCondToolAutoCr - Tile conditions tool to get auto correlation.
113  Provided it will be used. By default new one will be configured.
114  """
115 
116  acc = ComponentAccumulator()
117 
118  optFilterDeltaCorrelation = kwargs.get('OptFilterDeltaCorrelation', False)
119 
120  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
121  acc.merge( TileInfoLoaderCfg(flags) )
122 
123  if 'TileCondToolPulseShape' in kwargs:
124  pulseShapeTool = kwargs['TileCondToolPulseShape']
125  else:
126  from TileConditions.TilePulseShapeConfig import TileCondToolPulseShapeCfg
127  pulseShapeTool = acc.popToolsAndMerge( TileCondToolPulseShapeCfg(flags) )
128 
129  if optFilterDeltaCorrelation:
130  autoCorrelationTool = None
131  else:
132  if 'TileCondToolAutoCr' in kwargs:
133  autoCorrelationTool = kwargs['TileCondToolAutoCr']
134  else:
135  from TileConditions.TileAutoCorrelationConfig import TileCondToolAutoCrCfg
136  autoCorrelationTool = acc.popToolsAndMerge( TileCondToolAutoCrCfg(flags) )
137 
138  name = 'TileCondToolOfc'
139  TileCondToolOfc=CompFactory.TileCondToolOfc
140  acc.setPrivateTools( TileCondToolOfc(name,
141  OptFilterDeltaCorrelation = optFilterDeltaCorrelation,
142  TileCondToolPulseShape = pulseShapeTool,
143  TileCondToolAutoCr = autoCorrelationTool) )
144 
145  return acc
146 
147 
148 
149 if __name__ == "__main__":
150 
151  from AthenaConfiguration.AllConfigFlags import initConfigFlags
152  from AthenaConfiguration.TestDefaults import defaultTestFiles
153  from AthenaCommon.Logging import log
154  from AthenaCommon.Constants import DEBUG
155 
156  # Test setup
157  log.setLevel(DEBUG)
158 
159  flags = initConfigFlags()
160  flags.Input.Files = defaultTestFiles.RAW_RUN2
161  flags.Tile.RunType = TileRunType.PHY
162  flags.lock()
163 
165 
166  ofcCoolTool = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags) )
167  print(ofcCoolTool)
168 
169  ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(flags) )
170  print(ofcTool)
171 
172  acc.printConfig(withDetails = True, summariseProps = True)
173  print(acc.getService('IOVDbSvc'))
174  acc.store( open('TileOFC.pkl','wb') )
175 
176  print('All OK')
177 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TileOFCConfig.TileOFCCondAlgCfg
def TileOFCCondAlgCfg(flags, **kwargs)
Definition: TileOFCConfig.py:9
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:104
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
TileCondToolOfc
Calculates OFCs on the fly using pulse shapes and A/C matrix from database.
Definition: TileCondToolOfc.h:40
python.TileOFCConfig.TileCondToolOfcCoolCfg
def TileCondToolOfcCoolCfg(flags, **kwargs)
Definition: TileOFCConfig.py:69
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:11
python.TileAutoCorrelationConfig.TileCondToolAutoCrCfg
def TileCondToolAutoCrCfg(flags, **kwargs)
Definition: TileAutoCorrelationConfig.py:63
python.TilePulseShapeConfig.TileCondToolPulseShapeCfg
def TileCondToolPulseShapeCfg(flags, **kwargs)
Definition: TilePulseShapeConfig.py:86
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
TileCondToolOfcCool
extracts OFCs from database
Definition: TileCondToolOfcCool.h:28
Trk::open
@ open
Definition: BinningType.h:40
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
python.TileOFCConfig.TileCondToolOfcCfg
def TileCondToolOfcCfg(flags, **kwargs)
Definition: TileOFCConfig.py:101