CMS 3D CMS Logo

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 17 of file EventHypothesis.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 136 of file EventHypothesisLooper.h.

Constructor & Destructor Documentation

◆ Looper() [1/3]

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 152 of file EventHypothesisLooper.h.

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

153  : eh_(eh), filter_(ParticleFilterPtr(&filter, typename Looper<T>::null_deleter())), total_(-1) {
154  first();
155  }
const ParticleFilterPtr filter_
std::shared_ptr< const ParticleFilter > ParticleFilterPtr

◆ Looper() [2/3]

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 158 of file EventHypothesisLooper.h.

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

◆ Looper() [3/3]

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 163 of file EventHypothesisLooper.h.

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

◆ ~Looper()

template<typename T>
pat::eventhypothesis::Looper< T >::~Looper ( )
inline

Definition at line 62 of file EventHypothesisLooper.h.

62 {}

Member Function Documentation

◆ assertOk()

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

Definition at line 169 of file EventHypothesisLooper.h.

References cms::cuda::assert().

169  {
170  assert(iter_ <= eh_.end());
171  assert((iter_ + 1) >= eh_.begin());
172  assert((iter_ < eh_.begin()) || (iter_ == eh_.end()) || ((*filter_)(*iter_)));
173  return true;
174  }
const_iterator end() const
assert(be >=bs)
const_iterator begin() const
const ParticleFilterPtr filter_

◆ cand()

template<typename T>
const reco::Candidate& pat::eventhypothesis::Looper< T >::cand ( ) const
inline

C++ reference to pointed particle.

Definition at line 79 of file EventHypothesisLooper.h.

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

79 { return *iter_->second; }

◆ first()

template<typename T >
void pat::eventhypothesis::Looper< T >::first ( )
private

Definition at line 241 of file EventHypothesisLooper.h.

References cms::cuda::assert(), and ptr_.

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

241  {
242  num_ = 0;
243  iter_ = eh_.begin();
244  ptr_.clearCache();
245  for (; iter_ != eh_.end(); ++iter_) {
246  if ((*filter_)(*iter_))
247  break;
248  }
249  assert(assertOk());
250  }
const_iterator end() const
assert(be >=bs)
const_iterator begin() const
const ParticleFilterPtr filter_

◆ get()

template<typename T>
const T* pat::eventhypothesis::Looper< T >::get ( ) const
inline

◆ globalIndex()

template<typename T>
size_t pat::eventhypothesis::Looper< T >::globalIndex ( )
inline

Index of this item in the full EventHypothesis.

Definition at line 82 of file EventHypothesisLooper.h.

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

82 { return iter_ - eh_.begin(); }
const_iterator begin() const

◆ index()

template<typename T>
size_t pat::eventhypothesis::Looper< T >::index ( ) const
inline

Index of this item among those in the loop.

Definition at line 84 of file EventHypothesisLooper.h.

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

◆ isTypeOk()

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

test if the type is correct

Definition at line 72 of file EventHypothesisLooper.h.

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

72 { return ptr_.typeOk(iter_->second.get()); }

◆ operator bool()

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 253 of file EventHypothesisLooper.h.

253  {
254  return (iter_ < eh_.end()) && (iter_ >= eh_.begin());
255  }
const_iterator end() const
const_iterator begin() const

◆ operator!=()

template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator!= ( const Looper< T2 > &  other) const
inline

Definition at line 112 of file EventHypothesisLooper.h.

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

112  {
113  return iter_ != other.iter_;
114  }

◆ operator*()

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 65 of file EventHypothesisLooper.h.

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

65 { return ptr_.get(iter_->second.get()); }

◆ operator++()

template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::operator++ ( void  )

iteration

Definition at line 177 of file EventHypothesisLooper.h.

References cms::cuda::assert(), and ptr_.

177  {
178  ptr_.clearCache();
179  assert(assertOk());
180  if (iter_ == eh_.end())
181  return *this;
182  do {
183  ++iter_;
184  if (iter_ == eh_.end())
185  break;
186  if ((*filter_)(*iter_)) {
187  assert(assertOk());
188  ++num_;
189  return *this;
190  }
191  } while (true);
192  assert(assertOk());
193  return *this;
194  }
const_iterator end() const
assert(be >=bs)
const ParticleFilterPtr filter_

◆ operator--()

template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::operator-- ( )

iteration

Definition at line 196 of file EventHypothesisLooper.h.

References cms::cuda::assert(), and ptr_.

196  {
197  ptr_.clearCache();
198  assert(assertOk());
199  if (num_ < 0)
200  return *this;
201  do {
202  --iter_;
203  if (iter_ < eh_.begin()) {
204  num_ = -1;
205  break;
206  }
207  if ((*filter_)(*iter_)) {
208  assert(assertOk());
209  --num_;
210  return *this;
211  }
212  } while (true);
213  assert(assertOk());
214  return *this;
215  }
assert(be >=bs)
const_iterator begin() const
const ParticleFilterPtr filter_

◆ operator->()

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 67 of file EventHypothesisLooper.h.

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

67 { return ptr_.get(iter_->second.get()); }

◆ operator<()

template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator< ( const Looper< T2 > &  other) const
inline

Definition at line 124 of file EventHypothesisLooper.h.

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

124  {
125  return iter_ < other.iter_;
126  }

◆ operator<=()

template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator<= ( const Looper< T2 > &  other) const
inline

Definition at line 116 of file EventHypothesisLooper.h.

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

116  {
117  return iter_ <= other.iter_;
118  }

◆ operator==()

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 108 of file EventHypothesisLooper.h.

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

108  {
109  return iter_ == other.iter_;
110  }

◆ operator>()

template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator> ( const Looper< T2 > &  other) const
inline

Definition at line 128 of file EventHypothesisLooper.h.

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

128  {
129  return iter_ > other.iter_;
130  }

◆ operator>=()

template<typename T>
template<typename T2 >
bool pat::eventhypothesis::Looper< T >::operator>= ( const Looper< T2 > &  other) const
inline

Definition at line 120 of file EventHypothesisLooper.h.

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

120  {
121  return iter_ >= other.iter_;
122  }

◆ realSize()

template<typename T >
void pat::eventhypothesis::Looper< T >::realSize ( ) const
private

Definition at line 258 of file EventHypothesisLooper.h.

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

258  {
260  if (it < eh_.begin()) {
261  it = eh_.begin();
262  total_ = 0;
263  } else {
264  total_ = num_;
265  }
266  for (; it != eh_.end(); ++it) {
267  if ((*filter_)(*it))
268  ++total_;
269  }
270  }
const_iterator end() const
const_iterator begin() const
vector_type::const_iterator const_iterator
const ParticleFilterPtr filter_

◆ ref()

template<typename T>
const CandRefType& pat::eventhypothesis::Looper< T >::ref ( ) const
inline

EDM Ref to pointed particle.

Definition at line 77 of file EventHypothesisLooper.h.

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

77 { return iter_->second; }

◆ reset()

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 226 of file EventHypothesisLooper.h.

References cms::cuda::assert(), dqmdumpme::first, and B2GTnPMonitor_cfi::item.

226  {
227  assert(assertOk());
228  if (item >= 0) {
229  first();
230  std::advance(this, item);
231  } else {
232  num_ = item + 1;
233  iter_ = eh_.end();
234  std::advance(this, item);
235  }
236  assert(assertOk());
237  return *this;
238  }
const_iterator end() const
assert(be >=bs)

◆ role()

template<typename T>
const std::string& pat::eventhypothesis::Looper< T >::role ( ) const
inline

Role of pointed item.

Definition at line 75 of file EventHypothesisLooper.h.

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

75 { return iter_->first; }

◆ size()

template<typename T>
size_t pat::eventhypothesis::Looper< T >::size ( void  ) const
inline

◆ skip()

template<typename T >
Looper< T > & pat::eventhypothesis::Looper< T >::skip ( int  delta)

skip (might be slow)

Definition at line 218 of file EventHypothesisLooper.h.

References cms::cuda::assert(), and dumpMFGeometry_cfg::delta.

218  {
219  assert(assertOk());
220  std::advance(this, delta);
221  assert(assertOk());
222  return *this;
223  }
assert(be >=bs)

Member Data Documentation

◆ eh_

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

◆ filter_

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

Definition at line 143 of file EventHypothesisLooper.h.

◆ iter_

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

◆ num_

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

Definition at line 145 of file EventHypothesisLooper.h.

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

◆ ptr_

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

◆ total_

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

Definition at line 146 of file EventHypothesisLooper.h.

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