111 def ExecuteEvent(self,event):
112 h = self.M.h
113 tag = self.tag
114 DetID2Key={}
115 for nHit in range(event.Digi_ScifiHits.GetEntries()):
116 DetID2Key[event.Digi_ScifiHits[nHit].GetDetectorID()] = nHit
117
118 for aTrack in self.M.Reco_MuonTracks:
119 if not aTrack.GetUniqueID()==1: continue
120 fitStatus = aTrack.getFitStatus()
121 if not fitStatus.isFitConverged(): continue
122 state = aTrack.getFittedState()
123 mom = state.getMom()
124 slopeX = mom.X()/mom.Z()
125 slopeY = mom.Y()/mom.Z()
126 sortedClusters={}
127
128 pos = {}
129 for s in range(1, nStations+1): sortedClusters[s] = {'H':[],'V':[]}
130 for nM in range(aTrack.getNumPointsWithMeasurement()):
131 state = aTrack.getFittedState(nM)
132 Meas = aTrack.getPointWithMeasurement(nM)
133 W = Meas.getRawMeasurement()
134 clkey = W.getHitId()
135 aCl = self.M.trackTask.clusScifi[clkey]
136 aHit = event.Digi_ScifiHits[DetID2Key[aCl.GetFirst()]]
137 detID = aCl.GetFirst()
138 s = detID//1000000
139 aCl.GetPosition(A,B)
140 mat = (detID//10000)%10
141 if aHit.isVertical():
142 L = B[1]-state.getPos()[1]
143 sortedClusters[s]['V'].append( [clkey,L,B[0],state.getPos()[1],mat,(A[2]+B[2])/2.,state.getPos()[0],aCl.GetFirst(),aCl.GetTime()] )
144 rc = h['res'+str(s)+'V'].Fill( (A[0]+B[0])/2.-state.getPos()[0])
145 else:
146 L = A[0]-state.getPos()[0]
147 sortedClusters[s]['H'].append( [clkey,L,A[1],state.getPos()[0],mat,(A[2]+B[2])/2.,state.getPos()[1],aCl.GetFirst(),aCl.GetTime()] )
148 rc = h['res'+str(s)+'H'].Fill( (A[1]+B[1])/2.-state.getPos()[1])
149
150 for s in range(1, nStations+1):
151 if not (len(sortedClusters[s]['V']) * len(sortedClusters[s]['H']) ) ==1: continue
152 timeCorr = {}
153 for proj in ['V','H']:
154 clkey = sortedClusters[s][proj][0][0]
155 aCl = self.M.trackTask.clusScifi[clkey]
156 L = sortedClusters[s][proj][0][1]
157 rc = h['extrap'+str(s)+proj].Fill(abs(L))
158 time = aCl.GetTime()
160 mat = sortedClusters[s][proj][0][4]
161 sipm_array = int(sortedClusters[s][proj][0][7]/1000)%10
162 sipm_channel = sortedClusters[s][proj][0][7]%1000
163 if channelTimeAlignment==1 and s==2 and proj=='H':
164 time-= self.tdcScifiStationCalib[s][1][proj][1][sipm_array][sipm_channel]
165 time-= self.tdcScifiStationCalib[s][1][proj][mat]
166 time-= self.tdcScifiStationCalib[s][0]
167 timeCorr[proj] = time - abs(L)/self.V
168
169 dt = timeCorr['H'] - timeCorr['V']
170 rc = h['CTR_Scifi'+str(s)+tag].Fill(dt)
171 for proj in ['V','H']:
172 if proj=='V': o=1
173 else: o=0
174 if channelTimeAlignment==1 and s==2 and proj=='H':
175 rc = h['CTR_ScifiMat'+str(sortedClusters[s][proj][0][7])+tag].Fill(dt)
176 rc=h['dT_posxV'+str(s)+tag].Fill(sortedClusters[s]['V'][0][6],dt)
177 rc=h['dT_posxH'+str(s)+tag].Fill(sortedClusters[s]['H'][0][3],dt)
178 rc=h['dT_posyH'+str(s)+tag].Fill(sortedClusters[s]['H'][0][6], dt)
179 rc=h['dT_posyV'+str(s)+tag].Fill(sortedClusters[s]['V'][0][3], dt)
180 rc=h['CTR_timeH_posy_Scifi'+str(s)+tag].Fill(sortedClusters[s]['H'][0][6], sortedClusters[s][proj][0][8])
181 rc=h['CTR_timeV_posy_Scifi'+str(s)+tag].Fill(sortedClusters[s]['V'][0][3],sortedClusters[s][proj][0][8])
182
183 matH,matV = sortedClusters[s]['H'][0][4],sortedClusters[s]['V'][0][4]
184 rc = h['CTR_Scifi'+str(100*s+10*matH+matV)+tag].Fill(dt)
185 if abs(slopeX)<0.1 and abs(slopeY)<0.1:
186 rc = h['CTR_Scifi_beam'+str(s)+tag].Fill(dt)
187 rc = h['CTR_Scifi_beam'+str(100*s+10*matH+matV)+tag].Fill(dt)
188 dR = sortedClusters[s]['V'][0][2] - sortedClusters[s]['H'][0][3]
189 rc = h['resX'+str(s)+'V'].Fill(dR)
190 dR = sortedClusters[s]['H'][0][2]-sortedClusters[s]['V'][0][3]
191 rc = h['resX'+str(s)+'H'].Fill(dR)
192
193 if tag!='v0' and tag!='v0prime':
194 stationTimes = {}
195 for s in range(1, nStations+1):
196 if not (len(sortedClusters[s]['V']) * len(sortedClusters[s]['H']) ) ==1: continue
197 sTime = 0
198 for proj in ['V','H']:
199 clkey = sortedClusters[s][proj][0][0]
200 aCl = self.M.trackTask.clusScifi[clkey]
201 L = sortedClusters[s][proj][0][1]
202 time = aCl.GetTime()
204 mat = sortedClusters[s][proj][0][4]
205 time-= self.tdcScifiStationCalib[s][1][proj][mat]
206 time-= self.tdcScifiStationCalib[s][0]
207 time-= abs(L)/self.V
208 sTime += time
209 stationTimes[s] = [sTime/2.,(sortedClusters[s]['H'][0][5] + sortedClusters[s]['V'][0][5])/2.]
210 for s1 in range(1, nStations):
211 if not s1 in stationTimes: continue
212 for s2 in range(s1+1, nStations+1):
213 if not s2 in stationTimes: continue
214 dT = stationTimes[s2][0] - stationTimes[s1][0]
215
216 dZ = stationTimes[s2][1] - stationTimes[s1][1]
217 dL = dZ * ROOT.TMath.Sqrt( slopeX**2+slopeY**2+1 )
218 if slopeY>0.1: dL = -dL
219 dT -= dL / u.speedOfLight
220 rc = h['CTR_ScifiStation'+str(s1*10+s2)+tag].Fill(dT)
221 if abs(slopeX)<0.1 and abs(slopeY)<0.1:
222 rc = h['CTR_ScifiStation_beam'+str(s1*10+s2)+tag].Fill(dT)
223
Double_t GetCorrectedTime(Int_t fDetectorID, Double_t rawTime, Double_t L)