00001
00002 #ifndef XAOD_ANALYSIS
00003
00004 #ifndef JETUTILS_JETCELLACCESSOR_H
00005 #define JETUTILS_JETCELLACCESSOR_H
00025 #include "xAODJet/Jet.h"
00026
00027 #include "CaloEvent/CaloClusterCellLink.h"
00028 #include "CaloEvent/CaloPrefetch.h"
00029
00030 namespace jet{
00031 class JetCellAccessor {
00032 public:
00033 JetCellAccessor(const xAOD::Jet *jet) ;
00034
00035 typedef CaloClusterCellLink::const_iterator cell_iterator;
00036 typedef std::vector< ElementLink<xAOD::IParticleContainer> >::const_iterator constit_iterator;
00037 typedef double weight_t;
00038
00039 class const_iterator {
00040 friend class JetCellAccessor;
00041 protected:
00042 const_iterator( constit_iterator constIt, constit_iterator constItE, bool endIt=false) ;
00043
00044 public:
00045 const CaloCell* operator*() const {return (*m_cellIt);}
00046 const CaloCell* operator->() const {return (*m_cellIt);}
00047
00050 weight_t weight() const {return m_cellIt.weight();}
00051
00054 unsigned index() const {return m_cellIt.index();}
00055
00056 const_iterator& operator++() {++m_cellIt; ; prefetchCell() ; return *this;}
00057 const_iterator& operator--() {--m_cellIt; prefetchCell() ; return *this;}
00058 const_iterator& operator++(int) {++m_cellIt; prefetchCell() ; return *this;}
00059 const_iterator& operator--(int) {--m_cellIt; prefetchCell() ; return *this;}
00060 bool operator==(const const_iterator& b) const { return m_cellIt==b.m_cellIt;}
00061 bool operator!=(const const_iterator& b) const { return m_cellIt!=b.m_cellIt;}
00062
00063 protected:
00064
00065 inline void prefetchCell() {
00066 if(m_cellIt==m_endCellItinConstit) nextConstituent(); else CaloPrefetch::nextDDE( m_cellIt, m_endCellItinConstit );
00067 }
00068 void nextConstituent();
00069 bool setCellIteratorFromConstit(const xAOD::IParticle* p);
00070
00071 cell_iterator m_cellIt;
00072 cell_iterator m_endCellItinConstit;
00073 constit_iterator m_constitIt;
00074 constit_iterator m_constitItE;
00075
00076 };
00077
00078
00079 static const_iterator begin(const xAOD::Jet* jet);
00080 static const_iterator end(const xAOD::Jet* jet);
00081
00082 };
00083
00084 }
00085 #endif
00086
00087 #endif