SND@LHC Software
Loading...
Searching...
No Matches
DAQ_monitoring.py
Go to the documentation of this file.
1#!/usr/bin/env python
2import ROOT,os,sys
3import rootUtils as ut
4import reverseMapping
5
6class DAQ_boards(ROOT.FairTask):
7 " produce hitmaps as function of boards"
8 def Init(self,options,monitor):
9 self.M = monitor
10 h = self.M.h
11 ut.bookHist(h,'scifiboard','scifi hits per board; board id',100,-0.5,99.5,100,0.5,500.)
12 ut.bookHist(h,'mufiboard','mufi hits per board; board id',100,-0.5,99.5,100,0.5,500.)
13 ut.bookHist(h,'scifiboard0','scifi hits per board, unbiased; board id',100,-0.5,99.5,100,0.5,500.)
14 ut.bookHist(h,'mufiboard0','mufi hits per board, unbiased; board id',100,-0.5,99.5,100,0.5,500.)
16 runNr = str(options.runNumber).zfill(6)
17 if options.online:
18 self.R.Init(options.server+options.path+'run_'+ runNr+'/')
19 else:
20 if options.rawDataPath: self.R.Init(options.server+options.rawDataPath+"run_"+runNr+'/')
21 elif options.path.find('commissioning')>0 and options.path.find('test')<0: self.R.Init(options.server+options.path.replace("convertedData","raw_data")+"/data/run_"+runNr+'/')
22 else: self.R.Init(options.server+options.path.replace("convertedData","raw_data")+"/run_"+runNr+'/')
23 def ExecuteEvent(self,event):
24 h = self.M.h
25 W = self.M.Weight
26 mult = {'scifi': [0]*100,'mufi': [0]*100}
27 for aHit in event.Digi_ScifiHits:
28 daq = self.R.daqChannel(aHit)
29 boardN = int(daq["board"].split('_')[1])
30 mult['scifi'][boardN] += 1
31 for aHit in event.Digi_MuFilterHits:
32 allChannels = self.M.map2Dict(aHit,'GetAllSignals')
33 for c in allChannels:
34 daq = self.R.daqChannel(aHit,c)
35 boardN = int(daq["board"][0].split('_')[1])
36 mult['mufi'][boardN] += 1
37 # check for a scifi board with more than 10hits to have unbiased info for others
38 bTriggered = []
39 for b in range(len(mult['scifi'])):
40 if mult['scifi'][b]>10:
41 bTriggered.append(b)
42 trigger = -1
43 if len(bTriggered)>0:
44 trigger = bTriggered[int(ROOT.gRandom.Rndm()*len(bTriggered))]
45 for x in mult:
46 for b in range(len(mult[x])):
47 rc = h[x+'board'].Fill(b,mult[x][b])
48 if trigger >0 and not b==trigger: rc = h[x+'board0'].Fill(b,mult[x][b],W)
49
50 def Plot(self):
51 h = self.M.h
52 ut.bookCanvas(h,'boardmaps',' ',1024,768,2,3)
53 h['boardmaps'].cd(1)
54 h['scifiboard'].Draw('colz')
55 h['boardmaps'].cd(2)
56 h['mufiboard'].Draw('colz')
57 h['boardmaps'].cd(3)
58 h['scifiboard0'].Draw('colz')
59 h['boardmaps'].cd(4)
60 h['mufiboard0'].Draw('colz')
61 h['boardmaps'].cd(5)
62 h['scifiboard0'].ProfileX().Draw()
63 h['boardmaps'].cd(6)
64 h['mufiboard0'].ProfileX().Draw()
65 self.M.myPrint(h['boardmaps'],'boardmaps',subdir='daq/expert')
66
67class Time_evolution(ROOT.FairTask):
68 " time evolution of run"
69 def Init(self,options,monitor):
70 self.M = monitor
71 self.fsdict = self.M.fsdict
72 h = self.M.h
73 self.gtime = {'all':{0:[],1:[],3:[]}, 'B1only':{0:[],1:[],3:[]}, 'B2noB1':{0:[],1:[],3:[]}, 'noBeam':{0:[],1:[],3:[]}}
74 self.QDCtime = {0:ROOT.TGraph(),1:ROOT.TGraph(),2:ROOT.TGraph(),3:ROOT.TGraph()}
75
76 # the offsets encode the Nchannels per detector plane type: veto1&2, veto3, us, dsH, dsV
77 # Veto3 is single plane, but part f the Veto system and the second item in its list is
78 # set 0 to account of that
79 # 7*2*2*8 + 7*8 + 10*5*2*8 + 60*3*2 + 60*4
80 self.offsets = {1:[0,7*16,16],2:[7*2*2*8,0,8],3:[7*2*2*8+7*8,10*16,16],4:[7*2*2*8+7*8+10*5*2*8,60*2,2],5:[7*2*2*8+7*8+10*5*2*8+3*60*2,60,1]}
81 ut.bookHist(h,'ctime','delta event time per channel; dt [s]' ,1000,0.0,10.,1700,-0.5,1699.5)
82 ut.bookHist(h,'ctimeZ','delta event time per channel; dt [us]',10000,0.0,100.,1700,-0.5,1699.5)
83 ut.bookHist(h,'ctimeM','delta event time per channel; dt [ms]',1000,0.0,10.,1700,-0.5,1699.5)
84 ut.bookHist(h,'btime','delta timestamp per channel; ',self.M.Nbunches*4+200,-0.5,self.M.Nbunches*4-0.5+200,1700,-0.5,1699.5)
85 ut.bookHist(h,'bnr','bunch number; ',self.M.Nbunches,-0.5,self.M.Nbunches-0.5)
86 ut.bookHist(h,'Xbnr','bunch number; ',self.M.Nbunches*4,-0.5,self.M.Nbunches*4-0.5)
87 ut.bookHist(h,'bnrF','bunch number forward tracks; ',self.M.Nbunches,-0.5,self.M.Nbunches-0.5)
88 ut.bookHist(h,'bnrB','bunch number backward tracks; ',self.M.Nbunches,-0.5,self.M.Nbunches-0.5)
89# type of crossing, check for b1only,b2nob1,nobeam
90 self.xing = {'all':True,'B1only':False,'B2noB1':False,'noBeam':False}
91 for x in self.xing:
92 ut.bookHist(h,'bnr'+x,'bunch number; ',self.M.Nbunches,-0.5,self.M.Nbunches-0.5)
93 # The SciFi track monitoring plots are made in this module.
94 # These histograms are present in the SciFi_residuals module as well. Since running the latter is
95 # time-consuming, it is excluded from the baseline monitoring, while the relevant SciFi track
96 # plots are moved here. The DS track plots are defined in the MuFilter monitoring module.
97 ut.bookHist(h,'trackDir'+x,'track direction;',300,-0.5,0.25)
98 ut.bookHist(h,'trackDirSig'+x,'track direction significance;',100,-20,10)
99 if not self.M.fsdict and not self.M.hasBunchInfo and x!='all': continue
100 ut.bookHist(h,'trackSlopes'+x,'track slope; x/z [mrad]; y/z [mrad]',1000,-100,100,1000,-100,100)
101 ut.bookHist(h,'trackSlopesXL'+x,'track slope; x/z [rad]; y/z [rad]',2200,-1.1,1.1,2200,-1.1,1.1)
102 ut.bookHist(h,'trackPos'+x,'track pos; x [cm]; y [cm]',100,-90,10.,80,0.,80.)
103 ut.bookHist(h,'trackPosBeam'+x,'beam track pos slopes<0.1rad; x [cm]; y [cm]',100,-90,10.,80,0.,80.)
104 for item in h:
105 if isinstance(h[item], ROOT.TH2) and (item.find('trackPos')>0 or item.find('trackSlopes')>0):
106 h[item].SetTitleOffset(1.1, 'Y')
107
108 ut.bookHist(h,'Tboard','Hit time per board, wrt SciFi 4Y board 40; board id; t_{hit} - t_{board 40 mean} [clock cycles]',62,0.5,62.5,100,-5.,5.)
109 ut.bookHist(h,'Cckboard','160 MHz bunch number; board id; SND clock align phase wrt LHC [clock cycles]',62,0.5,62.5,100,0.,16.)
110 ut.bookHist(h,'Cckboard_normalized','160 MHz bunch number; board id; SND clock align phase wrt LHC [clock cycles]',62,0.5,62.5,100,0.,16.)
111 ut.bookHist(h,'CckboardB2','160 MHz bunch number; board id; SND clock align phase wrt LHC [clock cycles]',62,0.5,62.5,100,0.,16.)
112 self.board0 = 40
113
114 self.boardsVsTime = {}
115
116 self.Nevent = -1
117 self.Tprev = [-1]*1700
118 def ExecuteEvent(self,event):
119 self.Nevent +=1
120 h = self.M.h
121 W = self.M.Weight
122 T = event.EventHeader.GetEventTime()
123 Tsec = int(T/self.M.freq)
124
125 trackTask = self.M.FairTasks['simpleTracking']
126 direction = 0
127 DStrack = False
128 SFtrack = False
129 SL = False
130 for theTrack in self.M.Reco_MuonTracks:
131 if not theTrack.getFitStatus().isFitConverged() and theTrack.GetUniqueID()==1: continue
132 if theTrack.GetUniqueID()!=1:
133 DStrack = True
134 continue
135 # get the slopes and track positions
136 state = theTrack.getFittedState()
137 pos = state.getPos()
138 mom = state.getMom()
139 slopeX = mom.X()/mom.Z()
140 slopeY = mom.Y()/mom.Z()
141 for x in self.xing:
142 if self.M.xing[x]:
143 self.M.fillHist2('trackSlopes'+x,slopeX*1000-pos.X()/48.2,slopeY*1000-pos.Y()/48.2)
144 self.M.fillHist2('trackSlopesXL'+x,slopeX-pos.X()/48200,slopeY-pos.Y()/48200)
145 self.M.fillHist2('trackPos'+x,pos.X(),pos.Y())
146 if abs(slopeX)<0.1 and abs(slopeY)<0.1: self.M.fillHist2('trackPosBeam'+x,pos.X(),pos.Y())
147 # get the track direction
148 SL = trackTask.trackDir(theTrack)
149 if not SL: continue
150 SFtrack = True
151 if abs(SL[0])<0.03: direction = 1
152 elif SL[0]<-0.07: direction = -1
153 bn = int((T%(self.M.div*self.M.Nbunches))/self.M.div+0.5)
154 sbn = T%(self.M.div*self.M.Nbunches)
155 rc = h['bnr'].Fill( bn ,W)
156 rc = h['Xbnr'].Fill( sbn,W)
157 for x in self.xing:
158 if self.M.xing[x]:
159 if x=='all' or (DStrack or SFtrack): rc = h['bnr'+x].Fill( bn ,W)
160 if not SL: continue
161 rc = h['trackDir'+x].Fill(SL[0],W)
162 rc = h['trackDirSig'+x].Fill(SL[1],W)
163
164 if direction >0: rc = h['bnrF'].Fill(bn,W)
165 elif direction <0: rc = h['bnrB'].Fill(bn,W)
166 for x in self.xing:
167 if self.M.xing[x]:
168 self.gtime[x][0].append(T/self.M.freq)
169 if DStrack: self.gtime[x][3].append(T/self.M.freq)
170 if SFtrack: self.gtime[x][1].append(T/self.M.freq)
171
172 qdc = {0:0,1:0,2:0,3:0}
173
174 for aHit in event.Digi_MuFilterHits:
175 if not aHit.isValid(): continue
176 detID = aHit.GetDetectorID()
177 s = detID//10000
178 p = (detID//1000)%10
179 b = detID%1000
180 allChannels = self.M.map2Dict(aHit,'GetAllSignals')
181 for c in allChannels:
182 qdc[s]+= allChannels[c]
183 if b<60:
184 # Veto 1 and 2
185 if s==1 and p<2: s_index = s
186 # Veto 3, US and DSH
187 if (s==1 and p==2) or s==2 or s==3: s_index = s+1
188 cNr = self.offsets[s_index][0] + self.offsets[s_index][1]*p + self.offsets[s_index][2]*b + c
189 else: # only DSV
190 cNr = self.offsets[s+2][0] + self.offsets[s+2][1]*p + self.offsets[s+2][2]*(b-60) + c
191 if self.Tprev[cNr]>0:
192 dT = (T - self.Tprev[cNr])/self.M.freq
193 if dT<5E-9: print('something wrong',self.Nevent,s,p,b,c,dT,T,self.Tprev[cNr])
194 rc = h['ctimeZ'].Fill(dT*1E6,cNr,W)
195 rc = h['btime'].Fill(T-self.Tprev[cNr],cNr,W)
196 rc = h['ctimeM'].Fill(dT*1E3,cNr,W)
197 rc = h['ctime'].Fill(dT,cNr,W)
198 nb = aHit.GetBoardID(c)
199 if not nb in self.boardsVsTime: self.boardsVsTime[nb]={}
200 if not Tsec in self.boardsVsTime[nb]: self.boardsVsTime[nb][Tsec]=0
201 self.boardsVsTime[nb][Tsec]+=1
202 self.Tprev[cNr] = T
203 for aHit in event.Digi_ScifiHits:
204 if not aHit.isValid(): continue
205 qdc[0]+=1
206 nb = aHit.GetBoardID(0)
207 if not nb in self.boardsVsTime: self.boardsVsTime[nb]={}
208 if not Tsec in self.boardsVsTime[nb]: self.boardsVsTime[nb][Tsec]=0
209 self.boardsVsTime[nb][Tsec]+=1
210 for s in range(4):
211 self.QDCtime[s].SetPoint(self.Nevent,self.Nevent,qdc[s])
212
213 boards = {}
214 for aHit in event.Digi_MuFilterHits:
215 for x in aHit.GetAllTimes():
216 bid = aHit.GetBoardID(x.first)
217 if not bid in boards: boards[bid]=[]
218 boards[bid].append(x.second)
219 for aHit in event.Digi_ScifiHits:
220 bid = aHit.GetBoardID(0)
221 if not bid in boards: boards[bid]=[]
222 boards[bid].append(aHit.GetTime())
223# times relative to board 40
224 if self.board0 in boards:
225 boards[self.board0].sort()
226 T0 = 0
227 for x in boards[self.board0]: T0+=x
228 T0 = T0/len(boards[self.board0])
229 for b in boards:
230 for x in boards[b]:
231 rc = h['Tboard'].Fill(b,x-T0)
232 for b in boards:
233 for x in boards[b]:
234 rc = h['Cckboard'].Fill(b, sbn%4+x )
235 if self.M.fsdict or self.M.hasBunchInfo:
236 if self.M.xing['B2noB1']: rc = h['CckboardB2'].Fill(b, sbn%4+x )
237
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# time evolution of boards
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# analyse splash events
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 # if systems[sy]+'splash'+str(i) in h: h.pop(systems[sy]+'splash'+str(i)).Delete()
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# analyse splash events
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 #rc = h['EtimeZ'].Fit('expo','S','',0.,250.)
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 #rc = h['Etime'].Fit('expo','S')
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 # to make the titles better use 'x'
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 # normalize the h['Cckboard'] histo ber column(per board)
564 # to make the new h['Cckboard_normalized'] plot (so to have proper Nentries etc)
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 # no need to normalize if sum is 0
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 # single plot for the shifter
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')
Init(self, options, monitor)
Init(self, options, monitor)