ATLAS Offline Software
TileMBTSMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 '''
5 @file TileMBTSMonitorAlgorithm.py
6 @brief Python configuration of TileMBTSMonitorAlgorithm algorithm for the Run III
7 '''
8 
9 
10 def TileMBTSMonitoringConfig(flags, **kwargs):
11 
12  ''' Function to configure TileMBTSMonitorAlgorithm algorithm in the monitoring system.'''
13 
14  kwargs.setdefault('useTrigger', (flags.DQ.useTrigger and not flags.Input.isMC))
15  kwargs.setdefault('FillHistogramsPerMBTS', True)
16 
17  # Define one top-level monitoring algorithm. The new configuration
18  # framework uses a component accumulator.
19  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
20  result = ComponentAccumulator()
21 
22  from TileRecUtils.TileDQstatusConfig import TileDQstatusAlgCfg
23  result.merge( TileDQstatusAlgCfg(flags) )
24 
25  from TileGeoModel.TileGMConfig import TileGMCfg
26  result.merge(TileGMCfg(flags))
27 
28  from LArGeoAlgsNV.LArGMConfig import LArGMCfg
29  result.merge(LArGMCfg(flags))
30 
31  from TileConditions.TileCablingSvcConfig import TileCablingSvcCfg
32  result.merge( TileCablingSvcCfg(flags) )
33 
34  if kwargs['useTrigger']:
35  from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
36  result.merge( L1ConfigSvcCfg(flags) )
37 
38  from AthenaConfiguration.Enums import BeamType, Format
39  if flags.Input.Format is Format.POOL:
40  kwargs.setdefault('TileDigitsContainer', 'TileDigitsFlt')
41 
42  # The following class will make a sequence, configure algorithms, and link
43  # them to GenericMonitoringTools
44  from AthenaMonitoring import AthMonitorCfgHelper
45  helper = AthMonitorCfgHelper(flags, 'TileMBTSMonAlgCfg')
46 
47  # Adding an TileMBTSMonitorAlgorithm algorithm to the helper
48  from AthenaConfiguration.ComponentFactory import CompFactory
49  tileMBTSMonAlg = helper.addAlgorithm(CompFactory.TileMBTSMonitorAlgorithm, 'TileMBTSMonAlg')
50 
51  tileMBTSMonAlg.TriggerChain = ''
52 
53  runNumber = flags.Input.RunNumbers[0]
54 
55  numberOfMBTS = 32
56  if runNumber < 400000:
57  energyCuts = [60. / 222 for mbts in range(0, numberOfMBTS)]
58  else:
59  energyCuts = [0.1 for mbts in range(0, numberOfMBTS)]
60  kwargs.setdefault("EnergyCuts", energyCuts)
61 
62  for k, v in kwargs.items():
63  setattr(tileMBTSMonAlg, k, v)
64 
65  if 'FillHistogramsPerMBTS' in kwargs:
66  fillHistogramPerMBTS = kwargs['FillHistogramsPerMBTS']
67  elif hasattr(tileMBTSMonAlg,"_descriptors"): #GaudiConfig2 config
68  fillHistogramPerMBTS = tileMBTSMonAlg._descriptors['FillHistogramsPerMBTS'].default
69  else: #Run1/2 config
70  fillHistogramPerMBTS = tileMBTSMonAlg.getDefaultProperty('FillHistogramsPerMBTS')
71 
72  useTrigger = kwargs['useTrigger']
73 
74  run = str(runNumber)
75 
76  # 1) Configure histogram with TileMBTSMonAlg algorithm execution time
77  executeTimeGroup = helper.addGroup(tileMBTSMonAlg, 'TileMBTSMonExecuteTime', 'Tile/')
78  executeTimeGroup.defineHistogram('TIME_execute', path = 'MBTS', type='TH1F',
79  title = 'Time for execute TileMBTSMonAlg algorithm;time [#mus]',
80  xbins = 100, xmin = 0, xmax = 1000)
81 
82  nMBTSPerSide = numberOfMBTS // 2
83  labelsMBTS = ['MBTSA' + ('0' if x < 10 else '') + str(x) for x in range(0, nMBTSPerSide)]
84  labelsMBTS += ['MBTSC' + ('0' if x < 10 else '') + str(x) for x in range(0, nMBTSPerSide)]
85 
86 
87  # 2) Configure MBTS occupancy histogram
88  occupancyGroup = helper.addGroup(tileMBTSMonAlg, 'TileOccupancyMBTS', 'Tile')
89  occupancyGroup.defineHistogram('HitCounter;Occupancy', path = 'MBTS/Cell', type='TH1F',
90  xlabels = labelsMBTS, title = 'Run ' + run + ': MBTS Occupancy',
91  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
92 
93  # 3) Configure summary energy histogram
94  energySummaryGroup = helper.addGroup(tileMBTSMonAlg, 'TileEnergySummaryMBTS', 'Tile')
95  energySummaryGroup.defineHistogram('EnergyCounter,SummaryEnergy;SummaryEnergy', path = 'MBTS/Cell', type='TProfile',
96  title = 'Run ' + run + ': Average MBTS Energy;;Average Energy [pC]',
97  xlabels = labelsMBTS, xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
98 
99  # 4) Configure histogram with average MBTS time (energy above threshold)
100  timeSummaryGroup = helper.addGroup(tileMBTSMonAlg, 'TileTimeSummaryMBTS', 'Tile')
101  timeSummaryGroup.defineHistogram('TimeCounter,SummaryTime;SummaryTime', path = 'MBTS/Cell', type='TProfile',
102  title = 'Run ' + run + ': Average MBTS Time (Energy above threshold);;Average Time [ns]',
103  xlabels = labelsMBTS, xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
104 
105  # 5) Configure histogram with time of MBTS on A side
106  timeAGroup = helper.addGroup(tileMBTSMonAlg, 'TileTimeMBTSA', 'Tile')
107  timeAGroup.defineHistogram('TimeA;Time_A', path = 'MBTS/Cell', type='TH1F',
108  title = 'Run ' + run + ': Time of MBTS on A side;Time [ns]',
109  xbins = 151, xmin = -75.5, xmax = 75.5)
110 
111  # 6) Configure histogram time of MBTS on C side
112  timeCGroup = helper.addGroup(tileMBTSMonAlg, 'TileTimeMBTSC', 'Tile')
113  timeCGroup.defineHistogram('TimeC;Time_C', path = 'MBTS/Cell', type='TH1F',
114  title = 'Run ' + run + ': Time of MBTS on C side;Time [ns]',
115  xbins = 151, xmin = -75.5, xmax = 75.5)
116 
117  # 7) Configure histogram with time difference between MBTS on A and C sides
118  timeDifferenceGroup = helper.addGroup(tileMBTSMonAlg, 'TileTimeDifferenceMBTS', 'Tile')
119  timeDifferenceGroup.defineHistogram('TimeDifference;TimeDiff_A-C', path = 'MBTS/Cell', type='TH1F',
120  title = 'Run ' + run + ': Time difference between MBTS on A and C sides;Time [ns]',
121  xbins = 151, xmin = -75.5, xmax = 75.5)
122 
123  # 8) Configure histogram with time difference between MBTS on A and C sides vs luminosity block
124  timeDifferenceLBGroup = helper.addGroup(tileMBTSMonAlg, 'TileTimeDifferenceMBTSLB', 'Tile')
125  timeDifferenceLBGroup.defineHistogram('lumiBlock,TimeDifference;TimeDiff_A-C_LB', path = 'MBTS/Cell', type='TH2F',
126  title = ('Run ' + run + ': Time difference between MBTS on A and C sides vs LumiBlock'
127  + ';Luminosity Block;Time difference A-side - C-side [ns]'),
128  xbins = 1000, xmin = -0.5, xmax = 999.5, ybins = 151, ymin = -75.5, ymax = 75.5,
129  opt = 'kAddBinsDynamically', merge = 'merge')
130 
131  # 9) Configure histogram with coincident Hits (energy) between two MBTS counters
132  coincidentHitsGroup = helper.addGroup(tileMBTSMonAlg, 'TileCoincidentHitsMBTS', 'Tile')
133  coincidentHitsGroup.defineHistogram('CoincidentCounter1,CoincidentCounter2;CoincidentEnergyHits',
134  path = 'MBTS/Cell', type='TH2F', xlabels = labelsMBTS, ylabels = labelsMBTS,
135  title = 'Run ' + run + ': Coincident Hits (energy) between two MBTS counters',
136  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS,
137  ybins = numberOfMBTS, ymin = 0, ymax = numberOfMBTS)
138 
139 
140  # 10) Configure histogram with Tile readout errors for MBTS counters
141  errorLabels = ['General', 'Global CRC', 'ROD CRC', 'Frontend CRC', 'BCID', 'Header Format',
142  'Header Parity', 'Sample Format', 'Sample Parity', 'Memory Parity']
143  numberOfErrors = len(errorLabels)
144  errorsGroup = helper.addGroup(tileMBTSMonAlg, 'TileErrorsMBTS', 'Tile')
145  errorsGroup.defineHistogram('ErrorCounter,Error;ReadOutErrors', path = 'MBTS/Digit',
146  type='TH2F', xlabels = labelsMBTS, ylabels = errorLabels,
147  title = 'Run ' + run + ': Tile Readout Errors for MBTS counters',
148  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS,
149  ybins = numberOfErrors, ymin = 0, ymax = numberOfErrors)
150 
151 
152  isCosmics = flags.Beam.Type is BeamType.Cosmics
153  nEnergyBins = 550 if isCosmics else 400
154  maxEnergy = 5 if isCosmics else 80
155 
156  if fillHistogramPerMBTS:
157 
158  # 11) Configure histogram with MBTS counter energy
159  energyArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileEnergyMBTS', topPath = 'Tile/MBTS')
160  for postfix, tool in energyArray.Tools.items():
161  mbtsCounter = int( postfix.split('_')[1] )
162  mbtsName = labelsMBTS[mbtsCounter]
163  title = 'Run ' + run + ': Energy of ' + mbtsName + ';Energy [pC]'
164  name = 'Energy;Energy_' + mbtsName
165  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Cell',
166  xbins = nEnergyBins, xmin = -0.5, xmax = maxEnergy)
167 
168  # 12) Configure histogram with MBTS counter energy vs luminosity block
169  energyLBArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileEnergyLBMBTS', topPath = 'Tile/MBTS')
170  for postfix, tool in energyLBArray.Tools.items():
171  mbtsCounter = int( postfix.split('_')[1] )
172  mbtsName = labelsMBTS[mbtsCounter]
173  title = 'Run ' + run + ': Energy of ' + mbtsName + ' per lumiblock;Lumiblocks;Energy [pC]'
174  name = 'lumiBlock,Energy;EnergyLB_' + mbtsName
175  tool.defineHistogram(name, title = title, type = 'TProfile', path = 'Cell',
176  xbins = 1000, xmin = -0.5, xmax = 999.5, opt = 'kAddBinsDynamically', merge = 'merge')
177 
178  # 13) Configure histogram with MBTS counter time
179  timeArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileTimeMBTS', topPath = 'Tile/MBTS')
180  for postfix, tool in timeArray.Tools.items():
181  mbtsCounter = int( postfix.split('_')[1] )
182  mbtsName = labelsMBTS[mbtsCounter]
183  title = 'Run ' + run + ': Time of ' + mbtsName + ';Time [ns]'
184  name = 'Time;Time_' + mbtsName
185  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Cell',
186  xbins = 151, xmin = -75.5, xmax = 75.5)
187 
188  # 14) Configure histogram with MBTS counter pedestal
189  pedestalArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TilePedestalMBTS', topPath = 'Tile/MBTS')
190  for postfix, tool in pedestalArray.Tools.items():
191  mbtsCounter = int( postfix.split('_')[1] )
192  mbtsName = labelsMBTS[mbtsCounter]
193  title = 'Run ' + run + ': Pedestal of ' + mbtsName + ';Channel pedestal in ADC counts'
194  name = 'Pedestal;Pedestal_' + mbtsName
195  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Digit',
196  xbins = 100, xmin = 20.5, xmax = 120.5)
197 
198  # 15) Configure histogram with high frequency noise of MBTS counter
199  hfnArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileHFNoiseMBTS', topPath = 'Tile/MBTS')
200  for postfix, tool in hfnArray.Tools.items():
201  mbtsCounter = int( postfix.split('_')[1] )
202  mbtsName = labelsMBTS[mbtsCounter]
203  title = 'Run ' + run + ': High Frequency Noise of ' + mbtsName + ';Inter-sample RMS in ADC counts'
204  name = 'HFN;HFN_' + mbtsName
205  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Digit',
206  xbins = 100, xmin = 0, xmax = 5)
207 
208  # 16) Configure histogram with average pulse shape of MBTS counter
209  averagePulseArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileAveragePulseMBTS', topPath = 'Tile/MBTS')
210  for postfix, tool in averagePulseArray.Tools.items():
211  mbtsCounter = int( postfix.split('_')[1] )
212  mbtsName = labelsMBTS[mbtsCounter]
213  title = 'Run ' + run + ': Average Pulse for digitized signals of ' + mbtsName
214  title += ';TileCal Digital Sample;Average number of ADC counts'
215  name = 'SampleNumbers,Samples;AveragePulse_' + mbtsName
216  tool.defineHistogram(name, title = title, type = 'TProfile', path = 'Digit',
217  xbins = 7, xmin = -0.5, xmax = 6.5)
218 
219 
220  if useTrigger:
221 
222  tileMBTSMonAlg.CTP_ID = [-1] # Auto configuration
223 
224  # 17) Configure MBTS occupancy histogram with TBP fired
225  occupancyTrigGroup = helper.addGroup(tileMBTSMonAlg, 'TileTriggerOccupancyMBTS', 'Tile')
226  occupancyTrigGroup.defineHistogram('HitCounter;Occupancy_wTBP', path = 'MBTS/Cell', type='TH1F',
227  xlabels = labelsMBTS, title = f'Run {run}: MBTS Occupancy with TBP fired',
228  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
229 
230  # 18) Configure summary energy histogram for MBTS with TBP fired
231  energySummaryTrigGroup = helper.addGroup(tileMBTSMonAlg, 'TileTriggerEnergySummaryMBTS', 'Tile')
232  energySummaryTrigGroup.defineHistogram('HitCounter,SummaryEnergy;SummaryEnergy_TBP', path = 'MBTS/Cell', type='TProfile',
233  title = f'Run {run}: Average MBTS Energy with TBP fired;;Average Energy [pC]',
234  xlabels = labelsMBTS, xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
235 
236  # 19) Configure histogram with average MBTS time with TBP fired
237  timeSummaryTrigGroup = helper.addGroup(tileMBTSMonAlg, 'TileTriggerTimeSummaryMBTS', 'Tile')
238  timeSummaryTrigGroup.defineHistogram('HitCounter,SummaryTime;SummaryTime_TBP', path = 'MBTS/Cell', type='TProfile',
239  title = f'Run {run}: Average MBTS Time with TBP fired;;Average Time [ns]',
240  xlabels = labelsMBTS, xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
241 
242  # 20) Configure histogram with average MBTS triggers multiplicities per side with TBP fired
243  sides = ['A', 'C']
244  for side in sides:
245  multiplicityGroup = helper.addGroup(tileMBTSMonAlg, 'TileTriggerMultiplicityMBTS' + side, 'Tile')
246  multiplicityTitle = f'Run {run}: Average number of MBTS triggers on {side} side;BCID;Average # of Triggers'
247  multiplicityGroup.defineHistogram(f'bcid,multiplicity{side};MBTS{side}TriggersVsBCID', path = 'MBTS/Trigger',
248  type='TProfile', title = multiplicityTitle, xbins = 3565, xmin = -0.5, xmax = 3564.5)
249 
250  # 21) Configure histogram with MBTS triggers multiplicities per side with TBP fired
251  multiplicityPerSideGroup = helper.addGroup(tileMBTSMonAlg, 'TileTriggerMultiplicityPerSideMBTS', 'Tile')
252  multiplicityPerSideTitle = f'Run {run}: Number of MBTS triggers per side with TBP fired'
253  multiplicityPerSideTitle += ';# of Triggers on A side; # of Triggers on C side'
254  multiplicityPerSideGroup.defineHistogram('multiplicityA,multiplicityC;MBTSTriggersPerSide',
255  path = 'MBTS/Trigger', type='TH2F', title = multiplicityPerSideTitle,
256  xbins = nMBTSPerSide, xmin = -0.5, xmax = nMBTSPerSide - 0.5,
257  ybins = nMBTSPerSide, ymin = -0.5, ymax = nMBTSPerSide - 0.5)
258 
259  # 22) Configure histogram with coincident Hits (energy) between two MBTS counters
260  triggerNames = ['TBP', 'TAP', 'TAV']
261  triggerDescriptions = ['before prescale', 'after prescale', 'after veto']
262  triggersArray = helper.addArray([len(triggerNames)], tileMBTSMonAlg, 'MBTS_Triggers', topPath = 'Tile/MBTS')
263  for postfix, tool in triggersArray.Tools.items():
264  triggerIdx = int( postfix.split('_').pop() )
265  trigger = triggerNames[triggerIdx]
266  description = triggerDescriptions[triggerIdx]
267  tool.defineHistogram(f'TriggerCounter;MBTS_Triggers_{trigger}', path = 'Trigger', type='TH1F',
268  xlabels = labelsMBTS, title = f'Run {run}: MBTS triggers {description} ({trigger})',
269  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
270 
271  # 23) Configure histogram with coincident Hits (energy) between two MBTS counters in CTP window
272  triggersInWinArray = helper.addArray([len(triggerNames)], tileMBTSMonAlg, 'MBTS_TriggersInWindow', topPath = 'Tile/MBTS')
273  for postfix, tool in triggersInWinArray.Tools.items():
274  triggerIdx = int( postfix.split('_').pop() )
275  trigger = triggerNames[triggerIdx]
276  description = triggerDescriptions[triggerIdx]
277  tool.defineHistogram(f'TriggerCounter;MBTS_TriggersInWindow_{trigger}', path = 'Trigger', type='TH1F',
278  xlabels = labelsMBTS, title = f'Run {run}: MBTS triggers {description} ({trigger}) in CTP window',
279  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
280 
281  # 24) Configure histogram with sum of MBTS triggers
282  triggersSumLables = ['A-Inner', 'A-Outer', 'A-Total', 'C-Inner', 'C-Outer', 'C-Total']
283  triggersSumArray = helper.addArray([len(triggerNames)], tileMBTSMonAlg, 'MBTS_TriggersSum', topPath = 'Tile/MBTS')
284  for postfix, tool in triggersSumArray.Tools.items():
285  triggerIdx = int( postfix.split('_').pop() )
286  trigger = triggerNames[triggerIdx]
287  description = triggerDescriptions[triggerIdx]
288  tool.defineHistogram(f'TriggerType;MBTS_TriggersSum_{trigger}', path = 'Trigger', type='TH1F',
289  xlabels = triggersSumLables, title = f'Run {run}: Sum of MBTS triggers {description} ({trigger})',
290  xbins = len(triggersSumLables), xmin = 0, xmax = len(triggersSumLables))
291 
292  # 25) Configure histogram with coincident Hits (energy) between two MBTS counters
293  coinTrigArray = helper.addArray([len(triggerNames)], tileMBTSMonAlg, 'MBTS_CoincidentTriggers', topPath = 'Tile/MBTS')
294  for postfix, tool in coinTrigArray.Tools.items():
295  triggerIdx = int( postfix.split('_').pop() )
296  trigger = triggerNames[triggerIdx]
297  tool.defineHistogram(f'CoincidentTrigger1,CoincidentTrigger2;MBTS_CoincidentTriggers_{trigger}',
298  path = 'Trigger', type='TH2F', xlabels = labelsMBTS, ylabels = labelsMBTS,
299  title = f'Run {run}: Coincident {trigger}s fired between two MBTS counters',
300  xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS,
301  ybins = numberOfMBTS, ymin = 0, ymax = numberOfMBTS)
302 
303  # 26) Configure histogram with BCID difference between trigger and Event BCID
304  deltaBCIDSummaryArray = helper.addArray([len(triggerNames)], tileMBTSMonAlg, 'MBTS_DeltaBCID_Summary', topPath = 'Tile/MBTS')
305  for postfix, tool in deltaBCIDSummaryArray.Tools.items():
306  triggerIdx = int( postfix.split('_').pop() )
307  trigger = triggerNames[triggerIdx]
308  tool.defineHistogram(f'TriggerCounter,DeltaBCID;MBTS_DeltaBCID_Summary_{trigger}', path = 'Trigger', type='TProfile',
309  title = f'Run {run}: BCID difference of {trigger} from Event BCID;;Average BCID delta',
310  xlabels = labelsMBTS, xbins = numberOfMBTS, xmin = 0, xmax = numberOfMBTS)
311 
312  # 27) Configure histogram with BCID difference between TBP fire and L1Accept
313  deltaBCIDArray = helper.addArray([len(triggerNames), numberOfMBTS], tileMBTSMonAlg, 'MBTS_DeltaBCID', topPath = 'Tile/MBTS')
314  for postfix, tool in deltaBCIDArray.Tools.items():
315  elements = postfix.split('_')
316  mbtsCounter = int( elements.pop() )
317  triggerIdx = int( elements.pop() )
318  mbtsName = labelsMBTS[mbtsCounter]
319  trigger = triggerNames[triggerIdx]
320  deltaBCIDTitle = f'Run {run}: {mbtsName} BCID difference of {trigger} signal'
321  deltaBCIDTitle += f';Bunch crossing between {trigger} fire and L1Accept'
322  tool.defineHistogram(f'DeltaBCID;MBTS_DeltaBCID_{trigger}_{mbtsName}', path = 'Trigger', type='TH1F',
323  title = deltaBCIDTitle, xbins = 19, xmin = -9.5, xmax = 9.5)
324 
325  # 27.2) Configure histogram with BCID of MBTS signals
326  bcidArray = helper.addArray([len(triggerNames), numberOfMBTS], tileMBTSMonAlg, 'MBTS_BCID', topPath = 'Tile/MBTS')
327  for postfix, tool in bcidArray.Tools.items():
328  elements = postfix.split('_')
329  mbtsCounter = int( elements.pop() )
330  triggerIdx = int( elements.pop() )
331  mbtsName = labelsMBTS[mbtsCounter]
332  trigger = triggerNames[triggerIdx]
333  bcidTitle = f'Run {run}: {mbtsName} BCID of {trigger} signal;BCID'
334  tool.defineHistogram(f'MBTS_BCID;MBTS_BCID_{trigger}_{mbtsName}', path = 'Trigger', type='TH1F',
335  title = bcidTitle, xbins = 3565, xmin = -0.5, xmax = 3564.5)
336 
337  # 28) Configure histogram with MBTS counter energy with TBP fired
338  energyTrigArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileEnergyTrigMBTS', topPath = 'Tile/MBTS')
339  for postfix, tool in energyTrigArray.Tools.items():
340  mbtsCounter = int( postfix.split('_')[1] )
341  mbtsName = labelsMBTS[mbtsCounter]
342  title = f'Run {run}: Energy with TBP fired of {mbtsName};Energy [pC]'
343  name = f'Energy;Energy_TBP_{mbtsName}'
344  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Cell',
345  xbins = nEnergyBins, xmin = -0.5, xmax = maxEnergy)
346 
347  # 29) Configure histogram with MBTS counter energy vs luminosity block with TBP fired
348  energyTrigLBArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileEnergyTrigLBMBTS', topPath = 'Tile/MBTS')
349  for postfix, tool in energyTrigLBArray.Tools.items():
350  mbtsCounter = int( postfix.split('_')[1] )
351  mbtsName = labelsMBTS[mbtsCounter]
352  title = f'Run {run}: Energy with TBP fired of {mbtsName} per lumiblock;Lumiblocks;Energy [pC]'
353  name = f'lumiBlock,Energy;EnergyLB_TBP_{mbtsName}'
354  tool.defineHistogram(name, title = title, type = 'TProfile', path = 'Cell',
355  xbins = 1000, xmin = -0.5, xmax = 999.5, opt = 'kAddBinsDynamically', merge = 'merge')
356 
357  # 30) Configure histogram with MBTS counter time with TBP
358  timeTrigArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileTimeTrigMBTS', topPath = 'Tile/MBTS')
359  for postfix, tool in timeTrigArray.Tools.items():
360  mbtsCounter = int( postfix.split('_')[1] )
361  mbtsName = labelsMBTS[mbtsCounter]
362  title = f'Run {run}: Time with TBP fired of {mbtsName};Time [ns]'
363  name = f'Time;Time_TBP_{mbtsName}'
364  tool.defineHistogram(name, title = title, type = 'TH1F', path = 'Cell',
365  xbins = 151, xmin = -75.5, xmax = 75.5)
366 
367  # 31) Configure histogram with efficiency of MBTS counter with TBP
368  efficiencyTrigArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileEfficiencyTrigMBTS', topPath = 'Tile/MBTS')
369  for postfix, tool in efficiencyTrigArray.Tools.items():
370  mbtsCounter = int( postfix.split('_')[1] )
371  mbtsName = labelsMBTS[mbtsCounter]
372  title = f'Run {run}: Efficiency of LVL1 vs readout {mbtsName}'
373  title += ';Energy [pc];Fraction of events with TBP'
374  name = f'Energy,Efficiency;Efficiency_TBP_{mbtsName}'
375  tool.defineHistogram(name, title = title, type = 'TProfile', path = 'Cell',
376  xbins = 100, xmin = -0.55, xmax = 9.55)
377 
378  # 32) Configure histogram with average pulse shape of MBTS counter with TBP
379  averageTrigPulseArray = helper.addArray([numberOfMBTS], tileMBTSMonAlg, 'TileAveragePulseTrigMBTS', topPath = 'Tile/MBTS')
380  for postfix, tool in averageTrigPulseArray.Tools.items():
381  mbtsCounter = int( postfix.split('_')[1] )
382  mbtsName = labelsMBTS[mbtsCounter]
383  title = f'Run {run}: Average Pulse with TBP fired for digitized signals of {mbtsName}'
384  title += ';TileCal Digital Sample;Average number of ADC counts'
385  name = f'SampleNumbers,Samples;AveragePulse_TBP_{mbtsName}'
386  tool.defineHistogram(name, title = title, type = 'TProfile', path = 'Digit',
387  xbins = 7, xmin = -0.5, xmax = 6.5)
388 
389  accumalator = helper.result()
390  result.merge(accumalator)
391  return result
392 
393 
394 if __name__=='__main__':
395 
396  # Setup logs
397  from AthenaCommon.Logging import log
398  from AthenaCommon.Constants import INFO
399  log.setLevel(INFO)
400 
401  # Set the Athena configuration flags
402  from AthenaConfiguration.AllConfigFlags import initConfigFlags
403  from AthenaConfiguration.TestDefaults import defaultTestFiles
404  flags = initConfigFlags()
405  flags.Input.Files = defaultTestFiles.ESD_RUN2_MC
406  flags.Output.HISTFileName = 'TileMBTSMonitorOutput.root'
407  flags.DQ.useTrigger = False
408  flags.DQ.enableLumiAccess = False
409  flags.Exec.MaxEvents = 3
410  flags.fillFromArgs()
411  flags.lock()
412 
413  # Initialize configuration object, add accumulator, merge, and run.
414  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
415  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
416  cfg = MainServicesCfg(flags)
417  cfg.merge(PoolReadCfg(flags))
418 
419  cfg.merge( TileMBTSMonitoringConfig(flags, FillHistogramsPerMBTS = True) )
420 
421  cfg.printConfig(withDetails = True, summariseProps = True)
422  flags.dump()
423 
424  cfg.store( open('TileMBTSMonitorAlgorithm.pkl','wb') )
425 
426  sc = cfg.run()
427 
428  import sys
429  # Success should be 0
430  sys.exit(not sc.isSuccess())
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
TileDQstatusConfig.TileDQstatusAlgCfg
def TileDQstatusAlgCfg(flags, **kwargs)
Definition: TileDQstatusConfig.py:31
TileMBTSMonitorAlgorithm.TileMBTSMonitoringConfig
def TileMBTSMonitoringConfig(flags, **kwargs)
Definition: TileMBTSMonitorAlgorithm.py:10
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
LArGMConfig.LArGMCfg
def LArGMCfg(flags)
Definition: LArGMConfig.py:8
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
str
Definition: BTagTrackIpAccessor.cxx:11
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
python.TileCablingSvcConfig.TileCablingSvcCfg
def TileCablingSvcCfg(flags)
Definition: TileCablingSvcConfig.py:11
TileGMConfig.TileGMCfg
def TileGMCfg(flags)
Definition: TileGMConfig.py:7