ATLAS Offline Software
P4BaseIPtCotThPhiM.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef FOURMOM_P4BASEIPTCOTTHPHIM_H
8 #define FOURMOM_P4BASEIPTCOTTHPHIM_H
9 
10 // STL includes
11 #include <cmath>
12 #include <ostream>
13 #include <sstream>
14 #include <iomanip>
15 
16 // CLHEP includes
17 #include "CLHEP/Vector/LorentzVector.h"
18 #include "CLHEP/Units/SystemOfUnits.h"
19 
33 {
34  public:
35 
37  virtual ~P4BaseIPtCotThPhiM();
38 
40  // Const methods:
42 
46  double px() const;
47  double py() const;
48  double pz() const;
49  virtual double m() const = 0;
50  double m2() const;
51  double p() const;
52  double p2() const;
53  double eta() const;
54  virtual double phi() const = 0;
55  double e() const;
56  double et() const;
57  double pt() const;
58  virtual double iPt() const = 0;
59  double rapidity() const;
60  double cosPhi() const;
61  double sinPhi() const;
62  double tanTh() const;
63  double cosTh() const;
64  double sinTh() const;
65  virtual double cotTh() const = 0;
66  CLHEP::HepLorentzVector hlv() const;
67 
69  std::ostream& dump( std::ostream& out ) const;
70 
74  // Non-const methods:
77 
79  // Private data:
81  private:
82 };
83 
85 {}
86 
87 inline
88 double
90 {
91  return std::cos(this->phi())/this->iPt();
92 }
93 
94 inline
95 double
97 {
98  return std::sin(this->phi())/this->iPt();
99 }
100 
101 inline
102 double
104 {
105  return this->cotTh()/this->iPt();
106 }
107 
108 inline
109 double
111 {
112  const double mass = this->m();
113  return mass*mass;
114 }
115 
116 inline
117 double
119 {
120  const double theCotTh = this->cotTh();
121  return std::sqrt( 1 + theCotTh*theCotTh ) / this->iPt() ;
122 }
123 
124 inline
125 double
127 {
128  const double cotTh = this->cotTh();
129  const double iPt = this->iPt();
130  return ( 1 + cotTh*cotTh ) / (iPt*iPt) ;
131 }
132 
133 inline
134 double
136 {
137  const double theCotTh = this->cotTh();
138  const double aux = std::sqrt(1+theCotTh*theCotTh);
139  return -0.5 * std::log( (aux-theCotTh) / (aux+theCotTh) );
140 }
141 
142 inline
143 double
145 {
146  const double theE=this->e();
147  const double thePz=this->pz();
148  return 0.5*std::log((theE+thePz)/(theE-thePz));
149 }
150 
151 
152 inline
153 double
155 {
156  const double theM = this->m();
157  const double theP = this->p();
158  if ( theM == 0. ) {
159  return theP;
160  } else {
161  return std::sqrt( theP*theP + theM*theM );
162  }
163 }
164 
165 inline
166 double
168 {
169  const double theE = this->e();
170  const double theCotTh = this->cotTh();
171  return theE / std::sqrt( 1 + theCotTh*theCotTh );
172 }
173 
174 inline
175 double
177 {
178  return 1./this->iPt();
179 }
180 
181 inline
182 double
184 {
185  return 1./this->cotTh() ;
186 }
187 
188 inline
189 double
191 {
192  const double theCotTh = this->cotTh();
193  const double theCotTh2 = theCotTh*theCotTh;
194  const double theCosTh = std::sqrt(theCotTh2/(1.+theCotTh2));
195  if ( theCotTh >= 0. ) {
196  return theCosTh;
197  } else{
198  return -theCosTh;
199  }
200 }
201 
202 inline
203 double
205 {
206  const double theCotTh = this->cotTh();
207  return 1. / std::sqrt( 1 + theCotTh*theCotTh );
208 }
209 
210 inline
211 double
213 {
214  return std::cos(this->phi());
215 }
216 
217 inline
218 double
220 {
221  return std::sin(this->phi());
222 }
223 
224 inline
225 CLHEP::HepLorentzVector
227 {
228  //minimize the number of calculation and dereference
229  const double thePt = this->pt();
230  const double theM = this->m();
231  const double thePx = thePt*this->cosPhi();
232  const double thePy = thePt*this->sinPhi();
233  const double thePz = thePt * this->cotTh();
234  const double theE = std::sqrt( thePt * thePt
235  + thePz * thePz
236  + theM * theM );
237 
238  return CLHEP::HepLorentzVector( thePx, thePy, thePz, theE );
239 }
240 
241 inline
242 std::ostream&
243 P4BaseIPtCotThPhiM::dump( std::ostream& out ) const
244 {
245  std::stringstream s;
246  s << "[ipt,cotTh,phi,m] ="
247  << std::right << std::scientific << std::setprecision(8)
248  << std::setw(16) << this->iPt()
249  << std::setw(16) << this->cotTh()
250  << std::setw(16) << this->phi()
251  << std::setw(16) << this->m();
252 
253  out << s.str();
254 
255  return out;
256 }
257 
258 #endif // FOURMOM_P4BASEIPTCOTTHPHIM_H
259 
P4BaseIPtCotThPhiM::px
double px() const
{@ a la I4Momentum -like interface
Definition: P4BaseIPtCotThPhiM.h:89
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
P4BaseIPtCotThPhiM::pz
double pz() const
Definition: P4BaseIPtCotThPhiM.h:103
P4BaseIPtCotThPhiM::cotTh
virtual double cotTh() const =0
P4BaseIPtCotThPhiM
Definition: P4BaseIPtCotThPhiM.h:33
P4BaseIPtCotThPhiM::eta
double eta() const
Definition: P4BaseIPtCotThPhiM.h:135
P4BaseIPtCotThPhiM::pt
double pt() const
Definition: P4BaseIPtCotThPhiM.h:176
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
P4BaseIPtCotThPhiM::et
double et() const
Definition: P4BaseIPtCotThPhiM.h:167
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
P4BaseIPtCotThPhiM::hlv
CLHEP::HepLorentzVector hlv() const
Definition: P4BaseIPtCotThPhiM.h:226
dqt_zlumi_pandas.mass
mass
Definition: dqt_zlumi_pandas.py:170
P4BaseIPtCotThPhiM::iPt
virtual double iPt() const =0
P4BaseIPtCotThPhiM::m2
double m2() const
Definition: P4BaseIPtCotThPhiM.h:110
P4BaseIPtCotThPhiM::~P4BaseIPtCotThPhiM
virtual ~P4BaseIPtCotThPhiM()
virtual destructor needed for inheritance
Definition: P4BaseIPtCotThPhiM.h:84
P4BaseIPtCotThPhiM::p
double p() const
Definition: P4BaseIPtCotThPhiM.h:118
P4BaseIPtCotThPhiM::tanTh
double tanTh() const
Definition: P4BaseIPtCotThPhiM.h:183
P4BaseIPtCotThPhiM::dump
std::ostream & dump(std::ostream &out) const
Print I4Momentum content.
Definition: P4BaseIPtCotThPhiM.h:243
P4BaseIPtCotThPhiM::rapidity
double rapidity() const
Definition: P4BaseIPtCotThPhiM.h:144
P4BaseIPtCotThPhiM::p2
double p2() const
Definition: P4BaseIPtCotThPhiM.h:126
P4BaseIPtCotThPhiM::m
virtual double m() const =0
P4BaseIPtCotThPhiM::cosPhi
double cosPhi() const
Definition: P4BaseIPtCotThPhiM.h:212
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
P4BaseIPtCotThPhiM::sinTh
double sinTh() const
Definition: P4BaseIPtCotThPhiM.h:204
P4BaseIPtCotThPhiM::py
double py() const
Definition: P4BaseIPtCotThPhiM.h:96
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
P4BaseIPtCotThPhiM::phi
virtual double phi() const =0
P4BaseIPtCotThPhiM::cosTh
double cosTh() const
Definition: P4BaseIPtCotThPhiM.h:190
P4BaseIPtCotThPhiM::sinPhi
double sinPhi() const
Definition: P4BaseIPtCotThPhiM.h:219
P4BaseIPtCotThPhiM::e
double e() const
Definition: P4BaseIPtCotThPhiM.h:154