ATLAS Offline Software
Loading...
Searching...
No Matches
P4PtEtaPhiMBase.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 <iomanip>
8#include <cstdlib>
9
12
13double P4PtEtaPhiMBase::e() const
14{
15 const double theMass = this->m();
16 const double thePt = this->pt();
17 const double thePz = this->pz();
18
19 //DR from Frank Paige
20 // if negative pt point in the opposite direction
21 // BUT eta and phi still the same !!!
22
23 double eSign = (thePt >= 0.) ? +1. : -1.;
24 return eSign*std::sqrt(thePt*thePt + thePz*thePz + theMass*theMass);
25}
26
27double P4PtEtaPhiMBase::p() const
28{
29 const double thePt = this->pt();
30 const double thePz = this->pz();
31
32 //DR from Frank Paige
33 // if negative pt point in the opposite direction
34 // BUT eta and phi still the same !!!
35
36 double eSign = (thePt >= 0.) ? +1. : -1.;
37 return eSign*std::sqrt(thePt*thePt + thePz*thePz);
38}
39
40double P4PtEtaPhiMBase::p2() const
41{
42 /* This method has been implemented so as to give the same as would be obtained from pow((this->p()),2) with this->p() implemented according to Frank Paige's algorithm above. */
43
44 const double thePt = this->pt();
45 const double thePz = this->pz();
46
47 return thePt*thePt + thePz*thePz;
48}
49
50double P4PtEtaPhiMBase::m2() const
51{ const double theM=this->m();
52 return theM*theM;
53}
54
56{
57 return std::cos(this->phi());
58}
59
61{
62 return std::sin(this->phi());
63}
64
66{
67 return std::sinh(this->eta());
68}
69
71{
72 return std::tanh(this->eta());
73}
74
76{
77 // avoid numeric overflow if very large eta
78
79 double aEta=std::abs(this->eta());
80 if ( aEta>710) {
81 aEta=710;
82 }
83
84 return 1./std::cosh(aEta);
85}
86
88{
89 // avoid numeric overflow if very large eta
90
91 double theEta=this->eta();
92 if ( std::abs(theEta)>710) {
93 theEta=theEta>0 ? 710 : -710;
94 return 1./std::sinh(theEta);
95 }
96
97 return 1./std::sinh(this->eta());
98}
99
100
102 {
103 return this->e()*this->sinTh();
104 }
105
107 { return 1./this->pt();
108 }
109
111 {
112 const double theE=this->e();
113 const double thePz=this->pz();
114 return 0.5*std::log((theE+thePz)/(theE-thePz));
115 }
116
117 double P4PtEtaPhiMBase::px() const
118 { return this->pt()*this->cosPhi();
119 }
120
121 double P4PtEtaPhiMBase::py() const
122 { return this->pt()*this->sinPhi();
123 }
124
125 double P4PtEtaPhiMBase::pz() const
126{ return this->pt()*this->cotTh(); }
127
128 CLHEP::HepLorentzVector P4PtEtaPhiMBase::hlv() const
129{
130 //minimize the number of calculation and dereference
131 const double theM = this->m();
132 // note that pt can have negative sign : then it points in opposite direction but eta and phi are still on the same side
133 const double thePt = this->pt();
134
135
136 const double thePx = thePt*this->cosPhi();
137 const double thePy = thePt*this->sinPhi();
138
139 const double thePz = thePt*this->cotTh();
140
141 const double theE=std::sqrt(thePt*thePt+thePz*thePz+theM*theM);
142
143
144 return CLHEP::HepLorentzVector( thePx, thePy, thePz, theE );
145}
146
147std::ostream& P4PtEtaPhiMBase::dump( std::ostream& out ) const
148{
149 std::stringstream outx;
150 outx << "[pt,eta,phi,m] ="
151 << std::right << std::scientific << std::setprecision(8)
152 << std::setw(16) << this->pt()
153 << std::setw(16) << this->eta()
154 << std::setw(16) << this->phi()
155 << std::setw(16) << this->m();
156 out<<outx.str();
157
158 return out;
159
160}
161
163{
164 return 0;
165}
166
168{
169 std::cout << "FATAL ERROR dummy P4PtEtaPhiMBase::set4Mom called " << std::endl ;
170 std::abort();
171}
172
174{
175 std::cout << "FATAL ERROR dummy P4PtEtaPhiMBase::set4Mom called " << std::endl; ;
176 std::abort();
177
178}
179
180void P4PtEtaPhiMBase::set4Mom(const CLHEP::HepLorentzVector & )
181{
182 std::cout << "FATAL ERROR dummy P4PtEtaPhiMBase::set4Mom called " << std::endl ;
183 std::abort();
184}
I4Momentum is an abstract base class providing 4-momentum behavior.
Definition I4Momentum.h:31
virtual double m() const =0
mass
virtual double phi() const =0
phi in [-pi,pi[
virtual double pt() const =0
transverse momentum
virtual double eta() const =0
pseudo rapidity
virtual double rapidity() const
rapidity
virtual double m2() const
mass squared
virtual double pz() const
z component of momentum
virtual CLHEP::HepLorentzVector hlv() const
HepLorentzVector Special implementation from Frank Paige : if negative energy, points in opposite dir...
virtual double tanTh() const
tan theta
virtual double et() const
transverse energy defined to be e*sin(theta)
virtual double iPt() const
inverse of transverse momentum
virtual double cosTh() const
cosinus theta
virtual std::ostream & dump(std::ostream &out) const
Print I4Momentum content.
virtual double p() const
magnitude of 3-momentum.
virtual double sinPhi() const
sinus phi
virtual ~P4PtEtaPhiMBase()
virtual destructor needed by pool
virtual double sinTh() const
sinus theta
virtual double py() const
y component of momentum
virtual double cotTh() const
cottan theta
virtual double p2() const
square of momentum magnitude
virtual void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference DUMMY IMPLEMENTATION
virtual double cosPhi() const
cosinus phi
virtual const I4MomentumError * errors() const
Access to errors, if available; returns 0 if no errors.
virtual double px() const
x component of momentum
virtual double e() const
energy