ATLAS Offline Software
TileBadChannelsConfig.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 bad channels"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 _validSources = ['COOL','FILE']
9 
10 def TileBadChannelsCondAlgCfg(flags, **kwargs):
11  """Return component accumulator with configured Tile bad channels conditions algorithm
12 
13  Arguments:
14  flags: -- Athena configuration flags
15  Keyword arguments:
16  Source: -- source of Tile bad channels (COOL, FILE). Defaults to COOL.
17  TileBadChannels -- name of Tile bad channels object. Defaults to TileBadChannels.
18  """
19 
20  acc = ComponentAccumulator()
21 
22  source = kwargs.get('Source', 'COOL')
23  badChannels = kwargs.get('TileBadChannels', 'TileBadChannels')
24 
25  if source not in _validSources:
26  raise(Exception("Invalid source: %s" % source))
27 
28  name = badChannels + 'CondAlg'
29 
30  if source == 'COOL':
31  # Connect COOL Tile conditions proxies to the algorithm (default)
32 
33  from TileConditions.TileFolders import TileFolders
34  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
35 
36  TileCondProxyCoolBch=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerBch>")
37 
38  if flags.Tile.useOnlineChannelStatus:
39  onlineFolder = folders.addSplitMC('/TILE/ONL01/STATUS/ADC', '/TILE/ONL01/STATUS/ADC')
40  onlineBadChannelsProxy = TileCondProxyCoolBch('TileCondProxyCool_OnlBch', Source = onlineFolder)
41  else:
42  onlineBadChannelsProxy = None
43 
44  if flags.IOVDb.DatabaseInstance == 'CONDBR2':
45  if not flags.Common.isOnline:
46  oflineFolder = folders.add('/TILE/OFL02/STATUS/ADC', 'TILE_OFL')
47  offlineBadChannelsProxy = TileCondProxyCoolBch('TileCondProxyCool_OflBch', Source = oflineFolder)
48  else:
49  offlineBadChannelsProxy = None
50  else:
51  oflineFolder = folders.addSplitOnline('/TILE/OFL01/STATUS/ADC', '/TILE/OFL02/STATUS/ADC')
52  offlineBadChannelsProxy = TileCondProxyCoolBch('TileCondProxyCool_OflBch', Source = oflineFolder)
53 
54  from IOVDbSvc.IOVDbSvcConfig import addFolderList
55  acc.merge( addFolderList(flags, folders.get()) )
56 
57  else:
58  # Connect FILE Tile conditions proxies to the algorithm
59  TileCondProxyFileBch=CompFactory.getComp("TileCondProxyFile<TileCalibDrawerBch>")
60  if flags.Tile.useOnlineChannelStatus:
61  onlineBadChannelsProxy = TileCondProxyFileBch('TileCondProxyFile_OnlBch', Source = 'TileDefault.onlBch')
62  else:
63  onlineBadChannelsProxy = None
64  offlineBadChannelsProxy = TileCondProxyFileBch('TileCondProxyFile_OflBch', Source = 'TileDefault.oflBch')
65 
66 
67  TileCondIdTransforms=CompFactory.TileCondIdTransforms
68  TileBadChannelsCondAlg=CompFactory.TileBadChannelsCondAlg
69  badChannelsCondAlg = TileBadChannelsCondAlg( name = name,
70  OnlBchProxy = onlineBadChannelsProxy,
71  OflBchProxy = offlineBadChannelsProxy,
72  TileCondIdTransforms = TileCondIdTransforms(),
73  TileBadChannels = badChannels)
74 
75  acc.addCondAlgo(badChannelsCondAlg)
76 
77  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
78  acc.merge( TileCablingSvcCfg(flags) )
79 
80  return acc
81 
82 
83 def TileBadChanToolCfg(flags, **kwargs):
84  """Return component accumulator with configured private Tile bad channel tool
85  Arguments:
86  flags: -- Athena configuration flags
87  Keyword arguments:
88  Source: -- source of Tile bad channels (COOL, FILE). Defaults to COOL.
89  TileBadChannels -- name of Tile bad channels object. Defaults to TileBadChannels.
90  """
91 
92  acc = ComponentAccumulator()
93 
94  kwargs.setdefault('Source', 'COOL')
95  kwargs.setdefault('TileBadChannels', 'TileBadChannels')
96 
97  badChannels = kwargs['TileBadChannels']
98  name = 'TileBadChanTool'
99 
100  from TileGeoModel.TileGMConfig import TileGMCfg
101  acc.merge( TileGMCfg(flags) )
102 
103  from TileConditions.TileBadChannelsConfig import TileBadChannelsCondAlgCfg
104  acc.merge( TileBadChannelsCondAlgCfg(flags, **kwargs) )
105 
106  TileBadChanTool=CompFactory.TileBadChanTool
107  acc.setPrivateTools( TileBadChanTool(name, TileBadChannels = badChannels) )
108 
109  return acc
110 
111 
112 if __name__ == "__main__":
113 
114  from AthenaConfiguration.AllConfigFlags import initConfigFlags
115  from AthenaConfiguration.TestDefaults import defaultTestFiles
116  from AthenaCommon.Logging import log
117  from AthenaCommon.Constants import DEBUG
118 
119  # Test setup
120  log.setLevel(DEBUG)
121 
122  flags = initConfigFlags()
123  flags.Input.Files = defaultTestFiles.RAW_RUN2
124  flags.lock()
125 
127 
128  badChanTool = acc.popToolsAndMerge( TileBadChanToolCfg(flags) )
129  print(badChanTool)
130 
131  acc.printConfig(withDetails = True, summariseProps = True)
132  print(acc.getService('IOVDbSvc'))
133  acc.store( open('TileBadChannels.pkl','wb') )
134 
135  print('All OK')
TileCondIdTransforms
Definition: TileCondIdTransforms.h:16
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.IOVDbSvcConfig.addFolderList
def addFolderList(flags, listOfFolderInfoTuple, extensible=False, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:90
TileBadChannelsCondAlg
Condition algorithm to prepare TileBadChannels and put it into condition store.
Definition: TileBadChannelsCondAlg.h:31
TileCondProxyCool
The tool to get Tile conditions data from DB.
Definition: TileCondProxyCool.h:25
python.TileBadChannelsConfig.TileBadChanToolCfg
def TileBadChanToolCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:83
python.TileBadChannelsConfig.TileBadChannelsCondAlgCfg
def TileBadChannelsCondAlgCfg(flags, **kwargs)
Definition: TileBadChannelsConfig.py:10
TileCondProxyFile
The tool to get Tile conditions data from file.
Definition: TileCondProxyFile.h:28
Constants
some useful constants -------------------------------------------------—
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileBadChanTool
The tool to get Tile channel and ADC status.
Definition: TileBadChanTool.h:36
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7