ATLAS Offline Software
Loading...
Searching...
No Matches
P4EEtaPhiMBase.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#include <limits>
10
13
14double P4EEtaPhiMBase::m2() const {
15 const double theM = this->m();
16 return theM*theM;
17}
18
19
20
21double P4EEtaPhiMBase::p() const
22{
23 const double theM=this->m();
24 const double theE=this->e();
25 // if (theM==0.) return theE ;
26 // else return sqrt(theE*theE-theM*theM);
27 //DR from Frank Paige
28 // if negative energy point in the opposite direction
29 // BUT eta and phi still the same !!!
30 if (theM==0.) {
31 return theE;
32 } else {
33 double eSign = (theE >= 0) ? +1 : -1;
34 return eSign*std::sqrt(theE*theE-theM*theM);
35 }
36
37}
38
39double P4EEtaPhiMBase::p2() const
40{
48 const double theM=this->m();
49 const double theE=this->e();
50
51 return theE*theE-theM*theM;
52}
53
55{
56 return std::cos(this->phi());
57}
58
60{
61 return std::sin(this->phi());
62}
63
65{
66 // avoid numeric overflow if very large eta
67
68 double theEta=this->eta();
69 if ( std::abs(theEta)>710) {
70 theEta=theEta>0 ? 710 : -710;
71 return 1./std::sinh(theEta);
72 }
73
74 return 1./this->cotTh();
75}
76
78{
79 return std::sinh(this->eta());
80}
81
83{
84 return std::tanh(this->eta());
85}
86
88{
89 // avoid numeric overflow if very large eta
90
91 double aEta=std::abs(this->eta());
92 if ( aEta>710) {
93 aEta=710;
94 }
95
96 return 1./std::cosh(aEta);
97
98}
99
100
101double P4EEtaPhiMBase::pt() const
102 {
103 return this->p()*this->sinTh();
104 }
105
106double P4EEtaPhiMBase::et() const
107 {
108 return this->e()*this->sinTh();
109 }
110
112 { return 1./this->pt();
113 }
114
116 {
117 const double theE=this->e();
118 const double thePz=this->pz();
119 return 0.5*std::log((theE+thePz)/(theE-thePz));
120 }
121
122double P4EEtaPhiMBase::px() const
123 { return this->pt()*this->cosPhi();
124 }
125
126double P4EEtaPhiMBase::py() const
127 { return this->pt()*this->sinPhi();
128 }
129
130double P4EEtaPhiMBase::pz() const
131 { return this->p()*this->cosTh();
132 }
133
134CLHEP::HepLorentzVector P4EEtaPhiMBase::hlv() const
135{
136 //minimize the number of calculation and dereference
137 const double theCosTh=this->cosTh();
138
139 // DR from Frank Paige
140 // negative energy point in opposite direction
141 // BUT Eta and Phi still the same
142 // double theP=theE;
143
144 const double theP=this->p();
145
146 const double theSinTh=std::sqrt(1.-theCosTh*theCosTh);
147 const double thePt=theP*theSinTh;
148 const double thePx=thePt*this->cosPhi();
149 const double thePy=thePt*this->sinPhi();
150 const double thePz=theP*theCosTh;
151
152
153 return CLHEP::HepLorentzVector(thePx,thePy,thePz,this->e());
154
155}
156
157
158
159std::ostream& P4EEtaPhiMBase::dump( std::ostream& out ) const
160{
161
162 std::stringstream outx;
163 outx << "[e,eta,phi,m] ="
164 << std::right << std::scientific << std::setprecision(8)
165 << std::setw(16) << this->e()
166 << std::setw(16) << this->eta()
167 << std::setw(16) << this->phi()
168 << std::setw(16) << this->m();
169
170 out<<outx.str();
171
172 return out;
173}
174
176{
177 return 0;
178}
179
180
182{
183 std::cout << "FATAL ERROR dummy P4EEtaPhiMBase::set4Mom called " << std::endl; ;
184 std::abort();
185}
186
188{
189 std::cout << "FATAL ERROR dummy P4EEtaPhiMBase::set4Mom called " << std::endl ;
190 std::abort();
191
192}
193
194void P4EEtaPhiMBase::set4Mom(const CLHEP::HepLorentzVector & )
195{
196 std::cout << "FATAL ERROR dummy P4EEtaPhiMBase::set4Mom called " << std::endl ;
197 std::abort();
198}
199
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 eta() const =0
pseudo rapidity
virtual double e() const =0
energy
virtual CLHEP::HepLorentzVector hlv() const
HepLorentzVector Special implementation from Frank Paige : if negative energy, points in opposite dir...
virtual double m2() const
mass squared
virtual double cotTh() const
cottan theta
virtual const I4MomentumError * errors() const
Access to errors, if available; returns 0 if no errors.
virtual double rapidity() const
rapidity
virtual double p2() const
square of momentum magnitude
virtual std::ostream & dump(std::ostream &out=std::cout) const
Print I4Momentum content.
virtual double iPt() const
inverse of transverse momentum
virtual double pz() const
z component of momentum
virtual void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference DUMMY IMPLEMENTATION
virtual double py() const
y component of momentum
virtual double px() const
x component of momentum
virtual double cosPhi() const
cosinus phi
virtual double p() const
magnitude of 3-momentum.
virtual double sinTh() const
sinus theta
virtual double pt() const
transverse momentum
virtual double sinPhi() const
sinus phi
virtual ~P4EEtaPhiMBase()
virtual destructor needed by pool
virtual double et() const
transverse energy defined to be e*sin(theta)
virtual double cosTh() const
cosinus theta
virtual double tanTh() const
tan theta