ATLAS Offline Software
Loading...
Searching...
No Matches
P4ImplEEtaPhiM.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_P4IMPLEETAPHIM_H
8#define FOURMOM_P4IMPLEETAPHIM_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 P4ImplEEtaPhiMCnv_p1; // for persistency
38
40{
42
43 public:
44
46
50
53 explicit P4ImplEEtaPhiM( const P4ImplEEtaPhiM& rhs );
54
58
60 P4ImplEEtaPhiM( const double e, const double eta,
61 const double phi, const double m );
62
64 explicit P4ImplEEtaPhiM( const CLHEP::HepLorentzVector& hlv );
65
67 explicit P4ImplEEtaPhiM( const I4Momentum& theI4M );
68
70 explicit P4ImplEEtaPhiM( const I4Momentum* const theI4M );
71
73 virtual ~P4ImplEEtaPhiM();
74
76 // Const methods:
78
81 double m() const;
82 double eta() const;
83 double phi() const;
84 double e() const;
85
86 virtual const I4MomentumError* errors() const;
87
89
92
94 // Non-const methods:
96
98 void setE( const double theE );
100 void setEta( const double theEta );
102 void setPhi( const double thePhi );
104 void setM( const double theM );
105
107 void set4Mom( const I4Momentum & theI4Mom );
109 void set4Mom( const I4Momentum * const theI4Mom );
111 void set4Mom( const CLHEP::HepLorentzVector & theHlv );
113 void setErrors( const ErrorMatrixEEtaPhiM& err);
114
116 // Protected data:
118 private:
119
120 double m_e;
121 double m_eta;
122 double m_phi;
123 double m_m;
124 std::unique_ptr< ErrorType> m_error;
125
126};
127
129// Inline methods:
131
134 m_e ( 0.*CLHEP::GeV ),
135 m_eta( 0. ),
136 m_phi( 0. ),
137 m_m ( 0.*CLHEP::GeV ),
138 m_error(nullptr)
139{}
140
143 m_e ( rhs.m_e ),
144 m_eta( rhs.m_eta ),
145 m_phi( rhs.m_phi ),
146 m_m ( rhs.m_m ),
147 m_error(nullptr)
148{}
149
150inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const double e, const double eta,
151 const double phi, const double m ) :
153 m_e ( e ),
154 m_eta( eta ),
155 m_phi( phi ),
156 m_m ( m ),
157 m_error(nullptr)
158{
159 // could enforce phi range convention there
160 // const double twopi =2.*M_PI;
161 // const double threepi=3.*M_PI;
162 // m_phi=std::fmod(phi+threepi,twopi)-M_PI;
163}
164
165inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const CLHEP::HepLorentzVector& hlv ) :
167 m_e ( hlv.e() ),
168 m_eta( hlv.eta() ),
169 m_phi( hlv.phi() ),
170 m_m ( hlv.m() ),
171 m_error(nullptr)
172{}
173
176 m_e ( i4mom.e() ),
177 m_eta( i4mom.eta() ),
178 m_phi( i4mom.phi() ),
179 m_m ( i4mom.m() ),
180 m_error(nullptr)
181{}
182
183inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const I4Momentum * const i4Mom ) :
185 m_e ( i4Mom->e() ),
186 m_eta( i4Mom->eta() ),
187 m_phi( i4Mom->phi() ),
188 m_m ( i4Mom->m() ),
189 m_error(nullptr)
190{}
191
195
196inline double P4ImplEEtaPhiM::m() const
197{
198 return m_m;
199}
200
201inline double P4ImplEEtaPhiM::eta() const
202{
203 return m_eta;
204}
205
206inline double P4ImplEEtaPhiM::phi() const
207{
208 return m_phi;
209}
210
211inline double P4ImplEEtaPhiM::e() const
212{
213 return m_e;
214}
215
217{
218 return m_error.get();
219}
220
221inline void P4ImplEEtaPhiM::setE( const double theE )
222{
223 m_e = theE;
224}
225
226inline void P4ImplEEtaPhiM::setEta( const double theEta )
227{
228 m_eta = theEta;
229}
230
231inline void P4ImplEEtaPhiM::setPhi( const double thePhi )
232{
233 m_phi = thePhi;
234}
235
236inline void P4ImplEEtaPhiM::setM( const double theM )
237{
238 m_m = theM;
239}
240
241inline void P4ImplEEtaPhiM::set4Mom( const I4Momentum & theI4Mom )
242{
243 m_e = theI4Mom.e();
244 m_eta = theI4Mom.eta();
245 m_phi = theI4Mom.phi();
246 m_m = theI4Mom.m();
247}
248
249inline void P4ImplEEtaPhiM::set4Mom( const I4Momentum * const theI4Mom )
250{
251 this->set4Mom(*theI4Mom);
252}
253
254inline void P4ImplEEtaPhiM::set4Mom( const CLHEP::HepLorentzVector & hlv )
255{
256 m_e = hlv.e();
257 m_eta = hlv.eta();
258 //FIXME protect against negative energy
259 //assert(m_e >= 0,"P4::Impl::EEtaPhiM::set4Mom cannot have negative energy");
260 //assert(m_e >= 0);
261 // FIXME of the FIXME in fact it is not necessary to prtoect against negative energy
262 // and besides Seal assert does not work
263 // ASSERT( m_e >= 0 );
264 m_phi = hlv.phi();
265 m_m = hlv.m();
266}
267
268//void P4ImplEEtaPhiM::setErrors( const FourMomentumError* err)
270{
271 // if (m_error != 0) delete m_error;
272 // if (err != 0) m_error = new FourMomentumError(*err);
273 // else m_error = 0;
274
275 m_error = std::make_unique< ErrorType>(err, *this);
276}
277
278
279#endif // FOURMOM_P4IMPLEETAPHIM_H
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 eta() const =0
pseudo rapidity
virtual double e() const =0
energy
P4BaseEEtaPhiM is a base class for classes with 4-momentum behavior, for which E, eta,...
CLHEP::HepLorentzVector hlv() const
I4Momentum::Kind kind() const
P4ImplEEtaPhiM & operator=(const P4ImplEEtaPhiM &rhs)
Assignment operator.
double m() const
{@ a la I4Momentum -like interface
double eta() const
FourMomentumError< P4ImplEEtaPhiM > ErrorType
std::unique_ptr< ErrorType > m_error
virtual const I4MomentumError * errors() const
double phi() const
void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference
friend class P4ImplEEtaPhiMCnv_p1
void setEta(const double theEta)
set eta data member
void setE(const double theE)
set energy data member
void setM(const double theM)
set mass data member
P4ImplEEtaPhiM()
Default constructor:
void setErrors(const ErrorMatrixEEtaPhiM &err)
set the errors
void setPhi(const double thePhi)
set phi data member
virtual ~P4ImplEEtaPhiM()
virtual destructor needed by pool
double e() const