ATLAS Offline Software
PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.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 // TruthParticle.h
8 // Header file for class TruthParticle
9 // Author : Frank Paige Created : Jan 2004
10 // Author : Ketevi A. Assamagan Updated : May 2004
11 // Author : Sebastien Binet Updated : Jan 2005
13 #ifndef MCPARTICLEEVENT_TRUTHPARTICLE_H
14 #define MCPARTICLEEVENT_TRUTHPARTICLE_H
15 
23 // STL includes
24 #include <vector>
25 
26 // HepMC / CLHEP includes
27 #include "CLHEP/Vector/LorentzVector.h"
28 #include "AtlasHepMC/GenParticle.h"
30 #include "AtlasHepMC/Flow.h"
31 
32 // Gaudi includes
33 
34 // EventKernel includes
35 #include "EventKernel/IParticle.h"
36 
37 // FourMom includes
38 
39 // ParticleEvent includes
41 
42 // McParticleEvent includes
48 
49 // Forward declaration
50 namespace Trk { class RecVertex; }
52 
53 class TruthParticle : public ParticleImpl<
54  TruthParticleNavigation,
55  TruthParticleMomentum,
56  TruthParticleBase
57  >
58 {
59 
61  // Public typedefs:
63  public:
64 
65  // for readability and lazy people
70 
71  typedef std::size_t evtIndex_t;
73  // Public methods:
75  public:
76 
79  TruthParticle();
80 
83  TruthParticle( const TruthParticle& rhs );
84 
90  const TruthParticleContainer * container = 0 );
91 
94  TruthParticle& operator=( const TruthParticle& rhs );
95 
99 
101  // Const methods:
103 
105  HepMC::ConstGenParticlePtr genMother(const std::size_t i=0) const;
106 
109 
111  HepMC::ConstGenParticlePtr genChild( const std::size_t i ) const;
112 
118  int status() const;
119 
122  const HepMC::Flow flow() const;
123 
126  int flow( int code_index ) const;
127 
130  const HepMC::Polarization polarization() const;
131 
134  int barcode() const;
135 
138  long compressedExtBarCode() const { return 0; };
142  const TruthParticle * mother(const std::size_t i=0) const;
144 
146  const TruthParticle * child( const std::size_t i ) const;
147 
151  bool hasMother( const int pdgId ) const;
152 
156  bool hasChild( const int pdgId ) const;
157 
162  bool hasMother( const int pdgId, std::vector<unsigned int>& indices ) const;
163 
168  bool hasChild( const int pdgId, std::vector<unsigned int>& indices ) const;
169 
170  // Accessor functions
171 
175  bool hasEtIsol() const;
176 
182  double etIsol( const TruthParticleParameters::ConeSize coneIdx ) const;
183 
186  const TruthEtIsolations::EtIsol_t* etIsol() const;
187 
189  unsigned int nParents() const;
190 
192  unsigned int nDecay() const;
193 
195  CLHEP::HepLorentzVector transformVector( const HepMC::FourVector& ) const;
196 
198  CLHEP::HepLorentzVector pDecay( const std::size_t i ) const;
199 
201  int pdgDecay( const std::size_t i ) const;
202 
203 #ifdef HEPMC3
204 //FIXME
205 #else
206  operator const HepMC::GenParticle&() const;
209 #endif
210 
212 
214  // Non-const methods:
216 
217  // Set functions
218 
220  void setCharge( const ChargeType charge );
221 
222  void set4Mom( const HepMC::FourVector& hlv )
223  { this->momentumBase().set4Mom(hlv); }
224 
225  // un-hide base-class' set4Mom
227 
229  void setGenEventIndex( size_t index );
230 
232  // Protected methods:
234  protected:
235 
238 
239 
240 
242  // Protected data:
244  protected:
245 
249 
254  std::vector<int> m_mothers;
255 
260  std::vector<int> m_children;
261 
264 
265 };
266 
268 // I/O functions
270 std::ostream& operator<<( std::ostream& out, const TruthParticle& mc );
271 
273 // Inline methods:
275 
277 {}
278 
280 {
281  return this->particleBase().genParticle();
282 }
283 
284 inline int TruthParticle::status() const
285 {
286  return genParticle()->status();
287 }
288 
289 inline const HepMC::Flow TruthParticle::flow() const
290 {
291  return HepMC::flow(genParticle());
292 }
293 
294 inline int TruthParticle::flow( int code_index ) const
295 {
296  return HepMC::flow(genParticle(),code_index);
297 }
298 
299 inline const HepMC::Polarization TruthParticle::polarization() const
300 {
302 }
303 
304 inline int TruthParticle::barcode() const
305 {
306  return HepMC::barcode(genParticle());
307 }
308 
309 inline unsigned int TruthParticle::nParents() const
310 { return m_mothers.size(); }
311 
312 inline unsigned int TruthParticle::nDecay() const
313 { return m_children.size(); }
314 
315 #ifdef HEPMC3
316 
317 //FIXME
318 #else
319 
320 inline
321 TruthParticle::operator const HepMC::GenParticle&() const
322 {
323  return *genParticle();
324 }
325 
326 #endif
328 {
329  this->particleBase().setCharge( charge );
330 }
331 
332 inline CLHEP::HepLorentzVector TruthParticle::transformVector( const HepMC::FourVector& fv ) const
333 {
334  CLHEP::HepLorentzVector hlv(fv.x(),fv.y(),fv.z(),fv.t());
335  return hlv;
336 }
337 
340 }
341 
342 
343 #endif //> MCPARTICLEEVENT_TRUTHPARTICLE_H
Flow.h
TruthParticleMomentum::set4Mom
virtual void set4Mom(const I4Momentum *const theI4Mom)
set 4Momentum (will throw exception if cannot be implemented)
Definition: TruthParticleMomentum.h:283
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
HepMC::polarization
Polarization polarization(const T &a)
Definition: Polarization.h:47
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::pdgId
virtual int pdgId() const
Return enum indicating particle id the enum file is available in Event/EventKernel/PdtPdg....
Definition: ParticleImpl.h:738
TruthParticle::hasEtIsol
bool hasEtIsol() const
Return true if one has filled the Et isolation infos for this TruthParticle.
Definition: TruthParticle.cxx:183
TruthParticle::pDecay
CLHEP::HepLorentzVector pDecay(const std::size_t i) const
Return the 4-vec of i-th child of this particle.
Definition: TruthParticle.cxx:205
TruthParticle::barcode
int barcode() const
Forwards the HepMC::GenParticle::barcode() information.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:304
index
Definition: index.py:1
TruthParticle::genChild
HepMC::ConstGenParticlePtr genChild(const std::size_t i) const
Retrieve the i-th child (GenParticle) of this TruthParticle.
Definition: TruthParticle.cxx:118
TruthParticleMomentum.h
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
TruthParticleMomentum
Definition: TruthParticleMomentum.h:28
TruthParticle::mother
const TruthParticle * mother(const std::size_t i=0) const
Retrieve the i-th mother (TruthParticle) of this TruthParticle.
Definition: TruthParticle.cxx:90
TruthParticle::flow
const HepMC::Flow flow() const
Forwards the HepMC::GenParticle::flow() information.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:289
TruthParticleBase.h
TruthParticle
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:58
TruthParticleBase
Definition: TruthParticleBase.h:34
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
TruthEtIsolations::EtIsol_t
McAod::EtIsolations EtIsol_t
An array of doubles of fixed size to modelize the Et isolations for different values of isolation rad...
Definition: TruthEtIsolations.h:52
operator<<
std::ostream & operator<<(std::ostream &out, const TruthParticle &mc)
TruthParticleParameters::ConeSize
ConeSize
Enum for Cone size indexes (for isolation)
Definition: TruthParticleParamDefs.h:20
TruthParticle::~TruthParticle
~TruthParticle()
Default constructor:
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:276
IParticle.h
TruthParticle::hasMother
bool hasMother(const int pdgId) const
Return true if the given PDG::id to match can be found within the parents of this TruthParticle.
Definition: TruthParticle.cxx:129
TruthParticle::genParticle
HepMC::ConstGenParticlePtr genParticle() const
Retrieve the GenParticle this TruthParticle has been made from (if any)
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:279
TruthParticleContainer
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:42
TruthParticle::setGenEventIndex
void setGenEventIndex(size_t index)
set the GenEvent index
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:338
GenParticle.h
TruthEtIsolations.h
TruthParticle::polarization
const HepMC::Polarization polarization() const
Forwards the HepMC::GenParticle::polarization() information.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:299
ParticleImpl
Definition: ParticleImpl.h:39
mc
Definition: mc.PG_single_nu_valid.py:1
TruthParticle::nDecay
unsigned int nDecay() const
Number of children of this particle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:312
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::charge
virtual ChargeType charge() const
returns charge as a typedef ChargeType currently Charge Type is a double for jets this may be changed...
Definition: ParticleImpl.h:718
TruthParticle::setGenParticle
void setGenParticle(HepMC::ConstGenParticlePtr particle)
Fill the data members of ParticleBase from the GenParticle.
Definition: TruthParticle.cxx:240
HepMC::flow
int flow(const T &a, int i)
Definition: Flow.h:51
lumiFormat.i
int i
Definition: lumiFormat.py:85
TruthParticle::m_children
std::vector< int > m_children
vector of barcodes of all the children of this particle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:260
TruthParticle::evtIndex_t
std::size_t evtIndex_t
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:71
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TruthParticle::genMother
HepMC::ConstGenParticlePtr genMother(const std::size_t i=0) const
Retrieve the GenParticle mother of this TruthParticle.
Definition: TruthParticle.cxx:107
TruthParticleNavigation
NavigableTerminalNode TruthParticleNavigation
Definition: TruthParticleNavigation.h:23
TruthParticle::hasChild
bool hasChild(const int pdgId) const
Return true if the given PDG::id to match can be found within the children of this TruthParticle.
Definition: TruthParticle.cxx:141
TruthParticle::etIsol
const TruthEtIsolations::EtIsol_t * etIsol() const
Return the transverse energies for all the isolation cones.
Definition: TruthParticle.cxx:188
TruthParticleParamDefs.h
TruthParticleBase::genParticle
HepMC::ConstGenParticlePtr genParticle() const
return the HepMC::GenParticle which is being proxied
Definition: TruthParticleBase.h:180
TruthParticle::status
int status() const
Forwards the HepMC::GenParticle::status() information.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:284
TruthParticle::genEventIndex
evtIndex_t genEventIndex() const
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:211
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::momentumBase
const momentum_type & momentumBase() const
access to underlying base type (I4Momentum-like)
Definition: ParticleImpl.h:393
TruthParticle::TruthParticleImpl_t
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase > TruthParticleImpl_t
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:69
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::hlv
virtual CLHEP::HepLorentzVector hlv() const
CLHEP HepLorentzVector.
Definition: ParticleImpl.h:635
TruthParticle::transformVector
CLHEP::HepLorentzVector transformVector(const HepMC::FourVector &) const
returns a Pointer to a CLHEP::LorentzVector from a HepMC::FourVector
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:332
HepMC::ConstGenParticlePtr
const GenParticle * ConstGenParticlePtr
Definition: GenParticle.h:38
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
TruthParticle::operator=
TruthParticle & operator=(const TruthParticle &rhs)
Assignment operator.
Definition: TruthParticle.cxx:71
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::particleBase
const particle_type & particleBase() const
access to underlying base type (IParticle-like)
Definition: ParticleImpl.h:403
charge
double charge(const T &p)
Definition: AtlasPID.h:538
TruthParticle::m_container
const TruthParticleContainer * m_container
Pointer to the collection holding ourself.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:248
ChargeType
double ChargeType
typedef ChargeType used to anticipate changes here
Definition: Event/EventKernel/EventKernel/IParticle.h:40
TruthParticle::compressedExtBarCode
long compressedExtBarCode() const
Forwards the HepMC::GenParticle::barcode() information.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:138
TruthParticle::pdgDecay
int pdgDecay(const std::size_t i) const
Return the PDG-Id of the i-th child of this particle.
Definition: TruthParticle.cxx:221
TruthParticle::m_mothers
std::vector< int > m_mothers
vector of barcodes of all the mothers of this particle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:254
DeMoScan.index
string index
Definition: DeMoScan.py:364
TruthParticleBase::setCharge
void setCharge(const ChargeType charge)
Set the charge of this TruthParticleBase.
Definition: TruthParticleBase.h:186
ParticleImpl< TruthParticleNavigation, TruthParticleMomentum, TruthParticleBase >::set4Mom
virtual void set4Mom(const I4Momentum &p4)
Definition: ParticleImpl.h:875
TruthParticle::child
const TruthParticle * child(const std::size_t i) const
Retrieve the i-th child (TruthParticle) of this TruthParticle.
Definition: TruthParticle.cxx:98
TruthParticle::m_nGenEventIdx
evtIndex_t m_nGenEventIdx
the index of the GenEvent this particle is in
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:263
TruthParticle::nParents
unsigned int nParents() const
Number of parents of this particle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:309
TruthParticleNavigation.h
TruthParticle::set4Mom
void set4Mom(const HepMC::FourVector &hlv)
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:222
Polarization.h
TruthParticle::setCharge
void setCharge(const ChargeType charge)
Set the charge of this TruthParticle.
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:327
ParticleImpl.h
GenParticle
@ GenParticle
Definition: TruthClasses.h:30
TruthParticle::TruthParticle
TruthParticle()
Default constructor.
Definition: TruthParticle.cxx:33