CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 edm::AssociationMap
< edm::OneToOne< C,
reco::CandidateCollection > > 
map_type
 map type More...
 
typedef std::vector< const
map_type * > 
map_vector
 map vector More...
 
typedef std::vector< const
map_type * > 
map_vector
 map vector More...
 

Public Member Functions

 FastCandMatcher (const map_vector &maps)
 constructor More...
 
 FastCandMatcher (const map_vector &maps)
 constructor More...
 
 FastCandMatcher (const map_type &map)
 constructor More...
 
 FastCandMatcher (const map_type &map)
 constructor More...
 
const reco::Candidateoperator() (const reco::Candidate &) const
 get match from transient reference 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
 
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

Definition at line 18 of file FastCandMatcher.h.

map type

Definition at line 18 of file FastCandMatcher.h.

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

map vector

Definition at line 20 of file FastCandMatcher.h.

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

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

constructor

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

constructor

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

constructor

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

constructor

Member Function Documentation

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

Definition at line 29 of file FastCandMatcher.h.

References FastCandMatcher< C >::maps_.

29 { return maps_; }
std::vector< const map_type * > maps_
pointers to stored maps
template<typename C>
const std::vector<const map_type *>& FastCandMatcher< C >::maps ( ) const
inlineprotected

Definition at line 29 of file FastCandMatcher.h.

References FastCandMatcher< C >::maps_.

29 { return maps_; }
std::vector< const map_type * > maps_
pointers to stored maps
template<typename C>
const reco::Candidate* FastCandMatcher< C >::operator() ( const reco::Candidate ) const

get match from transient reference

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.

References reco::Candidate::begin(), reco::Candidate::end(), reco::Candidate::hasMasterClone(), i, m, reco::Candidate::masterClone(), reco::Candidate::mother(), reco::Candidate::numberOfDaughters(), reco::Candidate::numberOfMothers(), reco::Candidate::pdgId(), dt_offlineAnalysis_common_cff::reco, reco::Candidate::status(), reco::swap(), and tmp.

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 }
void swap(ora::Record &rh, ora::Record &lh)
Definition: Record.h:74
int i
Definition: DBlmapReader.cc:9
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
friend struct const_iterator
virtual int status() const =0
status word
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
virtual size_type numberOfDaughters() const =0
number of daughters
virtual bool hasMasterClone() const =0
virtual const_iterator end() const =0
last daughter const_iterator
virtual int pdgId() const =0
PDG identifier.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual const_iterator begin() const =0
first daughter const_iterator
std::vector< const map_type * > maps_
pointers to stored maps
virtual const CandidateBaseRef & masterClone() const =0

Member Data Documentation

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