ATLAS Offline Software
Loading...
Searching...
No Matches
P4BaseIPtCotThPhiM.h
Go to the documentation of this file.
1
2
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
31
33{
34 public:
35
37 virtual ~P4BaseIPtCotThPhiM();
38
40 // Const methods:
42
45
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
73
75 // Non-const methods:
77
79 // Private data:
81 private:
82};
83
86
87inline
88double
90{
91 return std::cos(this->phi())/this->iPt();
92}
93
94inline
95double
97{
98 return std::sin(this->phi())/this->iPt();
99}
100
101inline
102double
104{
105 return this->cotTh()/this->iPt();
106}
107
108inline
109double
111{
112 const double mass = this->m();
113 return mass*mass;
114}
115
116inline
117double
119{
120 const double theCotTh = this->cotTh();
121 return std::sqrt( 1 + theCotTh*theCotTh ) / this->iPt() ;
122}
123
124inline
125double
127{
128 const double cotTh = this->cotTh();
129 const double iPt = this->iPt();
130 return ( 1 + cotTh*cotTh ) / (iPt*iPt) ;
131}
132
133inline
134double
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
142inline
143double
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
152inline
153double
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
165inline
166double
168{
169 const double theE = this->e();
170 const double theCotTh = this->cotTh();
171 return theE / std::sqrt( 1 + theCotTh*theCotTh );
172}
173
174inline
175double
177{
178 return 1./this->iPt();
179}
180
181inline
182double
184{
185 return 1./this->cotTh() ;
186}
187
188inline
189double
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
202inline
203double
205{
206 const double theCotTh = this->cotTh();
207 return 1. / std::sqrt( 1 + theCotTh*theCotTh );
208}
209
210inline
211double
213{
214 return std::cos(this->phi());
215}
216
217inline
218double
220{
221 return std::sin(this->phi());
222}
223
224inline
225CLHEP::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
241inline
242std::ostream&
243P4BaseIPtCotThPhiM::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 is a base class for classes with 4-momentum behavior, for which 1/Pt,...
std::ostream & dump(std::ostream &out) const
Print I4Momentum content.
virtual double m() const =0
double px() const
{@ a la I4Momentum -like interface
virtual double iPt() const =0
virtual double cotTh() const =0
virtual ~P4BaseIPtCotThPhiM()
virtual destructor needed for inheritance
CLHEP::HepLorentzVector hlv() const
virtual double phi() const =0
-event-from-file