356 def ExecuteEvent(self,event):
357 h = self.M.h
358 for aTrack in self.M.Reco_MuonTracks:
359 if not aTrack.GetUniqueID()==1: continue
360 fitStatus = aTrack.getFitStatus()
361 if not fitStatus.isFitConverged(): continue
362 state = aTrack.getFittedState()
363 mom = state.getMom()
364 slopeX = mom.X()/mom.Z()
365 slopeY = mom.Y()/mom.Z()
366 sortedClusters={}
367 DetID2Key={}
368 for nHit in range(event.Digi_ScifiHits.GetEntries()):
369 DetID2Key[event.Digi_ScifiHits[nHit].GetDetectorID()] = nHit
370
371 pos = {}
372 for s in range(1, nStations+1): sortedClusters[s] = {'H':[],'V':[]}
373 for nM in range(aTrack.getNumPointsWithMeasurement()):
374 state = aTrack.getFittedState(nM)
375 Meas = aTrack.getPointWithMeasurement(nM)
376 W = Meas.getRawMeasurement()
377 clkey = W.getHitId()
378 aCl = self.trackTask.clusScifi[clkey]
379 aHit = event.Digi_ScifiHits[DetID2Key[aCl.GetFirst()]]
380 s = aCl.GetFirst()//1000000
381 aCl.GetPosition(A,B)
382 mat = (aCl.GetFirst()//10000)%10
383
384 if aHit.isVertical():
385 L = B[1]-state.getPos()[1]
386 sortedClusters[s]['V'].append( [clkey,L,B[0],state.getPos()[1],mat,(A[2]+B[2])/2.] )
387 else:
388 L = A[0]-state.getPos()[0]
389 sortedClusters[s]['H'].append( [clkey,L,A[1],state.getPos()[0],mat,(A[2]+B[2])/2.] )
390 stationTimes = {}
391 for s in range(1, nStations+1):
392 if not (len(sortedClusters[s]['V']) * len(sortedClusters[s]['H']) ) ==1: continue
393 sTime = 0
394 for proj in ['V','H']:
395 clkey = sortedClusters[s][proj][0][0]
396 aCl = self.trackTask.clusScifi[clkey]
397 L = sortedClusters[s][proj][0][1]
398 time = aCl.GetTime()
399 mat = sortedClusters[s][proj][0][4]
400 time-= self.tdcScifiStationCalib[s][1][proj][mat]
401 time-= self.tdcScifiStationCalib[s][0]
402 time-= abs(L)/self.V
403
404
405
406
407
408 sTime += time
409 stationTimes[s] = [sTime/2.,(sortedClusters[s]['H'][0][5] + sortedClusters[s]['V'][0][5])/2.]
410
411 if not 1 in stationTimes: continue
412
413 T0 = stationTimes[1][0]
414 Z0 = stationTimes[1][1]
415 for s in stationTimes:
416 if s == 1: continue
417 dZ = stationTimes[s][1]-Z0
418 dT = stationTimes[s][0]-T0
419 dL = dZ * ROOT.TMath.Sqrt( slopeX**2+slopeY**2+1 )
420
421
422 rc = h['dTvsZ'].Fill(dL,dT)
423 if abs(slopeX)<0.1 and abs(slopeY)<0.1:
424 rc = h['dTvsZ_beam'].Fill(dL,dT)
425
426
427