971 def ExecuteEvent(self,event):
972 scifiCorTest = False
973 systemAndPlanes = self.M.systemAndPlanes
974 sdict = self.M.sdict
975 s = 1
976 h = self.M.h
977 W = self.M.Weight
979 hits = {2:0,1:0,0:0,'0L':0,'0R':0,'1L':0,'1R':0}
980 vetoHitsFromPrev = 0
981 if event.EventHeader.GetRunId() < 6204 and event.EventHeader.GetRunId() > 5480: vetoHitsFromPrev = 5
982
983 N1 = event.GetReadEntry()
984 Tcurrent = event.EventHeader.GetEventTime()
985 dT = abs(Tcurrent-self.eventBefore['T'])
986 prevAdded = False
987 for j in [0,-1]:
988 if j<0 and N1>0:
989 if dT > vetoHitsFromPrev: continue
990 rc = event.GetEvent(N1-1)
991 prevAdded = True
992 for aHit in event.Digi_MuFilterHits:
993 if not aHit.isValid(): continue
994 Minfo = self.M.MuFilter_PlaneBars(aHit.GetDetectorID())
995 s,l,bar = Minfo['station'],Minfo['plane'],Minfo['bar']
996 if s>1: continue
997 allChannels = self.M.map2Dict(aHit,'GetAllSignals')
998 hits[l]+=len(allChannels)
999 if l != 2:
1000 for c in allChannels:
1001 if nSiPMs > c:
1002 hits[str(l)+'L']+=1
1003 else:
1004 hits[str(l)+'R']+=1
1005 allChannels.clear()
1006 if prevAdded and N1>1:
1007 rc = event.GetEvent(N1-2)
1008 Tprevprev = event.EventHeader.GetEventTime()
1009 dT = abs(Tcurrent-Tprevprev)
1010 if prevAdded: event.GetEvent(N1)
1011 prevEvent = False
1012 tightNoiseFilter = None
1013 otherAdvTrigger = None
1014 otherFastTrigger = None
1015 if dT < self.deadTime and dT > vetoHitsFromPrev:
1016 prevEvent = True
1017
1018 if event.EventHeader.GetRunId() > 6567 and N1>0:
1019 tightNoiseFilter, otherFastTrigger, otherAdvTrigger,Nprev,dt = self.checkOtherTriggers(event)
1020
1021 tmpT = self.eventBefore['T']
1022 tmpN = self.eventBefore['N']
1023 self.eventBefore['T'] = Tcurrent
1024 if (self.M.EventNumber - self.eventBefore['N'] > 1) and self.M.options.postScale < 2:
1025 print('what is going on?', self.M.EventNumber, self.eventBefore['N'])
1026 self.eventBefore['N'] = self.M.EventNumber
1027
1028 rc = h['scaler'].Fill(11)
1029 if self.M.Reco_MuonTracks.GetEntries()<2: return
1030
1031 planes = {}
1032 for scifiTrack in self.M.Reco_MuonTracks:
1033 if not scifiTrack.GetUniqueID()==1: continue
1034 fitStatus = scifiTrack.getFitStatus()
1035 if not fitStatus.isFitConverged(): continue
1036 if fitStatus.getNdf() < 5 or fitStatus.getNdf()>12 : continue
1037 if fitStatus.getChi2()/fitStatus.getNdf() > 80: continue
1038 for nM in range(scifiTrack.getNumPointsWithMeasurement()):
1039 M = scifiTrack.getPointWithMeasurement(nM)
1040 W = M.getRawMeasurement()
1041 detID = W.getDetId()
1042 planes[detID//100000] = 1
1043 rc = h['scaler'].Fill(10)
1044 scifiOneEff = 10 in planes or 11 in planes or not scifiCorTest
1045 if not scifiOneEff and len(planes) < 8: return
1046 if scifiOneEff and len(planes) < 10: return
1047 rc = h['scaler'].Fill(0)
1048 if not prevEvent: rc = h['scaler'].Fill(1)
1049
1050 for l in range(systemAndPlanes[1]-1):
1051 rc = h['hitVeto_'+str(l)].Fill(hits[str(l)+'L'],hits[str(l)+'R'])
1052 rc = h['hitVeto_01'].Fill(hits[0],hits[1])
1053 if systemAndPlanes[1] > 2 :
1054 rc = h['hitVeto_02'].Fill(hits[0],hits[2])
1055 rc = h['hitVeto_12'].Fill(hits[1],hits[2])
1056
1057 for muTrack in self.M.Reco_MuonTracks:
1058 if not muTrack.GetUniqueID()==3: continue
1059 fstate = muTrack.getFittedState()
1060 posT,momT = fstate.getPos(),fstate.getMom()
1061 lam = (self.zEx-posT.z())/momT.z()
1062 yExTag = posT.y()+lam*momT.y()
1063 xExTag = posT.x()+lam*momT.x()
1064 sstate = scifiTrack.getFittedState()
1065 pos = sstate.getPos()
1066 delX = xExTag - pos.x()
1067 delY = yExTag - pos.y()
1068 rc = h['X/Y'].Fill(delX,delY)
1069 if abs(delX)>10 or abs(delY)>10: return
1070
1071 for aTrack in self.M.Reco_MuonTracks:
1072 if not aTrack.GetUniqueID()==1: continue
1073 fitStatus = aTrack.getFitStatus()
1074 if not fitStatus.isFitConverged(): continue
1075 fstate = aTrack.getFittedState()
1076 pos,mom = [fstate.getPos(),fstate.getMom()]
1077 beam = False
1078 if abs(mom.x()/mom.z())<0.1 and abs(mom.y()/mom.z())<0.1: beam = True
1079
1080
1081
1082 dsHitTimes = []
1083 for aHit in event.Digi_MuFilterHits:
1084 if not aHit.isValid(): continue
1085 detID = aHit.GetDetectorID()
1086 Minfo = self.M.MuFilter_PlaneBars(detID)
1087 s,l,bar = Minfo['station'],Minfo['plane'],Minfo['bar']
1088 if s==3 and l==2:
1090 timeLeft = aHit.GetTime(0)
1091 timeRight = aHit.GetTime(1)
1092 if timeLeft>0 and timeRight>0:
1093 dL = abs(A[0]-B[0])
1096 dsHitTimes.append( (avTime-abs(A[0]-B[0])/15)/2)
1097 dsHitTimes.sort()
1098 scifiHitTimes = {1:[],2:[],3:[],4:[],5:[]}
1099 deltaT = -100
1100 if len(dsHitTimes)>0:
1101 for scifiHit in event.Digi_ScifiHits:
1102 detID = scifiHit.GetDetectorID()
1103 s = int(scifiHit.GetDetectorID()/1000000)
1104 if s>1.5: continue
1106 for s in scifiHitTimes:
1107 if len(scifiHitTimes[s])<1: continue
1108 scifiHitTimes[s].sort()
1109 deltaT = dsHitTimes[0] - scifiHitTimes[s][0] - (self.M.zPos['MuFilter'][34]-self.M.zPos['Scifi'][s*10])/u.speedOfLight
1110 rc = h['deltaT'].Fill(deltaT)
1111 if deltaT < -10: continue
1112
1113 T1 = event.EventHeader.GetEventTime()
1114 N1 = event.EventHeader.GetEventNumber()
1115 if prevAdded: rc = event.GetEvent(N1-2)
1116 else: rc = event.GetEvent(N1-1)
1117 T0 = event.EventHeader.GetEventTime()
1118 rc = event.GetEvent(N1+1)
1119 T2 = event.EventHeader.GetEventTime()
1120 rc = event.GetEvent(N1)
1121 if (T1-T0) < 100 and self.M.options.postScale < 2:
1122 if not prevEvent: print('what is going on?',N1,T1,T0,N1-1,tmpN,tmpT)
1123 prevEvent = True
1124 s = 1
1125 xEx = {}
1126 yEx = {}
1127 for l in range(systemAndPlanes[1]):
1128 zEx = self.M.zPos['MuFilter'][s*10+l]
1129 lam = (zEx-pos.z())/mom.z()
1130 xEx[l] = pos.x()+lam*mom.x()
1131 yEx[l] = pos.y()+lam*mom.y()
1132 for l in range(systemAndPlanes[1]):
1133 for noiseCut in self.noiseCuts:
1134 c=''
1135 if not prevEvent: c='NoPrev'
1136 nc = 'T'+c+str(noiseCut)
1137 ncL = 'T'+'TiNoFi'+str(noiseCut)
1138 if hits[l] > noiseCut or (l==2 and hits[l] > int(noiseCut/2+0.5)):
1139 rc = h[nc+'PosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1140 if tightNoiseFilter: rc = h[ncL+'PosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1141 if beam: rc = h[nc+'beamPosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1142 else:
1143 rc = h[nc+'XPosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1144 rc = h[nc+'XPosVetoXL_'+str(l)].Fill(xEx[l],yEx[l])
1145 if tightNoiseFilter: h[ncL+'XPosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1146 if beam: rc = h[nc+'beamXPosVeto_'+str(l)].Fill(xEx[l],yEx[l])
1147 if l==0:
1148 if -45<xEx[l] and xEx[l]<-10 and 27<yEx[l] and yEx[l]<54:
1149 rc = h['timeDiffPrev_'+str(noiseCut)].Fill(T1-T0)
1150 rc = h['timeDiffNext_'+str(noiseCut)].Fill(T2-T1)
1151 if ( systemAndPlanes[1]==2 and hits[0] > noiseCut and hits[1] > noiseCut) or \
1152 ( systemAndPlanes[1]==3 and hits[0] > noiseCut and hits[1] > noiseCut \
1153 and hits[2] > int(noiseCut/2+0.5) ):
1154 for l1 in range(systemAndPlanes[1]):
1155 rc = h[nc+'PosVeto_111'+str(l1)].Fill(xEx[l1],yEx[l1])
1156 if tightNoiseFilter:
1157 rc = h[ncL+'PosVeto_111'+str(l1)].Fill(xEx[l1],yEx[l1])
1158 if beam: rc = h[nc+'beamPosVeto_1110'].Fill(xEx[l],yEx[l])
1159 if ( systemAndPlanes[1]==2 and (hits[0] > noiseCut or hits[1] > noiseCut)) or \
1160 ( systemAndPlanes[1]==3 and (hits[0] > noiseCut or hits[1] > noiseCut \
1161 or hits[2] > int(noiseCut/2+0.5)) ):
1162 rc = h[nc+'PosVeto_000'].Fill(xEx[l],yEx[l])
1163 if tightNoiseFilter: h[ncL+'PosVeto_000'].Fill(xEx[l],yEx[l])
1164 if beam: rc = h[nc+'beamPosVeto_000'].Fill(xEx[l],yEx[l])
1165 else:
1166 if -45<xEx[l] and xEx[l]<-10 and 27<yEx[l] and yEx[l]<54:
1167 rc = h['XtimeDiffPrev_'+str(noiseCut)].Fill(T1-T0)
1168 rc = h['XtimeDiffNext_'+str(noiseCut)].Fill(T2-T1)
1169 if not prevEvent or (prevEvent and not tightNoiseFilter):
1170 if self.debug: print('no hits',noiseCut,prevEvent,beam,N1,tightNoiseFilter,otherFastTrigger,otherAdvTrigger)
1171 for l1 in range(systemAndPlanes[1]):
1172 rc = h[nc+'XPosVeto_111'+str(l1)].Fill(xEx[l1],yEx[l1])
1173 if tightNoiseFilter:
1174 rc = h[ncL+'XPosVeto_111'+str(l1)].Fill(xEx[l1],yEx[l1])
1175 if beam: rc = h[nc+'beamXPosVeto_1110'].Fill(xEx[l],yEx[l])
1176
1177 if hits[0] > noiseCut and hits[1] > noiseCut:
1178 rc = h[nc+'PosVeto_11'].Fill(xEx[l],yEx[l])
1179 if not (hits[0] > noiseCut or hits[1] > noiseCut):
1180 rc = h[nc+'XPosVeto_11'].Fill(xEx[l],yEx[l])
1181
void GetPosition(Int_t id, TVector3 &vLeft, TVector3 &vRight)
Float_t GetCorrectedTime(Int_t id, Int_t c, Double_t t, Double_t L)
Int_t GetConfParI(TString name)
Double_t GetCorrectedTime(Int_t fDetectorID, Double_t rawTime, Double_t L)