ATLAS Offline Software
LArFEBMonAlg.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 #
3 
4 def LArFEBMonConfig(flags, cellDebug=False, dspDebug=False):
5  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6  from AthenaMonitoring import AthMonitorCfgHelper
7  helper = AthMonitorCfgHelper(flags,'LArFEBMonAlgCfg')
8 
9  from AthenaConfiguration.ComponentFactory import CompFactory
10  LArFEBMonConfigCore(helper, CompFactory.LArFEBMonAlg,flags,cellDebug, dspDebug)
11 
13 
14  # adding LArFebErrorSummary algo
15  from LArROD.LArFebErrorSummaryMakerConfig import LArFebErrorSummaryMakerCfg
16  rv.merge(LArFebErrorSummaryMakerCfg(flags))
17 
18  rv.merge(helper.result())
19 
20  return rv
21 
22 def LArFEBMonConfigCore(helper,algoinstance,flags, cellDebug=False, dspDebug=False):
23 
24  from LArMonitoring.GlobalVariables import lArDQGlobals
25 
26  larFEBMonAlg = helper.addAlgorithm(algoinstance,'larFEBMonAlg')
27 
28  GroupName="FEBMon"
29  nslots=[]
30  for i in range(0,len(lArDQGlobals.FEB_Slot)):
31  nslots.append(lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[i]][1])
32 
33  larFEBMonAlg.MonGroup=GroupName
34  larFEBMonAlg.PartitionNames=lArDQGlobals.Partitions
35  larFEBMonAlg.SubDetNames=lArDQGlobals.SubDet
36  larFEBMonAlg.Streams=lArDQGlobals.defaultStreamNames
37 
38  isCOMP200="COMP200" in flags.IOVDb.DatabaseInstance
39 
40  if not isCOMP200:
41  dbString="<db>COOLONL_LAR/CONDBR2</db>"
42  persClass="AthenaAttributeList"
43  fld="/LAR/Configuration/DSPThresholdFlat/Thresholds"
44  havethem=False
45  for c in helper.resobj.getServices():
46  if c.getName()=="IOVDbSvc":
47  iovDbSvc=c
48  condLoader=helper.resobj.getCondAlgo("CondInputLoader")
49  havethem=True
50  break
51 
52  if not havethem:
53  from IOVDbSvc.IOVDbSvcConfig import IOVDbSvcCfg
54  helper.resobj.merge(IOVDbSvcCfg(flags))
55  condLoader=helper.resobj.getCondAlgo("CondInputLoader")
56  iovDbSvc=helper.resobj.getService("IOVDbSvc")
57 
58  iovDbSvc.Folders.append(fld+dbString)
59  condLoader.Load.add((persClass,fld))
60  larFEBMonAlg.Run2DSPThresholdsKey = fld
61  else:
62  fld='/LAR/Configuration/DSPThreshold/Thresholds'
63  db='LAR_ONL'
64  obj='LArDSPThresholdsComplete'
65  from IOVDbSvc.IOVDbSvcConfig import addFolders
66  helper.resobj.merge(addFolders(flags,fld,db,obj))
67  larFEBMonAlg.Run1DSPThresholdsKey = 'LArDSPThresholds'
68 
69 
70  Group = helper.addGroup(
71  larFEBMonAlg,
72  GroupName,
73  '/LAr/'+GroupName+'/'
74  )
75 
76 
77  #Summary histos
78  summary_hist_path='Summary/'
79 
80  #-- TTree for corrupted events timestamp
81  Group.defineTree('timestamp,time_ns,febHwId,febErrorType;LArCorrupted',
82  path=summary_hist_path,
83  title='Timestamps of corrupted LAr events',
84  treedef='timestamp/i:time_ns/i:febHwId/vector<int>:febErrorType/vector<int>')
85 
86  Group.defineHistogram('nbFEB;NbOfReadoutFEBGlobal',
87  title='# of readout FEB/DSP header',
88  type='TH1I',
89  path=summary_hist_path,
90  opt='kAlwaysCreate',
91  xbins=lArDQGlobals.N_FEB+11, xmin=-0.5, xmax=lArDQGlobals.N_FEB+10+0.5)
92  Group.defineHistogram('nbFEBpart,part;NbOfEvts2d',
93  title='# of readout FEB/DSP header;Num. FEBs;Partition',
94  type='TH2I',
95  path=summary_hist_path,
96  opt='kAlwaysCreate',
97  xbins=lArDQGlobals.N_FEB_Parttions_Max, xmin=-0.5, xmax=lArDQGlobals.N_FEB_Parttions_Max-0.5,
98  ybins=lArDQGlobals.N_Partitions, ymin=-0.5, ymax=lArDQGlobals.N_Partitions-0.5,
99  ylabels=lArDQGlobals.Partitions
100  )
101  Group.defineHistogram('febError,part;NbOfLArFEBMonErrors_dE',
102  title='# of data corruption errors',
103  type='TH2I',
104  path=summary_hist_path,
105  opt='kAlwaysCreate',
106  xbins=lArDQGlobals.N_FEBErrors, xmin=0.5, xmax=lArDQGlobals.N_FEBErrors+0.5,
107  ybins=lArDQGlobals.N_Partitions, ymin=-0.5, ymax=lArDQGlobals.N_Partitions-0.5,
108  xlabels=lArDQGlobals.FEBErrors, ylabels=lArDQGlobals.Partitions)
109  Group.defineHistogram('dspThrADC;dspThresholdsADC',
110  title='DSP thresholds to readout samples;Number of cells;Cell threshold in ADC counts',
111  type='TH1I',
112  path=summary_hist_path,
113  xbins=lArDQGlobals.DSPThr_Bins+1, xmin=-0.5, xmax=lArDQGlobals.DSPThr_Bins+0.5,
114  merge='identical')
115  Group.defineHistogram('dspThrQT;dspThresholds_qfactortime',
116  title='DSP thresholds to readout (qfactor+time);Number of cells;Cell threshold in ADC counts',
117  type='TH1I',
118  path=summary_hist_path,
119  xbins=lArDQGlobals.DSPThr_Bins+1, xmin=-0.5, xmax=lArDQGlobals.DSPThr_Bins+0.5,
120  merge='identical')
121  Group.defineHistogram('EvtType;Eventtype',
122  title='Event type (1st readout FEB)',
123  type='TH1I',
124  path=summary_hist_path,
125  xbins=lArDQGlobals.Evt_Bins, xmin=lArDQGlobals.Evt_Min, xmax=lArDQGlobals.Evt_Max,
126  xlabels=lArDQGlobals.Evt_labels)
127  Group.defineHistogram('LVL1Trig;TriggerWord',
128  title='Number of Events per L1 trigger word (8 bits);L1 trigger word',
129  type='TH1I',
130  path=summary_hist_path,
131  xbins=lArDQGlobals.L1Trig_Bins, xmin=lArDQGlobals.L1Trig_Min, xmax=lArDQGlobals.L1Trig_Max)
132  Group.defineHistogram('LVL1TrigAllDSP;TriggerWordAllDSP',
133  title='Number of L1 trigger word per DSP (8 bits);L1 trigger word',
134  type='TH1I',
135  path=summary_hist_path,
136  xbins=lArDQGlobals.L1Trig_Bins, xmin=lArDQGlobals.L1Trig_Min, xmax=lArDQGlobals.L1Trig_Max)
137  Group.defineHistogram('EvtRej;EventsRejected',
138  title='Nb of events rejected (at least one error)',
139  type='TH1I',
140  path=summary_hist_path,
141  xbins=lArDQGlobals.EvtRej_Bins, xmin=lArDQGlobals.EvtRej_Min, xmax=lArDQGlobals.EvtRej_Max,
142  xlabels=lArDQGlobals.EvtRej_labels)
143  Group.defineHistogram('LB0,EvtRejYield;RAW_YieldOfRejectedEventsVsLB',
144  title='Yield of corrupted events (DATACORRUPTED);Luminosity Block;Yield(%)',
145  type='TProfile',
146  path=summary_hist_path,
147  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
148  Group.defineHistogram('LB0,EvtRejYieldOut;RAW_YieldOfRejectedEventsVsLBout',
149  title='Yield of corrupted events (DATACORRUPTED) not vetoed by time window;Luminosity Block;Yield(%)',
150  type='TProfile',
151  path=summary_hist_path,
152  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
153  Group.defineHistogram('LB0,EvtOneErrorYield;RAW_YieldOfOneErrorEventsVsLB',
154  title='Yield of events with >=1 FEB in error;Luminosity Block;Yield(%)',
155  type='TProfile',
156  path=summary_hist_path,
157  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
158  Group.defineHistogram('rejBits;rejectionBits',
159  title='Errors at the origin of event rejection;Bits;Number of (rejected) events',
160  type='TH1I',
161  path=summary_hist_path,
162  xbins=lArDQGlobals.rejBits_Bins, xmin=-0.5, xmax=lArDQGlobals.rejBits_Bins-0.5)
163  Group.defineHistogram('LB0;NbOfEventsVsLB',
164  title='Nb of events per LB;Luminosity Block',
165  type='TH1I',
166  path=summary_hist_path,
167  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
168  Group.defineHistogram('NbOfSweet2;NbOfSw2',
169  title='# of cells with samples readout;Number of cells;Number of events',
170  type='TH1I',
171  path=summary_hist_path,
172  xbins=int(lArDQGlobals.N_Cells/10), xmin=-1000, xmax=lArDQGlobals.N_Cells-1000)
173  Group.defineHistogram('LB0,LArEvSize;eventSizeVsLB',
174  title='LAr event size (w/o ROS headers);Luminosity Block;Megabytes',
175  type='TProfile',
176  path=summary_hist_path,
177  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
178  Group.defineHistogram('NbOfSamp;NbOfSamples',
179  title='# of samples (1st readout FEB);Samples;Number of events',
180  type='TH1I',
181  path=summary_hist_path,
182  xbins=lArDQGlobals.Samples_Bins, xmin=lArDQGlobals.Samples_Min, xmax=lArDQGlobals.Samples_Max)
183 
184  isOnline = flags.DQ.Environment=='online'
185 
186  if isOnline:
187  Group.defineHistogram('LBf,EvtRejYield;RAW_EventsRejectedLB',
188  title='% of events rejected in current LB (online only)',
189  type='TProfile',
190  path=summary_hist_path,
191  xbins=1, xmin=0, xmax=1, xlabels=['% of events'])
192  Group.defineHistogram('LB,streamBin,LArEvSizePart;eventSizeStreamVsLB',
193  title='LAr event size per stream per LB (w/o ROS headers)',
194  type='TProfile2D',
195  path=summary_hist_path,
196  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max,
197  ybins=len(larFEBMonAlg.Streams),ymin=-0.5, ymax= len(larFEBMonAlg.Streams)-0.5,
198  ylabels=list(larFEBMonAlg.Streams)
199  )
200 
201  # Now per partition histograms
202  for subdet in range(0,lArDQGlobals.N_SubDet):
203  hist_path='/LAr/'+GroupName+'/'+lArDQGlobals.SubDet[subdet]+'/'
204  slot_low = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
205  slot_up = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
206  slot_n = int(slot_up - slot_low)
207  ft_low = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
208  ft_up = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
209  ft_n = int(ft_up - ft_low)
210 
211  darray = helper.addArray([lArDQGlobals.Partitions[2*subdet:2*subdet+2]],larFEBMonAlg,lArDQGlobals.SubDet[subdet],topPath='/')
212 
213  darray.defineHistogram('slotPar,FTPar;RAW_Parity',
214  title='Parity error;Slot;FT',
215  type='TH2I',
216  path=hist_path,
217  xbins=slot_n,xmin=slot_low,xmax=slot_up,
218  ybins=ft_n, ymin=ft_low, ymax=ft_up)
219 
220  darray.defineHistogram('slotBcid,FTBcid;RAW_BCID',
221  title='BCID mismatch betw. 2 halves of FEB;Slot;FT',
222  type='TH2I',
223  path=hist_path,
224  xbins=slot_n,xmin=slot_low,xmax=slot_up,
225  ybins=ft_n, ymin=ft_low, ymax=ft_up)
226 
227  darray.defineHistogram('slotRadd,FTRadd;RAW_RADD',
228  title='Sample header mismatch betw. 2 halves of FEB;Slot;FT',
229  type='TH2I',
230  path=hist_path,
231  xbins=slot_n,xmin=slot_low,xmax=slot_up,
232  ybins=ft_n, ymin=ft_low, ymax=ft_up)
233 
234  darray.defineHistogram('slotEvtid,FTEvtid;RAW_EVTID',
235  title='EVTID mismatch betw. 2 halves of FEB;Slot;FT',
236  type='TH2I',
237  path=hist_path,
238  xbins=slot_n,xmin=slot_low,xmax=slot_up,
239  ybins=ft_n, ymin=ft_low, ymax=ft_up)
240 
241  darray.defineHistogram('slotScac,FTScac;RAW_SCACStatus',
242  title='Wrong SCAC status in one half of a FEB;Slot;FT',
243  type='TH2I',
244  path=hist_path,
245  xbins=slot_n,xmin=slot_low,xmax=slot_up,
246  ybins=ft_n, ymin=ft_low, ymax=ft_up)
247 
248  darray.defineHistogram('slotscout,FTscout;RAW_scaOutOfRange',
249  title='Sca out of range;Slot;FT',
250  type='TH2I',
251  path=hist_path,
252  xbins=slot_n,xmin=slot_low,xmax=slot_up,
253  ybins=ft_n, ymin=ft_low, ymax=ft_up)
254 
255  darray.defineHistogram('slotgain,FTgain;RAW_gainMismatch',
256  title='Gain mismatch within time samples;Slot;FT',
257  type='TH2I',
258  path=hist_path,
259  xbins=slot_n,xmin=slot_low,xmax=slot_up,
260  ybins=ft_n, ymin=ft_low, ymax=ft_up)
261 
262  darray.defineHistogram('slottype,FTtype;RAW_typeMismatch',
263  title='Event type mismatch;Slot;FT',
264  type='TH2I',
265  path=hist_path,
266  xbins=slot_n,xmin=slot_low,xmax=slot_up,
267  ybins=ft_n, ymin=ft_low, ymax=ft_up)
268 
269  darray.defineHistogram('slotsmp,FTsmp;RAW_badNbOfSamp',
270  title='Non uniform number of samples;Slot;FT',
271  type='TH2I',
272  path=hist_path,
273  xbins=slot_n,xmin=slot_low,xmax=slot_up,
274  ybins=ft_n, ymin=ft_low, ymax=ft_up)
275 
276  darray.defineHistogram('slotzero,FTzero;RAW_zeroSamp',
277  title='Empty FEB data blocks;Slot;FT',
278  type='TH2I',
279  path=hist_path,
280  xbins=slot_n,xmin=slot_low,xmax=slot_up,
281  ybins=ft_n, ymin=ft_low, ymax=ft_up)
282 
283  darray.defineHistogram('slotsum,FTsum;RAW_checkSum',
284  title='Checksum / DSP block size;Slot;FT',
285  type='TH2I',
286  path=hist_path,
287  opt='kAlwaysCreate',
288  xbins=slot_n,xmin=slot_low,xmax=slot_up,
289  ybins=ft_n, ymin=ft_low, ymax=ft_up)
290 
291  darray.defineHistogram('slotmis,FTmis;RAW_missingHeader',
292  title='Missing header ;Slot;FT',
293  type='TH2I',
294  path=hist_path,
295  xbins=slot_n,xmin=slot_low,xmax=slot_up,
296  ybins=ft_n, ymin=ft_low, ymax=ft_up)
297 
298  darray.defineHistogram('slotgain,FTgain;RAW_badGain',
299  title='Bad gain ;Slot;FT',
300  type='TH2I',
301  path=hist_path,
302  xbins=slot_n,xmin=slot_low,xmax=slot_up,
303  ybins=ft_n, ymin=ft_low, ymax=ft_up)
304 
305  darray.defineHistogram('slotabs,FTabs;RAW_LArFEBMonErrorsAbsolute',
306  title='Nb of events with at least one error ;Slot;FT',
307  type='TH2I',
308  path=hist_path,
309  opt='kAlwaysCreate',
310  xbins=slot_n,xmin=slot_low,xmax=slot_up,
311  ybins=ft_n, ymin=ft_low, ymax=ft_up)
312 
313  darray.defineHistogram('slotmist,FTmist;RAW_missingTriggerType',
314  title='LVL1 trigger type missing or different from event type ;Slot;FT',
315  type='TH2I',
316  path=hist_path,
317  opt='kAlwaysCreate',
318  xbins=slot_n,xmin=slot_low,xmax=slot_up,
319  ybins=ft_n, ymin=ft_low, ymax=ft_up)
320 
321  darray.defineHistogram('slotnb,FTnb;RAW_nbOfEvts',
322  title='Nb of events (DSP header check only) ;Slot;FT',
323  type='TH2I',
324  path=hist_path,
325  opt='kAlwaysCreate',
326  xbins=slot_n,xmin=slot_low,xmax=slot_up,
327  ybins=ft_n, ymin=ft_low, ymax=ft_up)
328 
329  darray.defineHistogram('slotnb,FTnb,weightsweet1;RAW_NbOfSweet1PerFEB',
330  title='Average # of cells with (qfactor+time) readout ;Slot;FT',
331  type='TProfile2D',
332  path=hist_path,
333  opt='kAlwaysCreate',
334  xbins=slot_n,xmin=slot_low,xmax=slot_up,
335  ybins=ft_n, ymin=ft_low, ymax=ft_up)
336 
337  darray.defineHistogram('slotnb,FTnb,weightsweet2;RAW_NbOfSweet2PerFEB',
338  title='Average # of cells with samples readout ;Slot;FT',
339  type='TProfile2D',
340  path=hist_path,
341  opt='kAlwaysCreate',
342  xbins=slot_n,xmin=slot_low,xmax=slot_up,
343  ybins=ft_n, ymin=ft_low, ymax=ft_up)
344 
345  darray.defineHistogram('nbFEBpart;nbOfFebBlocks',
346  title='# of readout FEBs (DSP header check only) ;Slot;FT',
347  type='TH1I',
348  path=hist_path,
349  xbins=lArDQGlobals.N_FEB_Parttions_Max, xmin=-0.5, xmax=lArDQGlobals.N_FEB_Parttions_Max-0.5)
350 
351  darray.defineHistogram('slotMasked,FTMasked;RAW_knownFaultyFEB',
352  title='FEB with known errors (1:err. ignored 2:FEB masked);Slot;FT',
353  type='TH2I',
354  path=hist_path,
355  xbins=slot_n,xmin=slot_low,xmax=slot_up,
356  ybins=ft_n, ymin=ft_low, ymax=ft_up,
357  merge='identical')
358 
359  darray.defineHistogram('LB,LArEvSizePart;eventSizeVsLB',
360  title='LAr event size per LB (w/o ROS headers);Luminosity Block',
361  type='TProfile',
362  path=hist_path,
363  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
364 
365  if isOnline:
366  darray.defineHistogram('LBf,erronl;RAW_EventsRejectedLB',
367  title='% of events rejected in current LB (online only)',
368  type='TProfile',
369  path=hist_path,
370  opt='kAlwaysCreate',
371  xbins=1, xmin=0, xmax=1, xlabels=['% of events'])
372  darray.defineHistogram('LB,streamBin,LArEvSizePart;eventSizeStreamVsLB',
373  title='LAr event size per stream per LB (w/o ROS headers)',
374  type='TProfile2D',
375  path=hist_path,
376  xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max,
377  ybins=len(larFEBMonAlg.Streams),ymin=-0.5, ymax= len(larFEBMonAlg.Streams)-0.5,
378  ylabels=list(larFEBMonAlg.Streams)
379  )
380  pass
381 
382 
383 
384 
385 
386 if __name__=='__main__':
387 
388  from AthenaConfiguration.AllConfigFlags import initConfigFlags
389  flags = initConfigFlags()
390 
391  from AthenaCommon.Logging import log
392  from AthenaCommon.Constants import DEBUG
393  log.setLevel(DEBUG)
394 
395  from LArMonitoring.LArMonConfigFlags import addLArMonFlags
396  flags.addFlagsCategory("LArMon", addLArMonFlags)
397 
398  from AthenaConfiguration.TestDefaults import defaultTestFiles
399  flags.Input.Files = defaultTestFiles.RAW_RUN2
400 
401  flags.Output.HISTFileName = 'LArFEBMonOutput.root'
402  flags.DQ.enableLumiAccess = True
403  flags.DQ.useTrigger = False
404  flags.lock()
405 
406 
407  from CaloRec.CaloRecoConfig import CaloRecoCfg
408  cfg=CaloRecoCfg(flags)
409 
410  #from CaloD3PDMaker.CaloD3PDConfig import CaloD3PDCfg,CaloD3PDAlg
411  #cfg.merge(CaloD3PDCfg(flags, filename=flags.Output.HISTFileName, streamname='CombinedMonitoring'))
412 
413  aff_acc = LArFEBMonConfig(flags)
414  cfg.merge(aff_acc)
415 
416  cfg.printConfig()
417 
418  flags.dump()
419  f=open("LArFEBMon.pkl","wb")
420  cfg.store(f)
421  f.close()
422 
python.CaloRecoConfig.CaloRecoCfg
def CaloRecoCfg(flags, clustersname=None)
Definition: CaloRecoConfig.py:9
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArFEBMonAlg.LArFEBMonConfigCore
def LArFEBMonConfigCore(helper, algoinstance, flags, cellDebug=False, dspDebug=False)
Definition: LArFEBMonAlg.py:22
LArFEBMonAlg.LArFEBMonConfig
def LArFEBMonConfig(flags, cellDebug=False, dspDebug=False)
Definition: LArFEBMonAlg.py:4
python.LArFebErrorSummaryMakerConfig.LArFebErrorSummaryMakerCfg
def LArFebErrorSummaryMakerCfg(flags)
Definition: LArFebErrorSummaryMakerConfig.py:7
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Constants
some useful constants -------------------------------------------------—
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.IOVDbSvcConfig.addFolders
def addFolders(flags, folderStrings, detDb=None, className=None, extensible=False, tag=None, db=None, modifiers='')
Definition: IOVDbSvcConfig.py:72
python.IOVDbSvcConfig.IOVDbSvcCfg
def IOVDbSvcCfg(flags, **kwargs)
Definition: IOVDbSvcConfig.py:19
Trk::open
@ open
Definition: BinningType.h:40
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19