1 | import ROOT
|
---|
2 | import libPyROOT as _root
|
---|
3 | ROOT.gSystem.Load("libDelphes")
|
---|
4 |
|
---|
5 | #####################################################
|
---|
6 | ### Definition of the string conversion methods ###
|
---|
7 | #####################################################
|
---|
8 |
|
---|
9 | def _Event__str__( self ):
|
---|
10 | theString = "Event number %i\n" % self.Number
|
---|
11 | theString += "Read in %f and processed in %f.\n" % (self.ReadTime, self.ProcTime)
|
---|
12 | return theString
|
---|
13 |
|
---|
14 | if hasattr(_root,"MakeRootClass"):
|
---|
15 | _root.MakeRootClass( "Event" ).__str__ = _Event__str__
|
---|
16 | else:
|
---|
17 | _root.CreateScopeProxy( "Event" ).__str__ = _Event__str__
|
---|
18 |
|
---|
19 | def _LHCOEvent__str__( self ):
|
---|
20 | theString = "Trigger word: %b\n" % self.Trigger
|
---|
21 | return theString
|
---|
22 |
|
---|
23 | if hasattr(_root,"MakeRootClass"):
|
---|
24 | _root.MakeRootClass( "LHCOEvent" ).__str__ = _LHCOEvent__str__
|
---|
25 | else:
|
---|
26 | _root.CreateScopeProxy( "LHCOEvent" ).__str__ = _LHCOEvent__str__
|
---|
27 |
|
---|
28 | def _LHEFEvent__str__( self ):
|
---|
29 | hepmcstr = "Process ID: %i\n" % self.ProcessID
|
---|
30 | hepmcstr += "ScalePDF = %f\n" % self.ScalePDF
|
---|
31 | hepmcstr += "Alpha QED = %f\n" % self.AlphaQED
|
---|
32 | hepmcstr += "Alpha DCQ = %f\n" % self.AlphaQCD
|
---|
33 | hepmcstr += "Event weight = %f\n" % self.Weight
|
---|
34 | return hepmcstr
|
---|
35 |
|
---|
36 | if hasattr(_root,"MakeRootClass"):
|
---|
37 | _root.MakeRootClass( "LHEFEvent" ).__str__ = _LHEFEvent__str__
|
---|
38 | else:
|
---|
39 | _root.CreateScopeProxy( "LHEFEvent" ).__str__ = _LHEFEvent__str__
|
---|
40 |
|
---|
41 | def _HepMCEvent__str__( self ):
|
---|
42 | hepmcstr = "Process ID: %i\n" % self.ProcessID
|
---|
43 | hepmcstr += "Energy scale: %f\n" % self.Scale
|
---|
44 | hepmcstr += "Alpha QED = %f\n" % self.AlphaQED
|
---|
45 | hepmcstr += "Alpha QCD = %f\n" % self.AlphaQCD
|
---|
46 | hepmcstr += "Number of multi parton interactions: %f\n" % self.MPI
|
---|
47 | hepmcstr += """Q-scale used in evaluation of PDFs (in GeV): %f\n""" % self.ScalePDF
|
---|
48 | hepmcstr += """Fraction of beam momentum carried by %i parton ("beam side"): %f\n""" % (self.ID1,self.X1)
|
---|
49 | hepmcstr += """Fraction of beam momentum carried by %i parton ("target side"): %f\n""" % (self.ID2,self.X2)
|
---|
50 | hepmcstr += "PDF (id1, x1, Q) = %f\n" % self.PDF1
|
---|
51 | hepmcstr += "PDF (id2, x2, Q) = %f\n" % self.PDF2
|
---|
52 | return hepmcstr
|
---|
53 |
|
---|
54 | if hasattr(_root,"MakeRootClass"):
|
---|
55 | _root.MakeRootClass( "HepMCEvent" ).__str__ = _HepMCEvent__str__
|
---|
56 | else:
|
---|
57 | _root.CreateScopeProxy( "HepMCEvent" ).__str__ = _HepMCEvent__str__
|
---|
58 |
|
---|
59 |
|
---|
60 | def _GenParticle__str__( self ):
|
---|
61 | thestring = "Particle HEP ID number = %d\n" % self.PID
|
---|
62 | thestring += "Particle status: %d\n" % self.Status
|
---|
63 | if self.IsPU: thestring += "That particle is from PU.\n"
|
---|
64 | thestring += "Particle 1st mother: %d\n" % self.M1
|
---|
65 | thestring += "Particle 2nd mother: %d\n" % self.M2
|
---|
66 | thestring += "Particle 1st daughter: %d\n" % self.D1
|
---|
67 | thestring += "Particle last daughter: %d\n" % self.D2
|
---|
68 | thestring += "(Px,Py,Pz,E) = (%f,%f,%f,%f)\n" % (self.Px,self.Py,self.Pz,self.E)
|
---|
69 | thestring += "(Pt,Eta,Phi) = (%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
70 | thestring += "Rapidity = %f\n" % self.Rapidity
|
---|
71 | thestring += "Charge: %d\n" % self.Charge
|
---|
72 | thestring += "Mass: %f\n" % self.Mass
|
---|
73 | thestring += "Vertex position: (x,y,z,t) = (%f,%f,%f,%f)\n" % (self.X,self.Y,self.Z,self.T)
|
---|
74 | return thestring
|
---|
75 |
|
---|
76 | if hasattr(_root,"MakeRootClass"):
|
---|
77 | _root.MakeRootClass( "GenParticle" ).__str__ = _GenParticle__str__
|
---|
78 | else:
|
---|
79 | _root.CreateScopeProxy( "GenParticle" ).__str__ = _GenParticle__str__
|
---|
80 |
|
---|
81 | def _GenParticle_printDecay( self, db, particles, pre="" ):
|
---|
82 | thestring = "%s (%f,%f,%f,%f) (status %d)\n" % (db.GetParticle(self.PID).GetName(),self.Px,self.Py,self.Pz,self.E, self.Status)
|
---|
83 | for daughter in range(self.D1,self.D2+1):
|
---|
84 | if daughter==-1: break
|
---|
85 | if daughter<self.D2 : thestring += "%s+->%s" % (pre,particles.At(daughter).printDecay(db,particles,pre+"| "))
|
---|
86 | else: thestring += "%s+->%s" % (pre,particles.At(daughter).printDecay(db,particles,pre+" "))
|
---|
87 | return thestring
|
---|
88 |
|
---|
89 | if hasattr(_root,"MakeRootClass"):
|
---|
90 | _root.MakeRootClass( "GenParticle" ).printDecay = _GenParticle_printDecay
|
---|
91 | else:
|
---|
92 | _root.CreateScopeProxy( "GenParticle" ).printDecay = _GenParticle_printDecay
|
---|
93 |
|
---|
94 | def _MissingET__str__( self ):
|
---|
95 | thestring = "Mising transverse energy: %f\n" % self.MET
|
---|
96 | thestring += "Mising energy azimuthal angle: %f\n" % self.Phi
|
---|
97 | return thestring
|
---|
98 |
|
---|
99 | if hasattr(_root,"MakeRootClass"):
|
---|
100 | _root.MakeRootClass( "MissingET" ).__str__ = _MissingET__str__
|
---|
101 | else:
|
---|
102 | _root.CreateScopeProxy( "MissingET" ).__str__ = _MissingET__str__
|
---|
103 |
|
---|
104 | def _ScalarHT__str__( self ):
|
---|
105 | thestring = "Scalar sum of transverse momenta: %f\n" %self.HT
|
---|
106 |
|
---|
107 | if hasattr(_root,"MakeRootClass"):
|
---|
108 | _root.MakeRootClass( "ScalarHT" ).__str__ = _ScalarHT__str__
|
---|
109 | else:
|
---|
110 | _root.CreateScopeProxy( "ScalarHT" ).__str__ = _ScalarHT__str__
|
---|
111 |
|
---|
112 | def _Photon__str__( self ):
|
---|
113 | thestring = "(Pt,Eta,Phi) =(%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
114 | return thestring
|
---|
115 |
|
---|
116 | if hasattr(_root,"MakeRootClass"):
|
---|
117 | _root.MakeRootClass( "Photon" ).__str__ = _Photon__str__
|
---|
118 | else:
|
---|
119 | _root.CreateScopeProxy( "Photon" ).__str__ = _Photon__str__
|
---|
120 |
|
---|
121 | def _Electron__str__( self ):
|
---|
122 | thestring = "(Pt,Eta,Phi) =(%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
123 | thestring += "charge: %d\n" % self.Charge
|
---|
124 | return thestring
|
---|
125 |
|
---|
126 | if hasattr(_root,"MakeRootClass"):
|
---|
127 | _root.MakeRootClass( "Electron" ).__str__ = _Electron__str__
|
---|
128 | else:
|
---|
129 | _root.CreateScopeProxy( "Electron" ).__str__ = _Electron__str__
|
---|
130 |
|
---|
131 | def _Muon__str__( self ):
|
---|
132 | thestring = "(Pt,Eta,Phi) =(%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
133 | thestring += "charge: %d\n" % self.Charge
|
---|
134 | return thestring
|
---|
135 |
|
---|
136 | if hasattr(_root,"MakeRootClass"):
|
---|
137 | _root.MakeRootClass( "Muon" ).__str__ = _Muon__str__
|
---|
138 | else:
|
---|
139 | _root.CreateScopeProxy( "Muon" ).__str__ = _Muon__str__
|
---|
140 |
|
---|
141 |
|
---|
142 | def _Jet__str__( self ):
|
---|
143 | thestring = "(Pt,Eta,Phi) =(%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
144 | thestring += "Charge: %d\n" % self.Charge
|
---|
145 | thestring += "Mass: %f\n" % self.Mass
|
---|
146 | if self.BTag: thestring += "This jet is b-tagged.\n"
|
---|
147 | if self.TauTag: thestring += "This jet is tagged as a tau-jet.\n"
|
---|
148 | thestring += "Jet radius in (eta,phi) = (%f,%f)\n" % (self.DeltaEta,self.DeltaPhi)
|
---|
149 | thestring += "Number of constituents: %d\n" % self.Constituents.GetEntries()
|
---|
150 | thestring += "H/E ratio in the calorimeters: %f\n" % self.EhadOverEem
|
---|
151 | nch = 0
|
---|
152 | ech = 0.
|
---|
153 | for constit in self.Constituents:
|
---|
154 | if constit.Charge != 0:
|
---|
155 | fourvector = ROOT.TLorentzVector()
|
---|
156 | fourvector.SetPtEtaPhiM(constit.PT,constit.Eta,constit.Phi,0.)
|
---|
157 | nch += 1
|
---|
158 | ech += fourvector.E()
|
---|
159 | thestring += "Charged Energy fraction: %f\n" % (ech/self.P4().E())
|
---|
160 | thestring += "Charged Multiplicity: %d\n" % nch
|
---|
161 | return thestring
|
---|
162 |
|
---|
163 | if hasattr(_root,"MakeRootClass"):
|
---|
164 | _root.MakeRootClass( "Jet" ).__str__ = _Jet__str__
|
---|
165 | else:
|
---|
166 | _root.CreateScopeProxy( "Jet" ).__str__ = _Jet__str__
|
---|
167 |
|
---|
168 | def _Track__str__( self ):
|
---|
169 | thestring = "Particle HEP ID number = %d\n" % self.PID
|
---|
170 | thestring += "(Pt,Eta,Phi) = (%f,%f,%f)\n" % (self.PT,self.Eta,self.Phi)
|
---|
171 | thestring += "Charge: %d\n" % self.Charge
|
---|
172 | thestring += "At calorimeter surface: (Pt,Eta,Phi) = (%f,%f,%f)\n" % (self.PT,self.EtaOuter,self.PhiOuter)
|
---|
173 | thestring += "Vertex position: (x,y,z) = (%f,%f,%f)\n" % (self.X,self.Y,self.Z)
|
---|
174 | thestring += "Position at calorimer surface: (x,y,z) = (%f,%f,%f)\n" % (self.XOuter,self.YOuter,self.ZOuter)
|
---|
175 | return thestring
|
---|
176 |
|
---|
177 | if hasattr(_root,"MakeRootClass"):
|
---|
178 | _root.MakeRootClass( "Track" ).__str__ = _Track__str__
|
---|
179 | else:
|
---|
180 | _root.CreateScopeProxy( "Track" ).__str__ = _Track__str__
|
---|
181 |
|
---|
182 | def _Tower__str__( self):
|
---|
183 | thestring = "(Et,Eta,Phi) = (%f,%f,%f)\n" % (self.ET,self.Eta,self.Phi)
|
---|
184 | thestring += "(E,Eem,Ehad) = (%f,%f,%f)\n" % (tower.E,tower.Eem,tower.Ehad)
|
---|
185 | thestring += "Edges: %f, %f, %f, %f\n" % (tower.Edges[0],tower.Edges[1],tower.Edges[2],tower.Edges[3])
|
---|
186 | return thestring
|
---|
187 |
|
---|
188 | if hasattr(_root,"MakeRootClass"):
|
---|
189 | _root.MakeRootClass( "Tower" ).__str__ = _Tower__str__
|
---|
190 | else:
|
---|
191 | _root.CreateScopeProxy( "Tower" ).__str__ = _Tower__str__
|
---|
192 |
|
---|
193 | #####################################################
|
---|
194 | ### Definition of additional ROOT methods ###
|
---|
195 | #####################################################
|
---|
196 |
|
---|
197 | def _lorentzVector__str__( self ):
|
---|
198 | theString = "(pt, eta, phi) = (%f,%f,%f)\n" % (self.Pt(), self.Eta(), self.Phi())
|
---|
199 | theString += "mass = %f, p = %f, mt = %f\n" % (self.M(), self.P(), self.Mt())
|
---|
200 | return theString
|
---|
201 |
|
---|
202 | if hasattr(_root,"MakeRootClass"):
|
---|
203 | _root.MakeRootClass( "TLorentzVector" ).__str__ = _lorentzVector__str__
|
---|
204 | else:
|
---|
205 | _root.CreateScopeProxy( "TLorentzVector" ).__str__ = _lorentzVector__str__
|
---|
206 |
|
---|
207 |
|
---|