22def 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
78 summary_hist_path='Summary/'
79
80
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 opt='kLBNHistoryDepth=10,kAlwaysCreate',
192 xbins=1, xmin=0, xmax=1, xlabels=['% of events'])
193 Group.defineHistogram('LB,streamBin,LArEvSizePart;eventSizeStreamVsLB',
194 title='LAr event size per stream per LB (w/o ROS headers)',
195 type='TProfile2D',
196 path=summary_hist_path,
197 xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max,
198 ybins=len(larFEBMonAlg.Streams),ymin=-0.5, ymax= len(larFEBMonAlg.Streams)-0.5,
199 ylabels=list(larFEBMonAlg.Streams)
200 )
201
202
203 for subdet in range(0,lArDQGlobals.N_SubDet):
204 hist_path='/LAr/'+GroupName+'/'+lArDQGlobals.SubDet[subdet]+'/'
205 slot_low = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
206 slot_up = lArDQGlobals.FEB_Slot[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
207 slot_n = int(slot_up - slot_low)
208 ft_low = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][0] - 0.5
209 ft_up = lArDQGlobals.FEB_Feedthrough[lArDQGlobals.Partitions[subdet*2]][1] + 0.5
210 ft_n = int(ft_up - ft_low)
211
212 darray = helper.addArray([lArDQGlobals.Partitions[2*subdet:2*subdet+2]],larFEBMonAlg,lArDQGlobals.SubDet[subdet],topPath='/')
213
214 darray.defineHistogram('slotPar,FTPar;RAW_Parity',
215 title='Parity error;Slot;FT',
216 type='TH2I',
217 path=hist_path,
218 xbins=slot_n,xmin=slot_low,xmax=slot_up,
219 ybins=ft_n, ymin=ft_low, ymax=ft_up)
220
221 darray.defineHistogram('slotBcid,FTBcid;RAW_BCID',
222 title='BCID mismatch betw. 2 halves of FEB;Slot;FT',
223 type='TH2I',
224 path=hist_path,
225 xbins=slot_n,xmin=slot_low,xmax=slot_up,
226 ybins=ft_n, ymin=ft_low, ymax=ft_up)
227
228 darray.defineHistogram('slotRadd,FTRadd;RAW_RADD',
229 title='Sample header mismatch betw. 2 halves of FEB;Slot;FT',
230 type='TH2I',
231 path=hist_path,
232 xbins=slot_n,xmin=slot_low,xmax=slot_up,
233 ybins=ft_n, ymin=ft_low, ymax=ft_up)
234
235 darray.defineHistogram('slotEvtid,FTEvtid;RAW_EVTID',
236 title='EVTID mismatch betw. 2 halves of FEB;Slot;FT',
237 type='TH2I',
238 path=hist_path,
239 xbins=slot_n,xmin=slot_low,xmax=slot_up,
240 ybins=ft_n, ymin=ft_low, ymax=ft_up)
241
242 darray.defineHistogram('slotScac,FTScac;RAW_SCACStatus',
243 title='Wrong SCAC status in one half of a FEB;Slot;FT',
244 type='TH2I',
245 path=hist_path,
246 xbins=slot_n,xmin=slot_low,xmax=slot_up,
247 ybins=ft_n, ymin=ft_low, ymax=ft_up)
248
249 darray.defineHistogram('slotscout,FTscout;RAW_scaOutOfRange',
250 title='Sca out of range;Slot;FT',
251 type='TH2I',
252 path=hist_path,
253 xbins=slot_n,xmin=slot_low,xmax=slot_up,
254 ybins=ft_n, ymin=ft_low, ymax=ft_up)
255
256 darray.defineHistogram('slotgain,FTgain;RAW_gainMismatch',
257 title='Gain mismatch within time samples;Slot;FT',
258 type='TH2I',
259 path=hist_path,
260 xbins=slot_n,xmin=slot_low,xmax=slot_up,
261 ybins=ft_n, ymin=ft_low, ymax=ft_up)
262
263 darray.defineHistogram('slottype,FTtype;RAW_typeMismatch',
264 title='Event type mismatch;Slot;FT',
265 type='TH2I',
266 path=hist_path,
267 xbins=slot_n,xmin=slot_low,xmax=slot_up,
268 ybins=ft_n, ymin=ft_low, ymax=ft_up)
269
270 darray.defineHistogram('slotsmp,FTsmp;RAW_badNbOfSamp',
271 title='Non uniform number of samples;Slot;FT',
272 type='TH2I',
273 path=hist_path,
274 xbins=slot_n,xmin=slot_low,xmax=slot_up,
275 ybins=ft_n, ymin=ft_low, ymax=ft_up)
276
277 darray.defineHistogram('slotzero,FTzero;RAW_zeroSamp',
278 title='Empty FEB data blocks;Slot;FT',
279 type='TH2I',
280 path=hist_path,
281 xbins=slot_n,xmin=slot_low,xmax=slot_up,
282 ybins=ft_n, ymin=ft_low, ymax=ft_up)
283
284 darray.defineHistogram('slotsum,FTsum;RAW_checkSum',
285 title='Checksum / DSP block size;Slot;FT',
286 type='TH2I',
287 path=hist_path,
288 opt='kAlwaysCreate',
289 xbins=slot_n,xmin=slot_low,xmax=slot_up,
290 ybins=ft_n, ymin=ft_low, ymax=ft_up)
291
292 darray.defineHistogram('slotmis,FTmis;RAW_missingHeader',
293 title='Missing header ;Slot;FT',
294 type='TH2I',
295 path=hist_path,
296 xbins=slot_n,xmin=slot_low,xmax=slot_up,
297 ybins=ft_n, ymin=ft_low, ymax=ft_up)
298
299 darray.defineHistogram('slotgain,FTgain;RAW_badGain',
300 title='Bad gain ;Slot;FT',
301 type='TH2I',
302 path=hist_path,
303 xbins=slot_n,xmin=slot_low,xmax=slot_up,
304 ybins=ft_n, ymin=ft_low, ymax=ft_up)
305
306 darray.defineHistogram('slotabs,FTabs;RAW_LArFEBMonErrorsAbsolute',
307 title='Nb of events with at least one error ;Slot;FT',
308 type='TH2I',
309 path=hist_path,
310 opt='kAlwaysCreate',
311 xbins=slot_n,xmin=slot_low,xmax=slot_up,
312 ybins=ft_n, ymin=ft_low, ymax=ft_up)
313
314 darray.defineHistogram('slotmist,FTmist;RAW_missingTriggerType',
315 title='LVL1 trigger type missing or different from event type ;Slot;FT',
316 type='TH2I',
317 path=hist_path,
318 opt='kAlwaysCreate',
319 xbins=slot_n,xmin=slot_low,xmax=slot_up,
320 ybins=ft_n, ymin=ft_low, ymax=ft_up)
321
322 darray.defineHistogram('slotnb,FTnb;RAW_nbOfEvts',
323 title='Nb of events (DSP header check only) ;Slot;FT',
324 type='TH2I',
325 path=hist_path,
326 opt='kAlwaysCreate',
327 xbins=slot_n,xmin=slot_low,xmax=slot_up,
328 ybins=ft_n, ymin=ft_low, ymax=ft_up)
329
330 darray.defineHistogram('slotnb,FTnb,weightsweet1;RAW_NbOfSweet1PerFEB',
331 title='Average # of cells with (qfactor+time) readout ;Slot;FT',
332 type='TProfile2D',
333 path=hist_path,
334 opt='kAlwaysCreate',
335 xbins=slot_n,xmin=slot_low,xmax=slot_up,
336 ybins=ft_n, ymin=ft_low, ymax=ft_up)
337
338 darray.defineHistogram('slotnb,FTnb,weightsweet2;RAW_NbOfSweet2PerFEB',
339 title='Average # of cells with samples readout ;Slot;FT',
340 type='TProfile2D',
341 path=hist_path,
342 opt='kAlwaysCreate',
343 xbins=slot_n,xmin=slot_low,xmax=slot_up,
344 ybins=ft_n, ymin=ft_low, ymax=ft_up)
345
346 darray.defineHistogram('nbFEBpart;nbOfFebBlocks',
347 title='# of readout FEBs (DSP header check only) ;Number of read-out FEBs per event;Entries',
348 type='TH1I',
349 path=hist_path,
350 xbins=lArDQGlobals.N_FEB_Parttions_Max, xmin=-0.5, xmax=lArDQGlobals.N_FEB_Parttions_Max-0.5)
351
352 darray.defineHistogram('slotMasked,FTMasked;RAW_knownFaultyFEB',
353 title='FEB with known errors (1:err. ignored 2:FEB masked);Slot;FT',
354 type='TH2I',
355 path=hist_path,
356 xbins=slot_n,xmin=slot_low,xmax=slot_up,
357 ybins=ft_n, ymin=ft_low, ymax=ft_up,
358 merge='identical')
359
360 darray.defineHistogram('LB,LArEvSizePart;eventSizeVsLB',
361 title='LAr event size per LB (w/o ROS headers);Luminosity Block',
362 type='TProfile',
363 path=hist_path,
364 xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max)
365
366 if isOnline:
367 darray.defineHistogram('LBf,erronl;RAW_EventsRejectedLB',
368 title='% of events rejected in current LB (online only)',
369 type='TProfile',
370 path=hist_path,
371
372 opt='kLBNHistoryDepth=10,kAlwaysCreate',
373 xbins=1, xmin=0, xmax=1, xlabels=['% of events'])
374 darray.defineHistogram('LB,streamBin,LArEvSizePart;eventSizeStreamVsLB',
375 title='LAr event size per stream per LB (w/o ROS headers)',
376 type='TProfile2D',
377 path=hist_path,
378 xbins=lArDQGlobals.LB_Bins, xmin=lArDQGlobals.LB_Min, xmax=lArDQGlobals.LB_Max,
379 ybins=len(larFEBMonAlg.Streams),ymin=-0.5, ymax= len(larFEBMonAlg.Streams)-0.5,
380 ylabels=list(larFEBMonAlg.Streams)
381 )
382 pass
383
384
385
386
387