#include <PhysicsTools/CandUtils/interface/FastCandMatcher.h>
Public Types | |
typedef edm::AssociationMap < edm::OneToOne< C, reco::CandidateCollection > > | map_type |
map type | |
typedef std::vector< const map_type * > | map_vector |
map vector | |
Public Member Functions | |
FastCandMatcher (const map_type &map) | |
constructor | |
FastCandMatcher (const map_vector &maps) | |
constructor | |
const reco::Candidate * | operator() (const reco::Candidate &) const |
get match from transient reference | |
Protected Member Functions | |
const std::vector< const map_type * > & | maps () const |
Private Attributes | |
std::vector< const map_type * > | maps_ |
pointers to stored maps |
Definition at line 15 of file FastCandMatcher.h.
typedef edm::AssociationMap<edm::OneToOne<C, reco::CandidateCollection> > FastCandMatcher< C >::map_type |
typedef std::vector<const map_type *> FastCandMatcher< C >::map_vector |
FastCandMatcher< C >::FastCandMatcher | ( | const map_vector & | maps | ) | [explicit] |
constructor
FastCandMatcher< C >::FastCandMatcher | ( | const map_type & | map | ) | [explicit] |
constructor
const std::vector<const map_type *>& FastCandMatcher< C >::maps | ( | ) | const [inline, protected] |
Definition at line 29 of file FastCandMatcher.h.
References FastCandMatcher< C >::maps_.
00029 { return maps_; }
const reco::Candidate * FastCandMatcher< C >::operator() | ( | const reco::Candidate & | c | ) | const [inline] |
get match from transient reference
Definition at line 46 of file FastCandMatcher.h.
References reco::Candidate::begin(), reco::Candidate::end(), reco::Candidate::hasMasterClone(), i, m, FastCandMatcher< C >::maps_, reco::Candidate::masterClone(), reco::Candidate::mother(), reco::Candidate::numberOfDaughters(), reco::Particle::pdgId(), HcalSimpleRecAlgoImpl::reco(), reco::Particle::status(), std, swap(), and tmp.
00046 { 00047 using namespace reco; 00048 using namespace std; 00049 if ( c.hasMasterClone() ) 00050 return (*this)( * c.masterClone() ); 00051 unsigned int nDau = c.numberOfDaughters(); 00052 if ( nDau > 0 ) { 00053 // check for composite candidate c 00054 // navigate to daughters and find parent matches 00055 set<const reco::Candidate *> momsIntersection, momDaughters, tmp; 00056 for( Candidate::const_iterator dau = c.begin(); dau != c.end(); ++ dau ) { 00057 // check here generically if status == 3, then descend down to one more level 00058 const Candidate * dauMatch = (*this)( * dau ); 00059 // if a daughter does not match, return a null ref. 00060 if ( dauMatch == 0 ) return 0; 00061 // get matched mothers 00062 size_t mothers = dauMatch->numberOfMothers(); 00063 for( size_t i = 0; i < mothers; ++ i ) { 00064 const reco::Candidate * mom = dauMatch->mother( i ); 00065 if ( mom != 0 && mom->pdgId() == dauMatch->pdgId() && 00066 mom->status() == 3 && dauMatch->status() == 1 ) { 00067 // assume a single mother at this point... 00068 mom = mom->mother( 0 ); 00069 } 00070 momDaughters.insert( mom ); 00071 } 00072 // if no mother was found return null reference 00073 if ( momDaughters.size() == 0 ) return 0; 00074 // the first time, momsIntersection is set to momDaughters 00075 if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters; 00076 else { 00077 tmp.clear(); 00078 set_intersection( momsIntersection.begin(), momsIntersection.end(), 00079 momDaughters.begin(), momDaughters.end(), 00080 inserter( tmp, tmp.begin() ) ); 00081 swap( momsIntersection, tmp ); 00082 } 00083 if ( momsIntersection.size() == 0 ) return 0; 00084 } 00085 // if multiple mothers are found, return a null reference 00086 if ( momsIntersection.size() > 1 ) return 0; 00087 // return a reference to the unique mother 00088 return * momsIntersection.begin(); 00089 } else { 00090 // check for non-composite (leaf) candidate 00091 // if one of the maps contains the candidate c 00092 for( typename std::vector<const map_type *>::const_iterator m = maps_.begin(); 00093 m != maps_.end(); ++ m ) { 00094 for( typename map_type::const_iterator i = (*m)->begin(); i != (*m)->end(); ++ i ) { 00095 if ( & * i->key == & c ) 00096 return & * i->val; 00097 } 00098 } 00099 return 0; 00100 } 00101 }
std::vector<const map_type *> FastCandMatcher< C >::maps_ [private] |
pointers to stored maps
Definition at line 32 of file FastCandMatcher.h.
Referenced by FastCandMatcher< C >::maps(), and FastCandMatcher< C >::operator()().