ATLAS Offline Software
TileDCSConfig.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 DCS tool and conditions algorithm"""
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 
8 def TileDCSCondAlgCfg(flags, **kwargs):
9  """Return component accumulator with configured Tile DCS conditions algorithm
10 
11  Arguments:
12  flags -- Athena configuration flags
13  Keyword arguments:
14  ReadHV -- Read Tile DCS HV folder from DB. Defaults True.
15  ReadHVSET -- Read Tile DCS HVSET folder from DB. Defaults to False.
16  ReadSTATES -- Read Tile DCS STATES folder from DB. Defaults to True.
17  TileDCS -- name of Tile DCS conditions object. Defaults to TileDCS.
18  """
19 
20  isMC = flags.Input.isMC
21  isOnline = flags.Common.isOnline
22 
23  if isOnline or isMC:
24  raise(Exception('No Tile DCS information in online [%s] or MC [%s]' % (isOnline, isMC)))
25 
26  acc = ComponentAccumulator()
27 
28  dcs = kwargs.get('TileDCS', 'TileDCS')
29  readHV = kwargs.get('ReadHV', True)
30  readHVSET = kwargs.get('ReadHVSET', False)
31  readSTATES = kwargs.get('ReadSTATES', True)
32 
33  name = dcs + 'CondAlg'
34 
35  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
36  acc.merge( TileCablingSvcCfg(flags) )
37 
38  if not readHVSET:
39  from TileConditions.TileEMScaleConfig import TileEMScaleCondAlgCfg
40  acc.merge( TileEMScaleCondAlgCfg(flags) )
41 
42  from TileConditions.TileFolders import TileFolders
43  folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
44 
45  db = 'DCS_OFL'
46  if readHV:
47  folders.add('/TILE/DCS/HV', db)
48  if readHVSET:
49  folders.add('/TILE/DCS/HVSET', db)
50  if readSTATES:
51  folders.add('/TILE/DCS/STATES', db)
52 
53  from IOVDbSvc.IOVDbSvcConfig import addFolderList
54  acc.merge( addFolderList(flags, folders.get()) )
55 
56  TileDCSCondAlg=CompFactory.TileDCSCondAlg
57  dcsCondAlg = TileDCSCondAlg( name = name,
58  ReadHV = readHV,
59  ReadHVSET = readHVSET,
60  ReadSTATES = readSTATES,
61  TileDCS = dcs)
62 
63  acc.addCondAlgo(dcsCondAlg)
64 
65  return acc
66 
67 
68 def TileDCSToolCfg(flags, **kwargs):
69  """Return component accumulator with configured private Tile DCS tool
70  Arguments:
71  flags -- Athena configuration flags
72  Keyword arguments:
73  ReadHV -- Read Tile DCS HV folder from DB. Defaults True.
74  ReadHVSET -- Read Tile DCS HVSET folder from DB. Defaults to False.
75  ReadSTATES -- Read Tile DCS STATES folder from DB. Defaults to True.
76  TileDCS -- name of Tile DCS conditions object. Defaults to TileDCS.
77  """
78 
79  acc = ComponentAccumulator()
80 
81  kwargs.setdefault('TileDCS', 'TileDCS')
82  kwargs.setdefault('ReadHV', True)
83  kwargs.setdefault('ReadHVSET', False)
84  kwargs.setdefault('ReadSTATUS', True)
85 
86  dcs = kwargs['TileDCS']
87 
88  acc.merge( TileDCSCondAlgCfg(flags, **kwargs) )
89 
90  TileDCSTool=CompFactory.TileDCSTool
91  acc.setPrivateTools( TileDCSTool(TileDCS = dcs) )
92 
93  return acc
94 
95 
96 if __name__ == "__main__":
97 
98  from AthenaConfiguration.AllConfigFlags import initConfigFlags
99  from AthenaConfiguration.TestDefaults import defaultTestFiles
100  from AthenaCommon.Logging import log
101  from AthenaCommon.Constants import DEBUG
102 
103  # Test setup
104  log.setLevel(DEBUG)
105 
106  flags = initConfigFlags()
107  flags.Input.Files = defaultTestFiles.RAW_RUN2
108  flags.lock()
109 
111 
112  dcsTool = acc.popToolsAndMerge( TileDCSToolCfg(flags) )
113  print(dcsTool)
114 
115  acc.printConfig(withDetails = True, summariseProps = True)
116  print(acc.getService('IOVDbSvc'))
117  acc.store( open('TileDCS.pkl','wb') )
118 
119  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
python.TileDCSConfig.TileDCSToolCfg
def TileDCSToolCfg(flags, **kwargs)
Definition: TileDCSConfig.py:68
Constants
some useful constants -------------------------------------------------—
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
python.TileEMScaleConfig.TileEMScaleCondAlgCfg
def TileEMScaleCondAlgCfg(flags, **kwargs)
Definition: TileEMScaleConfig.py:10
python.TileDCSConfig.TileDCSCondAlgCfg
def TileDCSCondAlgCfg(flags, **kwargs)
Definition: TileDCSConfig.py:8
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
TileDCSTool
The tool to get Tile DCS information from DB.
Definition: TileDCSTool.h:23
TileDCSCondAlg
Condition algorithm to prepare TileDCSState object and put it into condition store.
Definition: TileDCSCondAlg.h:33
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11