CMS 3D CMS Logo

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

reco::modulesNew::Matcher< C1, C2, S, D > Class Template Reference

#include <NewMatcher.h>

Inheritance diagram for reco::modulesNew::Matcher< C1, C2, S, D >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper reco::modulesNew::CandMatcher< S, C1, C2, D >

List of all members.

Public Member Functions

 Matcher (const edm::ParameterSet &cfg)
 ~Matcher ()

Private Types

typedef edm::Association< C2 > MatchMap
typedef C1::value_type T1
typedef C2::value_type T2

Private Member Functions

double matchDistance (const T1 &c1, const T2 &c2) const
void produce (edm::Event &, const edm::EventSetup &)
bool select (const T1 &c1, const T2 &c2) const

Private Attributes

distance_
double distMin_
edm::InputTag matched_
select_
edm::InputTag src_

Detailed Description

template<typename C1, typename C2, typename S, typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
class reco::modulesNew::Matcher< C1, C2, S, D >

Definition at line 24 of file NewMatcher.h.


Member Typedef Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef edm::Association<C2> reco::modulesNew::Matcher< C1, C2, S, D >::MatchMap [private]

Definition at line 31 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef C1::value_type reco::modulesNew::Matcher< C1, C2, S, D >::T1 [private]

Definition at line 29 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
typedef C2::value_type reco::modulesNew::Matcher< C1, C2, S, D >::T2 [private]

Definition at line 30 of file NewMatcher.h.


Constructor & Destructor Documentation

template<typename C1 , typename C2 , typename S , typename D >
reco::modulesNew::Matcher< C1, C2, S, D >::Matcher ( const edm::ParameterSet cfg)

Definition at line 57 of file NewMatcher.h.

                                                              :
      src_(cfg.template getParameter<edm::InputTag>("src")),
      matched_(cfg.template getParameter<edm::InputTag>("matched")), 
      distMin_(cfg.template getParameter<double>("distMin")),
      select_(reco::modules::make<S>(cfg)), 
      distance_(reco::modules::make<D>(cfg)) {
      produces<MatchMap>();
    }
template<typename C1 , typename C2 , typename S , typename D >
reco::modulesNew::Matcher< C1, C2, S, D >::~Matcher ( )

Definition at line 67 of file NewMatcher.h.

{ }

Member Function Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
double reco::modulesNew::Matcher< C1, C2, S, D >::matchDistance ( const T1 c1,
const T2 c2 
) const [inline, private]

Definition at line 36 of file NewMatcher.h.

References reco::modulesNew::Matcher< C1, C2, S, D >::distance_.

                                                               {
        return distance_(c1, c2);
      }
template<typename C1 , typename C2 , typename S , typename D >
void reco::modulesNew::Matcher< C1, C2, S, D >::produce ( edm::Event evt,
const edm::EventSetup  
) [private, virtual]

Implements edm::EDProducer.

Definition at line 70 of file NewMatcher.h.

References trackerHits::c, edm::helper::Filler< Map >::fill(), first, edm::Event::getByLabel(), edm::helper::Filler< Map >::insert(), m, funct::master(), match(), edm::Event::put(), benchmark_cfg::select, findQualityFiles::size, and v.

                                                                           {
      using namespace edm;
      using namespace std;
      Handle<C2> matched;  
      evt.getByLabel(matched_, matched);
      Handle<C1> cands;  
      evt.getByLabel(src_, cands);
      auto_ptr<MatchMap> matchMap(new MatchMap(matched));
      size_t size = cands->size();
      if( size != 0 ) {
        typename MatchMap::Filler filler(*matchMap);

	::helper::MasterCollection<C1> master(cands);
        std::vector<int> indices(master.size(), -1);
        for(size_t c = 0; c != size; ++ c) {
          const T1 & cand = (*cands)[c];
          vector<helper::MatchPair> v;
          for(size_t m = 0; m != matched->size(); ++m) {
            const T2 & match = (* matched)[m];
            if (select(cand, match)) {
              double dist = matchDistance(cand, match);
              if (dist < distMin_) v.push_back(make_pair(m, dist));
            }
          }
          if(v.size() > 0) {
            size_t idx = master.index(c);
            assert(idx < indices.size());
            indices[idx] = min_element(v.begin(), v.end(), helper::SortBySecond())->first;
          }
        }
        filler.insert(master.get(), indices.begin(), indices.end());
        filler.fill();
      }
      evt.put(matchMap);
    }    
template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
bool reco::modulesNew::Matcher< C1, C2, S, D >::select ( const T1 c1,
const T2 c2 
) const [inline, private]

Definition at line 39 of file NewMatcher.h.

References reco::modulesNew::Matcher< C1, C2, S, D >::select_.

                                                      { 
        return select_(c1, c2); 
      }

Member Data Documentation

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
D reco::modulesNew::Matcher< C1, C2, S, D >::distance_ [private]
template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
double reco::modulesNew::Matcher< C1, C2, S, D >::distMin_ [private]

Definition at line 35 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
edm::InputTag reco::modulesNew::Matcher< C1, C2, S, D >::matched_ [private]

Definition at line 34 of file NewMatcher.h.

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
S reco::modulesNew::Matcher< C1, C2, S, D >::select_ [private]

Definition at line 42 of file NewMatcher.h.

Referenced by reco::modulesNew::Matcher< C1, C2, S, D >::select().

template<typename C1 , typename C2 , typename S , typename D = DeltaR<typename C1::value_type, typename C2::value_type>>
edm::InputTag reco::modulesNew::Matcher< C1, C2, S, D >::src_ [private]

Definition at line 33 of file NewMatcher.h.