1 #ifndef DataFormats_EventHypothesis_interface_EventHypothesisLooper_h
2 #define DataFormats_EventHypothesis_interface_EventHypothesisLooper_h
7 namespace pat {
namespace eventhypothesis {
22 cachePtr_ =
dynamic_cast<const T *
>(ptr);
29 if ((ptr != 0) && (cachePtr_ == 0))
throw cms::Exception(
"Type Checking") <<
30 "You can't convert a " <<
typeid(*ptr).name() <<
" to a " <<
typeid(
T).
name() <<
"\n" <<
31 "note: you can use c++filt command to convert the above in human readable types.\n";
62 const T *
get()
const {
return ptr_.get(
iter_->second.get()); }
93 operator bool()
const ;
98 template<
typename T2>
bool operator<=(const Looper<T2> &other)
const {
return iter_ <= other.iter_; }
100 template<
typename T2>
bool operator<(const Looper<T2> &other)
const {
return iter_ < other.iter_; }
129 eh_(eh), filter_(filter), total_(-1)
136 eh_(eh), filter_(filter), total_(-1)
144 assert(iter_ <= eh_.end());
145 assert((iter_+1) >= eh_.begin());
146 assert((iter_ < eh_.begin()) || (iter_ == eh_.end()) || ((*filter_)(*iter_)));
154 if (iter_ == eh_.end())
return *
this;
157 if (iter_ == eh_.end())
break;
158 if ((*filter_)(*iter_)) {
160 ++num_;
return *
this;
170 if (num_ < 0)
return *
this;
173 if (iter_ < eh_.begin()) { num_ = -1;
break; }
174 if ((*filter_)(*iter_)) {
176 --num_;
return *
this;
186 std::advance(
this, delta);
196 std::advance(
this, item);
198 num_ = item + 1; iter_ = eh_.end();
199 std::advance(
this, item);
210 for (; iter_ != eh_.end(); ++iter_) {
211 if ((*filter_)(*iter_))
break;
218 return (iter_ < eh_.end()) && (iter_ >= eh_.begin());
224 if (it < eh_.begin()) {
225 it = eh_.begin(); total_ = 0;
229 for (; it != eh_.end(); ++it) {
230 if ((*filter_)(*it)) ++total_;
const T * get(const reco::Candidate *ptr)
bool operator!=(const Looper< T2 > &other) const
bool typeOk(const reco::Candidate *ptr)
bool typeOk(const reco::Candidate *ptr)
bool isTypeOk() const
test if the type is correct
bool operator>=(const Looper< T2 > &other) const
const EventHypothesis & eh_
Looper & reset(int item=0)
Looper(const EventHypothesis &eh, const ParticleFilter &filter)
boost::shared_ptr< const ParticleFilter > ParticleFilterPtr
const ParticleFilterPtr filter_
const T & operator*() const
Accessor as if it was a const_iterator on a list of T.
Looper & operator++()
iteration
void operator()(void const *) const
const reco::Candidate & cand() const
C++ reference to pointed particle.
const CandRefType & ref() const
EDM Ref to pointed particle.
Looper & operator--()
iteration
size_t globalIndex()
Index of this item in the full EventHypothesis.
void doPtr(const reco::Candidate *ptr)
size_t size() const
Number of particles in the loop.
size_t index() const
Index of this item among those in the loop.
vector_type::const_iterator const_iterator
bool operator==(const Looper< T2 > &other) const
returns true if loopers point to the same record
bool operator>(const Looper< T2 > &other) const
Looper< reco::Candidate > CandLooper
const std::string & role() const
Role of pointed item.
Looper & skip(int delta)
skip (might be slow)
EventHypothesis::const_iterator const_iterator
const_iterator begin() const
const T * operator->() const
Accessor as if it was a const_iterator on a list of T.