ATLAS Offline Software
TileOFCConfig.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 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  runSplitOnline = 314449 #Use OFC stored in online folder for all runs before 2017
44  if flags.IOVDb.DatabaseInstance == 'CONDBR2' and runType is TileRunType.PHY and runNumber > runSplitOnline:
45  ofcFolder = folders.addSplitOnline('/TILE/ONL01/FILTER/' + ofcType, '/TILE/OFL02/FILTER/' + ofcType)
46  else:
47  ofcFolder = folders.addSplitMC('/TILE/ONL01/FILTER/' + ofcType, '/TILE/ONL01/FILTER/' + ofcType)
48 
49  TileCondProxyCoolOfc=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerOfc>")
50  ofcProxy = TileCondProxyCoolOfc('TileCondProxyCool_Ofc', Source = ofcFolder)
51 
52  from IOVDbSvc.IOVDbSvcConfig import addFolderList
53  acc.merge( addFolderList(flags, folders.get()) )
54 
55  else:
56  raise(Exception("Invalid source: %s" % source))
57 
58  TileCalibOfcCondAlg=CompFactory.getComp("TileCalibCondAlg<TileCalibDrawerOfc>")
59  ofcCondAlg = TileCalibOfcCondAlg( name = name, ConditionsProxy = ofcProxy, TileCalibData = ofc)
60 
61  acc.addCondAlgo(ofcCondAlg)
62 
63  return acc
64 
65 
66 def TileCondToolOfcCoolCfg(flags, **kwargs):
67  """Return component accumulator with configured Tile OFC conditions algorithm
68 
69  Arguments:
70  flags -- Athena configuration flags
71  Keyword arguments:
72  Source -- source of Tile OFC conditions (COOL, FILE). Defaults to COOL.
73  TileOfc -- name of Tile OFC conditions. Defaults to TileOfc + OfcType (capitalized).
74  OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2.
75  """
76 
77  acc = ComponentAccumulator()
78 
79  kwargs.setdefault('Source', 'COOL')
80  kwargs.setdefault('OfcType', 'OF2')
81 
82  ofcType = kwargs['OfcType']
83  ofc = 'TileOfc' + ofcType.capitalize()
84 
85  kwargs.setdefault('TileOfc', ofc)
86 
87  ofc = kwargs['TileOfc']
88  name = 'TileCondToolOfcCool'
89 
90  acc.merge( TileOFCCondAlgCfg(flags, **kwargs) )
91 
92  TileCondToolOfcCool=CompFactory.TileCondToolOfcCool
93  acc.setPrivateTools( TileCondToolOfcCool(name, TileOfc = ofc) )
94 
95  return acc
96 
97 
98 def TileCondToolOfcCfg(flags, **kwargs):
99  """Return component accumulator with configured Tile OFC conditions algorithm
100 
101  Arguments:
102  flags -- Athena configuration flags
103  Keyword arguments:
104  OfcType -- type of Tile OFC. Defaults to OF2. Possible OFC types: OF1, OF2.
105  OptFilterDeltaCorrelation -- flag to use delta correlation. Defaults to False.
106  If it is False auto correlation obtained from data will be used.
107  TileCondToolPulseShape - Tile conditions tool to get pulse shape.
108  Provided it will be used. By default new one will be configured.
109  TileCondToolAutoCr - Tile conditions tool to get auto correlation.
110  Provided it will be used. By default new one will be configured.
111  """
112 
113  acc = ComponentAccumulator()
114 
115  optFilterDeltaCorrelation = kwargs.get('OptFilterDeltaCorrelation', False)
116 
117  from TileConditions.TileInfoLoaderConfig import TileInfoLoaderCfg
118  acc.merge( TileInfoLoaderCfg(flags) )
119 
120  if 'TileCondToolPulseShape' in kwargs:
121  pulseShapeTool = kwargs['TileCondToolPulseShape']
122  else:
123  from TileConditions.TilePulseShapeConfig import TileCondToolPulseShapeCfg
124  pulseShapeTool = acc.popToolsAndMerge( TileCondToolPulseShapeCfg(flags) )
125 
126  if optFilterDeltaCorrelation:
127  autoCorrelationTool = None
128  else:
129  if 'TileCondToolAutoCr' in kwargs:
130  autoCorrelationTool = kwargs['TileCondToolAutoCr']
131  else:
132  from TileConditions.TileAutoCorrelationConfig import TileCondToolAutoCrCfg
133  autoCorrelationTool = acc.popToolsAndMerge( TileCondToolAutoCrCfg(flags) )
134 
135  name = 'TileCondToolOfc'
136  TileCondToolOfc=CompFactory.TileCondToolOfc
137  acc.setPrivateTools( TileCondToolOfc(name,
138  OptFilterDeltaCorrelation = optFilterDeltaCorrelation,
139  TileCondToolPulseShape = pulseShapeTool,
140  TileCondToolAutoCr = autoCorrelationTool) )
141 
142  return acc
143 
144 
145 
146 if __name__ == "__main__":
147 
148  from AthenaConfiguration.AllConfigFlags import initConfigFlags
149  from AthenaConfiguration.TestDefaults import defaultTestFiles
150  from AthenaCommon.Logging import log
151  from AthenaCommon.Constants import DEBUG
152 
153  # Test setup
154  log.setLevel(DEBUG)
155 
156  flags = initConfigFlags()
157  flags.Input.Files = defaultTestFiles.RAW_RUN2
158  flags.Tile.RunType = TileRunType.PHY
159  flags.lock()
160 
162 
163  ofcCoolTool = acc.popToolsAndMerge( TileCondToolOfcCoolCfg(flags) )
164  print(ofcCoolTool)
165 
166  ofcTool = acc.popToolsAndMerge( TileCondToolOfcCfg(flags) )
167  print(ofcTool)
168 
169  acc.printConfig(withDetails = True, summariseProps = True)
170  print(acc.getService('IOVDbSvc'))
171  acc.store( open('TileOFC.pkl','wb') )
172 
173  print('All OK')
174 
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:90
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:66
python.TileInfoLoaderConfig.TileInfoLoaderCfg
def TileInfoLoaderCfg(flags, **kwargs)
Definition: TileInfoLoaderConfig.py:12
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 -------------------------------------------------—
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
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.TileOFCConfig.TileCondToolOfcCfg
def TileCondToolOfcCfg(flags, **kwargs)
Definition: TileOFCConfig.py:98