ATLAS Offline Software
Loading...
Searching...
No Matches
TilePulseShapeConfig.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 pulse shape conditions tool and algorithm"""
4
5from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6from AthenaConfiguration.ComponentFactory import CompFactory
7from TileConfiguration.TileConfigFlags import TileRunType
8
9def TilePulseShapeCondAlgCfg(flags, **kwargs):
10 """Return component accumulator with configured Tile pulse shape conditions algorithm
11
12 Arguments:
13 flags -- Athena configuration flags
14 Keyword arguments:
15 Source -- source of Tile pulse shape conditions (COOL, FILE). Defaults to COOL.
16 TilePulseShape -- name of Tile pulse shape conditions object. Defaults to TilePulseShape.
17 PulseType -- type of Tile pulse shape. Defaults to run type (PED->PHY, BILAS->LAS).
18 Possible Tile pulse shape types:
19 PHY, LAS, CIS, CIS/PULSE100, CIS/PULSE5P2, CIS/LEAK100, CIS/LEAK5P2, MURCV.
20 """
21
22 acc = ComponentAccumulator()
23
24 runType = flags.Tile.RunType
25
26 source = kwargs.get('Source', 'COOL')
27 pulseShape = kwargs.get('TilePulseShape', 'TilePulseShape')
28 pulseType = kwargs.get('PulseType', runType.getCommonType().value)
29
30 actualPulseType = {'CIS' : 'CIS/PULSE100',
31 'CISPULSE100' : 'CIS/PULSE100', 'CISPULSE5P2' : 'CIS/PULSE5P2',
32 'CISLEAK100' : 'CIS/LEAK100', 'CISLEAK5P2' : 'CIS/LEAK5P2'}
33
34 pulse = actualPulseType.get(pulseType, pulseType)
35
36 if pulse not in ['PHY', 'LAS', 'CIS/PULSE100', 'CIS/PULSE5P2', 'CIS/LEAK100', 'CIS/LEAK5P2', 'MURCV']:
37 raise(Exception("Invalid Tile pulse shape type: %s" % pulse))
38
39 name = pulseShape + 'CondAlg'
40
41 if source == 'COOL':
42 # Connect COOL Tile conditions proxies to the algorithm (default)
43
44 if pulse in ['MURCV']:
45 raise(Exception('No Tile pulse shape [%s] in source: %s' % (pulse, source)))
46
47 from TileConditions.TileFolders import TileFolders
48 folders = TileFolders(isMC = flags.Input.isMC, isOnline = flags.Common.isOnline)
49
50 if flags.IOVDb.DatabaseInstance == 'CONDBR2':
51 if not flags.Common.isOnline:
52 pulseFolder = folders.add('/TILE/OFL02/PULSESHAPE/' + pulse, 'TILE_OFL')
53 else:
54 raise(Exception('No Tile pulse shapes in online CONDBR2'))
55 else:
56 pulseFolder = folders.addSplitOnline('/TILE/OFL01/PULSESHAPE/' + pulse, '/TILE/OFL02/PULSESHAPE/' + pulse)
57
58 TileCondProxyCoolFlt=CompFactory.getComp("TileCondProxyCool<TileCalibDrawerFlt>")
59 pulseProxy = TileCondProxyCoolFlt('TileCondProxyCool_PulseShape', Source = pulseFolder)
60
61 from IOVDbSvc.IOVDbSvcConfig import addFolderList
62 acc.merge( addFolderList(flags, folders.get()) )
63
64 elif source == 'FILE':
65 # Connect FILE Tile conditions proxies to the algorithm
66 fileExtention = {'PHY' : 'plsPhy', 'LAS' : 'plsLas', 'MURCV' : 'plsMuRcv',
67 'CIS/PULSE100' : 'plsCisPulse100', 'CIS/PULSE5P2' : 'plsCisPulse5p2',
68 'CIS/LEAK100' : 'plsCisLeak100', 'CIS/LEAK5P2' : 'plsCisLeak5p2'}
69
70 TileCondProxyFileFlt=CompFactory.getComp("TileCondProxyFile<TileCalibDrawerFlt>")
71 pulseProxy = TileCondProxyFileFlt('TileCondProxyFile_PulseShape',
72 Source = 'TileDefault.' + fileExtention[pulse])
73 else:
74 raise(Exception("Invalid source: %s" % source))
75
76 TilePulseShapeCondAlg = CompFactory.getComp("TileCondAlg<TilePulse,TileCalibDrawerFlt>")
77 pulseShapeCondAlg = TilePulseShapeCondAlg( name = name,
78 ConditionsProxy = pulseProxy,
79 TileCondData = pulseShape)
80
81 acc.addCondAlgo(pulseShapeCondAlg)
82
83 return acc
84
85
86def TileCondToolPulseShapeCfg(flags, **kwargs):
87 """Return component accumulator with configured private Tile pulse shape conditions tool
88
89 Arguments:
90 flags -- Athena configuration flags
91 Keyword arguments:
92 Source -- source of Tile pulse shape conditions (COOL, FILE). Defaults to COOL.
93 TilePulseShape -- name of Tile pulse shape conditions object. Defaults to TilePulseShape.
94 PulseType -- type of Tile pulse shape. Defaults to run type (PED->PHY, BILAS->LAS).
95 Possible Tile pulse shape types:
96 PHY, LAS, CIS/PULSE100, CIS/PULSE5P2, CIS/LEAK100, CIS/LEAK5P2, MURCV.
97 """
98
99 acc = ComponentAccumulator()
100
101 kwargs.setdefault('Source', 'COOL')
102 kwargs.setdefault('TilePulseShape', 'TilePulseShape')
103
104 pulseShape = kwargs['TilePulseShape']
105 name = 'TileCondToolPulseShape'
106
107 acc.merge( TilePulseShapeCondAlgCfg(flags, **kwargs) )
108
109 TileCondToolPulseShape=CompFactory.TileCondToolPulseShape
110 acc.setPrivateTools( TileCondToolPulseShape(name, TilePulseShape = pulseShape) )
111
112 return acc
113
114
116
117 kwargs.setdefault('Source', 'FILE')
118 kwargs.setdefault('TilePulseShape', 'TileMuRcvPulseShape')
119 kwargs['PulseType'] = 'MURCV'
120
121 pulseShape = kwargs['TilePulseShape']
122 name = 'TileCondToolPulseShape'
123
124 acc = TilePulseShapeCondAlgCfg(flags, **kwargs)
125
126 TileCondToolPulseShape=CompFactory.TileCondToolPulseShape
127 acc.setPrivateTools( TileCondToolPulseShape(name, TilePulseShape = pulseShape) )
128
129 return acc
130
131
132if __name__ == "__main__":
133
134 from AthenaConfiguration.AllConfigFlags import initConfigFlags
135 from AthenaConfiguration.TestDefaults import defaultTestFiles
136 from AthenaCommon.Logging import log
137 from AthenaCommon.Constants import DEBUG
138
139 # Test setup
140 log.setLevel(DEBUG)
141
142 flags = initConfigFlags()
143 flags.Input.Files = defaultTestFiles.RAW_RUN2
144 flags.Tile.RunType = TileRunType.PHY
145 flags.lock()
146
147 acc = ComponentAccumulator()
148
149 pulseShapeTool = acc.popToolsAndMerge( TileCondToolPulseShapeCfg(flags) )
150 print(pulseShapeTool)
151
152 muRcvPulseShapeTool = acc.popToolsAndMerge( TileCondToolMuRcvPulseShapeCfg(flags) )
153 print(muRcvPulseShapeTool)
154
155 acc.printConfig(withDetails = True, summariseProps = True)
156 print(acc.getService('IOVDbSvc'))
157 acc.store( open('TilePulseShape.pkl','wb') )
158
159 print('All OK')
160
void print(char *figname, TCanvas *c1)
TileCondToolMuRcvPulseShapeCfg(flags, **kwargs)
TilePulseShapeCondAlgCfg(flags, **kwargs)
TileCondToolPulseShapeCfg(flags, **kwargs)