ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsAnalysis/AnalysisCommon/ParticleEvent/ParticleEvent/CompositeParticle.h
Go to the documentation of this file.
1
2
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"
28
29// EventKernel includes
35
36// ParticleEvent includes
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;
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
199CLASS_DEF( CompositeParticle , 56025822 , 1 )
200
201#endif //> PARTICLEEVENT_COMPOSITEPARTICLE_H
Navigable< INavigable4MomentumCollection, double > CompositeParticleNavigation
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
class which is made from the composition of other particles.
ConstituentsIter_t constituents_end() const
iterator over constituents of this composite
ConstituentsIter_t constituents_begin() const
iterator over constituents of this composite
bool contains(const INavigable4Momentum *particle) const
check if a given particle is contained by this composite
void putElement(const INav4MomLink &ipart)
helper method to put elements into the underlying Navigable container
const Element * get_constituent(std::size_t idx) const
Return a constituent given its index.
void add(const INav4MomLink &ipart)
void get_constituents(std::vector< const Element * > &cont) const
Fill a vector of elements with the constituents which compose that CompositeParticle.
bool contains(const INav4MomLink &ipart) const
check if a given particle is contained by this composite
ParticleImpl< CompositeParticleNavigation, P4ImplPxPyPzE, ParticleEvent::Base > Base_t
std::vector< const INavigable4Momentum * > get_constituents() const
return the vector of constituents by value. FIXME: inefficient
virtual ~CompositeParticle()=default
Constructor with parameters:
virtual unsigned int size() const
virtual object_iter begin() const
NavigableIterator< INavigable4MomentumCollection, double, typename NavigationDefaults::DefaultChildColl< INavigable4MomentumCollection, double >::type > object_iter
Definition Navigable.h:159
virtual object_iter end() const