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

Functions

str MCPointPrintOut (self)
str MCTrackPrintOut (self)
str vetoHitPrintOut (self)
str TimeDetHitPrintOut (self)
str FitTrackPrintOut (self)
str TParticlePrintOut (self)
str ShipParticlePrintOut (self)
None Dump (self)
str TVector3PrintOut (self)
str TLorentzVectorPrintOut (self)
str TEvePointSetPrintOut (self)
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 98 of file decorators.py.

98def apply_decorators() -> None:
99 """Apply custom __repr__ methods to ROOT classes.
100
101 Call this function after ROOT libraries are fully loaded to enable
102 enhanced string representations for ROOT objects.
103 """
104 # Method-replacement is the whole point of this function; mypy flags
105 # each line with [method-assign] regardless.
106 ROOT.FairMCPoint.__repr__ = MCPointPrintOut # type: ignore[method-assign]
107 ROOT.ShipMCTrack.__repr__ = MCTrackPrintOut # type: ignore[method-assign]
108 ROOT.genfit.Track.__repr__ = FitTrackPrintOut # type: ignore[method-assign]
109 ROOT.TClonesArray.Dump = Dump # type: ignore[method-assign]
110 ROOT.TVector3.__repr__ = TVector3PrintOut # type: ignore[method-assign]
111 ROOT.TParticle.__repr__ = TParticlePrintOut # type: ignore[method-assign]
112 ROOT.ShipParticle.__repr__ = ShipParticlePrintOut # type: ignore[method-assign]
113 ROOT.TEvePointSet.__repr__ = TEvePointSetPrintOut # type: ignore[method-assign]
114 ROOT.vetoHit.__repr__ = vetoHitPrintOut # type: ignore[method-assign]
115 ROOT.TimeDetHit.__repr__ = TimeDetHitPrintOut # type: ignore[method-assign]
116 ROOT.TLorentzVector.__repr__ = TLorentzVectorPrintOut # type: ignore[method-assign]

◆ Dump()

None decorators.Dump ( self)

Definition at line 73 of file decorators.py.

73def Dump(self) -> None:
74 for k, obj in enumerate(self):
75 print(k, obj.__repr__())
76
77

◆ FitTrackPrintOut()

str decorators.FitTrackPrintOut ( self)

Definition at line 52 of file decorators.py.

52def FitTrackPrintOut(self) -> str:
53 st = self.getFitStatus()
54 if st.isFitConverged():
55 chi2DoF = st.getChi2() / st.getNdf()
56 sta = self.getFittedState()
57 P = sta.getMomMag()
58 return '("FitTrack") chi2/dof:%3.1F P:%5.2FGeV/c pdg:%i' % (chi2DoF, P, sta.getPDG())
59 return '("FitTrack") fit not converged'
60
61

◆ MCPointPrintOut()

str decorators.MCPointPrintOut ( self)

Definition at line 10 of file decorators.py.

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

◆ MCTrackPrintOut()

str decorators.MCTrackPrintOut ( self)

Definition at line 21 of file decorators.py.

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

◆ ShipParticlePrintOut()

str decorators.ShipParticlePrintOut ( self)

Definition at line 66 of file decorators.py.

66def ShipParticlePrintOut(self) -> str:
67 return (
68 f'("ShipParticle") {self.GetName()} M:{self.GetMass():5.2F}GeV/c2 '
69 f"P:{self.P():5.2F}GeV/c VxZ:{self.Vz() / u.m:5.2F}m"
70 )
71
72

◆ TEvePointSetPrintOut()

str decorators.TEvePointSetPrintOut ( self)

Definition at line 86 of file decorators.py.

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

◆ TimeDetHitPrintOut()

str decorators.TimeDetHitPrintOut ( self)

Definition at line 42 of file decorators.py.

42def TimeDetHitPrintOut(self) -> str:
43 t = self.GetMeasurements()
44 return '("TimeDetHit") detID:%7i TDC1:%5.2F TDC2:%5.2F isValid:%r' % (
45 self.GetDetectorID(),
46 t[0],
47 t[1],
48 self.isValid(),
49 )
50
51

◆ TLorentzVectorPrintOut()

str decorators.TLorentzVectorPrintOut ( self)

Definition at line 82 of file decorators.py.

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

◆ TParticlePrintOut()

str decorators.TParticlePrintOut ( self)

Definition at line 62 of file decorators.py.

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

◆ TVector3PrintOut()

str decorators.TVector3PrintOut ( self)

Definition at line 78 of file decorators.py.

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

◆ vetoHitPrintOut()

str decorators.vetoHitPrintOut ( self)

Definition at line 38 of file decorators.py.

38def vetoHitPrintOut(self) -> str:
39 return '("vetoHit") detID:%7i ADC:%5.2F TDC:%5.2F' % (self.GetDetectorID(), self.GetADC(), self.GetTDC())
40
41