ATLAS Offline Software
Loading...
Searching...
No Matches
P4PxPyPzEBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <cmath>
7#include <limits>
8#include <iomanip>
9#include <cstdlib>
10
13
14double P4PxPyPzEBase::m2() const
15{
16 const double px=this->px();
17 const double py=this->py();
18 const double pz=this->pz();
19 const double e =this->e();
20
21 const double m2 = e*e - (px*px + py*py + pz*pz);
22 return m2;
23}
24
25double P4PxPyPzEBase::m() const
26{
27 const double m2 = this->m2();
28
29 return m2 < 0.0 ? -std::sqrt(-m2) : std::sqrt (m2);
30}
31
32double P4PxPyPzEBase::eta() const
33{
34 const double e=this->e();
35
36 const double px=this->px();
37 const double py=this->py();
38 const double pz=this->pz();
39 // FIXME: should we use a more underflow-friendly formula:
40 // sqrt(a**2 + b**2)
41 // => y.sqrt(1+(x/y)**2) where y=max(|a|,|b|) and x=min(|a|,|b|)
42 const double p =std::sqrt (px*px + py*py + pz*pz);
43 if (p==0.0) return 0.0;
44 if (p==+pz) return +std::numeric_limits<double>::infinity();
45 if (p==-pz) return -std::numeric_limits<double>::infinity();
46 //PO flip if negative e
47 return (e>0 ? 1. : -1.)* 0.5*log((p+pz)/(p-pz));
48}
49
50double P4PxPyPzEBase::phi() const
51{
52 const double e=this->e();
53 const double px= (e>0 ? 1. : -1.)*this->px();
54 const double py= (e>0 ? 1. : -1.)*this->py();
55 return px == 0.0 && py == 0.0 ? 0.0 : atan2(py,px);
56}
57
58
59double P4PxPyPzEBase::p2() const
60{
61 const double px=this->px();
62 const double py=this->py();
63 const double pz=this->pz();
64
65 return px*px+py*py+pz*pz;
66}
67
68double P4PxPyPzEBase::p() const
69{
70 //PO return the correc
71 const double e=this->e();
72
73 return (e>0 ? 1. : -1.)*std::sqrt(this->p2());
74}
75
76
78{
79 return this->px()/this->pt();
80}
81
83{
84 return this->py()/this->pt();
85}
86
88{
89 return this->pt()/this->pz();
90}
91
93{
94 return this->pz()/this->pt();
95}
96
97
99{
100
101 return this->pz()/this->p();
102
103}
104
105
107{
108
109 return this->pt()/this->p();
110
111}
112
113
114double P4PxPyPzEBase::pt() const
115{
116 const double e=this->e();
117 const double px=this->px();
118 const double py=this->py();
119 //PO flip sign if negative energy
120 return (e>0 ? 1. : -1.)*std::sqrt(px*px+py*py);
121
122 }
123
124
125double P4PxPyPzEBase::et() const
126 {
127 //to be improved
128 return this->e()*this->sinTh();
129 }
130
131double P4PxPyPzEBase::iPt() const
132 { return 1./this->pt();
133 }
134
135
137{
138 const double e =this->e();
139 const double pz=this->pz();
140 if (e==0.0) return 0.0;
141 if (e==+pz) return +std::numeric_limits<double>::infinity();
142 if (e==-pz) return -std::numeric_limits<double>::infinity();
143 //PO invariant under flipping of 4-mom with neg E
144 return 0.5*std::log((e+pz)/(e-pz));
145}
146
147 CLHEP::HepLorentzVector P4PxPyPzEBase::hlv() const
148{ return CLHEP::HepLorentzVector(this->px(),this->py(),this->pz(),this->e());
149
150}
151
152std::ostream& P4PxPyPzEBase::dump( std::ostream& out ) const
153{
154
155 std::stringstream outx;
156 outx << "[px,py,pz,e] ="
157 << std::right << std::scientific << std::setprecision(8)
158 << std::setw(16) << this->px()
159 << std::setw(16) << this->py()
160 << std::setw(16) << this->pz()
161 << std::setw(16) << this->e();
162
163 out<<outx.str();
164
165 return out;
166
167}
168
170{
171 return 0;
172}
173
174
176{
177 std::cout << "FATAL ERROR dummy P4PxPyPzEBase::set4Mom called " << std::endl ;
178 std::abort();
179}
180
182{
183 std::cout << "FATAL ERROR dummy P4PxPyPzEBase::set4Mom called " << std::endl ;
184 std::abort();
185
186}
187
188void P4PxPyPzEBase::set4Mom(const CLHEP::HepLorentzVector & )
189{
190 std::cout << "FATAL ERROR dummy P4PxPyPzEBase::set4Mom called " << std::endl ;
191 std::abort();
192}
193
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition I4Momentum.h:31
virtual double pz() const =0
z component of momentum
virtual double px() const =0
x component of momentum
virtual double e() const =0
energy
virtual double py() const =0
y component of momentum
virtual double et() const
transverse energy defined to be e*sin(theta)
virtual double cosPhi() const
cosinus phi
virtual double sinPhi() const
sinus phi
virtual double tanTh() const
tan theta
virtual double m() const
mass
virtual double p2() const
square of momentum magnitude
virtual double m2() const
mass squared
virtual double sinTh() const
sinus theta
virtual double phi() const
phi in [-pi,pi[
virtual std::ostream & dump(std::ostream &out) const
Print I4Momentum content.
virtual void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference DUMMY IMPLEMENTATION
virtual double p() const
momentum magnitude
virtual double cotTh() const
cottan theta
virtual double pt() const
transverse momentum
virtual CLHEP::HepLorentzVector hlv() const
CLHEP HepLorentzVector.
virtual double eta() const
pseudo rapidity
virtual ~P4PxPyPzEBase()
virtual destructor needed by pool
virtual double iPt() const
inverse of transverse momentum
virtual const I4MomentumError * errors() const
Access to errors, if available; returns 0 if no errors.
virtual double cosTh() const
cosinus theta
virtual double rapidity() const
rapidity