ATLAS Offline Software
PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // CompositeParticle.h
8 // Header file for class CompositeParticle
9 // Author: Frank Paige - Jan 2004
10 // Author: Hong Ma - May 2004
11 // Author: Ketevi A. Assamagan - May 2004
12 // Author: Kyle Cranmer - May 2004
13 // Author: Adam Cunha - Apr 2007
14 // Author: S.Binet<binet@cern.ch> - Apr 2008
15 // Author: Karsten Koeneke - Jan 2011
17 #ifndef PARTICLEEVENT_COMPOSITEPARTICLE_H
18 #define PARTICLEEVENT_COMPOSITEPARTICLE_H
19 
20 // STL includes
21 //#include <iosfwd>
22 #include <vector>
23 #include <algorithm>
24 
25 #include "AthLinks/ElementLink.h"
26 #include "AthLinks/ElementLinkVector.h"
27 #include "AthenaKernel/CLASS_DEF.h"
28 
29 // EventKernel includes
35 
36 // ParticleEvent includes
38 #include "ParticleEvent/Lib/Base.h"
40 
41 // Forward declaration
42 
48  CompositeParticleNavigation,
49  P4ImplPxPyPzE,
50  ParticleEvent::Base
51  >
52 {
54  // Public typedefs:
56  public:
57  typedef ParticleImpl<
61  >
62  Base_t; // easy on the handwriting..
65 
67  // Public methods:
69  public:
70 
71  /* --- compiler generated constructors should be good enough ---
73  CompositeParticle();
74 
76  CompositeParticle( const CompositeParticle& rhs );
77 
79  CompositeParticle& operator=( const CompositeParticle& rhs );
80  */
81 
83 
85  virtual ~CompositeParticle() = default;
86 
88  // Const methods:
90 
92  std::vector<const INavigable4Momentum*> get_constituents() const
93  {
94  std::vector<const INavigable4Momentum*> constituents;
95  this->get_constituents<INavigable4Momentum>(constituents);
96  return constituents;
97  }
98 
103  template <class Element>
104  void get_constituents (std::vector<const Element*>& cont) const
105  {
106  const std::size_t iMax = this->navigableBase().size();
107  cont.clear();
108  cont.reserve( iMax );
109  for ( std::size_t i = 0; i != iMax; ++i ) {
110  const Element* constituent = this->get_constituent<Element>(i);
111  if ( constituent ) {
112  cont.push_back( constituent );
113  }
114  }
115  }
116 
122  template <class Element>
123  const Element* get_constituent (std::size_t idx) const
124  {
125  typedef typename Base_t::navigable_type navigable_type;
126  typedef typename navigable_type::object_iter object_iter;
127 
128  const Element * element = 0;
129  if (idx < this->navigableBase().size()) {
130  object_iter o = this->navigableBase().begin();
131  //can't use it as NavigatorIterator does not implement the
132  // RandomIterator concept !!
133  //std::advance(o, idx);
134  // so we use this O(n) approach:
135  while ( idx-- ) { ++o; }
136  element = dynamic_cast<const Element*>(*o);
137  }
138  return element;
139  }
140 
143  bool contains (const INavigable4Momentum* particle) const;
144 
147  bool contains (const INav4MomLink& ipart) const
148  { return contains(*ipart); }
149 
153  { return this->navigableBase().begin(); }
154 
157  ConstituentsIter_t constituents_end() const
158  { return this->navigableBase().end(); }
159 
161  // Non-const methods:
163 
164  //========================================================================
167  void add( const INav4MomLink& ipart );
168  void add( const INav4MomLinkContainer* iparts );
169  void add( const INav4MomLinkContainer& iparts );
170  void add( const INav4MomLink& p1, const INav4MomLink& p2 );
171  void add( const INav4MomLink& p1, const INav4MomLink& p2,
172  const INav4MomLink& p3 );
173  void add( const INav4MomLink& p1, const INav4MomLink& p2,
174  const INav4MomLink& p3, const INav4MomLink& p4 );
176  //========================================================================
177 
179  // Private methods:
181  private:
182 
184  void putElement( const INav4MomLink& ipart );
185 
187  // Private data:
189  private:
190 
191 };
192 
194 // Inline methods:
196 //std::ostream& operator<<( std::ostream& out, const CompositeParticle& o );
197 
199 CLASS_DEF( CompositeParticle , 56025822 , 1 )
200 
201 #endif //> PARTICLEEVENT_COMPOSITEPARTICLE_H
ParticleImpl< CompositeParticleNavigation, P4ImplPxPyPzE, ParticleEvent::Base >::navigable_type
CompositeParticleNavigation navigable_type
publish the type of the base class (ie: 'traits-itize' it)
Definition: ParticleImpl.h:48
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
CompositeParticle::constituents_end
ConstituentsIter_t constituents_end() const
iterator over constituents of this composite
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:157
INavigable4Momentum.h
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
CompositeParticle::contains
bool contains(const INavigable4Momentum *particle) const
check if a given particle is contained by this composite
Definition: CompositeParticle.cxx:51
Navigable::begin
virtual object_iter begin() const
CompositeParticle
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:52
CompositeParticle::get_constituents
void get_constituents(std::vector< const Element * > &cont) const
Fill a vector of elements with the constituents which compose that CompositeParticle.
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:104
CompositeParticle::Navigable_t
Base_t::navigable_type Navigable_t
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:63
Navigable::end
virtual object_iter end() const
NavigableIterator
Definition: NavigableIterator.h:24
ParticleImpl
Definition: ParticleImpl.h:39
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Base.h
ParticleEvent::Base
Definition: Base.h:34
lumiFormat.i
int i
Definition: lumiFormat.py:85
P4ImplPxPyPzE.h
INavigable4MomentumCollection.h
CompositeParticle::putElement
void putElement(const INav4MomLink &ipart)
helper method to put elements into the underlying Navigable container
Definition: CompositeParticle.cxx:150
P4ImplPxPyPzE
Definition: P4ImplPxPyPzE.h:32
CompositeParticle::ConstituentsIter_t
Navigable_t::object_iter ConstituentsIter_t
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:64
CompositeParticle::Base_t
ParticleImpl< CompositeParticleNavigation, P4ImplPxPyPzE, ParticleEvent::Base > Base_t
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:62
CompositeParticle::~CompositeParticle
virtual ~CompositeParticle()=default
Constructor with parameters:
CompositeParticle::get_constituents
std::vector< const INavigable4Momentum * > get_constituents() const
return the vector of constituents by value. FIXME: inefficient
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:92
CompositeParticleNavigation.h
ParticleImpl< CompositeParticleNavigation, P4ImplPxPyPzE, ParticleEvent::Base >::navigableBase
const navigable_type & navigableBase() const
access to underlying base type (INavigable-like)
Definition: ParticleImpl.h:383
ParticleImpl< CompositeParticleNavigation, P4ImplPxPyPzE, ParticleEvent::Base >::p2
virtual double p2() const
square of momentum magnitude
Definition: ParticleImpl.h:494
CompositeParticle::get_constituent
const Element * get_constituent(std::size_t idx) const
Return a constituent given its index.
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:123
CompositeParticle::add
void add(const INav4MomLink &ipart)
Definition: CompositeParticle.cxx:73
Navigable< INavigable4MomentumCollection, double >
CompositeParticle::contains
bool contains(const INav4MomLink &ipart) const
check if a given particle is contained by this composite
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:147
CompositeParticleNavigation
Navigable< INavigable4MomentumCollection, double > CompositeParticleNavigation
Definition: CompositeParticleNavigation.h:18
Navigable::size
virtual unsigned int size() const
INavigable4Momentum
Definition: INavigable4Momentum.h:21
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
LArNewCalib_DelayDump_OFC_Cali.idx
idx
Definition: LArNewCalib_DelayDump_OFC_Cali.py:69
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
CLASS_DEF.h
macros to associate a CLID to a type
ParticleImpl.h
CompositeParticle::constituents_begin
ConstituentsIter_t constituents_begin() const
iterator over constituents of this composite
Definition: PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h:152