CMS 3D CMS Logo

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

◆ map_type

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

map type

Definition at line 22 of file CandMatcherNew.h.

◆ map_vector

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

Definition at line 25 of file CandMatcherNew.h.

◆ reference_type

ref type

Definition at line 24 of file CandMatcherNew.h.

Constructor & Destructor Documentation

◆ CandMatcher() [1/2]

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

constructor

◆ CandMatcher() [2/2]

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

constructor

◆ ~CandMatcher()

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

destructor

Definition at line 54 of file CandMatcherNew.h.

54 {}

Member Function Documentation

◆ operator[]()

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 HltBtagPostValidation_cff::c, trackingPlots::common, ztail::d, mps_fire::i, heavyIonCSV_trainingSettings::idx, visualization-live-secondInstance_cfg::m, volumeBasedMagneticField_160812_cfi::master, 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  }
refprod_type ref() const
Definition: Association.h:67
d
Definition: ztail.py:151
Definition: common.py:1
map_type map_
match map at leaf level
edm::Association< C >::reference_type reference_type
ref type
fixed size matrix
tmp
align.sh
Definition: createJobs.py:716
void swap(reco::ClusterRemovalInfo &cri1, reco::ClusterRemovalInfo &cri2)
std::vector< std::string > set_intersection(std::vector< std::string > const &v1, std::vector< std::string > const &v2)

◆ ref()

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().

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

Member Data Documentation

◆ map_

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().