CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Protected Attributes
reco::utilsNew::CandMatcher< C > Class Template Reference

#include <CandMatcherNew.h>

Public Types

typedef edm::Association< C > map_type
 map type More...
 
typedef std::vector< const
map_type * > 
map_vector
 
typedef edm::Association< C >
::reference_type 
reference_type
 ref type More...
 

Public Member Functions

 CandMatcher (const map_vector &maps)
 constructor More...
 
 CandMatcher (const map_type &map)
 constructor More...
 
reference_type operator[] (const reco::Candidate &) const
 get match from transient reference More...
 
map_type::refprod_type ref () const
 reference to matched collection More...
 
virtual ~CandMatcher ()
 destructor More...
 

Protected Attributes

map_type map_
 match map at leaf level More...
 

Detailed Description

template<typename C>
class reco::utilsNew::CandMatcher< C >

Definition at line 19 of file CandMatcherNew.h.

Member Typedef Documentation

template<typename C>
typedef edm::Association<C> reco::utilsNew::CandMatcher< C >::map_type

map type

Definition at line 22 of file CandMatcherNew.h.

template<typename C>
typedef std::vector<const map_type *> reco::utilsNew::CandMatcher< C >::map_vector

Definition at line 25 of file CandMatcherNew.h.

ref type

Definition at line 24 of file CandMatcherNew.h.

Constructor & Destructor Documentation

template<typename C>
reco::utilsNew::CandMatcher< C >::CandMatcher ( const map_vector maps)
explicit

constructor

template<typename C>
reco::utilsNew::CandMatcher< C >::CandMatcher ( const map_type map)
explicit

constructor

template<typename C >
reco::utilsNew::CandMatcher< C >::~CandMatcher ( )
virtual

destructor

Definition at line 54 of file CandMatcherNew.h.

54 {}

Member Function Documentation

template<typename C >
CandMatcher< C >::reference_type reco::utilsNew::CandMatcher< C >::operator[] ( const reco::Candidate c) const

get match from transient reference

Definition at line 57 of file CandMatcherNew.h.

References ztail::d, reco::Candidate::daughter(), reco::Candidate::hasMasterClone(), mps_fire::i, edm::Ref< C, T, F >::isNull(), edm::Ref< C, T, F >::key(), visualization-live-secondInstance_cfg::m, funct::master(), reco::Candidate::masterClone(), reco::Candidate::numberOfDaughters(), dt_dqm_sourceclient_common_cff::reco, DBoxMetadataHelper::set_intersection(), reco::swap(), and createJobs::tmp.

57  {
58  using namespace reco;
59  using namespace std;
60  if (c.hasMasterClone()) {
61  const CandidateBaseRef &master = c.masterClone();
62  return master->numberOfDaughters() == 0 ? map_[master] : (*this)[*master];
63  }
64  size_t nDau = c.numberOfDaughters();
65  if (nDau == 0)
66  return reference_type();
67  set<size_t> momIdx, common, tmp;
68  for (size_t i = 0; i < nDau; ++i) {
69  const Candidate &d = *c.daughter(i);
70  reference_type m = (*this)[d];
71  if (m.isNull())
72  return reference_type();
73  momIdx.clear();
74  while (m->numberOfMothers() == 1) {
75  m = m->motherRef();
76  momIdx.insert(m.key());
77  }
78  if (momIdx.empty())
79  return reference_type();
80  if (common.empty())
81  common = momIdx;
82  else {
83  tmp.clear();
84  set_intersection(common.begin(), common.end(), momIdx.begin(), momIdx.end(), inserter(tmp, tmp.begin()));
85  swap(common, tmp);
86  }
87  if (common.empty())
88  return reference_type();
89  }
90  size_t idx = *max_element(common.begin(), common.end());
91  return reference_type(map_.ref(), idx);
92  }
Master< F > master(const F &f)
Definition: FunctClone.h:63
refprod_type ref() const
Definition: Association.h:67
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
tuple d
Definition: ztail.py:151
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool hasMasterClone() const =0
map_type map_
match map at leaf level
edm::Association< C >::reference_type reference_type
ref type
tmp
align.sh
Definition: createJobs.py:716
void swap(reco::ClusterRemovalInfo &cri1, reco::ClusterRemovalInfo &cri2)
virtual const CandidateBaseRef & masterClone() const =0
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)
template<typename C>
map_type::refprod_type reco::utilsNew::CandMatcher< C >::ref ( ) const
inline

reference to matched collection

Definition at line 35 of file CandMatcherNew.h.

References reco::utilsNew::CandMatcher< C >::map_, and edm::Association< C >::ref().

Referenced by reco::modulesNew::MCTruthCompositeMatcher::produce().

35 { return map_.ref(); }
refprod_type ref() const
Definition: Association.h:67
map_type map_
match map at leaf level

Member Data Documentation

template<typename C>
map_type reco::utilsNew::CandMatcher< C >::map_
protected

match map at leaf level

Definition at line 39 of file CandMatcherNew.h.

Referenced by reco::utilsNew::CandMatcher< C >::ref().