360 def ExecuteEvent(self,event):
361 h = self.M.h
362 s = 1
363 vetoHits = {10:[],11:[]}
364 for aHit in event.Digi_MuFilterHits:
365 if not aHit.isValid(): continue
366 detID = aHit.GetDetectorID()//1000
367 if not detID<20: continue
368 vetoHits[detID].append(aHit)
369 if not(len(vetoHits[10])==1) and not(len(vetoHits[11])==1): return
370
371 DetID2Key={}
372 for nHit in range(event.Digi_ScifiHits.GetEntries()):
373 DetID2Key[event.Digi_ScifiHits[nHit].GetDetectorID()] = nHit
374
375 Z0 = self.zPos['Scifi'][10]
376 times = []
377 for aTrack in event.Reco_MuonTracks:
378 if not aTrack.GetUniqueID()==1: continue
379 tdc = {10:{},11:{}}
380 S = aTrack.getFitStatus()
381 if not S.isFitConverged(): continue
382 mom = aTrack.getFittedState().getMom()
383 pos = aTrack.getFittedState().getPos()
384 slopeX = mom.X()/mom.Z()
385 slopeY = mom.Y()/mom.Z()
386
387 for nM in range(aTrack.getNumPointsWithMeasurement()):
388 state = aTrack.getFittedState(nM)
389 Meas = aTrack.getPointWithMeasurement(nM)
390 W = Meas.getRawMeasurement()
391 clkey = W.getHitId()
392 aCl = event.Cluster_Scifi[clkey]
393 aHit = event.Digi_ScifiHits[DetID2Key[aCl.GetFirst()]]
394 s = aCl.GetFirst()//1000000
395 aCl.GetPosition(A,B)
396 mat = (aCl.GetFirst()//10000)%10
397 if aHit.isVertical():
398 proj = 'V'
399 L = B[1]-state.getPos()[1]
400 else:
401 proj = 'H'
402 L = A[0]-state.getPos()[0]
403 time = aCl.GetTime()
404 time-= self.tdcScifiStationCalib[s][1][proj][mat]
405 time-= self.tdcScifiStationCalib[s][0]
406 time-= abs(L)/self.V
407
408 dZ = (A[2]+B[2])/2. - Z0
409 dL = dZ * ROOT.TMath.Sqrt( slopeX**2+slopeY**2+1 )
410 if slopeY>0.1: dL = -dL
411 time-= dL/self.C
412
413 times.append(time)
414
415 sTime = statistics.mean(times)
416 rms = statistics.stdev(times)
417 rc = h['trms'].Fill(rms)
418 s = 1
419 for l in range(2):
420 zEx = self.M.zPos['MuFilter'][1*10+l]
421 lam = (zEx-pos.z())/mom.z()
422 yEx = pos.y()+lam*mom.y()
423 xEx = pos.x()+lam*mom.x()
424 for aHit in vetoHits[10+l]:
425 detID = aHit.GetDetectorID()
427 D = (A[1]+B[1])/2. - yEx
428 if abs(D)<5:
429 bar = (detID%1000)
430 tdc[10+l][bar] = {'L':{},'R':{}}
431 for k in range(16):
432 qdc = aHit.GetSignal(k)
433 if qdc <0: continue
434 kx = k
435 side = 'L'
436 L = A[0]-xEx
437 if not k < 8 :
438 kx = k - 8
439 side = 'R'
440 L = B[0]-xEx
441 T = aHit.GetTime(k) * self.M.TDC2ns
442 T-= abs(L)/self.Vveto
443
444 dZ = (A[2]+B[2])/2. - Z0
445 dL = dZ * ROOT.TMath.Sqrt( slopeX**2+slopeY**2+1 )
446 if slopeY>0.1: dL = -dL
447 T-= dL/self.C
448 key = self.M.sdict[s]+str(s*10+l)+'_'+str(bar)+side+str(kx)
449
450 h['tvsQDC_'+key].Fill(qdc,T-sTime)
451
void GetPosition(Int_t id, TVector3 &vLeft, TVector3 &vRight)