ATLAS Offline Software
P4ImplEEtaPhiM.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_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
18 #include "EventKernel/I4Momentum.h"
19 
20 // FourMom includes
23 
24 #include <memory>
25 // forward declare
26 class P4ImplEEtaPhiMCnv_p1; // for persistency
40 {
41  friend class P4ImplEEtaPhiMCnv_p1;
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 
93  // 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 
133  P4BaseEEtaPhiM( ),
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 
142  P4BaseEEtaPhiM( ),
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 
150 inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const double e, const double eta,
151  const double phi, const double m ) :
152  P4BaseEEtaPhiM( ),
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 
165 inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const CLHEP::HepLorentzVector& hlv ) :
166  P4BaseEEtaPhiM( ),
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 
175  P4BaseEEtaPhiM( ),
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 
183 inline P4ImplEEtaPhiM::P4ImplEEtaPhiM( const I4Momentum * const i4Mom ) :
184  P4BaseEEtaPhiM( ),
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 
193 {
194 }
195 
196 inline double P4ImplEEtaPhiM::m() const
197 {
198  return m_m;
199 }
200 
201 inline double P4ImplEEtaPhiM::eta() const
202 {
203  return m_eta;
204 }
205 
206 inline double P4ImplEEtaPhiM::phi() const
207 {
208  return m_phi;
209 }
210 
211 inline double P4ImplEEtaPhiM::e() const
212 {
213  return m_e;
214 }
215 
217 {
218  return m_error.get();
219 }
220 
221 inline void P4ImplEEtaPhiM::setE( const double theE )
222 {
223  m_e = theE;
224 }
225 
226 inline void P4ImplEEtaPhiM::setEta( const double theEta )
227 {
228  m_eta = theEta;
229 }
230 
231 inline void P4ImplEEtaPhiM::setPhi( const double thePhi )
232 {
233  m_phi = thePhi;
234 }
235 
236 inline void P4ImplEEtaPhiM::setM( const double theM )
237 {
238  m_m = theM;
239 }
240 
241 inline 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 
249 inline void P4ImplEEtaPhiM::set4Mom( const I4Momentum * const theI4Mom )
250 {
251  this->set4Mom(*theI4Mom);
252 }
253 
254 inline 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
Definition: I4Momentum.h:31
P4ImplEEtaPhiM::m_error
std::unique_ptr< ErrorType > m_error
Definition: P4ImplEEtaPhiM.h:124
ErrorMatrixEEtaPhiM
Definition: ErrorMatrixEEtaPhiM.h:12
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
FourMomentumError.h
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
P4ImplEEtaPhiM::errors
virtual const I4MomentumError * errors() const
Definition: P4ImplEEtaPhiM.h:216
P4ImplEEtaPhiM::setM
void setM(const double theM)
set mass data member
Definition: P4ImplEEtaPhiM.h:236
P4ImplEEtaPhiM::kind
I4Momentum::Kind kind() const
Definition: P4ImplEEtaPhiM.h:88
P4ImplEEtaPhiMCnv_p1
Definition: P4ImplEEtaPhiMCnv_p1.h:38
P4ImplEEtaPhiM::ErrorType
FourMomentumError< P4ImplEEtaPhiM > ErrorType
Definition: P4ImplEEtaPhiM.h:45
P4ImplEEtaPhiM::eta
double eta() const
Definition: P4ImplEEtaPhiM.h:201
I4Momentum.h
P4ImplEEtaPhiM::~P4ImplEEtaPhiM
virtual ~P4ImplEEtaPhiM()
virtual destructor needed by pool
Definition: P4ImplEEtaPhiM.h:192
P4ImplEEtaPhiM::setEta
void setEta(const double theEta)
set eta data member
Definition: P4ImplEEtaPhiM.h:226
I4Momentum::Kind
Kind
Definition: I4Momentum.h:33
P4BaseEEtaPhiM.h
P4BaseEEtaPhiM::hlv
CLHEP::HepLorentzVector hlv() const
Definition: P4BaseEEtaPhiM.h:209
P4ImplEEtaPhiM::set4Mom
void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference
Definition: P4ImplEEtaPhiM.h:241
P4ImplEEtaPhiM
Definition: P4ImplEEtaPhiM.h:40
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:193
I4MomentumError
Definition: I4MomentumError.h:28
P4ImplEEtaPhiM::phi
double phi() const
Definition: P4ImplEEtaPhiM.h:206
I4Momentum::e
virtual double e() const =0
energy
P4ImplEEtaPhiM::m_e
double m_e
Definition: P4ImplEEtaPhiM.h:120
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
I4Momentum::eta
virtual double eta() const =0
pseudo rapidity
FourMomentumError
Definition: FourMomentumError.h:13
I4Momentum::phi
virtual double phi() const =0
phi in [-pi,pi[
P4BaseEEtaPhiM
Definition: P4BaseEEtaPhiM.h:33
P4ImplEEtaPhiM::m_eta
double m_eta
Definition: P4ImplEEtaPhiM.h:121
P4ImplEEtaPhiM::setErrors
void setErrors(const ErrorMatrixEEtaPhiM &err)
set the errors
Definition: P4ImplEEtaPhiM.h:269
P4ImplEEtaPhiM::m
double m() const
{@ a la I4Momentum -like interface
Definition: P4ImplEEtaPhiM.h:196
P4ImplEEtaPhiM::m_phi
double m_phi
Definition: P4ImplEEtaPhiM.h:122
I4Momentum::m
virtual double m() const =0
mass
P4ImplEEtaPhiM::setE
void setE(const double theE)
set energy data member
Definition: P4ImplEEtaPhiM.h:221
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
P4ImplEEtaPhiM::setPhi
void setPhi(const double thePhi)
set phi data member
Definition: P4ImplEEtaPhiM.h:231
P4ImplEEtaPhiM::m_m
double m_m
Definition: P4ImplEEtaPhiM.h:123
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
P4ImplEEtaPhiM::P4ImplEEtaPhiM
P4ImplEEtaPhiM()
Default constructor:
Definition: P4ImplEEtaPhiM.h:132
I4Momentum::P4EETAPHIM
@ P4EETAPHIM
Definition: I4Momentum.h:33
P4ImplEEtaPhiM::operator=
P4ImplEEtaPhiM & operator=(const P4ImplEEtaPhiM &rhs)
Assignment operator.
Definition: P4ImplEEtaPhiM.cxx:14
P4ImplEEtaPhiM::e
double e() const
Definition: P4ImplEEtaPhiM.h:211