Fork me on GitHub

source: git/python/DelphesAnalysis/Delphes.py@ 88a9b72

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 88a9b72 was ae1d49f, checked in by pavel <pavel@…>, 12 years ago

add DelphesAnalysis

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