FairShip
Loading...
Searching...
No Matches
decorators Namespace Reference

Functions

def MCPointPrintOut (x)
 
def MCTrackPrintOut (x)
 
def vetoHitPrintOut (x)
 
def TimeDetHitPrintOut (x)
 
def FitTrackPrintOut (x)
 
str TParticlePrintOut (x)
 
def ShipParticlePrintOut (x)
 
None Dump (x)
 
str TVector3PrintOut (x)
 
str TLorentzVectorPrintOut (x)
 
str TEvePointSetPrintOut (P)
 
None apply_decorators ()
 

Function Documentation

◆ apply_decorators()

None decorators.apply_decorators ( )
Apply custom __repr__ methods to ROOT classes.

Call this function after ROOT libraries are fully loaded to enable
enhanced string representations for ROOT objects.

Definition at line 99 of file decorators.py.

99def apply_decorators() -> None:
100 """Apply custom __repr__ methods to ROOT classes.
101
102 Call this function after ROOT libraries are fully loaded to enable
103 enhanced string representations for ROOT objects.
104 """
105 ROOT.FairMCPoint.__repr__ = MCPointPrintOut
106 ROOT.ShipMCTrack.__repr__ = MCTrackPrintOut
107 ROOT.genfit.Track.__repr__ = FitTrackPrintOut
108 ROOT.TClonesArray.Dump = Dump
109 ROOT.TVector3.__repr__ = TVector3PrintOut
110 ROOT.TParticle.__repr__ = TParticlePrintOut
111 ROOT.ShipParticle.__repr__ = ShipParticlePrintOut
112 ROOT.TEvePointSet.__repr__ = TEvePointSetPrintOut
113 ROOT.vetoHit.__repr__ = vetoHitPrintOut
114 ROOT.TimeDetHit.__repr__ = TimeDetHitPrintOut
115 ROOT.TLorentzVector.__repr__ = TLorentzVectorPrintOut

◆ Dump()

None decorators.Dump (   x)

Definition at line 70 of file decorators.py.

70def Dump(x) -> None:
71 k = 0
72 for obj in x:
73 print(k, obj.__repr__())
74 k += 1
75
76

◆ FitTrackPrintOut()

def decorators.FitTrackPrintOut (   x)

Definition at line 48 of file decorators.py.

48def FitTrackPrintOut(x):
49 st = x.getFitStatus()
50 if st.isFitConverged():
51 chi2DoF = st.getChi2() / st.getNdf()
52 sta = x.getFittedState()
53 P = sta.getMomMag()
54 txt = '("FitTrack") chi2/dof:%3.1F P:%5.2FGeV/c pdg:%i' % (chi2DoF, P, sta.getPDG())
55 else:
56 txt = '("FitTrack") fit not converged'
57 return txt
58
59

◆ MCPointPrintOut()

def decorators.MCPointPrintOut (   x)

Definition at line 10 of file decorators.py.

10def MCPointPrintOut(x):
11 p = ROOT.TDatabasePDG.Instance().GetParticle(x.PdgCode())
12 n = ""
13 if p:
14 n = p.GetName()
15 txt = f'("{x.Class_Name()}") X:{x.GetX():6.3F}cm Y:{x.GetY():6.3F}cm Z:{x.GetZ():6.3F}cm dE/dx:{x.GetEnergyLoss() / u.MeV:6.2F}MeV {n}'
16 return txt
17
18

◆ MCTrackPrintOut()

def decorators.MCTrackPrintOut (   x)

Definition at line 19 of file decorators.py.

19def MCTrackPrintOut(x):
20 c = x.GetPdgCode()
21 p = ROOT.TDatabasePDG.Instance().GetParticle(c)
22 n = ""
23 if p:
24 n = p.GetName()
25 m = x.GetMotherId()
26 txt = '("ShipMCTrack") pdgCode: %7i(%10s) Z=%6.1F m P=%6.3F GeV/c mother=%i %s' % (
27 c,
28 n,
29 x.GetStartZ() / u.m,
30 x.GetP(),
31 m,
32 x.GetProcName(),
33 )
34 return txt
35
36

◆ ShipParticlePrintOut()

def decorators.ShipParticlePrintOut (   x)

Definition at line 65 of file decorators.py.

65def ShipParticlePrintOut(x):
66 txt = f'("ShipParticle") {x.GetName()} M:{x.GetMass():5.2F}GeV/c2 P:{x.P():5.2F}GeV/c VxZ:{x.Vz() / u.m:5.2F}m'
67 return txt
68
69

◆ TEvePointSetPrintOut()

str decorators.TEvePointSetPrintOut (   P)

Definition at line 87 of file decorators.py.

87def TEvePointSetPrintOut(P) -> str:
88 x, y, z = c_double(), c_double(), c_double()
89 txt = ""
90 if P.GetN() == 0:
91 txt = "<ROOT.TEvePointSet object>"
92 for n in range(P.GetN()):
93 P.GetPoint(n, x, y, z)
94 txt += f"{n:6d} {x.value:7.1f}, {y.value:7.1f}, {z.value:9.1f} x, y, z cm\n"
95
96 return txt
97
98

◆ TimeDetHitPrintOut()

def decorators.TimeDetHitPrintOut (   x)

Definition at line 42 of file decorators.py.

42def TimeDetHitPrintOut(x):
43 t = x.GetMeasurements()
44 txt = '("TimeDetHit") detID:%7i TDC1:%5.2F TDC2:%5.2F isValid:%r' % (x.GetDetectorID(), t[0], t[1], x.isValid())
45 return txt
46
47

◆ TLorentzVectorPrintOut()

str decorators.TLorentzVectorPrintOut (   x)

Definition at line 82 of file decorators.py.

82def TLorentzVectorPrintOut(x) -> str:
83 txt = f"{x.Px():9.5F},{x.Py():9.5F},{x.Pz():9.5F},{x.E():9.5F},{x.Mag():9.5F}"
84 return txt
85
86

◆ TParticlePrintOut()

str decorators.TParticlePrintOut (   x)

Definition at line 60 of file decorators.py.

60def TParticlePrintOut(x) -> str:
61 txt = f'("TParticle") {x.GetName()} P:{x.P():5.2F}GeV/c VxZ:{x.Vz() / u.m:5.2F}m'
62 return txt
63
64

◆ TVector3PrintOut()

str decorators.TVector3PrintOut (   x)

Definition at line 77 of file decorators.py.

77def TVector3PrintOut(x) -> str:
78 txt = f"{x.X():9.5F},{x.Y():9.5F},{x.Z():9.5F}"
79 return txt
80
81

◆ vetoHitPrintOut()

def decorators.vetoHitPrintOut (   x)

Definition at line 37 of file decorators.py.

37def vetoHitPrintOut(x):
38 txt = '("vetoHit") detID:%7i ADC:%5.2F TDC:%5.2F' % (x.GetDetectorID(), x.GetADC(), x.GetTDC())
39 return txt
40
41