#include <DataFormats/PatCandidates/interface/EventHypothesis.h>
Public Types | |
typedef eventhypothesis::Looper < reco::Candidate > | CandLooper |
typedef eventhypothesis::CandRefType | CandRefType |
typedef vector_type::const_iterator | const_iterator |
typedef vector_type::const_reverse_iterator | const_reverse_iterator |
typedef eventhypothesis::ParticleFilter | ParticleFilter |
typedef eventhypothesis::ParticleFilterPtr | ParticleFilterPtr |
typedef std::pair< std::string, CandRefType > | value_type |
typedef std::vector< value_type > | vector_type |
Public Member Functions | |
void | add (const CandRefType &ref, const std::string &role) |
std::vector< CandRefType > | all (const ParticleFilter &filter) const |
Return EDM references to all particles which satisfy some condition. | |
std::vector< CandRefType > | all (const std::string &roleRegexp) const |
Return EDM references to all particles which have certaint roles. | |
const_iterator | begin () const |
size_t | count (const ParticleFilter &role) const |
Counts particles which satisfy some condition. | |
size_t | count (const std::string &roleRegexp) const |
Counts particles which have certaint roles. | |
size_t | count () const |
const_iterator | end () const |
const CandRefType & | get (const ParticleFilter &filter, int index=0) const |
const CandRefType & | get (const std::string &role, int index=0) const |
template<typename T> | |
const T * | getAs (const ParticleFilter &filter, int index=0) const |
template<typename T> | |
const T * | getAs (const std::string &role, int index=0) const |
CandLooper | loop (const ParticleFilterPtr &filter) const |
Loops over particles which satisfy some condition. | |
CandLooper | loop (const ParticleFilter *filter) const |
Loops over particles which satisfy some condition. | |
CandLooper | loop (const ParticleFilter &filter) const |
Loops over particles which satisfy some condition. | |
CandLooper | loop (const std::string &roleRegexp) const |
Loops over particles which have certaint roles. | |
CandLooper | loop () const |
Loops over all particles. | |
template<typename T> | |
eventhypothesis::Looper< T > | loopAs (const ParticleFilterPtr &filter) const |
Loops over particles which satisfy some condition. | |
template<typename T> | |
eventhypothesis::Looper< T > | loopAs (const ParticleFilter *filter) const |
Loops over particles which satisfy some condition. | |
template<typename T> | |
eventhypothesis::Looper< T > | loopAs (const ParticleFilter &filter) const |
Loops over particles which satisfy some condition. | |
template<typename T> | |
eventhypothesis::Looper< T > | loopAs (const std::string &roleRegexp) const |
Loops over particles which have certaint roles. | |
const CandRefType & | operator[] (const ParticleFilter &filter) const |
const CandRefType & | operator[] (const std::string &role) const |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | rend () const |
Private Member Functions | |
template<typename Iterator, typename Predicate> | |
Iterator | realGet (const Iterator &realBegin, const Iterator &realEnd, const Predicate &p, size_t idx) const |
Private Attributes | |
std::vector< value_type > | particles_ |
Classes | |
class | ByRole |
Definition at line 26 of file EventHypothesis.h.
Definition at line 33 of file EventHypothesis.h.
Definition at line 28 of file EventHypothesis.h.
typedef vector_type::const_iterator pat::EventHypothesis::const_iterator |
Definition at line 31 of file EventHypothesis.h.
typedef vector_type::const_reverse_iterator pat::EventHypothesis::const_reverse_iterator |
Definition at line 32 of file EventHypothesis.h.
Definition at line 50 of file EventHypothesis.h.
Definition at line 51 of file EventHypothesis.h.
typedef std::pair<std::string, CandRefType> pat::EventHypothesis::value_type |
Definition at line 29 of file EventHypothesis.h.
typedef std::vector<value_type> pat::EventHypothesis::vector_type |
Definition at line 30 of file EventHypothesis.h.
void pat::EventHypothesis::add | ( | const CandRefType & | ref, | |
const std::string & | role | |||
) |
Definition at line 4 of file EventHypothesis.cc.
References particles_.
00004 { 00005 particles_.push_back(value_type(role,ref)); 00006 }
std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all | ( | const ParticleFilter & | filter | ) | const |
Return EDM references to all particles which satisfy some condition.
Definition at line 44 of file EventHypothesis.cc.
References begin(), end(), filter, and it.
00045 { 00046 std::vector<pat::EventHypothesis::CandRefType> ret; 00047 for (const_iterator it = begin(); it != end(); ++it) { 00048 if (filter(*it)) ret.push_back(it->second); 00049 } 00050 return ret; 00051 }
std::vector< pat::EventHypothesis::CandRefType > pat::EventHypothesis::all | ( | const std::string & | roleRegexp | ) | const |
Return EDM references to all particles which have certaint roles.
Definition at line 38 of file EventHypothesis.cc.
00039 { 00040 return all(pat::eventhypothesis::RoleRegexpFilter(roleRegexp)); 00041 }
const_iterator pat::EventHypothesis::begin | ( | ) | const [inline] |
Definition at line 37 of file EventHypothesis.h.
References particles_.
Referenced by all(), pat::eventhypothesis::Looper< T >::assertOk(), count(), pat::eventhypothesis::Looper< T >::first(), get(), pat::eventhypothesis::Looper< T >::operator bool(), pat::eventhypothesis::Looper< T >::operator--(), and pat::eventhypothesis::Looper< T >::realSize().
00037 { return particles_.begin(); }
size_t pat::EventHypothesis::count | ( | const ParticleFilter & | role | ) | const |
size_t pat::EventHypothesis::count | ( | const std::string & | roleRegexp | ) | const |
Counts particles which have certaint roles.
Definition at line 54 of file EventHypothesis.cc.
References count().
00055 { 00056 return count(pat::eventhypothesis::RoleRegexpFilter(roleRegexp)); 00057 }
size_t pat::EventHypothesis::count | ( | void | ) | const [inline] |
Definition at line 65 of file EventHypothesis.h.
References particles_.
Referenced by count().
00065 { return particles_.size(); }
const_iterator pat::EventHypothesis::end | ( | ) | const [inline] |
Definition at line 38 of file EventHypothesis.h.
References particles_.
Referenced by all(), pat::eventhypothesis::Looper< T >::assertOk(), count(), pat::eventhypothesis::Looper< T >::first(), get(), pat::eventhypothesis::Looper< T >::operator bool(), pat::eventhypothesis::Looper< T >::operator++(), pat::eventhypothesis::Looper< T >::realSize(), and pat::eventhypothesis::Looper< T >::reset().
00038 { return particles_.end(); }
const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get | ( | const ParticleFilter & | filter, | |
int | index = 0 | |||
) | const |
Definition at line 23 of file EventHypothesis.cc.
References begin(), end(), Exception, it, rbegin(), realGet(), and rend().
00024 { 00025 if (index >= 0) { 00026 const_iterator it = realGet(begin(), end(), filter, index); 00027 if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; } 00028 return it->second; 00029 } else { 00030 const_reverse_iterator it = realGet(rbegin(), rend(), filter, -index); 00031 if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle matching filter with index " << index << "\n"; } 00032 return it->second; 00033 } 00034 }
const pat::EventHypothesis::CandRefType & pat::EventHypothesis::get | ( | const std::string & | role, | |
int | index = 0 | |||
) | const |
Definition at line 9 of file EventHypothesis.cc.
References begin(), end(), Exception, it, rbegin(), realGet(), and rend().
00010 { 00011 if (index >= 0) { 00012 const_iterator it = realGet(begin(), end(), ByRole(role), index); 00013 if (it == end()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; } 00014 return it->second; 00015 } else { 00016 const_reverse_iterator it = realGet(rbegin(), rend(), ByRole(role), -index); 00017 if (it == rend()) { throw cms::Exception("Index not found") << "Can't find a particle with role " << role << " and index " << index << "\n"; } 00018 return it->second; 00019 } 00020 }
const T * pat::EventHypothesis::getAs | ( | const ParticleFilter & | filter, | |
int | index = 0 | |||
) | const [inline] |
Definition at line 149 of file EventHypothesis.h.
References Exception, edm::Ptr< T >::get(), and name.
00150 { 00151 CandRefType ref = get(filter, index); 00152 const T* ret = dynamic_cast<const T*>(ref.get()); 00153 if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") << 00154 "You can't convert a " << typeid(*ref).name() << " to a " << typeid(T).name() << "\n" << 00155 "note: you can use c++filt command to convert the above in human readable types.\n"; 00156 return ret; 00157 }
const T * pat::EventHypothesis::getAs | ( | const std::string & | role, | |
int | index = 0 | |||
) | const [inline] |
Definition at line 138 of file EventHypothesis.h.
References Exception, edm::Ptr< T >::get(), and name.
00139 { 00140 CandRefType ref = get(role, index); 00141 const T* ret = dynamic_cast<const T*>(ref.get()); 00142 if ((ret == 0) && (ref.get() != 0)) throw cms::Exception("Type Checking") << 00143 "You can't convert a " << typeid(*ref).name() << " to a " << typeid(T).name() << "\n" << 00144 "note: you can use c++filt command to convert the above in human readable types.\n"; 00145 return ret; 00146 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop | ( | const ParticleFilterPtr & | filter | ) | const |
Loops over particles which satisfy some condition.
Definition at line 94 of file EventHypothesis.cc.
00095 { 00096 return CandLooper(*this, role); 00097 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop | ( | const ParticleFilter * | filter | ) | const |
Loops over particles which satisfy some condition.
The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loop(new WhateverFilterYouLike(...))
Definition at line 88 of file EventHypothesis.cc.
00089 { 00090 return CandLooper(*this, role); 00091 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop | ( | const ParticleFilter & | filter | ) | const |
Loops over particles which satisfy some condition.
The caller code owns the filter, and must take care it is not deleted while the looper is still being used
Definition at line 82 of file EventHypothesis.cc.
00083 { 00084 return CandLooper(*this, role); 00085 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop | ( | const std::string & | roleRegexp | ) | const |
Loops over particles which have certaint roles.
Definition at line 76 of file EventHypothesis.cc.
References loop().
00077 { 00078 return loop(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp)); 00079 }
pat::EventHypothesis::CandLooper pat::EventHypothesis::loop | ( | ) | const |
Loops over all particles.
Definition at line 70 of file EventHypothesis.cc.
References pat::eventhypothesis::AcceptAllFilter::get().
Referenced by loop().
00071 { 00072 return loop(pat::eventhypothesis::AcceptAllFilter::get()); 00073 }
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs | ( | const ParticleFilterPtr & | filter | ) | const [inline] |
Loops over particles which satisfy some condition.
Definition at line 181 of file EventHypothesis.h.
00182 { 00183 return pat::eventhypothesis::Looper<T>(*this, role); 00184 }
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs | ( | const ParticleFilter * | filter | ) | const [inline] |
Loops over particles which satisfy some condition.
The looper owns the filter, which will be deleted when the looper is deleted. That is, you can call eventHypothesis.loopAs<...>(new WhateverFilterYouLike(...))
Definition at line 174 of file EventHypothesis.h.
00175 { 00176 return pat::eventhypothesis::Looper<T>(*this, role); 00177 }
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs | ( | const ParticleFilter & | filter | ) | const [inline] |
Loops over particles which satisfy some condition.
The caller code owns the filter, and must take care it is not deleted while the looper is still being used
Definition at line 167 of file EventHypothesis.h.
00168 { 00169 return pat::eventhypothesis::Looper<T>(*this, role); 00170 }
eventhypothesis::Looper< T > pat::EventHypothesis::loopAs | ( | const std::string & | roleRegexp | ) | const [inline] |
Loops over particles which have certaint roles.
Definition at line 160 of file EventHypothesis.h.
00161 { 00162 return loopAs<T>(new pat::eventhypothesis::RoleRegexpFilter(roleRegexp)); 00163 }
const CandRefType& pat::EventHypothesis::operator[] | ( | const ParticleFilter & | filter | ) | const [inline] |
const CandRefType& pat::EventHypothesis::operator[] | ( | const std::string & | role | ) | const [inline] |
const_reverse_iterator pat::EventHypothesis::rbegin | ( | ) | const [inline] |
Definition at line 39 of file EventHypothesis.h.
References particles_.
Referenced by get().
00039 { return particles_.rbegin(); }
Iterator pat::EventHypothesis::realGet | ( | const Iterator & | realBegin, | |
const Iterator & | realEnd, | |||
const Predicate & | p, | |||
size_t | idx | |||
) | const [inline, private] |
Definition at line 123 of file EventHypothesis.h.
References it.
Referenced by get().
00124 { 00125 Iterator it = realBegin; 00126 while (it != realEnd) { 00127 if (pred(*it)) { 00128 if (idx == 0) return it; 00129 idx--; 00130 } 00131 ++it; 00132 } 00133 return it; 00134 }
const_reverse_iterator pat::EventHypothesis::rend | ( | ) | const [inline] |
Definition at line 40 of file EventHypothesis.h.
References particles_.
Referenced by get().
00040 { return particles_.rend(); }
std::vector<value_type> pat::EventHypothesis::particles_ [private] |