#include <CandMatcher.h>
Public Types | |
typedef reco::helper::CandMapTrait< C1, C2 >::type | map_type |
map type | |
typedef reco::helper::CandMapTrait< C1, C2 >::type | map_type |
map type | |
typedef std::vector< const map_type * > | map_vector |
map vector | |
typedef std::vector< const map_type * > | map_vector |
map vector | |
typedef reco::helper::CandRefTrait< C2 > ::ref_type | ref_type |
ref type | |
typedef reco::helper::CandRefTrait< C2 > ::ref_type | ref_type |
ref type | |
typedef map_type::key_type | reference_type |
concrete candidate reference type | |
typedef map_type::key_type | reference_type |
concrete candidate reference type | |
typedef reco::helper::CandRefTrait< C2 > ::refProd_type | refProd_type |
refProd type | |
typedef reco::helper::CandRefTrait< C2 > ::refProd_type | refProd_type |
refProd type | |
typedef reference_type::value_type | value_type |
concrete candidate reference type | |
typedef reference_type::value_type | value_type |
concrete candidate reference type | |
Public Member Functions | |
CandMatcherBase (const map_vector &maps) | |
constructor | |
CandMatcherBase (const map_type &map) | |
constructor | |
CandMatcherBase (const map_vector &maps) | |
constructor | |
CandMatcherBase (const map_type &map) | |
constructor | |
ref_type | operator() (const reco::Candidate &) const |
get match from transient reference | |
ref_type | operator() (const reco::Candidate &) const |
get match from transient reference | |
virtual | ~CandMatcherBase () |
destructor | |
virtual | ~CandMatcherBase () |
destructor | |
Protected Member Functions | |
virtual bool | compositePreselect (const reco::Candidate &c, const reco::Candidate &m) const =0 |
composite candidate preselection | |
virtual bool | compositePreselect (const reco::Candidate &c, const reco::Candidate &m) const =0 |
composite candidate preselection | |
virtual std::vector< const reco::Candidate * > | getDaughters (const reco::Candidate *) const =0 |
get ultimate daughter (can skip status = 3 in MC) | |
virtual std::vector< const reco::Candidate * > | getDaughters (const reco::Candidate *) const =0 |
get ultimate daughter (can skip status = 3 in MC) | |
void | initMaps () |
init maps | |
void | initMaps () |
init maps | |
const std::vector< const map_type * > & | maps () const |
const std::vector< const map_type * > & | maps () const |
Private Types | |
typedef std::map< const reco::Candidate *, reference_type > | CandRefMap |
pointer map type | |
typedef std::map< const reco::Candidate *, reference_type > | CandRefMap |
pointer map type | |
typedef std::map< const reco::Candidate *, ref_type > | MatchedRefMap |
pointer map type | |
typedef std::map< const reco::Candidate *, ref_type > | MatchedRefMap |
pointer map type | |
Private Member Functions | |
void | init () |
init at constructor | |
void | init () |
init at constructor | |
Private Attributes | |
CandRefMap | candRefs_ |
pointer map of candidates (e.g.: reco) | |
std::vector< const map_type * > | maps_ |
pointers to stored maps | |
refProd_type | matched_ |
reference to matched collectino | |
std::vector< std::set< size_t > > | matchedMothers_ |
mother + n.daughters indices from matched | |
MatchedRefMap | matchedRefs_ |
pointer map of matched candidates (e.g.: MC truth) |
Definition at line 16 of file CandMatcher.h.
typedef std::map<const reco::Candidate *, reference_type> CandMatcherBase< C1, C2 >::CandRefMap [private] |
pointer map type
Definition at line 55 of file CandMatcher.h.
typedef std::map<const reco::Candidate *, reference_type> CandMatcherBase< C1, C2 >::CandRefMap [private] |
pointer map type
Definition at line 56 of file CandMatcher.h.
typedef reco::helper::CandMapTrait<C1, C2>::type CandMatcherBase< C1, C2 >::map_type |
map type
Definition at line 20 of file CandMatcher.h.
typedef reco::helper::CandMapTrait<C1, C2>::type CandMatcherBase< C1, C2 >::map_type |
map type
Definition at line 19 of file CandMatcher.h.
typedef std::vector<const map_type *> CandMatcherBase< C1, C2 >::map_vector |
map vector
Definition at line 25 of file CandMatcher.h.
typedef std::vector<const map_type *> CandMatcherBase< C1, C2 >::map_vector |
map vector
Definition at line 26 of file CandMatcher.h.
typedef std::map<const reco::Candidate *, ref_type> CandMatcherBase< C1, C2 >::MatchedRefMap [private] |
pointer map type
Definition at line 58 of file CandMatcher.h.
typedef std::map<const reco::Candidate *, ref_type> CandMatcherBase< C1, C2 >::MatchedRefMap [private] |
pointer map type
Definition at line 57 of file CandMatcher.h.
typedef reco::helper::CandRefTrait<C2>::ref_type CandMatcherBase< C1, C2 >::ref_type |
ref type
Definition at line 22 of file CandMatcher.h.
typedef reco::helper::CandRefTrait<C2>::ref_type CandMatcherBase< C1, C2 >::ref_type |
ref type
Definition at line 21 of file CandMatcher.h.
typedef map_type::key_type CandMatcherBase< C1, C2 >::reference_type |
concrete candidate reference type
Definition at line 27 of file CandMatcher.h.
typedef map_type::key_type CandMatcherBase< C1, C2 >::reference_type |
concrete candidate reference type
Definition at line 28 of file CandMatcher.h.
typedef reco::helper::CandRefTrait<C2>::refProd_type CandMatcherBase< C1, C2 >::refProd_type |
refProd type
Definition at line 24 of file CandMatcher.h.
typedef reco::helper::CandRefTrait<C2>::refProd_type CandMatcherBase< C1, C2 >::refProd_type |
refProd type
Definition at line 23 of file CandMatcher.h.
typedef reference_type::value_type CandMatcherBase< C1, C2 >::value_type |
concrete candidate reference type
Definition at line 29 of file CandMatcher.h.
typedef reference_type::value_type CandMatcherBase< C1, C2 >::value_type |
concrete candidate reference type
Definition at line 30 of file CandMatcher.h.
CandMatcherBase< C1, C2 >::CandMatcherBase | ( | const map_vector & | maps | ) | [explicit] |
constructor
CandMatcherBase< C1, C2 >::CandMatcherBase | ( | const map_type & | map | ) | [explicit] |
constructor
CandMatcherBase< C1, C2 >::~CandMatcherBase | ( | ) | [virtual] |
CandMatcherBase< C1, C2 >::CandMatcherBase | ( | const map_vector & | maps | ) | [explicit] |
constructor
CandMatcherBase< C1, C2 >::CandMatcherBase | ( | const map_type & | map | ) | [explicit] |
constructor
virtual CandMatcherBase< C1, C2 >::~CandMatcherBase | ( | ) | [virtual] |
destructor
virtual bool CandMatcherBase< C1, C2 >::compositePreselect | ( | const reco::Candidate & | c, |
const reco::Candidate & | m | ||
) | const [protected, pure virtual] |
composite candidate preselection
Implemented in CandMatcher< C1, C2 >, and CandMatcher< C1, C2 >.
virtual bool CandMatcherBase< C1, C2 >::compositePreselect | ( | const reco::Candidate & | c, |
const reco::Candidate & | m | ||
) | const [protected, pure virtual] |
composite candidate preselection
Implemented in CandMatcher< C1, C2 >, and CandMatcher< C1, C2 >.
virtual std::vector<const reco::Candidate *> CandMatcherBase< C1, C2 >::getDaughters | ( | const reco::Candidate * | ) | const [protected, pure virtual] |
get ultimate daughter (can skip status = 3 in MC)
Implemented in CandMatcher< C1, C2 >, and CandMatcher< C1, C2 >.
virtual std::vector<const reco::Candidate *> CandMatcherBase< C1, C2 >::getDaughters | ( | const reco::Candidate * | ) | const [protected, pure virtual] |
get ultimate daughter (can skip status = 3 in MC)
Implemented in CandMatcher< C1, C2 >, and CandMatcher< C1, C2 >.
void CandMatcherBase< C1, C2 >::init | ( | ) | [private] |
init at constructor
void CandMatcherBase< C1, C2 >::init | ( | void | ) | [private] |
init at constructor
Definition at line 89 of file CandMatcher.h.
References edm::errors::InvalidReference, and m.
{ matched_ = maps_.front()->refProd().val; for( typename map_vector::const_iterator m = maps_.begin() + 1; m != maps_.end(); ++ m ) { if( (*m)->refProd().val != matched_ ) throw edm::Exception( edm::errors::InvalidReference ) << "Multiple match maps specified matching different MC truth collections.\n" << "Please, specify maps all matching to the same MC truth collection.\n" << "In most of the cases you may want to match to genParticleCandidate."; } }
void CandMatcherBase< C1, C2 >::initMaps | ( | ) | [protected] |
init maps
Definition at line 114 of file CandMatcher.h.
References reco::Candidate::begin(), trackerHits::c, reco::Candidate::end(), f, i, j, gen::k, m, and dt_dqm_sourceclient_common_cff::reco.
Referenced by CandMatcher< C1, C2 >::CandMatcher().
{ using namespace reco; using namespace std; for( typename map_vector::const_iterator m = maps_.begin(); m != maps_.end(); ++ m ) { typename CandMatcherBase<C1, C2>::map_type::ref_type::key_type cands = (*m)->refProd().key; for( size_t i = 0; i < cands->size(); ++ i ) { candRefs_[ & (*cands)[ i ] ] = reference_type( cands, i ); } const C2 & matched = * matched_; size_t matchedSize = matched.size(); for( size_t i = 0; i < matchedSize; ++ i ) matchedRefs_[ & matched[ i ] ] = ref_type( matched_, i ); matchedMothers_.resize( matchedSize ); for( size_t i = 0; i < matchedSize; ++ i ) { const Candidate & c = matched[ i ]; for( Candidate::const_iterator d = c.begin(); d != c.end(); ++ d ) { vector<const Candidate *> daus = getDaughters( & * d ); for( size_t j = 0; j < daus.size(); ++ j ) { const Candidate * daughter = daus[ j ]; typename MatchedRefMap::const_iterator f = matchedRefs_.find( daughter ); if ( f == matchedRefs_.end() ) continue; size_t k = f->second.key(); assert( k < matchedMothers_.size() ); matchedMothers_[ k ].insert( i ); } } } } }
void CandMatcherBase< C1, C2 >::initMaps | ( | ) | [protected] |
init maps
const std::vector<const map_type *>& CandMatcherBase< C1, C2 >::maps | ( | ) | const [inline, protected] |
Definition at line 49 of file CandMatcher.h.
References CandMatcherBase< C1, C2 >::maps_.
{ return maps_; }
const std::vector<const map_type *>& CandMatcherBase< C1, C2 >::maps | ( | ) | const [inline, protected] |
Definition at line 48 of file CandMatcher.h.
References CandMatcherBase< C1, C2 >::maps_.
{ return maps_; }
CandMatcherBase< C1, C2 >::ref_type CandMatcherBase< C1, C2 >::operator() | ( | const reco::Candidate & | c | ) | const |
get match from transient reference
Definition at line 150 of file CandMatcher.h.
References reco::Candidate::begin(), reco::Candidate::end(), f, reco::Candidate::hasMasterClone(), edm::Ref< C, T, F >::isNull(), gen::k, edm::Ref< C, T, F >::key(), m, reco::Candidate::masterClone(), reco::Candidate::numberOfDaughters(), dt_dqm_sourceclient_common_cff::reco, reco::swap(), and tmp.
{ using namespace reco; using namespace std; if ( c.hasMasterClone() ) return (*this)( * c.masterClone() ); unsigned int nDau = c.numberOfDaughters(); const C2 & matched = * matched_; if ( nDau > 0 ) { // check for composite candidate c // navigate to daughters and find parent matches set<size_t> momsIntersection, momDaughters, tmp; for( Candidate::const_iterator d = c.begin(); d != c.end(); ++ d ) { // check here generically if status == 3, then descend down to one more level ref_type m = (*this)( * d ); // if a daughter does not match, return a null ref. if ( m.isNull() ) return ref_type(); // get matched mother indices (fetched previously) const set<size_t> & allMomDaughters = matchedMothers_[ m.key() ]; momDaughters.clear(); for( set<size_t>::const_iterator k = allMomDaughters.begin(); k != allMomDaughters.end(); ++ k ) { size_t m = * k; if( compositePreselect( c, matched[ m ] ) ) momDaughters.insert( m ); } // if no mother was found return null reference if ( momDaughters.size() == 0 ) return ref_type(); // the first time, momsIntersection is set to momDaughters if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters; else { tmp.clear(); set_intersection( momsIntersection.begin(), momsIntersection.end(), momDaughters.begin(), momDaughters.end(), inserter( tmp, tmp.begin() ) ); swap( momsIntersection, tmp ); } if ( momsIntersection.size() == 0 ) return ref_type(); } // if multiple mothers are found, return a null reference if ( momsIntersection.size() > 1 ) return ref_type(); // return a reference to the unique mother return ref_type( matched_, * momsIntersection.begin() ); } else { // check for non-composite (leaf) candidate // if one of the maps contains the candidate c for( typename std::vector<const map_type *>::const_iterator m = maps_.begin(); m != maps_.end(); ++ m ) { typename CandRefMap::const_iterator f = candRefs_.find( & c ); if ( f != candRefs_.end() ) { reference_type ref = f->second; typename map_type::const_iterator f = (*m)->find( ref ); if ( f != (*m)->end() ) { return f->val; } } } return ref_type(); } }
ref_type CandMatcherBase< C1, C2 >::operator() | ( | const reco::Candidate & | ) | const |
get match from transient reference
CandRefMap CandMatcherBase< C1, C2 >::candRefs_ [private] |
pointer map of candidates (e.g.: reco)
Definition at line 59 of file CandMatcher.h.
std::vector< const map_type * > CandMatcherBase< C1, C2 >::maps_ [private] |
pointers to stored maps
Definition at line 51 of file CandMatcher.h.
Referenced by CandMatcherBase< C1, C2 >::maps().
refProd_type CandMatcherBase< C1, C2 >::matched_ [private] |
reference to matched collectino
Definition at line 53 of file CandMatcher.h.
std::vector< std::set< size_t > > CandMatcherBase< C1, C2 >::matchedMothers_ [private] |
mother + n.daughters indices from matched
Definition at line 63 of file CandMatcher.h.
MatchedRefMap CandMatcherBase< C1, C2 >::matchedRefs_ [private] |
pointer map of matched candidates (e.g.: MC truth)
Definition at line 61 of file CandMatcher.h.