1 #ifndef CandUtils_CandMatcher_h 2 #define CandUtils_CandMatcher_h 15 template<
typename C1,
typename C2 = C1>
48 const std::vector<const map_type *> &
maps()
const {
return maps_; }
51 std::vector<const map_type *>
maps_;
55 typedef std::map<const reco::Candidate *, reference_type>
CandRefMap;
68 template<
typename C1,
typename C2 = C1>
88 template<
typename C1,
typename C2>
91 for(
typename map_vector::const_iterator
m =
maps_.begin() + 1;
93 if( (*m)->refProd().val !=
matched_ )
95 <<
"Multiple match maps specified matching different MC truth collections.\n" 96 <<
"Please, specify maps all matching to the same MC truth collection.\n" 97 <<
"In most of the cases you may want to match to genParticleCandidate.";
101 template<
typename C1,
typename C2>
107 template<
typename C1,
typename C2>
113 template<
typename C1,
typename C2>
115 using namespace reco;
117 for(
typename map_vector::const_iterator
m =
maps_.begin();
120 for(
size_t i = 0;
i < cands->size(); ++
i ) {
124 size_t matchedSize = matched.size();
125 for(
size_t i = 0;
i < matchedSize; ++
i )
128 for(
size_t i = 0;
i < matchedSize; ++
i ) {
132 for(
size_t j = 0; j < daus.size(); ++ j ) {
134 typename MatchedRefMap::const_iterator
f =
matchedRefs_.find( daughter );
136 size_t k = f->second.key();
145 template<
typename C1,
typename C2>
149 template<
typename C1,
typename C2>
151 using namespace reco;
160 set<size_t> momsIntersection, momDaughters,
tmp;
168 momDaughters.clear();
169 for( set<size_t>::const_iterator
k = allMomDaughters.begin();
170 k != allMomDaughters.end(); ++
k ) {
173 momDaughters.insert( m );
176 if ( momDaughters.size() == 0 )
return ref_type();
178 if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters;
181 set_intersection( momsIntersection.begin(), momsIntersection.end(),
182 momDaughters.begin(), momDaughters.end(),
183 inserter( tmp, tmp.begin() ) );
184 swap( momsIntersection, tmp );
186 if ( momsIntersection.size() == 0 )
return ref_type();
189 if ( momsIntersection.size() > 1 )
return ref_type();
195 for(
typename std::vector<const map_type *>::const_iterator
m =
maps_.begin();
197 typename CandRefMap::const_iterator
f =
candRefs_.find( & c );
201 if ( f != (*m)->end() ) {
210 template<
typename C1,
typename C2>
216 template<
typename C1,
typename C2>
222 template<
typename C1,
typename C2>
226 template<
typename C1,
typename C2>
228 std::vector<const reco::Candidate *>
v;
233 template<
typename C1,
typename C2>
void init()
init at constructor
std::vector< const map_type * > map_vector
map vector
std::map< const reco::Candidate *, reference_type > CandRefMap
pointer map type
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
composite candidate preselection
reference_type::value_type value_type
concrete candidate reference type
reco::helper::CandRefTrait< C2 >::refProd_type refProd_type
refProd type
virtual std::vector< const reco::Candidate * > getDaughters(const reco::Candidate *) const =0
get ultimate daughter (can skip status = 3 in MC)
CandRefMap candRefs_
pointer map of candidates (e.g.: reco)
virtual ~CandMatcherBase()
destructor
Tag::key_type key_type
insert key type
key_type key() const
Accessor for product key.
refProd_type matched_
reference to matched collectino
std::map< const reco::Candidate *, ref_type > MatchedRefMap
pointer map type
void swap(Association< C > &lhs, Association< C > &rhs)
const std::vector< const map_type * > & maps() const
reco::helper::CandRefTrait< C2 >::ref_type ref_type
ref type
Container::value_type value_type
reco::helper::CandMapTrait< C1, C2 >::type map_type
map type
MatchedRefMap matchedRefs_
pointer map of matched candidates (e.g.: MC truth)
const_iterator end() const
last daughter const_iterator
CandMatcher(const typename CandMatcherBase< C1, C2 >::map_vector &maps)
constructor
CandMatcherBase(const map_vector &maps)
constructor
virtual ~CandMatcher()
destructor
bool isNull() const
Checks for null.
ref_type operator()(const reco::Candidate &) const
get match from transient reference
virtual const CandidateBaseRef & masterClone() const =0
std::vector< std::set< size_t > > matchedMothers_
mother + n.daughters indices from matched
virtual std::vector< const reco::Candidate * > getDaughters(const reco::Candidate *) const
get ultimate daughter (get all in the general case)
std::vector< std::vector< double > > tmp
std::vector< const map_type * > maps_
pointers to stored maps
const_iterator begin() const
first daughter const_iterator
virtual size_type numberOfDaughters() const =0
number of daughters
map_type::key_type reference_type
concrete candidate reference type
virtual bool hasMasterClone() const =0