ATLAS Offline Software
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 
12 {}
13 
14 double P4EEtaPhiMBase::m2() const {
15  const double theM = this->m();
16  return theM*theM;
17 }
18 
19 
20 
21 double 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 
39 double 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 
54 double P4EEtaPhiMBase::cosPhi() const
55 {
56  return std::cos(this->phi());
57 }
58 
59 double P4EEtaPhiMBase::sinPhi() const
60 {
61  return std::sin(this->phi());
62 }
63 
64 double P4EEtaPhiMBase::tanTh() const
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 
77 double P4EEtaPhiMBase::cotTh() const
78 {
79  return std::sinh(this->eta());
80 }
81 
82 double P4EEtaPhiMBase::cosTh() const
83 {
84  return std::tanh(this->eta());
85 }
86 
87 double P4EEtaPhiMBase::sinTh() const
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 
101 double P4EEtaPhiMBase::pt() const
102  {
103  return this->p()*this->sinTh();
104  }
105 
106 double P4EEtaPhiMBase::et() const
107  {
108  return this->e()*this->sinTh();
109  }
110 
111 double P4EEtaPhiMBase::iPt() const
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 
122 double P4EEtaPhiMBase::px() const
123  { return this->pt()*this->cosPhi();
124  }
125 
126 double P4EEtaPhiMBase::py() const
127  { return this->pt()*this->sinPhi();
128  }
129 
130 double P4EEtaPhiMBase::pz() const
131  { return this->p()*this->cosTh();
132  }
133 
134 CLHEP::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 
159 std::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 
194 void P4EEtaPhiMBase::set4Mom(const CLHEP::HepLorentzVector & )
195 {
196  std::cout << "FATAL ERROR dummy P4EEtaPhiMBase::set4Mom called " << std::endl ;
197  std::abort();
198 }
199 
P4EEtaPhiMBase::cotTh
virtual double cotTh() const
cottan theta
Definition: P4EEtaPhiMBase.cxx:77
P4EEtaPhiMBase::pz
virtual double pz() const
z component of momentum
Definition: P4EEtaPhiMBase.cxx:130
P4EEtaPhiMBase::pt
virtual double pt() const
transverse momentum
Definition: P4EEtaPhiMBase.cxx:101
I4Momentum
Definition: I4Momentum.h:31
P4EEtaPhiMBase.h
P4EEtaPhiMBase::cosPhi
virtual double cosPhi() const
cosinus phi
Definition: P4EEtaPhiMBase.cxx:54
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
P4EEtaPhiMBase::dump
virtual std::ostream & dump(std::ostream &out=std::cout) const
Print I4Momentum content.
Definition: P4EEtaPhiMBase.cxx:159
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
P4EEtaPhiMBase::rapidity
virtual double rapidity() const
rapidity
Definition: P4EEtaPhiMBase.cxx:115
P4EEtaPhiMBase::errors
virtual const I4MomentumError * errors() const
Access to errors, if available; returns 0 if no errors.
Definition: P4EEtaPhiMBase.cxx:175
P4EEtaPhiMBase::py
virtual double py() const
y component of momentum
Definition: P4EEtaPhiMBase.cxx:126
P4EEtaPhiMBase::hlv
virtual CLHEP::HepLorentzVector hlv() const
HepLorentzVector Special implementation from Frank Paige : if negative energy, points in opposite dir...
Definition: P4EEtaPhiMBase.cxx:134
I4MomentumError
Definition: I4MomentumError.h:28
P4EEtaPhiMBase::p2
virtual double p2() const
square of momentum magnitude
Definition: P4EEtaPhiMBase.cxx:39
I4Momentum::e
virtual double e() const =0
energy
P4EEtaPhiMBase::cosTh
virtual double cosTh() const
cosinus theta
Definition: P4EEtaPhiMBase.cxx:82
I4Momentum::eta
virtual double eta() const =0
pseudo rapidity
P4EEtaPhiMBase::~P4EEtaPhiMBase
virtual ~P4EEtaPhiMBase()
virtual destructor needed by pool
Definition: P4EEtaPhiMBase.cxx:11
P4EEtaPhiMBase::set4Mom
virtual void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference DUMMY IMPLEMENTATION
Definition: P4EEtaPhiMBase.cxx:181
I4Momentum::phi
virtual double phi() const =0
phi in [-pi,pi[
P4EEtaPhiMBase::p
virtual double p() const
magnitude of 3-momentum.
Definition: P4EEtaPhiMBase.cxx:21
I4Momentum::m
virtual double m() const =0
mass
P4EEtaPhiMBase::sinTh
virtual double sinTh() const
sinus theta
Definition: P4EEtaPhiMBase.cxx:87
P4EEtaPhiMBase::sinPhi
virtual double sinPhi() const
sinus phi
Definition: P4EEtaPhiMBase.cxx:59
P4EEtaPhiMBase::tanTh
virtual double tanTh() const
tan theta
Definition: P4EEtaPhiMBase.cxx:64
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
P4EEtaPhiMBase::m2
virtual double m2() const
mass squared
Definition: P4EEtaPhiMBase.cxx:14
P4EEtaPhiMBase::et
virtual double et() const
transverse energy defined to be e*sin(theta)
Definition: P4EEtaPhiMBase.cxx:106
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
P4EEtaPhiMBase::iPt
virtual double iPt() const
inverse of transverse momentum
Definition: P4EEtaPhiMBase.cxx:111
P4EEtaPhiMBase::px
virtual double px() const
x component of momentum
Definition: P4EEtaPhiMBase.cxx:122