ATLAS Offline Software
P4ImplPtEtaPhiM.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_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
18 #include "EventKernel/I4Momentum.h"
19 
20 // FourMom includes
23 
24 #include<memory>
25 // forward declare
26 class P4ImplPtEtaPhiMCnv_p1; //> for persistency
27 
41 {
42  friend class P4ImplPtEtaPhiMCnv_p1;
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 
94  // 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 
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 {}
142 
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 {}
151 
152 inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const double pt, const double eta,
153  const double phi, const double m ) :
154  P4BasePtEtaPhiM( ),
155  m_pt ( pt ),
156  m_eta( eta ),
157  m_phi( phi ),
158  m_m ( m ),
159  m_error(nullptr)
160 {}
161 
162 inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const CLHEP::HepLorentzVector& hlv ) :
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 {}
170 
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 {}
179 
180 inline P4ImplPtEtaPhiM::P4ImplPtEtaPhiM( const I4Momentum * const i4Mom ) :
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 {}
188 
190 {}
191 
192 inline double P4ImplPtEtaPhiM::m() const
193 {
194  return m_m;
195 }
196 
197 inline double P4ImplPtEtaPhiM::eta() const
198 {
199  return m_eta;
200 }
201 
202 inline double P4ImplPtEtaPhiM::phi() const
203 {
204  return m_phi;
205 }
206 
207 inline 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 
220 inline void P4ImplPtEtaPhiM::setPt( const double thePt )
221 {
222  m_pt = thePt;
223 }
224 
225 inline void P4ImplPtEtaPhiM::setEta( const double theEta )
226 {
227  m_eta = theEta;
228 }
229 
230 inline void P4ImplPtEtaPhiM::setPhi( const double thePhi )
231 {
232  m_phi = thePhi;
233 }
234 
235 inline void P4ImplPtEtaPhiM::setM( const double theM )
236 {
237  m_m = theM;
238 }
239 
240 inline 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 
248 inline void P4ImplPtEtaPhiM::set4Mom( const I4Momentum* const theI4Mom )
249 {
250  this->set4Mom(*theI4Mom);
251 }
252 
253 inline 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
I4Momentum
Definition: I4Momentum.h:31
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
P4ImplPtEtaPhiM::eta
double eta() const
Definition: P4ImplPtEtaPhiM.h:197
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
P4ImplPtEtaPhiM::pt
double pt() const
Definition: P4ImplPtEtaPhiM.h:207
P4BasePtEtaPhiM.h
FourMomentumError.h
perp
Scalar perp() const
perp method - perpenticular length
Definition: AmgMatrixBasePlugin.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
test_pyathena.pt
pt
Definition: test_pyathena.py:11
P4ImplPtEtaPhiM::errors
virtual const I4MomentumError * errors() const
Definition: P4ImplPtEtaPhiM.h:212
P4ImplPtEtaPhiM::setErrors
void setErrors(const ErrorMatrixPtEtaPhiM &err)
set the errors
Definition: P4ImplPtEtaPhiM.h:267
I4Momentum::pt
virtual double pt() const =0
transverse momentum
I4Momentum.h
P4ImplPtEtaPhiMCnv_p1
Definition: P4ImplPtEtaPhiMCnv_p1.h:38
I4Momentum::Kind
Kind
Definition: I4Momentum.h:33
P4ImplPtEtaPhiM::ErrorType
FourMomentumError< P4ImplPtEtaPhiM > ErrorType
Definition: P4ImplPtEtaPhiM.h:46
P4BasePtEtaPhiM::hlv
CLHEP::HepLorentzVector hlv() const
Definition: P4BasePtEtaPhiM.h:217
P4ImplPtEtaPhiM::~P4ImplPtEtaPhiM
virtual ~P4ImplPtEtaPhiM()
virtual destructor needed by pool
Definition: P4ImplPtEtaPhiM.h:189
P4ImplPtEtaPhiM::m_error
std::unique_ptr< ErrorType > m_error
Definition: P4ImplPtEtaPhiM.h:126
P4ImplPtEtaPhiM::P4ImplPtEtaPhiM
P4ImplPtEtaPhiM()
Default constructor:
Definition: P4ImplPtEtaPhiM.h:134
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
P4ImplPtEtaPhiM::kind
I4Momentum::Kind kind() const
Definition: P4ImplPtEtaPhiM.h:89
P4ImplPtEtaPhiM::m_pt
double m_pt
Definition: P4ImplPtEtaPhiM.h:122
P4ImplPtEtaPhiM::setEta
void setEta(const double theEta)
set eta data member
Definition: P4ImplPtEtaPhiM.h:225
I4MomentumError
Definition: I4MomentumError.h:28
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
I4Momentum::eta
virtual double eta() const =0
pseudo rapidity
ErrorMatrixPtEtaPhiM
Definition: ErrorMatrixPtEtaPhiM.h:12
P4ImplPtEtaPhiM
Definition: P4ImplPtEtaPhiM.h:41
FourMomentumError
Definition: FourMomentumError.h:13
I4Momentum::phi
virtual double phi() const =0
phi in [-pi,pi[
I4Momentum::P4PTETAPHIM
@ P4PTETAPHIM
Definition: I4Momentum.h:33
P4ImplPtEtaPhiM::setPhi
void setPhi(const double thePhi)
set phi data member
Definition: P4ImplPtEtaPhiM.h:230
P4ImplPtEtaPhiM::operator=
P4ImplPtEtaPhiM & operator=(const P4ImplPtEtaPhiM &rhs)
Assignment operator.
Definition: P4ImplPtEtaPhiM.cxx:14
P4ImplPtEtaPhiM::m_phi
double m_phi
Definition: P4ImplPtEtaPhiM.h:124
I4Momentum::m
virtual double m() const =0
mass
P4ImplPtEtaPhiM::setPt
void setPt(const double thePt)
set pt data member
Definition: P4ImplPtEtaPhiM.h:220
P4ImplPtEtaPhiM::m_m
double m_m
Definition: P4ImplPtEtaPhiM.h:125
P4ImplPtEtaPhiM::m
double m() const
{@ a la I4Momentum -like interface
Definition: P4ImplPtEtaPhiM.h:192
P4ImplPtEtaPhiM::phi
double phi() const
Definition: P4ImplPtEtaPhiM.h:202
P4ImplPtEtaPhiM::m_eta
double m_eta
Definition: P4ImplPtEtaPhiM.h:123
P4BasePtEtaPhiM
Definition: P4BasePtEtaPhiM.h:33
P4ImplPtEtaPhiM::setM
void setM(const double theM)
set mass data member
Definition: P4ImplPtEtaPhiM.h:235
P4ImplPtEtaPhiM::set4Mom
void set4Mom(const I4Momentum &theI4Mom)
set all 4-mom from another I4Momentum reference
Definition: P4ImplPtEtaPhiM.h:240