ATLAS Offline Software
TruthParticleContainer.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TruthParticleContainer.cxx
7 // Implementation file for class TruthParticleContainer
8 // Author: S.Binet<binet@cern.ch>
10 
11 
12 // STL includes
13 #include <iostream>
14 
15 // McParticleEvent includes
17 
21 
24  m_genEvent ( ),
25  m_etIsolations( ),
26  m_particles ( )
27 {}
28 
29 /*
30 TruthParticleContainer::TruthParticleContainer( const TruthParticleContainer& rhs ) :
31  DataVector<I4Momentum> ( rhs ),
32  DataVector<INavigable4Momentum>( rhs ),
33  DataVector<TruthParticle>( rhs ),
34  m_genEvent ( rhs.m_genEvent ),
35  m_etIsolations( rhs.m_etIsolations ),
36  m_particles ( rhs.m_particles )
37 {}
38 
39 TruthParticleContainer& TruthParticleContainer::operator=( const TruthParticleContainer& rhs )
40 {
41  if ( this != &rhs ) {
42  DataVector<TruthParticle>::operator=(rhs);
43  m_genEvent = rhs.m_genEvent;
44  m_etIsolations = rhs.m_etIsolations;
45  m_particles = rhs.m_particles;
46  }
47 
48  return *this;
49 }
50 */
51 
54  m_genEvent ( ),
55  m_etIsolations( ),
56  m_particles ( )
57 {}
58 
62 
63 const TruthParticle*
64 TruthParticleContainer::truthParticle( const int barcode,std::size_t genEventIdx ) const
65 {
67  Map_t::const_iterator itr = m_particles.find(mcLink.compress());
68  if ( itr != m_particles.end() ) {
69  return itr->second;
70  }
71  return nullptr;
72 }
73 
74 std::size_t
75 TruthParticleContainer::truthParticleIdx( const int barcode, std::size_t genEventIdx ) const
76 {
78  Map_t::const_iterator itr = m_particles.find(mcLink.compress());
79  if ( itr != m_particles.end() ) {
80  for ( std::size_t idx = 0; idx != this->size(); ++idx ) {
81  if ( this->operator[](idx) == itr->second ) {
82  return idx;
83  }
84  }
85  }
86  return NoIdx;
87 }
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
TruthParticleContainer::m_particles
Map_t m_particles
Dictionary to ease the extraction of a TruthParticle (contained by this collection) from the HepMC::G...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:205
TruthParticleContainer.h
TruthParticle
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticle.h:58
TruthParticleContainer::genEventIdx
std::size_t genEventIdx() const
Retrieve the index (within a McEventCollection) of the HepMC::GenEvent this TruthParticleContainer is...
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:243
TruthParticleContainer::TruthParticleContainer
TruthParticleContainer()
Default constructor:
Definition: TruthParticleContainer.cxx:22
SG::OwnershipPolicy
OwnershipPolicy
describes the possible element ownership policies (see e.g. DataVector)
Definition: OwnershipPolicy.h:16
SG::OWN_ELEMENTS
@ OWN_ELEMENTS
this data object owns its elements
Definition: OwnershipPolicy.h:17
HepMC::barcode
int barcode(const T *p)
Definition: Barcode.h:16
TruthParticleContainer::NoIdx
static const std::size_t NoIdx
Definition: PhysicsAnalysis/TruthParticleID/McParticleEvent/McParticleEvent/TruthParticleContainer.h:51
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TruthParticleContainer::truthParticle
const TruthParticle * truthParticle(const int barcode, std::size_t genEventIdx=0) const
return a const pointer to an TruthParticle given the barcode of the HepMC::GenParticle it is wrapping
Definition: TruthParticleContainer.cxx:64
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TruthParticleContainer::truthParticleIdx
std::size_t truthParticleIdx(const int barcode, std::size_t genEventIdx=0) const
return the index to an TruthParticle given the barcode of the HepMC::GenParticle it is wrapping retur...
Definition: TruthParticleContainer.cxx:75
DataVector< TruthParticle >::size
size_type size() const noexcept
Returns the number of elements in the collection.