394 def DrawMCTracks(self, option: str = "") -> None:
395 n = -1
396 ntot = 0
397 fPos = ROOT.TVector3()
398 fMom = ROOT.TVector3()
399 for fT in sTree.MCTrack:
400 n += 1
401 DTrack = ROOT.TEveLine()
402 DTrack.SetPickable(ROOT.kTRUE)
403 DTrack.SetTitle(fT.__repr__())
404 fT.GetStartVertex(fPos)
405 hitlist = {}
406 hitlist[fPos.Z()] = [fPos.X(), fPos.Y()]
407
408 if abs(fT.GetPdgCode()) == options.HiddenParticleID:
409 for da in sTree.MCTrack:
410 if da.GetMotherId() == n:
411 break
412
413 da.GetStartVertex(fPos)
414 hitlist[fPos.Z()] = [fPos.X(), fPos.Y()]
415
416 for P in [
417 "vetoPoint",
418 "strawtubesPoint",
419 "ShipRpcPoint",
420 "TargetPoint",
421 "MTCDetPoint",
422 "SiliconTargetPoint",
423 "TimeDetPoint",
424 ]:
425 if not sTree.GetBranch(P):
426 continue
427 c = eval("sTree." + P)
428 for p in c:
429 if p.GetTrackID() == n:
430 if hasattr(p, "LastPoint"):
431 lp = p.LastPoint()
432 if lp.x() == lp.y() and lp.x() == lp.z() and lp.x() == 0:
433
434 hitlist[p.GetZ()] = [p.GetX(), p.GetY()]
435 else:
436 hitlist[lp.z()] = [lp.x(), lp.y()]
437 hitlist[2.0 * p.GetZ() - lp.z()] = [
438 2.0 * p.GetX() - lp.x(),
439 2.0 * p.GetY() - lp.y(),
440 ]
441 else:
442 hitlist[p.GetZ()] = [p.GetX(), p.GetY()]
443 if len(hitlist) == 1:
444 if fT.GetMotherId() < 0:
445 continue
446 if abs(sTree.MCTrack[fT.GetMotherId()].GetPdgCode()) == options.HiddenParticleID:
447
448
449 evVx = False
450 for da in sTree.MCTrack:
451 if da.GetMotherId() == n:
452 evVx = True
453 break
454 if evVx:
455 hitlist[da.GetStartZ()] = [da.GetStartX(), da.GetStartY()]
456 else:
457 zEx = 10 * u.m
458 fT.GetMomentum(fMom)
459 lam = (zEx + fPos.Z()) / fMom.Z()
460 hitlist[zEx + fPos.Z()] = [
461 fPos.X() + lam * fMom.X(),
462 fPos.Y() + lam * fMom.Y(),
463 ]
464
465 lz = list(hitlist.keys())
466 if len(lz) > 1:
467 lz.sort()
468 for z in lz:
469 DTrack.SetNextPoint(hitlist[z][0], hitlist[z][1], z)
470 p = pdg.GetParticle(fT.GetPdgCode())
471 if p:
472 pName = p.GetName()
473 else:
474 pName = str(fT.GetPdgCode())
475 DTrack.SetName("MCTrack_" + str(n) + "_" + pName)
476 c = ROOT.kYellow
477 if abs(fT.GetPdgCode()) == options.HiddenParticleID:
478 c = ROOT.kMagenta
479 DTrack.SetMainColor(c)
480 DTrack.SetLineWidth(3)
481 self.comp.AddElement(DTrack)
482 ntot += 1
483 print("draw ", ntot, " MC tracks")
484