CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
FastCandMatcher< C > Class Template Reference

#include <FastCandMatcher.h>

Public Types

typedef edm::AssociationMap< edm::OneToOne< C, reco::CandidateCollection > > map_type
 map type More...
 
typedef std::vector< const map_type * > map_vector
 map vector More...
 

Public Member Functions

 FastCandMatcher (const map_type &map)
 constructor More...
 
 FastCandMatcher (const map_vector &maps)
 constructor More...
 
const reco::Candidateoperator() (const reco::Candidate &) const
 get match from transient reference More...
 

Protected Member Functions

const std::vector< const map_type * > & maps () const
 

Private Attributes

std::vector< const map_type * > maps_
 pointers to stored maps More...
 

Detailed Description

template<typename C>
class FastCandMatcher< C >

Definition at line 15 of file FastCandMatcher.h.

Member Typedef Documentation

◆ map_type

map type

Definition at line 18 of file FastCandMatcher.h.

◆ map_vector

template<typename C>
typedef std::vector<const map_type *> FastCandMatcher< C >::map_vector

map vector

Definition at line 20 of file FastCandMatcher.h.

Constructor & Destructor Documentation

◆ FastCandMatcher() [1/2]

template<typename C>
FastCandMatcher< C >::FastCandMatcher ( const map_vector maps)
explicit

constructor

◆ FastCandMatcher() [2/2]

template<typename C>
FastCandMatcher< C >::FastCandMatcher ( const map_type map)
explicit

constructor

Member Function Documentation

◆ maps()

template<typename C>
const std::vector<const map_type *>& FastCandMatcher< C >::maps ( ) const
inlineprotected

Definition at line 29 of file FastCandMatcher.h.

29 { return maps_; }

References FastCandMatcher< C >::maps_.

◆ operator()()

template<typename C >
const reco::Candidate * FastCandMatcher< C >::operator() ( const reco::Candidate c) const

get match from transient reference

Definition at line 46 of file FastCandMatcher.h.

46  {
47  using namespace reco;
48  using namespace std;
49  if ( c.hasMasterClone() )
50  return (*this)( * c.masterClone() );
51  unsigned int nDau = c.numberOfDaughters();
52  if ( nDau > 0 ) {
53  // check for composite candidate c
54  // navigate to daughters and find parent matches
55  set<const reco::Candidate *> momsIntersection, momDaughters, tmp;
56  for( Candidate::const_iterator dau = c.begin(); dau != c.end(); ++ dau ) {
57  // check here generically if status == 3, then descend down to one more level
58  const Candidate * dauMatch = (*this)( * dau );
59  // if a daughter does not match, return a null ref.
60  if ( dauMatch == 0 ) return 0;
61  // get matched mothers
62  size_t mothers = dauMatch->numberOfMothers();
63  for( size_t i = 0; i < mothers; ++ i ) {
64  const reco::Candidate * mom = dauMatch->mother( i );
65  if ( mom != 0 && mom->pdgId() == dauMatch->pdgId() &&
66  mom->status() == 3 && dauMatch->status() == 1 ) {
67  // assume a single mother at this point...
68  mom = mom->mother( 0 );
69  }
70  momDaughters.insert( mom );
71  }
72  // if no mother was found return null reference
73  if ( momDaughters.size() == 0 ) return 0;
74  // the first time, momsIntersection is set to momDaughters
75  if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters;
76  else {
77  tmp.clear();
78  set_intersection( momsIntersection.begin(), momsIntersection.end(),
79  momDaughters.begin(), momDaughters.end(),
80  inserter( tmp, tmp.begin() ) );
81  swap( momsIntersection, tmp );
82  }
83  if ( momsIntersection.size() == 0 ) return 0;
84  }
85  // if multiple mothers are found, return a null reference
86  if ( momsIntersection.size() > 1 ) return 0;
87  // return a reference to the unique mother
88  return * momsIntersection.begin();
89  } else {
90  // check for non-composite (leaf) candidate
91  // if one of the maps contains the candidate c
92  for( typename std::vector<const map_type *>::const_iterator m = maps_.begin();
93  m != maps_.end(); ++ m ) {
94  for( typename map_type::const_iterator i = (*m)->begin(); i != (*m)->end(); ++ i ) {
95  if ( & * i->key == & c )
96  return & * i->val;
97  }
98  }
99  return 0;
100  }
101 }

References HltBtagPostValidation_cff::c, mps_fire::i, visualization-live-secondInstance_cfg::m, reco::Candidate::mother(), reco::Candidate::numberOfMothers(), reco::Candidate::pdgId(), reco::Candidate::status(), reco::swap(), and createJobs::tmp.

Member Data Documentation

◆ maps_

template<typename C>
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().

mps_fire.i
i
Definition: mps_fire.py:355
FastCandMatcher::maps_
std::vector< const map_type * > maps_
pointers to stored maps
Definition: FastCandMatcher.h:32
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
reco::candidate::const_iterator
Definition: const_iterator.h:14
reco::Candidate::status
virtual int status() const =0
status word
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
reco::Candidate::mother
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
reco::Candidate::numberOfMothers
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
edm::AssociationMap::const_iterator
friend struct const_iterator
Definition: AssociationMap.h:274
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
reco::Candidate
Definition: Candidate.h:27
std
Definition: JetResolutionObject.h:76