238 def Plot(self):
239 h = self.M.h
240 gtime = self.gtime
241 if self.M.TStart < 0:
242 T0 = gtime['all'][0][0]
243 tmax = gtime['all'][0][len(gtime['all'][0])-1] - T0
244 else:
245 T0 = self.M.TStart/self.M.freq
246 tmax = self.M.TEnd/self.M.freq - T0
247
248 nbins = int(tmax)
249 yunit = "events per s"
250 systems = {0:'Scifi',1:'Veto',2:'US',3:'DS'}
251 if self.fsdict or self.M.hasBunchInfo: Xi = ['','B1only', 'B2noB1','noBeam']
252 else: Xi = ['']
253
254 if 'time' in h:
255 if self.M.TStart < 0:
256 for x in Xi:
257 for y in ['time','timeWt','timeWtDS']:
258 h.pop(y+x).Delete()
259 h.pop('boardVStime').Delete()
260 if not 'time' in h:
261 for x in Xi:
262 ut.bookHist(h,'time'+x,'DAQ Event Rate '+x+'; elapsed time from run start t [s];'+yunit,nbins,0,tmax)
263 ut.bookHist(h,'timeWt'+x,'events with Scifi(red) DS(cyan) tracks; elapsed time from run start t [s];'+yunit,nbins,0,tmax)
264 ut.bookHist(h,'timeWtDS'+x,'elapsed time from start, events with DS tracks; t [s];'+yunit,nbins,0,tmax)
265
266 ut.bookHist(h,'boardVStime','Board Hit Rate; t [s]; board id',nbins,0,tmax,len(self.boardsVsTime),0.5,len(self.boardsVsTime)+0.5)
267 if not 'Etime' in h:
268 ut.bookHist(h,'Etime','time difference between consecutive events; dt [s]',100,0.0,1.)
269 ut.bookHist(h,'EtimeZ','time difference between consecutive events; dt [us]',10000,0.0,100.)
270 for x in h:
271 if isinstance(h[x], ROOT.TH2):
272 h[x].SetStats(0)
273
274 for n in range(1,len(gtime['all'][0])):
275 dT = gtime['all'][0][n]-gtime['all'][0][n-1]
276 rc = h['Etime'].Fill( dT )
277 rc = h['EtimeZ'].Fill( dT*1E6)
278 K = {0:'',1:'Wt',3:'WtDS'}
279 for k in K:
280 for n in range(len(gtime['all'][k])):
281 rc = h['time'+K[k]].Fill(gtime['all'][k][n]-T0)
282 if self.fsdict or self.M.hasBunchInfo:
283 for x in ['B1only', 'B2noB1','noBeam']:
284 for k in K:
285 for n in range(len(gtime[x][k])):
286 rc = h['time'+K[k]+x].Fill(gtime[x][k][n]-T0)
287
288 boards = list(self.boardsVsTime.keys())
289 boards.sort()
290 i = 1
291 yAx = h['boardVStime'].GetYaxis()
292 for nb in boards:
293 snb = str(nb)
294 yAx.SetBinLabel(i,snb)
295 for t in self.boardsVsTime[nb]:
296 rc = h['boardVStime'].Fill(t-T0,i,self.boardsVsTime[nb][t])
297 i+=1
298 ut.bookCanvas(h,'boardsVsTimeStats','board nr vs time',2000,1600,1,1)
299 tc = h['boardsVsTimeStats'].cd()
300 h['boardVStime'].Draw('colz')
301 tc.SetLogz()
302 self.M.myPrint(h['boardsVsTimeStats'],"board nr versus time",subdir='daq/expert')
303 self.M.myPrint(h['boardsVsTimeStats'],"board nr versus time",subdir='daq/shifter')
304
305
306 withTGraph = False
307 anaSplash = False
308 if anaSplash and withTGraph:
309 splashBins = []
310 av = h['time'].GetEntries()/nbins
311 for i in range(1,nbins+1):
312 B = h['time'].GetBinContent(i)
313 if B>5*av:
314 tmin = h['time'].GetBinLowEdge(i)
315 tmax = tmin+h['time'].GetBinWidth(i)
316 if 'splash'+str(i) in h:
317 h.pop('splash'+str(i)).Delete()
318 h.pop('Qsplash'+str(i)).Delete()
319 ut.bookHist(h,'splash'+str(i),'; t [us];events per usec',1000000,0,(tmax-tmin)*1E6)
320 ut.bookHist(h,'Qsplash'+str(i),' qdc; t [us];sum qdc per usec',1000000,0,(tmax-tmin)*1E6)
321 for sy in systems:
322
323 h[systems[sy]+'splash'+str(i)] = ROOT.TGraph()
324 splashBins.append( [i,tmin,tmax] )
325 for n in range(1,len(gtime['all'][0])):
326 T = gtime['all'][0][n-1]-T0
327 for s in splashBins:
328 if T>s[1] and T<s[2]:
329 rc = h['splash'+str(s[0])].Fill((T-s[1])*1E6)
330 for sy in systems:
331 N = h[systems[sy]+'splash'+str(s[0])].GetN()
332 h[systems[sy]+'splash'+str(s[0])].SetPoint(N,(T-s[1])*1E6,self.QDCtime[sy].GetPointY(n-1))
333 N = len(splashBins)
334 if N>0:
335 iy = int(ROOT.TMath.Sqrt(N))
336 ix = N//iy
337 if N>ix*iy: ix+=1
338 ut.bookCanvas(h,'Tsplash','rates',1800,1200,ix,iy)
339 for sy in systems: ut.bookCanvas(h,systems[sy]+'splash','qdc sum',1800,1200,ix,iy)
340 n=1
341 for s in splashBins:
342 h['Tsplash'].cd(n)
343 h['splash'+str(s[0])].Draw('hist')
344 for sy in systems:
345 tc = h[systems[sy]+'splash'].cd(n)
346 tc.SetLogy(1)
347 hist = h['Qsplash'+str(s[0])]
348 hist.Reset()
349 g = h[systems[sy]+'splash'+str(s[0])]
350 for i in range(g.GetN()):
351 T,QDC = g.GetPointX(i),g.GetPointY(i)
352 rc = hist.Fill(T,QDC)
353 h[systems[sy]+'Qsplash'+str(s[0])] = ROOT.TGraph()
354 for i in range(hist.GetNbinsX()):
355 QDC = hist.GetBinContent(i+1)
356 if not QDC>0: continue
357 T = hist.GetBinCenter(i+1)
358 h[systems[sy]+'Qsplash'+str(s[0])].AddPoint(T,QDC)
359 h['QXsplash'+str(s[0])] = h['Qsplash'+str(s[0])].RebinX(10000,'QXsplash'+str(s[0]))
360 xmax = hist.GetMaximum()
361 h['QXsplash'+str(s[0])].Reset()
362 h['QXsplash'+str(s[0])].SetMaximum(xmax)
363 h['QXsplash'+str(s[0])].DrawClone()
364 h[systems[sy]+'Qsplash'+str(s[0])].SetName(systems[sy]+'Gsplash'+str(s[0]))
365 h[systems[sy]+'Qsplash'+str(s[0])].Draw('Bsame')
366 n+=1
367 self.M.myPrint(h['Tsplash'],"Splashes",subdir='daq/expert')
368 for sy in systems: self.M.myPrint(h[systems[sy]+'splash'],systems[sy]+" qdc sum",subdir='daq/expert')
369
370 elif anaSplash:
371
372 splashBins = []
373 av = h['time'].GetEntries()/nbins
374 for i in range(1,nbins+1):
375 B = h['time'].GetBinContent(i)
376 if B>5*av:
377 tmin = h['time'].GetBinLowEdge(i)
378 tmax = tmin+h['time'].GetBinWidth(i)
379 if 'splash'+str(i) in h: h.pop('splash'+str(i)).Delete()
380 ut.bookHist(h,'splash'+str(i),'; t [#mus];events per #mus',1000000,0,(tmax-tmin)*1E6)
381 for sy in systems:
382 if systems[sy]+'splash'+str(i) in h: h.pop(systems[sy]+'splash'+str(i)).Delete()
383 ut.bookHist(h,systems[sy]+'splash'+str(i),systems[sy]+'sum qdc / N; t [1#mus];average sum qdc per event #mus',1000000,0,(tmax-tmin)*1E6)
384 splashBins.append( [i,tmin,tmax] )
385 for n in range(1,len(gtime['all'][0])):
386 T = gtime['all'][0][n-1]-T0
387 for s in splashBins:
388 if T>s[1] and T<s[2]:
389 rc = h['splash'+str(s[0])].Fill((T-s[1])*1E6)
390 for sy in systems:
391 rc = h[systems[sy]+'splash'+str(s[0])].Fill((T-s[1])*1E6,self.QDCtime[sy].GetPointY(n-1))
392 N = len(splashBins)
393 if N>0:
394 iy = int(ROOT.TMath.Sqrt(N))
395 ix = N//iy
396 if N>ix*iy: ix+=1
397 ut.bookCanvas(h,'Tsplash','rates',1800,1200,ix,iy)
398 for sy in systems: ut.bookCanvas(h,systems[sy]+'splash','qdc sum',1800,1200,ix,iy)
399 n=1
400 for s in splashBins:
401 h['Tsplash'].cd(n)
402 h['splash'+str(s[0])].Draw('hist')
403 for sy in systems:
404 tc = h[systems[sy]+'splash'].cd(n)
405 tc.SetLogy(1)
406 h[systems[sy]+'splash'+str(s[0])].Divide(h['splash'+str(s[0])])
407 h[systems[sy]+'splash'+str(s[0])].Draw('hist')
408 n+=1
409 self.M.myPrint(h['Tsplash'],"Splashes",subdir='daq/expert')
410 for sy in systems: self.M.myPrint(h[systems[sy]+'splash'],systems[sy]+" qdc sum",subdir='daq/expert')
411
412 ut.bookCanvas(h,'eventAndTrackRates','rates',1024,3*768,1,3)
413 ut.bookCanvas(h,'Txing','rates per xing type',1024,3*768,1,4)
414
415 tc = h['eventAndTrackRates'].cd(1)
416 h['time'].SetStats(0)
417 h['time'].Draw()
418 tc = h['eventAndTrackRates'].cd(2)
419 h['timeWt'].SetStats(0)
420 h['timeWt'].SetLineColor(ROOT.kRed)
421 h['timeWtDS'].SetStats(0)
422 h['timeWtDS'].SetLineColor(ROOT.kCyan)
423 mx = max( h['timeWt'].GetBinContent(h['timeWtDS'].GetMaximumBin()),\
424 h['timeWtDS'].GetBinContent(h['timeWtDS'].GetMaximumBin()) )
425 h['timeWt'].SetMaximum(mx)
426 h['timeWt'].Draw()
427 h['timeWtDS'].Draw('same')
428 tc = h['eventAndTrackRates'].cd(3)
429 tc.SetLogy(1)
430 h['EtimeZ'].Draw()
431
432 h['eventAndTrackRates'].Update()
433 stats = h['EtimeZ'].FindObject('stats')
434 stats.SetOptFit(1111111)
435 tc = h['eventAndTrackRates'].cd(4)
436 tc.SetLogy(1)
437 h['Etime'].Draw()
438
439 h['eventAndTrackRates'].Update()
440 stats = h['Etime'].FindObject('stats')
441 stats.SetOptFit(1111111)
442 h['eventAndTrackRates'].Update()
443 self.M.myPrint(h['eventAndTrackRates'],"Rates",subdir='daq/shifter')
444 if self.fsdict or self.M.hasBunchInfo:
445 j = 1
446 for x in ['B1only', 'B2noB1','noBeam']:
447 tc = h['Txing'].cd(j)
448 hmax = 0
449 for ty in ['','Wt','WtDS']:
450 mx = h['time'+ty+x].GetMaximum()
451 if mx>hmax: hmax = mx
452 for ty in ['','Wt','WtDS']:
453 h['time'+ty+x].SetMaximum(hmax)
454 h['time'+ty+x].SetStats(0)
455 h['time'+x].Draw()
456 h['timeWt'+x].SetLineColor(ROOT.kRed)
457 h['timeWtDS'+x].SetLineColor(ROOT.kCyan)
458 h['timeWt'+x].Draw('same')
459 h['timeWtDS'+x].Draw('same')
460 j+=1
461 tc = h['Txing'].cd(j)
462 hmax = 0
463 for x in ['B1only', 'B2noB1','noBeam']:
464 mx = h['bnr'+x].GetMaximum()
465 if mx>hmax: hmax = mx
466 h['bnrB1only'].SetMaximum(hmax)
467 h['bnrB1only'].SetStats(0)
468 h['bnrB1only'].SetLineColor(ROOT.kBlue)
469 h['bnrB1only'].Draw()
470 h['bnrB2noB1'].SetStats(0)
471 h['bnrB2noB1'].SetLineColor(ROOT.kGreen)
472 h['bnrB2noB1'].Draw('same')
473 h['bnrnoBeam'].SetStats(0)
474 h['bnrnoBeam'].SetLineColor(ROOT.kOrange)
475 h['bnrnoBeam'].Draw('same')
476 h['Txing'].Update()
477 self.M.myPrint(h['Txing'],"RatesXing",subdir='daq/expert')
478
479 for xi in self.xing:
480 if not self.M.fsdict and not self.M.hasBunchInfo and xi!='all': continue
481
482 x = xi
483 if xi =='all': x=''
484 tname = 'scifi-trackSlopes'+x
485 ut.bookCanvas(h,tname,"track directions",1600,1800,3,2)
486 h[tname].cd(1)
487 rc = h['trackSlopes'+xi].Draw('colz')
488 h[tname].cd(2)
489 rc = h['trackSlopes'+xi].ProjectionX("slopeX"+xi)
490 rc.Draw()
491 rc.SetTitle('track X slope')
492 h[tname].cd(3)
493 rc = h['trackSlopes'+xi].ProjectionY("slopeY"+xi)
494 rc.Draw()
495 rc.SetTitle('track Y slope')
496 h[tname].cd(4)
497 rc = h['trackSlopesXL'+xi].Draw('colz')
498 h[tname].cd(5)
499 rc = h['trackSlopesXL'+xi].ProjectionX("slopeXL"+xi)
500 rc.Draw()
501 rc.SetTitle('track X slope')
502 h[tname].cd(6)
503 rc = h['trackSlopesXL'+xi].ProjectionY("slopeYL"+xi)
504 rc.Draw()
505 rc.SetTitle('track Y slope')
506 if xi=='all': self.M.myPrint(self.M.h[tname],tname,subdir='scifi/shifter')
507 else: self.M.myPrint(self.M.h[tname],tname,subdir='scifi/shifter/'+xi)
508 tname = 'scifi-trackPos'+x
509 ut.bookCanvas(h,tname,"track position first state",600,1200,1,2)
510 h[tname].cd(1)
511 rc = h['trackPosBeam'+xi].Draw('colz')
512 h[tname].cd(2)
513 rc = h['trackPos'+xi].Draw('colz')
514 if xi=='all': self.M.myPrint(self.M.h[tname],'trackPos'+xi,subdir='scifi/shifter')
515 else: self.M.myPrint(self.M.h[tname],'trackPos'+xi,subdir='scifi/shifter/'+xi)
516
517 if self.fsdict or self.M.hasBunchInfo:
518 ut.bookCanvas(h,'scifi-trackDirection',' ',1024,768,4,2)
519 j=1
520 for x in self.xing:
521 h['scifi-trackDirection'].cd(j)
522 h['trackDir'+x].Draw()
523 h['scifi-trackDirection'].cd(4+j)
524 h['trackDir'+x].Draw()
525 j+=1
526 else:
527 ut.bookCanvas(h,'scifi-trackDirection',' ',1024,768,2,1)
528 h['scifi-trackDirection'].cd(1)
529 h['trackDirall'].Draw()
530 h['scifi-trackDirection'].cd(2)
531 h['trackDirSigall'].Draw()
532 self.M.myPrint(h['scifi-trackDirection'],'trackdirections',subdir='scifi/expert')
533
534 ut.bookCanvas(h,'bunchNumber','bunch nr',2048,1600,1,3)
535 tc = h['bunchNumber'].cd(1)
536 h['bnr'].SetStats(0)
537 h['bnr'].Draw()
538 tc = h['bunchNumber'].cd(2)
539 h['bnrF'].SetStats(0)
540 h['bnrF'].Draw()
541 tc = h['bunchNumber'].cd(3)
542 h['bnrB'].SetStats(0)
543 h['bnrB'].Draw()
544 self.M.myPrint(h['bunchNumber'],"BunchNr",subdir='daq/shifter')
545
546 ut.bookCanvas(h,'sndclock','snd bunch nr',1200,900,1,1)
547 tc = h['sndclock'].cd()
548 h['Xbnr'].SetStats(0)
549 h['Xbnr'].Draw()
550 self.M.myPrint(h['sndclock'],"XBunchNr",subdir='daq/expert')
551
552 ut.bookCanvas(h,'channels',' channel dt',1024,4*768,1,4)
553 tc = h['channels'].cd(1)
554 h['ctimeZ'].Draw('colz')
555 tc = h['channels'].cd(2)
556 h['ctimeM'].Draw('colz')
557 tc = h['channels'].cd(3)
558 h['ctime'].Draw('colz')
559 tc = h['channels'].cd(4)
560 h['btime'].Draw('colz')
561 self.M.myPrint(h['channels'],"mufilter channel dT",subdir='daq/expert')
562
563
564
565 for ix in range(1,h['Cckboard'].GetNbinsX()+1):
566 NixSum=0
567 for iy in range(1,h['Cckboard'].GetNbinsY()+1):
568 NixSum +=h['Cckboard'].GetBinContent(ix,iy)
569 for iy in range(1,h['Cckboard'].GetNbinsY()+1):
570
571 if NixSum!=0:
572 h['Cckboard_normalized'].SetBinContent(ix, iy, h['Cckboard'].GetBinContent(ix,iy)/NixSum)
573 h['Cckboard_normalized'].GetZaxis().SetTitle('normalized entries per board')
574 h['Cckboard_normalized'].GetZaxis().RotateTitle()
575 ut.bookCanvas(h,'boardsAlignment_expert','',1024,768,2,1)
576 h['boardsAlignment_expert'].cd(1)
577 ROOT.gPad.SetMargin(0.15,0.15,0.1,0.1)
578 ROOT.gPad.SetGrid()
579 h['Tboard'].Draw('colz')
580 h['boardsAlignment_expert'].cd(2)
581 ROOT.gPad.SetMargin(0.15,0.15,0.1,0.1)
582 h['Cckboard_normalized'].Draw('colz')
583 ROOT.gPad.SetGrid()
584 self.M.myPrint(h['boardsAlignment_expert'],"board time diff",subdir='daq/expert')
585
586
587 ut.bookCanvas(h,'boardsAlignment','',1024,768,1,1)
588 h['Cckboard_normalized'].Draw('colz')
589 ROOT.gPad.SetGrid()
590 self.M.myPrint(h['boardsAlignment'],"board time diff",subdir='daq/shifter')