276 def DrawMCTracks(self,option=''):
277 n = -1
278 ntot = 0
279 fPos = ROOT.TVector3()
280 fMom = ROOT.TVector3()
281 for fT in sTree.MCTrack:
282 n+=1
283 DTrack = ROOT.TEveLine()
284 DTrack.SetPickable(ROOT.kTRUE)
285 DTrack.SetTitle(fT.__repr__())
286 fT.GetStartVertex(fPos)
287 hitlist = {}
288 hitlist[fPos.Z()] = [fPos.X(),fPos.Y()]
289
290 if abs(fT.GetPdgCode()) == options.HiddenParticleID:
291 for da in sTree.MCTrack:
292 if da.GetMotherId()==n: break
293
294 da.GetStartVertex(fPos)
295 hitlist[fPos.Z()] = [fPos.X(),fPos.Y()]
296
297 for P in ["vetoPoint","muonPoint","EcalPoint","HcalPoint","preshowerPoint","strawtubesPoint","ShipRpcPoint","TargetPoint","TimeDetPoint",
298 "MuFilterPoint","ScifiPoint"]:
299 if not sTree.GetBranch(P): continue
300 c=eval("sTree."+P)
301 for p in c:
302 if p.GetTrackID()==n:
303 if hasattr(p, "LastPoint"):
304 lp = p.LastPoint()
305 if lp.x()==lp.y() and lp.x()==lp.z() and lp.x()==0:
306
307 hitlist[p.GetZ()] = [p.GetX(),p.GetY()]
308 else:
309 hitlist[lp.z()] = [lp.x(),lp.y()]
310 hitlist[2.*p.GetZ()-lp.z()] = [2.*p.GetX()-lp.x(),2.*p.GetY()-lp.y()]
311 else:
312 hitlist[p.GetZ()] = [p.GetX(),p.GetY()]
313 if len(hitlist)==1:
314 if fT.GetMotherId()<0: continue
315 if abs(sTree.MCTrack[fT.GetMotherId()].GetPdgCode()) == options.HiddenParticleID:
316
317
318 evVx = False
319 for da in sTree.MCTrack:
320 if da.GetMotherId()==n:
321 evVx = True
322 break
323 if evVx : hitlist[da.GetStartZ()] = [da.GetStartX(),da.GetStartY()]
324 else :
325 zEx = 10*u.m
326 fT.GetMomentum(fMom)
327 lam = (zEx+fPos.Z())/fMom.Z()
328 hitlist[zEx+fPos.Z()] = [fPos.X()+lam*fMom.X(),fPos.Y()+lam*fMom.Y()]
329
330 lz = list(hitlist.keys())
331 if len(lz)>1:
332 lz.sort()
333 for z in lz: DTrack.SetNextPoint(hitlist[z][0],hitlist[z][1],z)
334 p = pdg.GetParticle(fT.GetPdgCode())
335 if p : pName = p.GetName()
336 else: pName = str(fT.GetPdgCode())
337 DTrack.SetName('MCTrack_'+str(n)+'_'+pName)
338 c = ROOT.kYellow
339 if abs(fT.GetPdgCode()) == options.HiddenParticleID:c = ROOT.kMagenta
340 DTrack.SetMainColor(c)
341 DTrack.SetLineWidth(3)
342 self.comp.AddElement(DTrack)
343 ntot+=1
344 print("draw ",ntot," MC tracks")