CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Attributes

FastCandMatcher< C > Class Template Reference

#include <FastCandMatcher.h>

List of all members.

Public Types

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

Public Member Functions

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

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

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 [inline, protected]

Definition at line 29 of file FastCandMatcher.h.

References FastCandMatcher< C >::maps_.

{ return maps_; }
template<typename C>
const std::vector<const map_type *>& FastCandMatcher< C >::maps ( ) const [inline, protected]

Definition at line 29 of file FastCandMatcher.h.

References FastCandMatcher< C >::maps_.

{ return 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(), L1Trigger_dataformats::reco, reco::Candidate::status(), reco::swap(), and tmp.

                                                                                    {
  using namespace reco;
  using namespace std;
  if ( c.hasMasterClone() )
    return (*this)( * c.masterClone() );
  unsigned int nDau = c.numberOfDaughters();
  if ( nDau > 0 ) {
    // check for composite candidate c
    // navigate to daughters and find parent matches
    set<const reco::Candidate *> momsIntersection, momDaughters, tmp;
    for( Candidate::const_iterator dau = c.begin(); dau != c.end(); ++ dau ) {
      // check here generically if status == 3, then descend down to one more level
      const Candidate * dauMatch = (*this)( * dau );
      // if a daughter does not match, return a null ref.
      if ( dauMatch == 0 ) return 0;
      // get matched mothers
      size_t mothers = dauMatch->numberOfMothers();
      for( size_t i = 0; i < mothers; ++ i ) {
        const reco::Candidate * mom = dauMatch->mother( i );
        if ( mom != 0 && mom->pdgId() == dauMatch->pdgId() && 
             mom->status() == 3 && dauMatch->status() == 1 ) {
          // assume a single mother at this point...
          mom = mom->mother( 0 );
        }
        momDaughters.insert( mom );
      }
      // if no mother was found return null reference
      if ( momDaughters.size() == 0 ) return 0;
      // the first time, momsIntersection is set to momDaughters
      if ( momsIntersection.size() == 0 ) momsIntersection = momDaughters;
      else {
        tmp.clear();
        set_intersection( momsIntersection.begin(), momsIntersection.end(),
                          momDaughters.begin(), momDaughters.end(),
                         inserter( tmp, tmp.begin() ) );
        swap( momsIntersection, tmp );
      }
      if ( momsIntersection.size() == 0 ) return 0;
    }
    // if multiple mothers are found, return a null reference
    if ( momsIntersection.size() > 1 ) return 0;
    // return a reference to the unique mother
    return * momsIntersection.begin();
  } else {
    // check for non-composite (leaf) candidate 
    // if one of the maps contains the candidate c
    for( typename std::vector<const map_type *>::const_iterator m = maps_.begin(); 
         m != maps_.end(); ++ m ) {
      for( typename map_type::const_iterator i = (*m)->begin(); i != (*m)->end(); ++ i ) {
        if ( & * i->key == & c )
          return & * i->val;
      }
    }
    return 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().