66 for s
in systemAndPlanes:
67 for l
in range(systemAndPlanes[s]):
68 ut.bookHist(h,
'hit_'+
str(s*10+l),
'channel map / plane '+
str(s*10+l),160,-0.5,159.5)
69 if s==3: ut.bookHist(h,
'bar_'+
str(s*10+l),
'hit map / plane '+
str(s*10+l),60,-0.5,59.5)
70 else: ut.bookHist(h,
'bar_'+
str(s*10+l),
'hit map / plane '+
str(s*10+l),10,-0.5,9.5)
71 ut.bookHist(h,
'sig_'+
str(s*10+l),
'signal / plane '+
str(s*10+l),200,0.0,200.)
72 if s==2: ut.bookHist(h,
'sigS_'+
str(s*10+l),
'signal / plane '+
str(s*10+l),200,0.0,200.)
73 ut.bookHist(h,
'sigL_'+
str(s*10+l),
'signal / plane '+
str(s*10+l),200,0.0,200.)
74 ut.bookHist(h,
'sigR_'+
str(s*10+l),
'signal / plane '+
str(s*10+l),200,0.0,200.)
75 ut.bookHist(h,
'Tsig_'+
str(s*10+l),
'signal / plane '+
str(s*10+l),200,0.0,200.)
76 ut.bookHist(h,
'occ_'+
str(s*10+l),
'channel occupancy '+
str(s*10+l),100,0.0,200.)
77 ut.bookHist(h,
'occTag_'+
str(s*10+l),
'channel occupancy '+
str(s*10+l),100,0.0,200.)
79 ut.bookHist(h,
'leftvsright_1',
'Veto hits in left / right',10,-0.5,9.5,10,-0.5,9.5)
80 ut.bookHist(h,
'leftvsright_2',
'US hits in left / right',10,-0.5,9.5,10,-0.5,9.5)
81 ut.bookHist(h,
'leftvsright_3',
'DS hits in left / right',2,-0.5,1.5,2,-0.5,1.5)
82 ut.bookHist(h,
'leftvsright_signal_1',
'Veto signal in left / right',100,-0.5,200.,100,-0.5,200.)
83 ut.bookHist(h,
'leftvsright_signal_2',
'US signal in left / right',100,-0.5,200.,100,-0.5,200.)
84 ut.bookHist(h,
'leftvsright_signal_3',
'DS signal in left / right',100,-0.5,200.,100,-0.5,200.)
86 ut.bookHist(h,
'dtime',
'delta event time; dt [ns]',100,0.0,1000.)
87 ut.bookHist(h,
'dtimeu',
'delta event time; dt [us]',100,0.0,1000.)
88 ut.bookHist(h,
'dtimem',
'delta event time; dt [ms]',100,0.0,1000.)
90 ut.bookHist(h,
'bs',
'beam spot',100,-100.,10.,100,0.,80.)
91 ut.bookHist(h,
'bsDS',
'beam spot',60,-0.5,59.5,60,-0.5,59.5)
92 ut.bookHist(h,
'slopes',
'track slopes',100,-0.1,0.1,100,-0.1,0.1)
96 if Nev < 0 : Nev = eventTree.GetEntries()
98 t0 = eventTree.EventHeader.GetEventTime()/freq
100 for event
in eventTree:
105 for aHit
in event.Digi_MuFilterHits:
106 if not aHit.isValid():
continue
107 detID = aHit.GetDetectorID()
108 if aHit.isVertical(): withX =
True
110 l = (detID%10000)//1000
118 if not key
in planes: planes[key] = {}
119 sumSignal = aHit.SumOfSignals()
120 planes[key][bar] = [sumSignal[
'SumL'],sumSignal[
'SumR']]
121 nSiPMs = aHit.GetnSiPMs()
122 nSides = aHit.GetnSides()
125 allChannels = aHit.GetAllSignals(
False)
131 for c
in allChannels:
138 rc = h[
'leftvsright_'+
str(s)].Fill(Nleft,Nright)
139 rc = h[
'leftvsright_signal_'+
str(s)].Fill(Sleft,Sright)
140 for c
in allChannels:
141 channel = bar*nSiPMs*nSides + c[0]
142 rc = h[
'hit_'+
str(s)+
str(l)].Fill(
int(channel))
143 rc = h[
'bar_'+
str(s)+
str(l)].Fill(bar)
145 elif c[0]<nSiPMs: rc = h[
'sigL_'+
str(s)+
str(l)].Fill(c[1])
146 else : rc = h[
'sigR_'+
str(s)+
str(l)].Fill(c[1])
147 rc = h[
'sig_'+
str(s)+
str(l)].Fill(c[1])
150 if len(planes[key]) > 2: maxOneBar =
False
153 installed_stations = {}
155 for l
in range(systemAndPlanes[s]):
156 if h[
'hit_'+
str(s)+
str(l)].GetEntries()>0:
157 if not s
in installed_stations: installed_stations[s]=0
158 installed_stations[s]+=1
161 for s
in installed_stations:
162 if installed_stations[s]>0: x+=1
163 if installed_stations[s]>y: y = installed_stations[s]
164 ut.bookCanvas(h,
'hitmaps',
' ',1200,1600,x,y)
165 ut.bookCanvas(h,
'barmaps',
' ',1200,1600,x,y)
166 ut.bookCanvas(h,
'signal',
' ',1200,1600,x,y)
167 ut.bookCanvas(h,
'Tsignal',
' ',1200,1600,x,y)
169 for S
in installed_stations:
170 for l
in range(installed_stations[S]):
172 tc = h[
'hitmaps'].cd(n)
173 h[
'hit_'+
str(S)+
str(l)].Draw()
174 tc = h[
'barmaps'].cd(n)
175 h[
'bar_'+
str(S)+
str(l)].Draw()
176 tc = h[
'signal'].cd(n)
177 h[
'sig_'+
str(S)+
str(l)].Draw()
178 tc = h[
'Tsignal'].cd(n)
179 h[
'Tsig_'+
str(S)+
str(l)].Draw()
181 ut.bookCanvas(h,
'USBars',
' ',1200,900,1,1)
182 colours = {0:ROOT.kOrange,1:ROOT.kRed,2:ROOT.kGreen,3:ROOT.kBlue,4:ROOT.kMagenta}
184 h[
'bar_2'+
str(i)].SetLineColor(colours[i])
185 h[
'bar_2'+
str(i)].SetLineWidth(2)
186 h[
'bar_2'+
str(i)].SetStats(0)
188 h[
'bar_21'].Draw(
'same')
189 h[
'bar_22'].Draw(
'same')
190 h[
'bar_23'].Draw(
'same')
191 h[
'bar_24'].Draw(
'same')
192 h[
'lbar2']=ROOT.TLegend(0.6,0.6,0.99,0.99)
194 h[
'lbar2'].AddEntry(h[
'bar_2'+
str(i)],
'plane '+
str(i+1),
"f")
197 h[
'hit_3'+
str(i)].SetLineColor(colours[i])
198 h[
'hit_3'+
str(i)].SetLineWidth(2)
199 h[
'hit_3'+
str(i)].SetStats(0)
201 h[
'hit_31'].Draw(
'same')
202 h[
'hit_32'].Draw(
'same')
203 h[
'hit_33'].Draw(
'same')
204 h[
'lbar3']=ROOT.TLegend(0.6,0.6,0.99,0.99)
206 h[
'lbar3'].AddEntry(h[
'hit_3'+
str(i)],
'plane '+
str(i+1),
"f")
209 ut.bookCanvas(h,
'LR',
' ',1800,900,3,2)
211 h[
'leftvsright_'+
str(1)].Draw(
'textBox')
213 h[
'leftvsright_'+
str(2)].Draw(
'textBox')
215 h[
'leftvsright_'+
str(3)].Draw(
'textBox')
217 h[
'leftvsright_signal_1'].SetMaximum(h[
'leftvsright_signal_1'].GetBinContent(10,10))
218 h[
'leftvsright_signal_2'].SetMaximum(h[
'leftvsright_signal_2'].GetBinContent(10,10))
219 h[
'leftvsright_signal_3'].SetMaximum(h[
'leftvsright_signal_3'].GetBinContent(10,10))
220 h[
'leftvsright_signal_'+
str(1)].Draw(
'colz')
222 h[
'leftvsright_signal_'+
str(2)].Draw(
'colz')
224 h[
'leftvsright_signal_'+
str(3)].Draw(
'colz')
226 ut.bookCanvas(h,
'LRinEff',
' ',1800,450,3,1)
228 h[
'lLRinEff'+
str(s)]=ROOT.TLegend(0.6,0.54,0.99,0.93)
229 name =
'leftvsright_signal_'+
str(s)
230 h[name+
'0Y'] = h[name].ProjectionY(name+
'0Y',1,1)
231 h[name+
'0X'] = h[name].ProjectionX(name+
'0X',1,1)
232 h[name+
'1X'] = h[name].ProjectionY(name+
'1Y')
233 h[name+
'1Y'] = h[name].ProjectionX(name+
'1X')
234 tc = h[
'LRinEff'].cd(s)
236 h[name+
'0X'].SetStats(0)
237 h[name+
'0Y'].SetStats(0)
238 h[name+
'1X'].SetStats(0)
239 h[name+
'1Y'].SetStats(0)
240 h[name+
'0X'].SetLineColor(ROOT.kRed)
241 h[name+
'0Y'].SetLineColor(ROOT.kGreen)
242 h[name+
'1X'].SetLineColor(ROOT.kMagenta)
243 h[name+
'1Y'].SetLineColor(ROOT.kCyan)
244 h[name+
'0X'].SetMaximum(max(h[name+
'1X'].GetMaximum(),h[name+
'1Y'].GetMaximum()))
246 h[name+
'0Y'].Draw(
'same')
247 h[name+
'1X'].Draw(
'same')
248 h[name+
'1Y'].Draw(
'same')
250 h[
'lLRinEff'+
str(s)].AddEntry(h[name+
'0X'],
'left with no signal right',
"f")
251 h[
'lLRinEff'+
str(s)].AddEntry(h[name+
'0Y'],
'right with no signal left',
"f")
252 h[
'lLRinEff'+
str(s)].AddEntry(h[name+
'1X'],
'left all',
"f")
253 h[
'lLRinEff'+
str(s)].AddEntry(h[name+
'1Y'],
'right all',
"f")
254 h[
'lLRinEff'+
str(s)].Draw()
258 ut.bookCanvas(h,
'signalUSVeto',
' ',1200,1600,3,7)
261 for plane
in range(2):
262 for side
in [
'L',
'R',
'S']:
263 tc = h[
'signalUSVeto'].cd(l)
265 if side==
'S':
continue
266 h[
'sig'+side+
'_'+
str( s*10+plane)].Draw()
268 for plane
in range(5):
269 for side
in [
'L',
'R',
'S']:
270 tc = h[
'signalUSVeto'].cd(l)
272 h[
'sig'+side+
'_'+
str( s*10+plane)].Draw()
273 ut.bookCanvas(h,
'signalDS',
' ',900,1600,2,7)
276 for plane
in range(7):
277 for side
in [
'L',
'R']:
278 tc = h[
'signalDS'].cd(l)
280 h[
'sig'+side+
'_'+
str( s*10+plane)].Draw()
283 for canvas
in [
'signalUSVeto',
'LR',
'hitmaps',
'barmaps',
'signal',
'Tsignal',
'USBars']:
285 h[canvas].Print(canvas+
'-run'+
str(options.runNumber)+
'.png')
320 trackTask.ExecuteTask()
323 for aTrack
in eventTree.fittedTracks:
324 state = aTrack.getFittedState()
326 rc = h[
'bs'].Fill(pos.x(),pos.y())
327 points = aTrack.getPoints()
329 m = p.getRawMeasurement()
331 key = m.getHitId()//1000
332 aHit = eventTree.Digi_MuFilterHits[key]
333 if aHit.GetDetectorID() != detID:
continue
335 l = (detID%10000)//1000
342 if s==3
and l%2==0: Ybar=bar
343 if s==3
and l%2==1: Xbar=bar
344 nSiPMs = aHit.GetnSiPMs()
345 nSides = aHit.GetnSides()
346 for p
in range(nSides):
347 c=bar*nSiPMs*nSides + p*nSiPMs
348 for i
in range(nSiPMs):
349 signal = aHit.GetSignal(i+p*nSiPMs)
351 rc = h[
'Tsig_'+
str(s)+
str(l)].Fill(signal)
353 slopeY= mom.X()/mom.Z()
354 slopeX= mom.Y()/mom.Z()
355 h[
'slopes'].Fill(slopeX,slopeY)
356 if not Ybar<0
and not Xbar<0
and abs(slopeY)<0.01: rc = h[
'bsDS'].Fill(Xbar,Ybar)
363 for s
in systemAndPlanes:
364 for plane
in range(systemAndPlanes[s]):
365 stations[s*10+plane] = {}
367 for aHit
in eventTree.Digi_MuFilterHits:
369 if not aHit.isValid():
continue
370 s = aHit.GetDetectorID()//10000
371 p = (aHit.GetDetectorID()//1000)%10
372 bar = aHit.GetDetectorID()%1000
375 if bar<60: plane = s*10+2*p
376 else: plane = s*10+2*p+1
377 stations[plane][k] = aHit
378 if not len(stations[30])*len(stations[31])*len(stations[32])*len(stations[33]) == 1:
return -1
381 for p
in range(30,34):
382 k = list(stations[p].keys())[0]
383 hitlist[k] = stations[p][k]
384 theTrack = trackTask.fitTrack(hitlist)
388 name = {1:
'Veto',2:
'US',3:
'DS'}
389 for s
in systemAndPlanes:
390 for l
in range(systemAndPlanes[s]):
391 ut.bookHist(h,
'dtLRvsX_'+name[s]+
str(s*10+l),
'dt vs x track '+
str(s*10+l)+
";X [cm]; dt [ns]",80,-70.,10.,100,-10.,10.)
393 for l
in range(systemAndPlanes[s]):
394 ut.bookHist(h,
'resY_'+name[s]+
str(s*10+l),
'residual Y '+
str(s*10+l),100,-20.,20.)
395 ut.bookHist(h,
'resY_'+name[s]+
'L'+
str(s*10+l),
'residual Y '+
str(s*10+l),100,-20.,20.)
396 ut.bookHist(h,
'resY_'+name[s]+
'R'+
str(s*10+l),
'residual Y '+
str(s*10+l),100,-20.,20.)
397 ut.bookHist(h,
'resY_'+name[s]+
'S'+
str(s*10+l),
'residual Y '+
str(s*10+l),100,-20.,20.)
398 ut.bookHist(h,
'track_'+name[s]+
str(s*10+l),
'track x/y '+
str(s*10+l),80,-70.,10.,80,0.,80.)
399 for bar
in range(10):
400 ut.bookHist(h,
'nSiPMs_'+name[s]+
str(s*10+l)+
'_'+
str(bar),
'#sipms',16,-0.5,15.5)
401 ut.bookHist(h,
'signalS_'+name[s]+
str(s*10+l)+
'_'+
str(bar),
'signal',100,0.,200.)
402 ut.bookHist(h,
'signalL_'+name[s]+
str(s*10+l)+
'_'+
str(bar),
'signal',100,0.,200.)
404 if Nev < 0 : Nev = eventTree.GetEntries()
406 for event
in eventTree:
410 if not hasattr(theTrack,
"getFittedState"):
continue
412 state = theTrack.getFittedState()
418 for p
in range(5): dsHits[s*10+p]=[]
419 for aHit
in eventTree.Digi_MuFilterHits:
420 if not aHit.isValid():
continue
421 plane = (aHit.GetDetectorID()//1000)
422 dsHits[plane].append(aHit)
424 for plane
in range(5):
426 lam = (z-pos.z())/mom.z()
427 xEx,yEx = pos.x()+lam*mom.x(),pos.y()+lam*mom.y()
429 if plane ==0: tag = 1
432 for aHit
in dsHits[s*10+tag]:
433 detID = aHit.GetDetectorID()
435 dy = (A[1]+B[1])/2. - yEx
436 if abs(dy)<5: tagged =
True
437 if not tagged:
continue
438 rc = h[
'track_US'+
str(s*10+plane)].Fill(xEx,yEx)
439 for aHit
in dsHits[s*10+plane]:
440 detID = aHit.GetDetectorID()
443 dy = (A[1]+B[1])/2. - yEx
444 rc = h[
'resY_US'+
str(s*10+plane)].Fill(dy)
445 S = aHit.GetAllSignals()
447 left,right,small =
False,
False,
False
449 if x.first<8: left =
True
452 if left: rc = h[
'resY_USL'+
str(s*10+plane)].Fill(dy)
453 if right: rc = h[
'resY_USR'+
str(s*10+plane)].Fill(dy)
454 if small: rc = h[
'resY_USS'+
str(s*10+plane)].Fill(dy)
456 rc = h[
'nSiPMs_US'+
str(s*10+plane)+
'_'+
str(bar)].Fill(S.size())
459 else: rc = h[
'signalL_US'+
str(s*10+plane)+
'_'+
str(bar)].Fill(x.second)
461 dt = aHit.GetDeltaT(
False)
462 h[
'dtLRvsX_US'+
str(s*10+plane)].Fill(xEx,dt*1E9/freq)
465 for plane
in range(4):
467 lam = (z-pos.z())/mom.z()
468 xEx,yEx = pos.x()+lam*mom.x(),pos.y()+lam*mom.y()
469 for aHit
in dsHits[s*10+plane]:
471 if not aHit.GetnSides()==2:
continue
472 detID = aHit.GetDetectorID()
474 dt = aHit.GetDeltaT(
False)
475 h[
'dtLRvsX_DS'+
str(s*10+plane)].Fill(xEx,dt*1E9/freq)
481 ut.bookCanvas(h,
'E',
'',1200,2000,4,5)
482 ut.bookCanvas(h,
'T',
'',800,1600,1,5)
483 ut.bookCanvas(h,
'TDS',
'',800,900,1,2)
485 for plane
in range(5):
486 tc = h[
'E'].cd(4*plane+1)
487 h[
'track_US'+
str(s*10+plane)].Draw(
'colz')
489 for side
in [
'L',
'R',
'S']:
490 tc = h[
'E'].cd(4*plane+2+l)
492 res = h[
'resY_US'+side+
str(s*10+plane)]
494 binw = res.GetBinWidth(1)
495 myGauss = ROOT.TF1(
'gauss',
'abs([0])*'+
str(binw)+
'/(abs([2])*sqrt(2*pi))*exp(-0.5*((x-[1])/[2])**2)+abs([3])',4)
496 myGauss.SetParameter(0,res.GetEntries())
497 myGauss.SetParameter(1,0)
498 myGauss.SetParameter(2,2.)
499 rc = res.Fit(myGauss,
'SL',
'',-15.,15.)
502 stats = res.FindObject(
'stats')
503 stats.SetOptFit(111111)
508 tracks = h[
'track_US'+
str(s*10+plane)].GetEntries()
509 eff = fitResult.Parameter(0)/tracks
510 effErr = fitResult.ParError(0)/tracks
511 latex.DrawLatexNDC(0.2,0.8,
'eff=%5.2F+/-%5.2F%%'%(eff,effErr))
512 h[
'E'].Print(
'Eff'+
'-run'+
str(options.runNumber)+
'.png')
514 latex.SetTextColor(ROOT.kRed)
515 for plane
in range(5):
516 tc = h[
'T'].cd(plane+1)
517 hist = h[
'dtLRvsX_US'+
str(s*10+plane)]
521 h[
'gdtLRvsX_US'+
str(s*10+plane)] = ROOT.TGraph()
522 g = h[
'gdtLRvsX_US'+
str(s*10+plane)]
523 xproj = hist.ProjectionX(
'tmpx')
524 for nx
in range(1,hist.GetNbinsX()+1):
525 tmp = hist.ProjectionY(
'tmp',nx,nx)
526 X = xproj.GetBinCenter(nx)
528 g.SetPoint(nx-1,X,dt)
529 g.SetLineColor(ROOT.kBlue)
532 rc = g.Fit(
'pol1',
'S',
'',-50.,-10.)
534 m = 1./result.Parameter(1)
535 b = -result.Parameter(0) * m
536 txt =
'dt X relation: X = #frac{dt}{%5.2F} +%5.2F '%(1./m,b)
537 latex.DrawLatexNDC(0.2,0.8,txt)
538 h[
'T'].Print(
'dTvsX'+
'-run'+
str(options.runNumber)+
'.png')
542 for plane
in range(2):
543 tc = h[
'TDS'].cd(plane+1)
544 hist = h[
'dtLRvsX_DS'+
str(s*10+plane)]
548 h[
'gdtLRvsX_DS'+
str(s*10+plane)] = ROOT.TGraph()
549 g = h[
'gdtLRvsX_DS'+
str(s*10+plane)]
550 xproj = hist.ProjectionX(
'tmpx')
551 for nx
in range(1,hist.GetNbinsX()+1):
552 tmp = hist.ProjectionY(
'tmp',nx,nx)
553 X = xproj.GetBinCenter(nx)
555 g.SetPoint(nx-1,X,dt)
556 g.SetLineColor(ROOT.kBlue)
559 rc = g.Fit(
'pol1',
'S',
'',-50.,-10.)
561 m = 1./result.Parameter(1)
562 b = -result.Parameter(0) * m
563 txt =
'dt X relation: X = #frac{dt}{%5.2F} +%5.2F '%(1./m,b)
564 latex.DrawLatexNDC(0.2,0.8,txt)
565 h[
'TDS'].Print(
'dTvsXDS'+
'-run'+
str(options.runNumber)+
'.png')
568 binning = {1:50,2:50,3:50}
569 for s
in systemAndPlanes:
570 for l
in range(systemAndPlanes[s]):
571 ut.bookHist(h,
'timeDiffsL_'+
str(s*10+l),
' deviation from mean'+
str(s*10+l)+
'; [ns]',100,-binning[s],binning[s])
572 ut.bookHist(h,
'timeDiffsR_'+
str(s*10+l),
' deviation from mean'+
str(s*10+l)+
'; [ns]',100,-binning[s],binning[s])
573 ut.bookHist(h,
'timeDiffsLR_'+
str(s*10+l),
' mean left - mean right'+
str(s*10+l)+
'; [ns]',100,-binning[s],binning[s])
576 if Nev < 0 : Nev = eventTree.GetEntries()
577 for event
in eventTree:
580 for aHit
in event.Digi_MuFilterHits:
581 if not aHit.isValid():
continue
582 detID = aHit.GetDetectorID()
584 l = (detID%10000)//1000
591 nSides = aHit.GetnSides()
592 nSiPMs = aHit.GetnSiPMs()
594 allChannels = aHit.GetAllTimes()
597 for c
in allChannels:
604 if nL >0: meanL = meanL/nL * 1E9/freq
605 if nR >0: meanR = meanR/nR * 1E9/freq
606 if nL>0
and nR>0: rc = h[
'timeDiffsLR_'+
str(s*10+l)].Fill(meanL-meanR)
607 for c
in allChannels:
609 dt = c[1]* 1E9/freq - meanL
610 rc = h[
'timeDiffsL_'+
str(s*10+l)].Fill(dt)
612 dt = c[1]* 1E9/freq - meanR
613 rc = h[
'timeDiffsR_'+
str(s*10+l)].Fill(dt)
615 installed_stations = {0:0,1:5,2:4}
618 for s
in installed_stations:
619 if installed_stations[s]>0: x+=1
620 if installed_stations[s]>y: y = installed_stations[s]
621 ut.bookCanvas(h,
'dt',
' ',800,1600,1,5)
622 ut.bookCanvas(h,
'dtLR',
' ',1200,1600,x,y)
624 for S
in installed_stations:
625 for l
in range(installed_stations[S]):
630 h[
'timeDiffsL_'+
str(S+1)+
str(l)].SetLineColor(ROOT.kRed)
631 h[
'timeDiffsL_'+
str(S+1)+
str(l)].Draw()
632 h[
'timeDiffsR_'+
str(S+1)+
str(l)].SetLineColor(ROOT.kGreen)
633 h[
'timeDiffsR_'+
str(S+1)+
str(l)].Draw(
'same')
636 h[
'timeDiffsLR_'+
str(S+1)+
str(l)].Draw()
637 h[
'dt'].Print(
'dt'+
'-run'+
str(options.runNumber)+
'.png')
638 h[
'dtLR'].Print(
'dtLR'+
'-run'+
str(options.runNumber)+
'.png')