ATLAS Offline Software
Loading...
Searching...
No Matches
P4ImplPtEtaPhiM.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_P4IMPLPTETAPHIM_H
8#define FOURMOM_P4IMPLPTETAPHIM_H
9
10// STL includes
11#include <cmath>
12
13// CLHEP includes
14#include "CLHEP/Vector/LorentzVector.h"
15#include "CLHEP/Units/SystemOfUnits.h"
16
17// EventKernel includes
19
20// FourMom includes
23
24#include<memory>
25// forward declare
26class P4ImplPtEtaPhiMCnv_p1; //> for persistency
27
38
39
41{
43
44 public:
45
47
51
54 explicit P4ImplPtEtaPhiM( const P4ImplPtEtaPhiM& rhs );
55
59
61 P4ImplPtEtaPhiM( const double pt, const double eta,
62 const double phi, const double m );
63
65 P4ImplPtEtaPhiM( const CLHEP::HepLorentzVector& hlv );
66
68 explicit P4ImplPtEtaPhiM( const I4Momentum& theI4M );
69
71 explicit P4ImplPtEtaPhiM( const I4Momentum* const theI4M );
72
74 virtual ~P4ImplPtEtaPhiM();
75
77 // Const methods:
79
82 double m() const;
83 double eta() const;
84 double phi() const;
85 double pt() const;
86
87 virtual const I4MomentumError* errors() const;
88
90
93
95 // Non-const methods:
97
99 void setPt( const double thePt );
101 void setEta( const double theEta );
103 void setPhi( const double thePhi );
105 void setM( const double theM );
106
108 void setErrors( const ErrorMatrixPtEtaPhiM& err);
109
111 void set4Mom( const I4Momentum & theI4Mom );
113 void set4Mom( const I4Momentum * const theI4Mom );
115 void set4Mom( const CLHEP::HepLorentzVector & theHlv );
116
118 // Private data:
120 private:
121
122 double m_pt;
123 double m_eta;
124 double m_phi;
125 double m_m;
126 std::unique_ptr< ErrorType> m_error;
127
128};
129
131// Inline methods:
133
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{}
142
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{}
151
152inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const double pt, const double eta,
153 const double phi, const double m ) :
155 m_pt ( pt ),
156 m_eta( eta ),
157 m_phi( phi ),
158 m_m ( m ),
159 m_error(nullptr)
160{}
161
162inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const CLHEP::HepLorentzVector& hlv ) :
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{}
170
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{}
179
180inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const I4Momentum * const i4Mom ) :
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{}
188
191
192inline double P4ImplPtEtaPhiM::m() const
193{
194 return m_m;
195}
196
197inline double P4ImplPtEtaPhiM::eta() const
198{
199 return m_eta;
200}
201
202inline double P4ImplPtEtaPhiM::phi() const
203{
204 return m_phi;
205}
206
207inline double P4ImplPtEtaPhiM::pt() const
208{
209 return m_pt;
210}
211
213{
214 // check if the pointer is empty before dereferencing
215 return m_error.get();
216}
217
218// setters
219
220inline void P4ImplPtEtaPhiM::setPt( const double thePt )
221{
222 m_pt = thePt;
223}
224
225inline void P4ImplPtEtaPhiM::setEta( const double theEta )
226{
227 m_eta = theEta;
228}
229
230inline void P4ImplPtEtaPhiM::setPhi( const double thePhi )
231{
232 m_phi = thePhi;
233}
234
235inline void P4ImplPtEtaPhiM::setM( const double theM )
236{
237 m_m = theM;
238}
239
240inline void P4ImplPtEtaPhiM::set4Mom( const I4Momentum& i4mom )
241{
242 m_pt = i4mom.pt();
243 m_eta = i4mom.eta();
244 m_phi = i4mom.phi();
245 m_m = i4mom.m();
246}
247
248inline void P4ImplPtEtaPhiM::set4Mom( const I4Momentum* const theI4Mom )
249{
250 this->set4Mom(*theI4Mom);
251}
252
253inline void P4ImplPtEtaPhiM::set4Mom( const CLHEP::HepLorentzVector & hlv)
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}
266
268{
269 m_error = std::make_unique< ErrorType>(err, *this);
270}
271
272#endif // FOURMOM_P4IMPLPTETAPHIM_H
Scalar perp() const
perp method - perpendicular length
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 pt() const =0
transverse momentum
virtual double eta() const =0
pseudo rapidity
P4BasePtEtaPhiM is a base class for classes with 4-momentum behavior, for which pt,...
CLHEP::HepLorentzVector hlv() const
void setM(const double theM)
set mass data member
double eta() const
void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference
void setPhi(const double thePhi)
set phi data member
virtual const I4MomentumError * errors() const
double phi() const
double pt() const
P4ImplPtEtaPhiM()
Default constructor:
P4ImplPtEtaPhiM & operator=(const P4ImplPtEtaPhiM &rhs)
Assignment operator.
virtual ~P4ImplPtEtaPhiM()
virtual destructor needed by pool
void setErrors(const ErrorMatrixPtEtaPhiM &err)
set the errors
I4Momentum::Kind kind() const
std::unique_ptr< ErrorType > m_error
friend class P4ImplPtEtaPhiMCnv_p1
void setEta(const double theEta)
set eta data member
void setPt(const double thePt)
set pt data member
double m() const
{@ a la I4Momentum -like interface
FourMomentumError< P4ImplPtEtaPhiM > ErrorType