CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
pat::eventhypothesis::Looper< T > Class Template Reference

#include <EventHypothesis.h>

Classes

struct  null_deleter
 

Public Member Functions

const reco::Candidatecand () const
 C++ reference to pointed particle. More...
 
const Tget () const
 Accessor as if it was a smart pointer to const T *. More...
 
size_t globalIndex ()
 Index of this item in the full EventHypothesis. More...
 
size_t index () const
 Index of this item among those in the loop. More...
 
bool isTypeOk () const
 test if the type is correct More...
 
 Looper (const EventHypothesis &eh, const ParticleFilter &filter)
 
 Looper (const EventHypothesis &eh, const ParticleFilter *filter)
 
 Looper (const EventHypothesis &eh, const ParticleFilterPtr &filter)
 
 operator bool () const
 
template<typename T2 >
bool operator!= (const Looper< T2 > &other) const
 
const Toperator* () const
 Accessor as if it was a const_iterator on a list of T. More...
 
Looperoperator++ ()
 iteration More...
 
Looperoperator-- ()
 iteration More...
 
const Toperator-> () const
 Accessor as if it was a const_iterator on a list of T. More...
 
template<typename T2 >
bool operator< (const Looper< T2 > &other) const
 
template<typename T2 >
bool operator<= (const Looper< T2 > &other) const
 
template<typename T2 >
bool operator== (const Looper< T2 > &other) const
 returns true if loopers point to the same record More...
 
template<typename T2 >
bool operator> (const Looper< T2 > &other) const
 
template<typename T2 >
bool operator>= (const Looper< T2 > &other) const
 
const CandRefTyperef () const
 EDM Ref to pointed particle. More...
 
Looperreset (int item=0)
 
const std::string & role () const
 Role of pointed item. More...
 
size_t size () const
 Number of particles in the loop. More...
 
Looperskip (int delta)
 skip (might be slow) More...
 
 ~Looper ()
 

Private Types

typedef
EventHypothesis::const_iterator 
const_iterator
 

Private Member Functions

bool assertOk () const
 
void first ()
 
void realSize () const
 

Private Attributes

const EventHypothesiseh_
 
const ParticleFilterPtr filter_
 
const_iterator iter_
 
int num_
 
DynCastCandPtr< Tptr_
 
int total_
 

Detailed Description

template<typename T>
class pat::eventhypothesis::Looper< T >

Definition at line 11 of file EventHypothesis.h.

Member Typedef Documentation

Definition at line 105 of file EventHypothesisLooper.h.

Constructor & Destructor Documentation

template<typename T >
pat::eventhypothesis::Looper< T >::Looper ( const EventHypothesis eh,
const ParticleFilter filter 
)

Looper from EventHypothesis and an external, not owned, ParticleFilter. That is: MyFilter flt; Looper(eh, flt);

Definition at line 121 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::first().

121  :
122  eh_(eh), filter_(ParticleFilterPtr(&filter, typename Looper<T>::null_deleter())), total_(-1)
123  {
124  first();
125  }
boost::shared_ptr< const ParticleFilter > ParticleFilterPtr
const ParticleFilterPtr filter_
template<typename T >
pat::eventhypothesis::Looper< T >::Looper ( const EventHypothesis eh,
const ParticleFilter filter 
)

Looper from EventHypothesis and an internal, owned, ParticleFilter That is: Looper(eh, new MyFilter());

Definition at line 128 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::first().

128  :
129  eh_(eh), filter_(filter), total_(-1)
130  {
131  first();
132  }
const ParticleFilterPtr filter_
template<typename T >
pat::eventhypothesis::Looper< T >::Looper ( const EventHypothesis eh,
const ParticleFilterPtr filter 
)

Looper from EventHypothesis and a shared ParticleFilter That is: Looper(eh, ParticleFilterPtr(new MyFilter()));

Definition at line 135 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::first().

135  :
136  eh_(eh), filter_(filter), total_(-1)
137  {
138  first();
139  }
const ParticleFilterPtr filter_
template<typename T>
pat::eventhypothesis::Looper< T >::~Looper ( )
inline

Definition at line 55 of file EventHypothesisLooper.h.

55 {}

Member Function Documentation

template<typename T >
bool pat::eventhypothesis::Looper< T >::assertOk ( ) const
private

Definition at line 143 of file EventHypothesisLooper.h.

143  {
144  assert(iter_ <= eh_.end());
145  assert((iter_+1) >= eh_.begin());
146  assert((iter_ < eh_.begin()) || (iter_ == eh_.end()) || ((*filter_)(*iter_)));
147  return true;
148  }
const ParticleFilterPtr filter_
const_iterator end() const
const_iterator begin() const
template<typename T>
const reco::Candidate& pat::eventhypothesis::Looper< T >::cand ( ) const
inline

C++ reference to pointed particle.

Definition at line 72 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

72 { return *iter_->second; }
template<typename T >
void pat::eventhypothesis::Looper< T >::first ( )
private

Definition at line 206 of file EventHypothesisLooper.h.

References ptr_.

Referenced by pat::eventhypothesis::Looper< T >::Looper().

206  {
207  num_ = 0;
208  iter_ = eh_.begin();
209  ptr_.clearCache();
210  for (; iter_ != eh_.end(); ++iter_) {
211  if ((*filter_)(*iter_)) break;
212  }
213  assert(assertOk());
214  }
const ParticleFilterPtr filter_
const_iterator end() const
const_iterator begin() const
template<typename T>
const T* pat::eventhypothesis::Looper< T >::get ( void  ) const
inline
template<typename T>
size_t pat::eventhypothesis::Looper< T >::globalIndex ( )
inline

Index of this item in the full EventHypothesis.

Definition at line 75 of file EventHypothesisLooper.h.

References pat::EventHypothesis::begin(), pat::eventhypothesis::Looper< T >::eh_, and pat::eventhypothesis::Looper< T >::iter_.

75 { return iter_ - eh_.begin(); }
const_iterator begin() const
template<typename T>
size_t pat::eventhypothesis::Looper< T >::index ( ) const
inline

Index of this item among those in the loop.

Definition at line 77 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::num_.

template<typename T>
bool pat::eventhypothesis::Looper< T >::isTypeOk ( ) const
inline

test if the type is correct

Definition at line 65 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_, and pat::eventhypothesis::Looper< T >::ptr_.

65 { return ptr_.typeOk(iter_->second.get()); }
template<typename T >
pat::eventhypothesis::Looper< T >::operator bool ( ) const

Returns true if you have not run out of the boundaries. It does NOT check if typeOk()

Definition at line 217 of file EventHypothesisLooper.h.

217  {
218  return (iter_ < eh_.end()) && (iter_ >= eh_.begin());
219  }
const_iterator end() const
const_iterator begin() const
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator!= ( const Looper< T2 > &  other) const
inline

Definition at line 97 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

97 { return iter_ != other.iter_; }
template<typename T>
const T& pat::eventhypothesis::Looper< T >::operator* ( void  ) const
inline

Accessor as if it was a const_iterator on a list of T.

Definition at line 58 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_, and pat::eventhypothesis::Looper< T >::ptr_.

58 { return ptr_.get(iter_->second.get()); }
template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::operator++ ( void  )

iteration

Definition at line 151 of file EventHypothesisLooper.h.

References ptr_.

151  {
152  ptr_.clearCache();
153  assert(assertOk());
154  if (iter_ == eh_.end()) return *this;
155  do {
156  ++iter_;
157  if (iter_ == eh_.end()) break;
158  if ((*filter_)(*iter_)) {
159  assert(assertOk());
160  ++num_; return *this;
161  }
162  } while (true);
163  assert(assertOk());
164  return *this;
165  }
const ParticleFilterPtr filter_
const_iterator end() const
template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::operator-- ( )

iteration

Definition at line 167 of file EventHypothesisLooper.h.

References ptr_.

167  {
168  ptr_.clearCache();
169  assert(assertOk());
170  if (num_ < 0) return *this;
171  do {
172  --iter_;
173  if (iter_ < eh_.begin()) { num_ = -1; break; }
174  if ((*filter_)(*iter_)) {
175  assert(assertOk());
176  --num_; return *this;
177  }
178  } while (true);
179  assert(assertOk());
180  return *this;
181  }
const ParticleFilterPtr filter_
const_iterator begin() const
template<typename T>
const T* pat::eventhypothesis::Looper< T >::operator-> ( ) const
inline

Accessor as if it was a const_iterator on a list of T.

Definition at line 60 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_, and pat::eventhypothesis::Looper< T >::ptr_.

60 { return ptr_.get(iter_->second.get()); }
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator< ( const Looper< T2 > &  other) const
inline

Definition at line 100 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

100 { return iter_ < other.iter_; }
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator<= ( const Looper< T2 > &  other) const
inline

Definition at line 98 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

98 { return iter_ <= other.iter_; }
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator== ( const Looper< T2 > &  other) const
inline

returns true if loopers point to the same record

Definition at line 96 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

96 { return iter_ == other.iter_; }
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator> ( const Looper< T2 > &  other) const
inline

Definition at line 101 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

101 { return iter_ > other.iter_; }
template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator>= ( const Looper< T2 > &  other) const
inline

Definition at line 99 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

99 { return iter_ >= other.iter_; }
template<typename T >
void pat::eventhypothesis::Looper< T >::realSize ( ) const
private

Definition at line 222 of file EventHypothesisLooper.h.

Referenced by pat::eventhypothesis::Looper< T >::size().

222  {
224  if (it < eh_.begin()) {
225  it = eh_.begin(); total_ = 0;
226  } else {
227  total_ = num_;
228  }
229  for (; it != eh_.end(); ++it) {
230  if ((*filter_)(*it)) ++total_;
231  }
232  }
const ParticleFilterPtr filter_
const_iterator end() const
vector_type::const_iterator const_iterator
const_iterator begin() const
template<typename T>
const CandRefType& pat::eventhypothesis::Looper< T >::ref ( ) const
inline

EDM Ref to pointed particle.

Definition at line 70 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

70 { return iter_->second; }
template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::reset ( int  item = 0)

Reset to the start or to any other specific item; negatives count from the end. might be slow, especially with negative items

Definition at line 192 of file EventHypothesisLooper.h.

References first.

Referenced by BeautifulSoup.BeautifulStoneSoup::__init__().

192  {
193  assert(assertOk());
194  if (item >= 0) {
195  first();
196  std::advance(this, item);
197  } else {
198  num_ = item + 1; iter_ = eh_.end();
199  std::advance(this, item);
200  }
201  assert(assertOk());
202  return *this;
203  }
const_iterator end() const
template<typename T>
const std::string& pat::eventhypothesis::Looper< T >::role ( ) const
inline

Role of pointed item.

Definition at line 68 of file EventHypothesisLooper.h.

References pat::eventhypothesis::Looper< T >::iter_.

68 { return iter_->first; }
template<typename T>
size_t pat::eventhypothesis::Looper< T >::size ( void  ) const
inline
template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::skip ( int  delta)

skip (might be slow)

Definition at line 184 of file EventHypothesisLooper.h.

184  {
185  assert(assertOk());
186  std::advance(this, delta);
187  assert(assertOk());
188  return *this;
189  }
dbl * delta
Definition: mlp_gen.cc:36

Member Data Documentation

template<typename T>
const EventHypothesis& pat::eventhypothesis::Looper< T >::eh_
private
template<typename T>
const ParticleFilterPtr pat::eventhypothesis::Looper< T >::filter_
private

Definition at line 112 of file EventHypothesisLooper.h.

template<typename T>
const_iterator pat::eventhypothesis::Looper< T >::iter_
private
template<typename T>
int pat::eventhypothesis::Looper< T >::num_
private

Definition at line 114 of file EventHypothesisLooper.h.

Referenced by pat::eventhypothesis::Looper< T >::index().

template<typename T>
DynCastCandPtr<T> pat::eventhypothesis::Looper< T >::ptr_
mutableprivate
template<typename T>
int pat::eventhypothesis::Looper< T >::total_
mutableprivate

Definition at line 115 of file EventHypothesisLooper.h.

Referenced by pat::eventhypothesis::Looper< T >::size().