ATLAS Offline Software
CpmMonitorAlgorithm.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 #
4 def CpmMonitoringConfig(inputFlags):
5  '''Function to configure LVL1 Cpm algorithm in the monitoring system.'''
6 
7  import math
8  labelDebug = False
9  # get the component factory - used for getting the algorithms
10  from AthenaConfiguration.ComponentFactory import CompFactory
11  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
12  result = ComponentAccumulator()
13 
14  # make the athena monitoring helper
15  from AthenaMonitoring import AthMonitorCfgHelper
16  helper = AthMonitorCfgHelper(inputFlags,'CpmMonitoringCfg')
17 
18  # Use metadata to check Run3 compatible trigger info is available
19  from AthenaConfiguration.AutoConfigFlags import GetFileMD
20  from AthenaConfiguration.Enums import Format
21  md = GetFileMD(inputFlags.Input.Files)
22  inputContainsRun3FormatConfigMetadata = ("metadata_items" in md and any(('TriggerMenuJson' in key) for key in md["metadata_items"].keys()))
23  if inputFlags.Input.Format is Format.POOL and not inputContainsRun3FormatConfigMetadata:
24  # No L1 menu available in the POOL file.
25  return helper.result()
26 
27  # get any algorithms
28  CpmMonAlg = helper.addAlgorithm(CompFactory.CpmMonitorAlgorithm,'CpmMonAlg')
29 
30  # add any steering
31  groupName = 'CpmMonitor' # the monitoring group name is also used for the package name
32  CpmMonAlg.PackageName = groupName
33  crates = 4
34  CpmMonAlg.s_crates = crates
35  maxSlices = 5
36  CpmMonAlg.s_maxSlices = maxSlices
37  isolBits = 5
38  CpmMonAlg.s_isolBits = isolBits
39  tobsPerCPM = 5
40  CpmMonAlg.s_tobsPerCPM = tobsPerCPM
41  maxTobsPerCmx = 70
42  CpmMonAlg.MaxTOBsPerCMX = maxTobsPerCmx
43 
44  # set up the directory structure
45  mainDir = 'L1Calo'
46  trigPath = 'CPM' # replaces m_rootDir
47  errorPath=trigPath+"/Errors/Hardware"
48  monShiftPath=errorPath
49  monExpertPath=errorPath
50  monDetailPath=errorPath+"/Detail/"
51  monCPMinputPath=trigPath+"/Input/"
52  monRoIPath=trigPath+"/Output/"
53  monCMXPath=trigPath+"_CMX/Errors/Hardware/"
54  monCMXinPath=trigPath+"_CMX/Input/"
55  monCMXoutPath=trigPath+"_CMX/Output/"
56 
57  monEventsPath=errorPath+"/Detail/"
58 
59  # add monitoring algorithm to group, with group name and main directory
60  myGroup = helper.addGroup(CpmMonAlg, groupName , mainDir)
61 
62  #
63  # CPM Towers - monCPMinputPath
64  #
65  # Trigger Tower plots - for binning see TrigT1CaloLWHistogramTool::bookPPMEmEtaVsPhi
66  etabins_2d=66
67  etamin_2d=-3.3
68  etamax_2d=3.3
69  phibins_2d=64
70  phimin_2d=0.0
71  phimax_2d=64.0
72  # Labels from TrigT1CaloLWHistogramTool::bookCPMEmEtaVsPhi
73  etalabels=[""]*66
74  for i in range(-25,25,4):
75  chan = i if i < -1 else i+1
76  eta = (chan/10.)+0.05
77  etalabels[chan+33] = f"{chan}/{eta:.2f}"
78  for i in range(8):
79  etalabels[i] = "+"
80  etalabels[i+58] = "+"
81  philabels=[""]*64
82  for chan in range(0,64,4):
83  rad = (chan+.5)*math.pi/32
84  philabels[chan] = f"{chan}/{rad:.2f}"
85  philabels[63] = "etaVphi"
86  # for 2D histograms x,y;histogram alias
87  myGroup.defineHistogram('etaTT,phiTT;ppm_em_2d_etaPhi_tt_Hitmap',title='PPM Trigger Tower EM eta/phi;Tower #eta; Tower #phi',type='TH2F',
88  cutmask='mask_em_TT',path=monCPMinputPath,
89  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
90  myGroup.defineHistogram('etaTT,phiTT;ppm_had_2d_etaPhi_tt_Hitmap',title='PPM Trigger Tower HAD eta/phi;Tower #eta; Tower #phi',type='TH2F',
91  cutmask='mask_had_TT',path=monCPMinputPath,
92  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
93 
94  # CPMTower plots
95  maxEnergyRange = 256 # Maximum energy plotted
96  # EM 1d
97  myGroup.defineHistogram('etCpmTT_em;cpm_em_1d_tt_Et', title='CPM Tower EM Et;CPM Tower EM Energy;',
98  cutmask='',path=monCPMinputPath,xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange)
99  myGroup.defineHistogram('etaCpmTT_em;cpm_em_1d_tt_Eta', title='CPM Tower EM eta;CPM Tower EM #eta;',
100  cutmask='',path=monCPMinputPath,xbins=50,xmin=-2.5,xmax=2.5)
101  myGroup.defineHistogram('phiCpmTT_em;cpm_em_1d_tt_Phi', title='CPM Tower EM phi;CPM Tower EM #phi;',
102  cutmask='',path=monCPMinputPath,xbins=64,xmin=0,xmax=2*math.pi)
103  # EM 2d
104  myGroup.defineHistogram('etaCpmTT_em,phiScaledCpmTT_em;cpm_em_2d_etaPhi_tt_Hitmap',
105  title='CPM Tower EM eta/phi;Tower #eta; Tower #phi',type='TH2F',
106  cutmask='',path=monCPMinputPath,
107  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
108  xlabels=etalabels,ylabels=philabels,
109  opt='kAlwaysCreate' if labelDebug else '')
110  myGroup.defineHistogram('etaCpmTT_em,phiScaledCpmTT_em;cpm_em_2d_etaPhi_tt_EtWeighted',
111  title='CPM Tower EM eta/phi weighted;Tower #eta; Tower #phi',type='TH2F',
112  cutmask='',path=monCPMinputPath,
113  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d, weight="etCpmTT_em")
114  # 2d errors monDetailPath
115  myGroup.defineHistogram('GLinkParityError,cpmLoc;cpm_2d_Status',
116  title='CPM Sub-status bits;;',type='TH2F',
117  cutmask='',path=monDetailPath,
118  xbins=8,xmin=0.,xmax=8.0,ybins=56,ymin=0.,ymax=56.0)
119 
120 
121  # HAD 1d
122  myGroup.defineHistogram('etCpmTT_had;cpm_had_1d_tt_Et', title='CPM Tower HAD Et;CPM Tower HAD Energy;',
123  cutmask='',path=monCPMinputPath,xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange)
124  myGroup.defineHistogram('etaCpmTT_had;cpm_had_1d_tt_Eta', title='CPM Tower HAD eta;CPM Tower HAD #eta;',
125  cutmask='',path=monCPMinputPath,xbins=50,xmin=-2.5,xmax=2.5)
126  myGroup.defineHistogram('phiCpmTT_had;cpm_had_1d_tt_Phi', title='CPM Tower HAD phi;CPM Tower HAD #phi;',
127  cutmask='',path=monCPMinputPath,xbins=64,xmin=0,xmax=2*math.pi)
128  # HAD 2d
129  myGroup.defineHistogram('etaCpmTT_had,phiScaledCpmTT_had;cpm_had_2d_etaPhi_tt_Hitmap',
130  title='CPM Tower HAD eta/phi;Tower #eta; Tower #phi',type='TH2F',
131  cutmask='',path=monCPMinputPath,
132  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
133  xlabels=etalabels,ylabels=philabels,
134  opt='kAlwaysCreate' if labelDebug else '')
135  myGroup.defineHistogram('etaCpmTT_had,phiScaledCpmTT_had;cpm_had_2d_etaPhi_tt_EtWeighted'
136  ,title='CPM Tower HAD eta/phi weighted;Tower #eta; Tower #phi',type='TH2F',
137  cutmask='',path=monCPMinputPath,
138  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d, weight="etCpmTT_had")
139 
140  xbinshist = int(crates * maxSlices)
141  myGroup.defineHistogram('sliceCpmTT_tot,peakCpmTT_tot;cpm_2d_tt_Slices'
142  ,title='CPM Slices and Triggered Slice;Crate/Number of Slices;Triggered Slice',type='TH2F',
143  cutmask='',path=monCPMinputPath,
144  xbins=xbinshist,xmin=0,xmax=xbinshist,ybins=maxSlices,ymin=0,ymax=maxSlices)
145 
146 
147  #
148  # Errors - monDetailPath
149  #
150  # em - tot means addition of CPM and Overlap containers
151  myGroup.defineHistogram('etaCpmTT_em_tot,phiScaledCpmTT_em_tot;cpm_em_2d_etaPhi_tt_Parity'
152  ,title='CPM Tower EM Parity Errors;Tower #eta; Tower #phi',type='TH2F',
153  cutmask='parityErrorCpmTT_em',path=monDetailPath,
154  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
155  myGroup.defineHistogram('etaCpmTT_em_tot,phiScaledCpmTT_em_tot;cpm_em_2d_etaPhi_tt_LinkDown',
156  title='CPM Tower EM Link Down Errors;Tower #eta; Tower #phi',type='TH2F',
157  cutmask='linkDownErrorCpmTT_em',path=monDetailPath,
158  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
159 
160  # had
161  myGroup.defineHistogram('etaCpmTT_had_tot,phiScaledCpmTT_had_tot;cpm_had_2d_etaPhi_tt_Parity',
162  title='CPM Tower HAD Parity Errors;Tower #eta; Tower #phi',type='TH2F',
163  cutmask='parityErrorCpmTT_had',path=monDetailPath,
164  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
165  myGroup.defineHistogram('etaCpmTT_had_tot,phiScaledCpmTT_had_tot;cpm_had_2d_etaPhi_tt_LinkDown',
166  title='CPM Tower HAD Link Down Errors;Tower #eta; Tower #phi',type='TH2F',
167  cutmask='linkDownErrorCpmTT_had',path=monDetailPath,
168  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d)
169 
170 
171  #
172  # CPM TOB RoIs - monRoIPath
173  #
174  # Labels from TrigT1CaloLWHistogramTool::bookCPMRoIEtaVsPhi
175  etalabels_roi=[""]*66
176  for chan in range(-24,26,4):
177  eta = (chan/10.)
178  etalabels_roi[chan+32] = f"{chan}/{eta:.2f}"
179  for i in range(8):
180  etalabels_roi[i] = "+"
181  etalabels_roi[i+58] = "+"
182  philabels_roi=[""]*64
183  for chan in range(0,64,4):
184  rad = (chan+1)*math.pi/32
185  philabels_roi[chan] = f"{chan}/{rad:.2f}"
186  philabels_roi[63] = "etaVphi"
187  isolRange=32 # Maximum range for encoded isolation
188  myGroup.defineHistogram('energyTobRoIsEner;cpm_1d_roi_EnergyEm', title='CPM TOB RoI Cluster Energy EM;Cluster Energy;',
189  cutmask='mask_tobroi_ener_em',path=monRoIPath,
190  xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange,
191  opt='kAlwaysCreate' if labelDebug else '')
192  myGroup.defineHistogram('energyTobRoIsEner;cpm_1d_roi_EnergyTau', title='CPM TOB RoI Cluster Energy Tau;Cluster Energy;',
193  cutmask='mask_tobroi_ener_tau',path=monRoIPath,
194  xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange,
195  opt='kAlwaysCreate' if labelDebug else '')
196 
197  myGroup.defineHistogram('energyTobRoIsIsol;cpm_1d_roi_IsolationEm', title='CPM TOB RoI Encoded Isolation Value EM;;',
198  cutmask='mask_tobroi_isol_em',path=monRoIPath,
199  xbins=isolRange,xmin=0,xmax=isolRange)
200  myGroup.defineHistogram('energyTobRoIsIsol;cpm_1d_roi_IsolationTau', title='CPM TOB RoI Encoded Isolation Value Tau;;',
201  cutmask='mask_tobroi_isol_tau',path=monRoIPath,
202  xbins=isolRange,xmin=0,xmax=isolRange)
203 
204 
205  # bit masks
206  myGroup.defineHistogram('bitsTobRoIsIsolEm;cpm_1d_roi_IsolationBitsEm', title='CPM TOB RoI Encoded Isolation Bits EM;Bit;',
207  cutmask='',path=monRoIPath,
208  xbins=isolBits,xmin=0,xmax=isolBits, weight="bitsTobRoIsIsolEmWeight")
209 
210  #
211  myGroup.defineHistogram('bitsTobRoIsIsolTau;cpm_1d_roi_IsolationBitsTau', title='CPM TOB RoI Encoded Isolation Bits Tau;Bit;',
212  cutmask='',path=monRoIPath,
213  xbins=isolBits,xmin=0,xmax=isolBits, weight="bitsTobRoIsIsolTauWeight")
214 
215  # 2D
216  # isolation
217  myGroup.defineHistogram('etaTobRoIsIsol,phiTobRoIsIsol;cpm_2d_etaPhi_roi_HitmapIsolEm',
218  title='CPM TOB RoIs EM Non-zero Isolation Hit Map;Tower #eta; Tower #phi',type='TH2F',
219  cutmask='mask_tobroi_isol_em',path=monRoIPath,
220  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
221  xlabels=etalabels_roi,ylabels=philabels_roi,
222  opt='kAlwaysCreate' if labelDebug else '')
223  myGroup.defineHistogram('etaTobRoIsIsol,phiTobRoIsIsol;cpm_2d_etaPhi_roi_HitmapIsolTau',
224  title='CPM TOB RoIs Tau Non-zero Isolation Hit Map;Tower #eta; Tower #phi',type='TH2F',
225  cutmask='mask_tobroi_isol_tau',path=monRoIPath,
226  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
227  xlabels=etalabels_roi,ylabels=philabels_roi,
228  opt='kAlwaysCreate' if labelDebug else '')
229 
230  # energy
231  myGroup.defineHistogram('etaTobRoIsEner,phiTobRoIsEner;cpm_2d_etaPhi_roi_HitmapEm',
232  title='CPM TOB RoIs EM Hit Map;Tower #eta; Tower #phi',type='TH2F',
233  cutmask='mask_tobroi_ener_em',path=monRoIPath,
234  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
235  xlabels=etalabels_roi,ylabels=philabels_roi,
236  opt='kAlwaysCreate' if labelDebug else '')
237  myGroup.defineHistogram('etaTobRoIsEner,phiTobRoIsEner;cpm_2d_etaPhi_roi_EtWeightedEm',
238  title='CPM TOB RoIs EM Weighted by Energy;Tower #eta; Tower #phi',type='TH2F',
239  cutmask='mask_tobroi_ener_em',path=monRoIPath,
240  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d, weight="energyTobRoIsEner",
241  xlabels=etalabels_roi,ylabels=philabels_roi,
242  opt='kAlwaysCreate' if labelDebug else '')
243 
244  myGroup.defineHistogram('etaTobRoIsEner,phiTobRoIsEner;cpm_2d_etaPhi_roi_HitmapTau',
245  title='CPM TOB RoIs Tau Hit Map;Tower #eta; Tower #phi',type='TH2F',
246  cutmask='mask_tobroi_ener_tau',path=monRoIPath,
247  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d,
248  xlabels=etalabels_roi,ylabels=philabels_roi,
249  opt='kAlwaysCreate' if labelDebug else '')
250  myGroup.defineHistogram('etaTobRoIsEner,phiTobRoIsEner;cpm_2d_etaPhi_roi_EtWeightedTau',
251  title='CPM TOB RoIs Tau Weighted by Energy;Tower #eta; Tower #phi',type='TH2F',
252  cutmask='mask_tobroi_ener_tau',path=monRoIPath,
253  xbins=etabins_2d,xmin=etamin_2d,xmax=etamax_2d,ybins=phibins_2d,ymin=phimin_2d,ymax=phimax_2d, weight="energyTobRoIsEner",
254  xlabels=etalabels_roi,ylabels=philabels_roi,
255  opt='kAlwaysCreate' if labelDebug else '')
256 
257  # TOBs per CPM
258  myGroup.defineHistogram('tobPerCPMEm;cpm_1d_roi_TOBsPerCPMEm', title='CPM TOB RoI TOBs per CPM EM;Number of TOBs;',
259  cutmask='',path=monRoIPath,
260  xbins=tobsPerCPM+1,xmin=1,xmax=tobsPerCPM+2)
261  myGroup.defineHistogram('tobPerCPMTau;cpm_1d_roi_TOBsPerCPMTau', title='CPM TOB RoI TOBs per CPM Tau;Number of TOBs;',
262  cutmask='',path=monRoIPath,
263  xbins=tobsPerCPM+1,xmin=1,xmax=tobsPerCPM+2)
264 
265  #
266  # CMX-CP TOBs - monCMXinPath
267  #
268  myGroup.defineHistogram('cmxCpmTobsEnerLeft;cmx_1d_tob_EnergyLeft', title='CMX-CP TOBs Cluster Energy Left CMX',
269  cutmask='',path=monCMXinPath,
270  xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange)
271  myGroup.defineHistogram('cmxCpmTobsEnerRight;cmx_1d_tob_EnergyRight', title='CMX-CP TOBs Cluster Energy Right CMX',
272  cutmask='',path=monCMXinPath,
273  xbins=maxEnergyRange,xmin=0,xmax=maxEnergyRange)
274  myGroup.defineHistogram('cmxCpmTobsLeft;cmx_1d_tob_TOBsPerCPMLeft', title='CMX-CP TOBs per CPM Left CMX;Number of TOBs;',
275  cutmask='',path=monCMXinPath,
276  xbins=tobsPerCPM+1,xmin=1,xmax=tobsPerCPM+2,
277  opt='kAlwaysCreate' if labelDebug else '')
278  myGroup.defineHistogram('cmxCpmTobsRight;cmx_1d_tob_TOBsPerCPMRight', title='CMX-CP TOBs per CPM Right CMX;Number of TOBs;',
279  cutmask='',path=monCMXinPath,
280  xbins=tobsPerCPM+1,xmin=1,xmax=tobsPerCPM+2,
281  opt='kAlwaysCreate' if labelDebug else '')
282 
283  #
284  myGroup.defineHistogram('cmxCpmTobsIsolLeft;cmx_1d_tob_IsolationLeft', title='CMX-CP TOBs Encoded Isolation Value Left CMX;;',
285  cutmask='', path=monCMXinPath,
286  xbins=isolRange,xmin=0,xmax=isolRange)
287  myGroup.defineHistogram('cmxCpmTobsIsolRight;cmx_1d_tob_IsolationRight', title='CMX-CP TOBs Encoded Isolation Value Right CMX;;',
288  cutmask='', path=monCMXinPath,
289  xbins=isolRange,xmin=0,xmax=isolRange)
290  # isolation Bits
291  myGroup.defineHistogram('cmxCpmTobsIsolBitsLeft;cmx_1d_tob_IsolationBitsLeft',
292  title='CMX-CP TOBs Encoded Isolation Bits Left CMX;Bit;',
293  cutmask='', path=monCMXinPath, xbins=isolBits,xmin=0,xmax=isolBits,weight='cmxCpmTobsIsolBitsLeftWeight')
294  myGroup.defineHistogram('cmxCpmTobsIsolBitsRight;cmx_1d_tob_IsolationBitsRight',
295  title='CMX-CP TOBs Encoded Isolation Bits Right CMX;Bit;',
296  cutmask='', path=monCMXinPath, xbins=isolBits,xmin=0,xmax=isolBits,weight='cmxCpmTobsIsolBitsRightWeight')
297 
298  # Energy
299  myGroup.defineHistogram('cmxCpmTobsEnerXLeft,cmxCpmTobsEnerYLeft;cmx_2d_tob_HitmapLeft',
300  title='CMX-CP TOBs Left CMX Hit Map',type='TH2F',
301  cutmask='',path=monCMXinPath,
302  xbins=56,xmin=0.,xmax=56.0,ybins=64,ymin=0.,ymax=64.)
303  myGroup.defineHistogram('cmxCpmTobsEnerXRight,cmxCpmTobsEnerYRight;cmx_2d_tob_HitmapRight',
304  title='CMX-CP TOBs Right CMX Hit Map',type='TH2F',
305  cutmask='',path=monCMXinPath,
306  xbins=56,xmin=0.,xmax=56.0,ybins=64,ymin=0.,ymax=64.)
307 
308  #
309  myGroup.defineHistogram('cmxCpmTobsIsolXLeft,cmxCpmTobsIsolYLeft;cmx_2d_tob_HitmapIsolLeft',
310  title='CMX-CP TOBs Left CMX Non-zero Isolation Hit Map',type='TH2F',
311  cutmask='',path=monCMXinPath,
312  xbins=56,xmin=0.,xmax=56.0,ybins=64,ymin=0.,ymax=64.)
313  myGroup.defineHistogram('cmxCpmTobsIsolXRight,cmxCpmTobsIsolYRight;cmx_2d_tob_HitmapIsolRight',
314  title='CMX-CP TOBs Right CMX Non-zero Isolation Hit Map',type='TH2F',
315  cutmask='',path=monCMXinPath,
316  xbins=56,xmin=0.,xmax=56.0,ybins=64,ymin=0.,ymax=64.)
317 
318  # error overflow
319  myGroup.defineHistogram('cmxCpmTobsErrorX,cmxCpmTobsErrorCmx;cmx_2d_tob_Overflow',
320  title='CMX-CP TOBs Overflow',type='TH2F',
321  cutmask='',path=monCMXinPath,
322  xbins=56,xmin=0.,xmax=56.0,ybins=2,ymin=0.,ymax=2.)
323 
324 
325  #
326  myGroup.defineHistogram('cmxTobsCmxLeft;cmx_1d_tob_TOBsPerCMXLeft', title='CMX-CP TOBs per CMX Left;Number of TOBs;',
327  cutmask='',path=monCMXinPath,
328  xbins=maxTobsPerCmx,xmin=0,xmax=maxTobsPerCmx)
329  myGroup.defineHistogram('cmxTobsCmxRight;cmx_1d_tob_TOBsPerCMXRight', title='CMX-CP TOBs per CMX Right;Number of TOBs;',
330  cutmask='',path=monCMXinPath,
331  xbins=maxTobsPerCmx,xmin=0,xmax=maxTobsPerCmx)
332 
333 
334  # CMX error bits
335  myGroup.defineHistogram('cmxCpmTobsErrorX,cmxCpmTobsErrorYbase;cmx_2d_tob_Parity',
336  title='CMX-CP TOB Parity Errors;;CMX/Phase',type='TH2F',
337  cutmask='cmxCpmTobsErrorParity',path=monCMXPath,
338  xbins=56,xmin=0.,xmax=56.0,ybins=10,ymin=0.,ymax=10.)
339 
340  #
341  # CMX-CP Hits
342  #
343  xbinsThresh = crates * maxSlices
344  myGroup.defineHistogram('cmxCpHitsCrateSlices,cmxCpHitsPeak;cmx_2d_thresh_Slices',
345  title='CMX Slices and Triggered Slice;Crate/Number of Slices;Triggered Slice',type='TH2F',
346  cutmask='',path=monCMXoutPath,
347  xbins=xbinsThresh,xmin=0.,xmax=xbinsThresh,ybins=maxSlices,ymin=0.,ymax=maxSlices)
348 
349  #
350  myGroup.defineHistogram('cmxCpHitsCrateCmx;cmx_1d_topo_OutputChecksum', title='CMX-CP Topo Output Checksum Non-zero',
351  cutmask='cmxCpHits0TopoCheckSum',path=monCMXoutPath,
352  xbins=8,xmin=0,xmax=8)
353  #
354  myGroup.defineHistogram('cmxCpMapX,cmxCpMapY;cmx_2d_topo_CPMOccupancyMap',
355  title="CMX-CP Topo CPM Occupancy Maps;;",type='TH2F',
356  cutmask='',path=monCMXoutPath,
357  xbins=14,xmin=1.,xmax=15.0,ybins=8,ymin=0.,ymax=8.0,weight='cmxCpMapHit')
358 
359  myGroup.defineHistogram('cmxCpCountsX,cmxCpCountsY;cmx_2d_topo_CPMOccupancyCounts',
360  title="CMX-CP Topo CPM Occupancy Counts Weighted;;",type='TH2F',
361  cutmask='',path=monCMXoutPath,
362  xbins=14,xmin=1.,xmax=15.0,ybins=8,ymin=0.,ymax=8.0,weight='cmxCpCountsHit')
363 
364  # labels from TrigT1CaloLWHistogramTool::numbers
365  number_labels=[f'{i+1}' if i < tobsPerCPM else '' for i in range(7)]
366  #
367  myGroup.defineHistogram('cmxTopoTobsCpmRight;cmx_1d_topo_TOBsPerCPMRight', title='CMX-CP Topo TOBs per CPM Right CMX;Number of TOBs',
368  cutmask='',path=monCMXoutPath,
369  xbins=7,xmin=1,xmax=8,
370  xlabels=number_labels,
371  opt='kAlwaysCreate' if labelDebug else '')
372  myGroup.defineHistogram('cmxTopoTobsCpmLeft;cmx_1d_topo_TOBsPerCPMLeft', title='CMX-CP Topo TOBs per CPM Left CMX;Number of TOBs',
373  cutmask='',path=monCMXoutPath,
374  xbins=7,xmin=1,xmax=8,
375  xlabels=number_labels,
376  opt='kAlwaysCreate' if labelDebug else '')
377 
378  #
379  # X labels from TrigT1CaloLWHistogramTool::bookCPMSumVsThreshold
380  sumvsthreshold_labels = ["L0","L1","L2","L3","R0","R1","R2","T"]
381  # Trigger threshold labels from menu
382  from TrigConfigSvc.TriggerConfigAccess import getL1MenuAccess
383  l1menu = getL1MenuAccess(inputFlags)
384  emThresholdNames = list(l1menu.thresholdNames('EM'))
385  #
386  myGroup.defineHistogram('cmxCpThresBinLeftX,cmxCpThresBinLeftY;cmx_2d_thresh_SumsWeightedLeft',
387  title="CMX-CP Hit Sums Thresholds Weighted Left CMX;Sum (Local/Remote/Total);",type='TH2F',
388  cutmask='',path=monCMXoutPath,
389  xbins=8,xmin=0.,xmax=8.0,ybins=16,ymin=0.,ymax=16.0,weight='cmxCpThresBinLeftHit',
390  xlabels=sumvsthreshold_labels, ylabels=emThresholdNames,
391  opt='kAlwaysCreate' if labelDebug else '')
392  myGroup.defineHistogram('cmxCpThresBinRightX,cmxCpThresBinRightY;cmx_2d_thresh_SumsWeightedRight',
393  title="CMX-CP Hit Sums Thresholds Weighted Right CMX;Sum (Local/Remote/Total);",type='TH2F',
394  cutmask='',path=monCMXoutPath,
395  xbins=8,xmin=0.,xmax=8.0,ybins=16,ymin=0.,ymax=16.0,weight='cmxCpThresBinRightHit',
396  xlabels=sumvsthreshold_labels, ylabels=emThresholdNames,
397  opt='kAlwaysCreate' if labelDebug else '')
398 
399  #
400  myGroup.defineHistogram('cmxCpTopoTobsCmxLeft;cmx_1d_topo_TOBsPerCMXLeft', title='CMX-CP Topo TOBs per CMX Left;Number of TOBs;',
401  cutmask='',path=monCMXoutPath,
402  xbins=maxTobsPerCmx,xmin=0,xmax=maxTobsPerCmx,
403  opt='kAlwaysCreate' if labelDebug else '')
404  myGroup.defineHistogram('cmxCpTopoTobsCmxRight;cmx_1d_topo_TOBsPerCMXRight', title='CMX-CP Topo TOBs per CMX Right;Number of TOBs;',
405  cutmask='',path=monCMXoutPath,
406  xbins=maxTobsPerCmx,xmin=0,xmax=maxTobsPerCmx,
407  opt='kAlwaysCreate' if labelDebug else '')
408 
409 
410  #
411  # Error Overview and Summary
412  #
413  NumberOfSummaryBins=8
414  errorOverview_labels = [ "EM parity","EM link""Had parity","Had link","CPM status","TOB parity","Sum parity","CMX status"]
415 
416  # 2d overview to expert path
417  myGroup.defineHistogram('cpmErrorX,cpmErrorY;cpm_2d_ErrorOverview',
418  title="CP Error Overview;;",type='TH2F',
419  path=monExpertPath,
420  xbins=64,xmin=0.,xmax=64.0,ybins=NumberOfSummaryBins,ymin=0.,ymax=NumberOfSummaryBins,ylabels=errorOverview_labels)
421 
422  # 1d summary to shiftpath
423  myGroup.defineHistogram('cpmErrorSummary;cpm_1d_ErrorSummary', title='CP Error Summary;;Events',
424  path=monShiftPath,
425  xbins=NumberOfSummaryBins,xmin=0,xmax=NumberOfSummaryBins,xlabels=errorOverview_labels)
426 
427  # event numbers
428  myGroup.defineHistogram('evtstr,cpmErrorSummary_Events;cpm_2d_ErrorEventNumbers',
429  title="CP Error Event Numbers;Events with Error/Mismatch;",type='TH2I',
430  path=monEventsPath,merge='merge',
431  xbins=1,ymin=0,ymax=NumberOfSummaryBins,ylabels=errorOverview_labels)
432 
433  acc = helper.result()
434  result.merge(acc)
435  return result
436 
437 
438 if __name__=='__main__':
439  # set input file and config options
440  from AthenaConfiguration.AllConfigFlags import initConfigFlags
441  import glob
442 
443  inputs = glob.glob('/eos/atlas/atlastier0/rucio/data18_13TeV/physics_Main/00354311/data18_13TeV.00354311.physics_Main.recon.ESD.f1129/data18_13TeV.00354311.physics_Main.recon.ESD.f1129._lb0013._SFO-8._0001.1')
444 
445  flags = initConfigFlags()
446  flags.Input.Files = inputs
447  flags.Output.HISTFileName = 'ExampleMonitorOutput_LVL1.root'
448 
449  flags.lock()
450  flags.dump() # print all the configs
451 
452  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
453  from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
454  cfg = MainServicesCfg(flags)
455  cfg.merge(PoolReadCfg(flags))
456 
457  CpmMonitorCfg = CpmMonitoringConfig(flags)
458  cfg.merge(CpmMonitorCfg)
459 
460  # message level for algorithm
461  CpmMonitorCfg.getEventAlgo('CpmMonAlg').OutputLevel = 2 # 1/2 INFO/DEBUG
462  # options - print all details of algorithms, very short summary
463  cfg.printConfig(withDetails=False, summariseProps = True)
464 
465  nevents=-1
466  cfg.run(nevents)
467 
468 
469 
470 
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True)
Definition: AutoConfigFlags.py:51
python.TriggerConfigAccess.getL1MenuAccess
L1MenuAccess getL1MenuAccess(flags=None)
Definition: TriggerConfigAccess.py:129
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:256
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
python.PoolReadConfig.PoolReadCfg
def PoolReadCfg(flags)
Definition: PoolReadConfig.py:69
CpmMonitorAlgorithm.CpmMonitoringConfig
def CpmMonitoringConfig(inputFlags)
Definition: CpmMonitorAlgorithm.py:4