ATLAS Offline Software
Loading...
Searching...
No Matches
TileMuIdMonitorAlgorithm.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3#
4'''
5@file TileMuIdMonitorAlgorithm.py
6@brief Python configuration of TileMuIdMonitorAlgorithm algorithm for the Run III
7'''
8def TileMuIdMonitoringConfig(flags, **kwargs):
9
10 ''' Function to configure TileMuIdMonitorAlgorithm algorithm in the monitoring system.'''
11
12 # Define one top-level monitoring algorithm. The new configuration
13 # framework uses a component accumulator.
14 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
15 result = ComponentAccumulator()
16
17 from TileGeoModel.TileGMConfig import TileGMCfg
18 result.merge(TileGMCfg(flags))
19
20 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
21 result.merge(LArGMCfg(flags))
22
23 # The following class will make a sequence, configure algorithms, and link
24 # them to GenericMonitoringTools
25 from AthenaMonitoring import AthMonitorCfgHelper
26 helper = AthMonitorCfgHelper(flags,'TileMuIdMonitoring')
27
28 # Adding an TileCellMonitorAlgorithm algorithm to the helper
29 from AthenaConfiguration.ComponentFactory import CompFactory
30 tileMuIdMonAlg = helper.addAlgorithm(CompFactory.TileMuIdMonitorAlgorithm, 'TileMuIdMonAlg')
31
32 tileMuIdMonAlg.TriggerChain = ''
33
34 # L1Trigger Type Bits:
35 # bit0_RNDM, bit1_ZeroBias, bit2_L1Cal, bit3_Muon,
36 # bit4_RPC, bit5_FTK, bit6_CTP, bit7_Calib, AnyPhysTrig
37 kwargs.setdefault('fillHistogramsForL1Triggers', ['AnyPhysTrig', 'bit7_Calib'])
38 l1Triggers = kwargs['fillHistogramsForL1Triggers']
39
40 for k, v in kwargs.items():
41 setattr(tileMuIdMonAlg, k, v)
42
43 run = str(flags.Input.RunNumbers[0])
44
45 # 1) Configure histogram with TileMuIdMonAlg algorithm execution time
46 executeTimeGroup = helper.addGroup(tileMuIdMonAlg, 'TileMuIdMonExecuteTime', 'Tile/')
47 executeTimeGroup.defineHistogram('TIME_execute', path = 'MuId', type='TH1F',
48 title = 'Time for execute TileMuIdMonAlg algorithm;time [#mus]',
49 xbins = 100, xmin = 0, xmax = 1000)
50
51
52 from TileCalibBlobObjs.Classes import TileCalibUtils as Tile
53
54 from TileMonitoring.TileMonitoringCfgHelper import addTileEtaPhiMapsArray
55
56 # 2) Configure histograms with most energetic Tile MuId muon position
57 addTileEtaPhiMapsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEtaPhi', type='TH2D',
58 title = 'Tile MuId muon position', path = 'Tile/MuId',
59 run = run, triggers = l1Triggers, perSample = False)
60
61 # 3) Configure histograms with most energetic Tile MuId muon position when Tags=1
62 addTileEtaPhiMapsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagEtaPhi', type='TH2D',
63 title = 'Tile MuId Tags=1 muon position', path = 'Tile/MuId',
64 run = run, triggers = l1Triggers, perSample = False)
65
66 # 4) Configure histograms with most energetic Tile MuId muon position when Tags=2
67 addTileEtaPhiMapsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagEtaPhi', type='TH2D',
68 title = 'Tile MuId Tags=2 muon position', path = 'Tile/MuId',
69 run = run, triggers = l1Triggers, perSample = False)
70
71
72 from TileMonitoring.TileMonitoringCfgHelper import addTile2DHistogramsArray
73
74 # 5) Configure histograms with Tile MuId muon quality vs energy
75 addTile2DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEneQuality',
76 xvalue = 'energy', yvalue = 'quality', type='TH2D',
77 title = 'Tile MuId muon quality vs energy [MeV];Energy [MeV];Quality',
78 path = 'Tile/MuId', xbins = 50, xmin = 0., xmax = 10000.,
79 ybins = 4, ymin = -0.5, ymax = 1.5, run = run, triggers = l1Triggers)
80
81 # 6) Configure histograms with Tile MuId muon quality vs energy when Tags=1
82 addTile2DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagEneQuality',
83 xvalue = 'energy', yvalue = 'quality', type='TH2D',
84 title = 'Tile MuId Tags=1 muon quality vs energy [MeV];Energy [MeV];Quality',
85 path = 'Tile/MuId', xbins = 50, xmin = 0., xmax = 10000.,
86 ybins = 4, ymin = -0.5, ymax = 1.5, run = run, triggers = l1Triggers)
87
88 # 7) Configure histograms with Tile MuId muon quality vs energy when Tags=2
89 addTile2DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagEneQuality',
90 xvalue = 'energy', yvalue = 'quality', type='TH2D',
91 title = 'Tile MuId Tags=2 muon quality vs energy [MeV];Energy [MeV];Quality',
92 path = 'Tile/MuId', xbins = 50, xmin = 0., xmax = 10000.,
93 ybins = 4, ymin = -0.5, ymax = 1.5, run = run, triggers = l1Triggers)
94
95
96 from TileMonitoring.TileMonitoringCfgHelper import addTile1DHistogramsArray
97
98 # 8) Configure histograms with Tile MuId number of tags
99 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdTags', xvalue = 'nTags',
100 title = 'Tile MuId number of tags', path = 'Tile/MuId',
101 xbins = 5, xmin = -0.5, xmax = 4.5, type = 'TH1D', run = run,
102 triggers = l1Triggers, perPartition = False, perSample = False,
103 perGain = False, subDirectory = False, allPartitions = False)
104
105 # 9) Configure histograms with all Tile MuId energy
106 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEnergy', xvalue = 'energy',
107 title = 'Tile MuId Energy;Energy [MeV]', path = 'Tile/MuId',
108 xbins = 100, xmin = 0., xmax = 10000., type = 'TH1D', run = run,
109 triggers = l1Triggers, perPartition = False, perSample = False,
110 perGain = False, subDirectory = False, allPartitions = False)
111
112 # 10) Configure histograms with all Tile MuId muon quality
113 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdQuality', xvalue = 'quality',
114 title = 'Tile MuId muon quality', path = 'Tile/MuId',
115 xbins = 4, xmin = -0.5, xmax = 1.5, type = 'TH1D', run = run,
116 triggers = l1Triggers, perPartition = False, perSample = False,
117 perGain = False, subDirectory = False, allPartitions = False)
118
119 # 11) Configure histograms with all Tile MuId muon eta position
120 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEta', xvalue = 'eta',
121 title = 'Tile MuId muon #eta position;#eta', path = 'Tile/MuId',
122 xbins = 40, xmin = -2., xmax = 2., type = 'TH1D', run = run,
123 triggers = l1Triggers, perPartition = False, perSample = False,
124 perGain = False, subDirectory = False, allPartitions = False)
125
126 # 12) Configure histograms with all Tile MuId muon phi position
127 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdPhi', xvalue = 'phi',
128 title = 'Tile MuId muon #phi position;#phi', path = 'Tile/MuId',
129 xbins = Tile.MAX_DRAWER, xmin = -3.15, xmax = 3.15, type = 'TH1D',
130 run = run, triggers = l1Triggers, perPartition = False, perSample = False,
131 perGain = False, subDirectory = False, allPartitions = False)
132
133 # 13) Configure histograms with all Tile MuId muon average energy vs eta
134 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEneEta', xvalue = 'eta',
135 value = 'energy', title = 'Tile MuId muon average energy;#eta',
136 path = 'Tile/MuId', xbins = 40, xmin = -2., xmax = 2., type = 'TProfile',
137 run = run, triggers = l1Triggers, perPartition = False, perSample = False,
138 perGain = False, subDirectory = False, allPartitions = False)
139
140 # 14) Configure histograms with all Tile MuId muon average energy vs phi
141 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuIdEnePhi', xvalue = 'phi', value='energy',
142 title = 'Tile MuId muon everage energy [MeV];#phi', path = 'Tile/MuId',
143 xbins = Tile.MAX_DRAWER, xmin = -3.15, xmax = 3.15, type = 'TProfile',
144 run = run, triggers = l1Triggers, perPartition = False, perSample = False,
145 perGain = False, subDirectory = False, allPartitions = False)
146
147
148 # 15) Configure histograms with all Tile MuId energy when Tags=1
149 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagEnergy', xvalue = 'energy',
150 title = 'Tile MuId Tags=1 Energy;Energy [MeV]', path = 'Tile/MuId',
151 xbins = 100, xmin = 0., xmax = 10000., type = 'TH1D', run = run,
152 triggers = l1Triggers, perPartition = False, perSample = False,
153 perGain = False, subDirectory = False, allPartitions = False)
154
155 # 16) Configure histograms with all Tile MuId muon quality when Tags=1
156 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagQuality', xvalue = 'quality',
157 title = 'Tile MuId Tags=1 muon quality', path = 'Tile/MuId',
158 xbins = 4, xmin = -0.5, xmax = 1.5, type = 'TH1D', run = run,
159 triggers = l1Triggers, perPartition = False, perSample = False,
160 perGain = False, subDirectory = False, allPartitions = False)
161
162 # 17) Configure histograms with all Tile MuId muon eta position when Tags=1
163 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagEta', xvalue = 'eta',
164 title = 'Tile MuId Tags=1 muon #eta position;#eta', path = 'Tile/MuId',
165 weight = 'energy', xbins = 40, xmin = -2., xmax = 2., type = 'TH1D', run = run,
166 triggers = l1Triggers, perPartition = False, perSample = False,
167 perGain = False, subDirectory = False, allPartitions = False)
168
169 # 18) Configure histograms with all Tile MuId muon phi position when Tags=1
170 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId1TagPhi', xvalue = 'phi',
171 title = 'Tile MuId Tags=1 muon #phi position;#phi', path = 'Tile/MuId',
172 weight = 'energy', xbins = Tile.MAX_DRAWER, xmin = -3.15, xmax = 3.15, type = 'TH1D',
173 run = run, triggers = l1Triggers, perPartition = False, perSample = False,
174 perGain = False, subDirectory = False, allPartitions = False)
175
176 # 19) Configure histograms with all Tile MuId energy when Tags=2
177 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagEnergy', xvalue = 'energy',
178 title = 'Tile MuId Tags=2 Energy; Energy [MeV]', path = 'Tile/MuId',
179 xbins = 100, xmin = 0., xmax = 10000., type = 'TH1D', run = run,
180 triggers = l1Triggers, perPartition = False, perSample = False,
181 perGain = False, subDirectory = False, allPartitions = False)
182
183 # 20) Configure histograms with all Tile MuId muon quality when Tags=2
184 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagQuality', xvalue = 'quality',
185 title = 'Tile MuId Tags=2 muon quality', path = 'Tile/MuId',
186 xbins = 4, xmin = -0.5, xmax = 1.5, type = 'TH1D', run = run,
187 triggers = l1Triggers, perPartition = False, perSample = False,
188 perGain = False, subDirectory = False, allPartitions = False)
189
190 # 21) Configure histograms with all Tile MuId muon eta position when Tags=2
191 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagEta', xvalue = 'eta',
192 title = 'Tile MuId Tags=2 muon #eta position;#eta', path = 'Tile/MuId',
193 weight = 'energy', xbins = 40, xmin = -2., xmax = 2., type = 'TH1D', run = run,
194 triggers = l1Triggers, perPartition = False, perSample = False,
195 perGain = False, subDirectory = False, allPartitions = False)
196
197 # 22) Configure histograms with all Tile MuId muon phi position when Tags=2
198 addTile1DHistogramsArray(helper, tileMuIdMonAlg, name = 'TileMuId2TagPhi', xvalue = 'phi',
199 title = 'Tile MuId Tags=2 muon #phi position;#phi', path = 'Tile/MuId',
200 weight = 'energy', xbins = Tile.MAX_DRAWER, xmin = -3.15, xmax = 3.15, type = 'TH1D',
201 run = run, triggers = l1Triggers, perPartition = False, perSample = False,
202 perGain = False, subDirectory = False, allPartitions = False)
203
204 accumalator = helper.result()
205 result.merge(accumalator)
206 return result
207
208if __name__=='__main__':
209
210 # Setup logs
211 from AthenaCommon.Logging import log
212 from AthenaCommon.Constants import INFO
213 log.setLevel(INFO)
214
215 # Set the Athena configuration flags
216 from AthenaConfiguration.AllConfigFlags import initConfigFlags
217 from AthenaConfiguration.TestDefaults import defaultTestFiles
218 flags = initConfigFlags()
219 flags.Input.Files = defaultTestFiles.ESD
220 flags.Output.HISTFileName = 'TileMuIdMonitorOutput.root'
221 flags.DQ.useTrigger = False
222 flags.DQ.enableLumiAccess = False
223 flags.Exec.MaxEvents = 3
224 flags.fillFromArgs()
225 flags.lock()
226
227 # Initialize configuration object, add accumulator, merge, and run.
228 from AthenaConfiguration.MainServicesConfig import MainServicesCfg
229 from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
230 cfg = MainServicesCfg(flags)
231 cfg.merge(PoolReadCfg(flags))
232
233 l1Triggers = ['bit0_RNDM', 'bit1_ZeroBias', 'bit2_L1Cal', 'bit3_Muon',
234 'bit4_RPC', 'bit5_FTK', 'bit6_CTP', 'bit7_Calib', 'AnyPhysTrig']
235
236 cfg.merge( TileMuIdMonitoringConfig(flags,
237 fillHistogramsForL1Triggers = l1Triggers) )
238
239 cfg.printConfig(withDetails = True, summariseProps = True)
240 flags.dump()
241
242 cfg.store( open('TileMuIdMonitorAlgorithm.pkl','wb') )
243
244 sc = cfg.run()
245
246 import sys
247 # Success should be 0
248 sys.exit(not sc.isSuccess())
TileMuIdMonitoringConfig(flags, **kwargs)