00001
00002 #ifndef XAODJET_JETCONSTITUENTSVECTOR_H
00003 #define XAODJET_JETCONSTITUENTSVECTOR_H
00033 // use JetConstituentVector::asSTLVector().
00037
00038
00039
00040 #include "AthLinks/ElementLink.h"
00041
00042
00043 #include "xAODBase/IParticle.h"
00044 #include "xAODBase/IParticleContainer.h"
00045
00046 #include "xAODJet/JetTypes.h"
00047
00048 namespace xAOD {
00049
00056 class JetConstituent : public xAOD::JetFourMom_t {
00057 public:
00058 friend class JetConstituentVector;
00059
00060
00061 JetConstituent(const IParticle* part=0) : xAOD::JetFourMom_t(), m_part(part){}
00062
00063 double pt() const { return Pt();}
00065 double eta() const { return Eta();}
00067 double phi() const { return Phi();}
00069 double m() const { return M();}
00071 double e() const { return E();}
00073 double rapidity() const { return Rapidity();}
00074
00076 typedef TLorentzVector FourMom_t;
00077
00079
00080
00081
00083
00084
00086 Type::ObjectType type() const { return m_part->type();}
00087
00089 template< class T >
00090 const T& auxdata( const std::string& name,
00091 const std::string& clsname = "" ) const;
00092
00094 const JetConstituent* operator->() const {return this;};
00095
00097 const IParticle* rawConstituent() const { return m_part; }
00098 protected:
00099
00100 const IParticle * m_part;
00101
00102 };
00103
00104
00112 class JetConstituentVector {
00113
00114 public:
00115
00116 class iterator {
00117 public:
00118 friend class JetConstituentVector;
00119 typedef std::vector< ElementLink< IParticleContainer > >::const_iterator ELiterator;
00120
00121 iterator(ELiterator it, JetConstitScale s) : m_index(it), m_sigState(s) {}
00122
00123 iterator & operator++();
00124 iterator & operator++(int);
00125 iterator & operator--();
00126 iterator & operator--(int);
00127 bool operator==( const iterator & other);
00128 bool operator!=( const iterator & other);
00129
00130 const JetConstituent* operator*();
00131 const JetConstituent* operator->();
00132
00133
00134 void inc(){ this->operator++();}
00135 void dec(){ this->operator--();}
00136
00137
00138 protected:
00139
00140
00141 void update4Mom();
00142
00143 ELiterator m_index;
00144 ELiterator m_cachedMomIndex;
00145 JetConstituent m_4mom;
00146
00147 JetConstitScale m_sigState;
00148
00149 };
00150
00151 typedef iterator const_iterator;
00152 typedef std::vector< ElementLink< IParticleContainer > > ELvector;
00153
00154 JetConstituentVector(const ELvector* elv , JetConstitScale s ) : m_elVector(elv) , m_sigState(s) {}
00155
00157 bool isValid() const;
00158
00159
00161 bool empty() const ;
00163 size_t size() const ;
00164
00166 iterator begin() const ;
00168 iterator end() const ;
00169
00171 iterator begin(JetConstitScale s) const ;
00173 iterator end(JetConstitScale s) const ;
00174
00175
00177 JetConstituent operator[](size_t i) const ;
00179 JetConstituent at(size_t i) const ;
00181 JetConstituent front() const ;
00183 JetConstituent back() const ;
00184
00187 std::vector<const IParticle*> asIParticleVector() const ;
00188
00192 std::vector<JetConstituent> asSTLVector();
00193
00194 protected:
00195
00196 const std::vector< ElementLink< IParticleContainer > > * m_elVector;
00197 JetConstitScale m_sigState;
00198
00199 };
00200
00201
00202 #ifndef __GCCXML__
00203
00204
00205
00206 template<class TT> const TT& JetConstituent::auxdata( const std::string& name,
00207 const std::string& clsname ) const {
00208 return m_part->template auxdata<TT>(name, clsname);
00209 }
00210
00211
00212 #endif // not __GCCXML__
00213
00214 }
00215
00216 #endif