90 def ExecuteEvent(self,event):
91 h = self.M.h
92 tag = self.tag
93 DetID2Key={}
94 for nHit in range(event.Digi_ScifiHits.GetEntries()):
95 DetID2Key[event.Digi_ScifiHits[nHit].GetDetectorID()] = nHit
96
97 for aTrack in self.M.Reco_MuonTracks:
98 if not aTrack.GetUniqueID()==1: continue
99 fitStatus = aTrack.getFitStatus()
100 if not fitStatus.isFitConverged(): continue
101 state = aTrack.getFittedState()
102 mom = state.getMom()
103 slopeX = mom.X()/mom.Z()
104 slopeY = mom.Y()/mom.Z()
105 sortedClusters={}
106
107 pos = {}
108 for s in range(1, nStations+1): sortedClusters[s] = {'H':[],'V':[]}
109 for nM in range(aTrack.getNumPointsWithMeasurement()):
110 state = aTrack.getFittedState(nM)
111 Meas = aTrack.getPointWithMeasurement(nM)
112 W = Meas.getRawMeasurement()
113 clkey = W.getHitId()
114 aCl = self.M.trackTask.clusScifi[clkey]
115 aHit = event.Digi_ScifiHits[DetID2Key[aCl.GetFirst()]]
116 s = aCl.GetFirst()//1000000
117 aCl.GetPosition(A,B)
118 mat = (aCl.GetFirst()//10000)%10
119 if aHit.isVertical():
120 L = B[1]-state.getPos()[1]
121 sortedClusters[s]['V'].append( [clkey,L,B[0],state.getPos()[1],mat,(A[2]+B[2])/2.] )
122 rc = h['res'+str(s)+'V'].Fill( (A[0]+B[0])/2.-state.getPos()[0])
123 else:
124 L = A[0]-state.getPos()[0]
125 sortedClusters[s]['H'].append( [clkey,L,A[1],state.getPos()[0],mat,(A[2]+B[2])/2.] )
126 rc = h['res'+str(s)+'H'].Fill( (A[1]+B[1])/2.-state.getPos()[1])
127
128 for s in range(1, nStations+1):
129 if not (len(sortedClusters[s]['V']) * len(sortedClusters[s]['H']) ) ==1: continue
130 timeCorr = {}
131 for proj in ['V','H']:
132 clkey = sortedClusters[s][proj][0][0]
133 aCl = self.M.trackTask.clusScifi[clkey]
134 L = sortedClusters[s][proj][0][1]
135 rc = h['extrap'+str(s)+proj].Fill(abs(L))
136 time = aCl.GetTime()
138 mat = sortedClusters[s][proj][0][4]
139 time-= self.tdcScifiStationCalib[s][1][proj][mat]
140 time-= self.tdcScifiStationCalib[s][0]
141 timeCorr[proj] = time - abs(L)/self.V
142
143 dt = timeCorr['H'] - timeCorr['V']
144 rc = h['CTR_Scifi'+str(s)+tag].Fill(dt)
145 matH,matV = sortedClusters[s]['H'][0][4],sortedClusters[s]['V'][0][4]
146 rc = h['CTR_Scifi'+str(100*s+10*matH+matV)+tag].Fill(dt)
147 if abs(slopeX)<0.1 and abs(slopeY)<0.1:
148 rc = h['CTR_Scifi_beam'+str(s)+tag].Fill(dt)
149 rc = h['CTR_Scifi_beam'+str(100*s+10*matH+matV)+tag].Fill(dt)
150 dR = sortedClusters[s]['V'][0][2] - sortedClusters[s]['H'][0][3]
151 rc = h['resX'+str(s)+'V'].Fill(dR)
152 dR = sortedClusters[s]['H'][0][2]-sortedClusters[s]['V'][0][3]
153 rc = h['resX'+str(s)+'H'].Fill(dR)
154
155 if tag!='v0':
156 stationTimes = {}
157 for s in range(1, nStations+1):
158 if not (len(sortedClusters[s]['V']) * len(sortedClusters[s]['H']) ) ==1: continue
159 sTime = 0
160 for proj in ['V','H']:
161 clkey = sortedClusters[s][proj][0][0]
162 aCl = self.M.trackTask.clusScifi[clkey]
163 L = sortedClusters[s][proj][0][1]
164 time = aCl.GetTime()
166 mat = sortedClusters[s][proj][0][4]
167 time-= self.tdcScifiStationCalib[s][1][proj][mat]
168 time-= self.tdcScifiStationCalib[s][0]
169 time-= abs(L)/self.V
170 sTime += time
171 stationTimes[s] = [sTime/2.,(sortedClusters[s]['H'][0][5] + sortedClusters[s]['V'][0][5])/2.]
172 for s1 in range(1, nStations):
173 if not s1 in stationTimes: continue
174 for s2 in range(s1+1, nStations+1):
175 if not s2 in stationTimes: continue
176 dT = stationTimes[s2][0] - stationTimes[s1][0]
177
178 dZ = stationTimes[s2][1] - stationTimes[s1][1]
179 dL = dZ * ROOT.TMath.Sqrt( slopeX**2+slopeY**2+1 )
180 if slopeY>0.1: dL = -dL
181 dT -= dL / u.speedOfLight
182 rc = h['CTR_ScifiStation'+str(s1*10+s2)+tag].Fill(dT)
183 if abs(slopeX)<0.1 and abs(slopeY)<0.1:
184 rc = h['CTR_ScifiStation_beam'+str(s1*10+s2)+tag].Fill(dT)
185
Double_t GetCorrectedTime(Int_t fDetectorID, Double_t rawTime, Double_t L)