ATLAS Offline Software
Loading...
Searching...
No Matches
P4ImplPtEtaPhiM Class Reference

P4ImplPtEtaPhiM is a base class for classes with 4-momentum behavior, for which pt, eta, phi and M are natural parameters, which is typically the case for a ger object. More...

#include <P4ImplPtEtaPhiM.h>

Inheritance diagram for P4ImplPtEtaPhiM:
Collaboration diagram for P4ImplPtEtaPhiM:

Public Types

typedef FourMomentumError< P4ImplPtEtaPhiMErrorType

Public Member Functions

 P4ImplPtEtaPhiM ()
 Default constructor:
 P4ImplPtEtaPhiM (const P4ImplPtEtaPhiM &rhs)
 Copy constructor.
P4ImplPtEtaPhiMoperator= (const P4ImplPtEtaPhiM &rhs)
 Assignment operator.
 P4ImplPtEtaPhiM (const double pt, const double eta, const double phi, const double m)
 constructor with all data members
 P4ImplPtEtaPhiM (const CLHEP::HepLorentzVector &hlv)
 constructor from hlv to allow conversion from hlv
 P4ImplPtEtaPhiM (const I4Momentum &theI4M)
 constructor from any I4Momentum reference
 P4ImplPtEtaPhiM (const I4Momentum *const theI4M)
 constructor from any I4Momentum pointer
virtual ~P4ImplPtEtaPhiM ()
 virtual destructor needed by pool
double m () const
 {@ a la I4Momentum -like interface
double eta () const
double phi () const
double pt () const
virtual const I4MomentumErrorerrors () const
I4Momentum::Kind kind () const
void setPt (const double thePt)
 set pt data member
void setEta (const double theEta)
 set eta data member
void setPhi (const double thePhi)
 set phi data member
void setM (const double theM)
 set mass data member
void setErrors (const ErrorMatrixPtEtaPhiM &err)
 set the errors
void set4Mom (const I4Momentum &theI4Mom)
 set all 4-mom from another I4Momentum reference
void set4Mom (const I4Momentum *const theI4Mom)
 set all 4-mom from another I4Momentum pointer
void set4Mom (const CLHEP::HepLorentzVector &theHlv)
 set all 4-mom from CLHEP HepLorentzVector
double px () const
 {@ a la I4Momentum -like interface
double py () const
double pz () const
double m2 () const
double p () const
double p2 () const
double e () const
double et () const
double iPt () const
double rapidity () const
double cosPhi () const
double sinPhi () const
double tanTh () const
double cosTh () const
double sinTh () const
double cotTh () const
CLHEP::HepLorentzVector hlv () const
std::ostream & dump (std::ostream &out) const
 Print I4Momentum content.

Private Attributes

double m_pt
double m_eta
double m_phi
double m_m
std::unique_ptr< ErrorTypem_error

Friends

class P4ImplPtEtaPhiMCnv_p1

Detailed Description

P4ImplPtEtaPhiM is a base class for classes with 4-momentum behavior, for which pt, eta, phi and M are natural parameters, which is typically the case for a ger object.

Any class deriving from it should implement pt(), eta(), phi(), m().

Author
Olga Igonkina olya@.nosp@m.cern.nosp@m..ch

Definition at line 40 of file P4ImplPtEtaPhiM.h.

Member Typedef Documentation

◆ ErrorType

Constructor & Destructor Documentation

◆ P4ImplPtEtaPhiM() [1/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( )
inline

Default constructor:

Definition at line 134 of file P4ImplPtEtaPhiM.h.

134 :
135 P4BasePtEtaPhiM( ),
136 m_pt ( 0.*CLHEP::GeV ),
137 m_eta( 0. ),
138 m_phi( 0. ),
139 m_m ( 0.*CLHEP::GeV ),
140 m_error(nullptr)
141{}
std::unique_ptr< ErrorType > m_error

◆ P4ImplPtEtaPhiM() [2/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( const P4ImplPtEtaPhiM & rhs)
inlineexplicit

Copy constructor.

Definition at line 143 of file P4ImplPtEtaPhiM.h.

143 :
144 P4BasePtEtaPhiM( ),
145 m_pt ( rhs.m_pt ),
146 m_eta( rhs.m_eta ),
147 m_phi( rhs.m_phi ),
148 m_m ( rhs.m_m ),
149 m_error(nullptr)
150{}

◆ P4ImplPtEtaPhiM() [3/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( const double pt,
const double eta,
const double phi,
const double m )
inline

constructor with all data members

Definition at line 152 of file P4ImplPtEtaPhiM.h.

153 :
154 P4BasePtEtaPhiM( ),
155 m_pt ( pt ),
156 m_eta( eta ),
157 m_phi( phi ),
158 m_m ( m ),
159 m_error(nullptr)
160{}
double eta() const
double phi() const
double pt() const
double m() const
{@ a la I4Momentum -like interface

◆ P4ImplPtEtaPhiM() [4/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( const CLHEP::HepLorentzVector & hlv)
inline

constructor from hlv to allow conversion from hlv

Definition at line 162 of file P4ImplPtEtaPhiM.h.

162 :
163 P4BasePtEtaPhiM( ),
164 m_pt ( hlv.perp() ),
165 m_eta( hlv.eta() ),
166 m_phi( hlv.phi() ),
167 m_m ( hlv.m() ),
168 m_error(nullptr)
169{}
CLHEP::HepLorentzVector hlv() const

◆ P4ImplPtEtaPhiM() [5/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( const I4Momentum & theI4M)
inlineexplicit

constructor from any I4Momentum reference

Definition at line 171 of file P4ImplPtEtaPhiM.h.

171 :
172 P4BasePtEtaPhiM( ),
173 m_pt ( i4mom.pt() ),
174 m_eta( i4mom.eta() ),
175 m_phi( i4mom.phi() ),
176 m_m ( i4mom.m() ),
177 m_error(nullptr)
178{}

◆ P4ImplPtEtaPhiM() [6/6]

P4ImplPtEtaPhiM::P4ImplPtEtaPhiM ( const I4Momentum *const theI4M)
inlineexplicit

constructor from any I4Momentum pointer

Definition at line 180 of file P4ImplPtEtaPhiM.h.

180 :
181 P4BasePtEtaPhiM( ),
182 m_pt ( i4Mom->pt() ),
183 m_eta( i4Mom->eta() ),
184 m_phi( i4Mom->phi() ),
185 m_m ( i4Mom->m() ),
186 m_error(nullptr)
187{}

◆ ~P4ImplPtEtaPhiM()

P4ImplPtEtaPhiM::~P4ImplPtEtaPhiM ( )
inlinevirtual

virtual destructor needed by pool

Definition at line 189 of file P4ImplPtEtaPhiM.h.

190{}

Member Function Documentation

◆ cosPhi()

double P4BasePtEtaPhiM::cosPhi ( ) const
inlineinherited

Definition at line 172 of file P4BasePtEtaPhiM.h.

173{
174 return std::cos(this->phi());
175}
virtual double phi() const =0

◆ cosTh()

double P4BasePtEtaPhiM::cosTh ( ) const
inlineinherited

Definition at line 184 of file P4BasePtEtaPhiM.h.

185{
186 return std::tanh(this->eta());
187}
virtual double eta() const =0

◆ cotTh()

double P4BasePtEtaPhiM::cotTh ( ) const
inlineinherited

Definition at line 201 of file P4BasePtEtaPhiM.h.

202{
203 return std::sinh(this->eta());
204}

◆ dump()

std::ostream & P4BasePtEtaPhiM::dump ( std::ostream & out) const
inlineinherited

Print I4Momentum content.

Definition at line 236 of file P4BasePtEtaPhiM.h.

237{
238 std::stringstream s;
239 s << "[pt,eta,phi,m] ="
240 << std::right << std::scientific << std::setprecision(8)
241 << std::setw(16) << this->pt()
242 << std::setw(16) << this->eta()
243 << std::setw(16) << this->phi()
244 << std::setw(16) << this->m();
245
246 out << s.str();
247 return out;
248}
virtual double m() const =0
virtual double pt() const =0

◆ e()

double P4BasePtEtaPhiM::e ( ) const
inlineinherited

Definition at line 141 of file P4BasePtEtaPhiM.h.

142{
143 const double theMass = this->m();
144 const double thePt = this->pt();
145 const double thePz = this->pz();
146
147 //DR from Frank Paige
148 // if negative pt point in the opposite direction
149 // BUT eta and phi still the same !!!
150
151 const double eSign = (thePt >= 0.) ? +1. : -1.;
152 return eSign * std::sqrt( thePt*thePt + thePz*thePz + theMass*theMass);
153}
double pz() const

◆ errors()

const I4MomentumError * P4ImplPtEtaPhiM::errors ( ) const
inlinevirtual

Reimplemented in P4Impl< P4ImplPtEtaPhiM >.

Definition at line 212 of file P4ImplPtEtaPhiM.h.

213{
214 // check if the pointer is empty before dereferencing
215 return m_error.get();
216}

◆ et()

double P4BasePtEtaPhiM::et ( ) const
inlineinherited

Definition at line 155 of file P4BasePtEtaPhiM.h.

156{
157 return this->e()*this->sinTh();
158}
double e() const
double sinTh() const

◆ eta()

double P4ImplPtEtaPhiM::eta ( void ) const
inlinevirtual

Implements P4BasePtEtaPhiM.

Definition at line 197 of file P4ImplPtEtaPhiM.h.

198{
199 return m_eta;
200}

◆ hlv()

CLHEP::HepLorentzVector P4BasePtEtaPhiM::hlv ( ) const
inlineinherited

Definition at line 217 of file P4BasePtEtaPhiM.h.

218{
219 //minimize the number of calculation and dereference
220 const double theM = this->m();
221 // note that pt can have negative sign : then it points in opposite direction but eta and phi are still on the same side
222 const double thePt = this->pt();
223
224
225 const double thePx = thePt*this->cosPhi();
226 const double thePy = thePt*this->sinPhi();
227
228 const double thePz = thePt*this->cotTh();
229
230 const double theE=std::sqrt(thePt*thePt+thePz*thePz+theM*theM);
231
232
233 return CLHEP::HepLorentzVector( thePx, thePy, thePz, theE );
234}
double cosPhi() const
double sinPhi() const
double cotTh() const

◆ iPt()

double P4BasePtEtaPhiM::iPt ( ) const
inlineinherited

Definition at line 160 of file P4BasePtEtaPhiM.h.

161{
162 return 1./this->pt();
163}

◆ kind()

I4Momentum::Kind P4ImplPtEtaPhiM::kind ( ) const
inline

Definition at line 89 of file P4ImplPtEtaPhiM.h.

◆ m()

double P4ImplPtEtaPhiM::m ( void ) const
inlinevirtual

{@ a la I4Momentum -like interface

Implements P4BasePtEtaPhiM.

Definition at line 192 of file P4ImplPtEtaPhiM.h.

193{
194 return m_m;
195}

◆ m2()

double P4BasePtEtaPhiM::m2 ( ) const
inlineinherited

Definition at line 110 of file P4BasePtEtaPhiM.h.

111{
112 const double mass = this->m();
113 return mass*mass;
114}

◆ operator=()

P4ImplPtEtaPhiM & P4ImplPtEtaPhiM::operator= ( const P4ImplPtEtaPhiM & rhs)

Assignment operator.

Definition at line 14 of file P4ImplPtEtaPhiM.cxx.

15{
16 if ( this != &rhs ) {
17 m_pt = rhs.m_pt;
18 m_eta = rhs.m_eta;
19 m_phi = rhs.m_phi;
20 m_m = rhs.m_m;
21 }
22 return *this;
23}

◆ p()

double P4BasePtEtaPhiM::p ( ) const
inlineinherited

Definition at line 116 of file P4BasePtEtaPhiM.h.

117{
118 const double thePt = this->pt();
119 const double thePz = this->pz();
120
121 //DR from Frank Paige
122 // if negative pt point in the opposite direction
123 // BUT eta and phi still the same !!!
124
125 const double eSign = (thePt >= 0.) ? +1. : -1.;
126 return eSign * std::sqrt( thePt*thePt + thePz*thePz );
127}

◆ p2()

double P4BasePtEtaPhiM::p2 ( ) const
inlineinherited

Definition at line 129 of file P4BasePtEtaPhiM.h.

130{
131 // This method has been implemented so as to give the same as would be
132 // obtained from pow((this->p()),2) with this->p() implemented according to
133 // Frank Paige's algorithm above.
134
135 const double pt = this->pt();
136 const double pz = this->pz();
137
138 return pt*pt + pz*pz;
139}

◆ phi()

double P4ImplPtEtaPhiM::phi ( void ) const
inlinevirtual

Implements P4BasePtEtaPhiM.

Definition at line 202 of file P4ImplPtEtaPhiM.h.

203{
204 return m_phi;
205}

◆ pt()

double P4ImplPtEtaPhiM::pt ( void ) const
inlinevirtual

Implements P4BasePtEtaPhiM.

Definition at line 207 of file P4ImplPtEtaPhiM.h.

208{
209 return m_pt;
210}

◆ px()

double P4BasePtEtaPhiM::px ( ) const
inlineinherited

{@ a la I4Momentum -like interface

Definition at line 95 of file P4BasePtEtaPhiM.h.

96{
97 return this->pt() * std::cos(this->phi());
98}

◆ py()

double P4BasePtEtaPhiM::py ( ) const
inlineinherited

Definition at line 100 of file P4BasePtEtaPhiM.h.

101{
102 return this->pt() * std::sin(this->phi());
103}

◆ pz()

double P4BasePtEtaPhiM::pz ( ) const
inlineinherited

Definition at line 105 of file P4BasePtEtaPhiM.h.

106{
107 return this->pt()/this->tanTh();
108}
double tanTh() const

◆ rapidity()

double P4BasePtEtaPhiM::rapidity ( ) const
inlineinherited

Definition at line 165 of file P4BasePtEtaPhiM.h.

166 {
167 const double theE=this->e();
168 const double thePz=this->pz();
169 return 0.5*std::log((theE+thePz)/(theE-thePz));
170 }

◆ set4Mom() [1/3]

void P4ImplPtEtaPhiM::set4Mom ( const CLHEP::HepLorentzVector & theHlv)
inline

set all 4-mom from CLHEP HepLorentzVector

Definition at line 253 of file P4ImplPtEtaPhiM.h.

254{
255 m_pt = hlv.perp();
256 m_eta = hlv.eta();
257 //FIXME protect against negative energy
258 //assert(m_e >= 0,"P4ImplPtEtaPhiM::set4Mom cannot have negative energy");
259 //assert(m_e >= 0);
260 // FIXME of the FIXME in fact it is not necessary to prtoect against negative energy
261 // and besides Seal assert does not work
262 // ASSERT( m_e >= 0 );
263 m_phi = hlv.phi();
264 m_m = hlv.m();
265}

◆ set4Mom() [2/3]

void P4ImplPtEtaPhiM::set4Mom ( const I4Momentum & theI4Mom)
inline

set all 4-mom from another I4Momentum reference

Definition at line 240 of file P4ImplPtEtaPhiM.h.

241{
242 m_pt = i4mom.pt();
243 m_eta = i4mom.eta();
244 m_phi = i4mom.phi();
245 m_m = i4mom.m();
246}

◆ set4Mom() [3/3]

void P4ImplPtEtaPhiM::set4Mom ( const I4Momentum *const theI4Mom)
inline

set all 4-mom from another I4Momentum pointer

Definition at line 248 of file P4ImplPtEtaPhiM.h.

249{
250 this->set4Mom(*theI4Mom);
251}
void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference

◆ setErrors()

void P4ImplPtEtaPhiM::setErrors ( const ErrorMatrixPtEtaPhiM & err)
inline

set the errors

Definition at line 267 of file P4ImplPtEtaPhiM.h.

268{
269 m_error = std::make_unique< ErrorType>(err, *this);
270}

◆ setEta()

void P4ImplPtEtaPhiM::setEta ( const double theEta)
inline

set eta data member

Definition at line 225 of file P4ImplPtEtaPhiM.h.

226{
227 m_eta = theEta;
228}

◆ setM()

void P4ImplPtEtaPhiM::setM ( const double theM)
inline

set mass data member

Definition at line 235 of file P4ImplPtEtaPhiM.h.

236{
237 m_m = theM;
238}

◆ setPhi()

void P4ImplPtEtaPhiM::setPhi ( const double thePhi)
inline

set phi data member

Definition at line 230 of file P4ImplPtEtaPhiM.h.

231{
232 m_phi = thePhi;
233}

◆ setPt()

void P4ImplPtEtaPhiM::setPt ( const double thePt)
inline

set pt data member

Definition at line 220 of file P4ImplPtEtaPhiM.h.

221{
222 m_pt = thePt;
223}

◆ sinPhi()

double P4BasePtEtaPhiM::sinPhi ( ) const
inlineinherited

Definition at line 177 of file P4BasePtEtaPhiM.h.

178{
179 return std::sin(this->phi());
180}

◆ sinTh()

double P4BasePtEtaPhiM::sinTh ( ) const
inlineinherited

Definition at line 189 of file P4BasePtEtaPhiM.h.

190{
191 // avoid numeric overflow if very large eta
192
193 double aEta=std::abs(this->eta());
194 if ( aEta>710) {
195 aEta=710;
196 }
197
198 return 1./std::cosh(aEta);
199}

◆ tanTh()

double P4BasePtEtaPhiM::tanTh ( ) const
inlineinherited

Definition at line 206 of file P4BasePtEtaPhiM.h.

207{
208 return 1./std::sinh(this->eta());
209}

◆ P4ImplPtEtaPhiMCnv_p1

friend class P4ImplPtEtaPhiMCnv_p1
friend

Definition at line 42 of file P4ImplPtEtaPhiM.h.

Member Data Documentation

◆ m_error

std::unique_ptr< ErrorType> P4ImplPtEtaPhiM::m_error
private

Definition at line 126 of file P4ImplPtEtaPhiM.h.

◆ m_eta

double P4ImplPtEtaPhiM::m_eta
private

Definition at line 123 of file P4ImplPtEtaPhiM.h.

◆ m_m

double P4ImplPtEtaPhiM::m_m
private

Definition at line 125 of file P4ImplPtEtaPhiM.h.

◆ m_phi

double P4ImplPtEtaPhiM::m_phi
private

Definition at line 124 of file P4ImplPtEtaPhiM.h.

◆ m_pt

double P4ImplPtEtaPhiM::m_pt
private

Definition at line 122 of file P4ImplPtEtaPhiM.h.


The documentation for this class was generated from the following files: