CMS 3D CMS Logo

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

MatchedProbeMaker< T > Class Template Reference

#include <MatchedProbeMaker.h>

Inheritance diagram for MatchedProbeMaker< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef std::vector< Tcollection

Public Member Functions

 MatchedProbeMaker (const edm::ParameterSet &iConfig)
 ~MatchedProbeMaker ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual void produce (edm::Event &, const edm::EventSetup &)

Private Attributes

edm::InputTag m_candidateSource
edm::InputTag m_referenceSource
edm::InputTag m_resMatchMapSource
bool matched_

Detailed Description

template<typename T>
class MatchedProbeMaker< T >

Definition at line 30 of file MatchedProbeMaker.h.


Member Typedef Documentation

template<typename T >
typedef std::vector< T > MatchedProbeMaker< T >::collection

Definition at line 33 of file MatchedProbeMaker.h.


Constructor & Destructor Documentation

template<typename T >
MatchedProbeMaker< T >::MatchedProbeMaker ( const edm::ParameterSet iConfig) [explicit]

Definition at line 54 of file MatchedProbeMaker.h.

                                                                      :
   m_candidateSource(iConfig.getUntrackedParameter<edm::InputTag>("CandidateSource")),
   m_referenceSource(iConfig.getUntrackedParameter<edm::InputTag>("ReferenceSource")),
   m_resMatchMapSource(iConfig.getUntrackedParameter<edm::InputTag>("ResMatchMapSource",edm::InputTag("Dummy"))),
   matched_(iConfig.getUntrackedParameter< bool >("Matched",true))
{
   //register your products
   produces< edm::RefVector< collection > >();
}
template<typename T >
MatchedProbeMaker< T >::~MatchedProbeMaker ( )

Definition at line 66 of file MatchedProbeMaker.h.

{}

Member Function Documentation

template<typename T >
void MatchedProbeMaker< T >::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 137 of file MatchedProbeMaker.h.

{
}
template<typename T >
void MatchedProbeMaker< T >::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 143 of file MatchedProbeMaker.h.

{
}
template<typename T >
void MatchedProbeMaker< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 70 of file MatchedProbeMaker.h.

References f, edm::Event::getByLabel(), i, j, LogDebug, muon::overlap(), edm::Event::put(), and dt_dqm_sourceclient_common_cff::reco.

{
  LogDebug("MatchedProbeMaker");
 
  using namespace edm;
  using namespace reco;

  std::auto_ptr< edm::RefVector< collection > > outputCollection_matched( new edm::RefVector< collection > );
  std::auto_ptr< edm::RefVector< collection > > outputCollection_unmatched(new edm::RefVector< collection > );
  
  // Get the candidates from the event
  edm::Handle< edm::RefVector< collection > > Cands;
  iEvent.getByLabel(m_candidateSource,Cands);

  edm::Handle< reco::CandidateView > Refs;
  iEvent.getByLabel(m_referenceSource,Refs);

  // Get the resolution matching map from the event
  edm::Handle<reco::CandViewMatchMap> ResMatchMap;

  if(iEvent.getByLabel(m_resMatchMapSource,ResMatchMap)){
    // Loop over the candidates looking for a match
    for (unsigned i=0; i<Cands->size(); i++) {
      const edm::Ref< collection > CandRef = (*Cands)[i];      
      reco::CandidateBaseRef candBaseRef( CandRef );
      
      // Loop over match map
      reco::CandViewMatchMap::const_iterator f = ResMatchMap->find( candBaseRef );
      if( f!=ResMatchMap->end() ) {
        outputCollection_matched->push_back(CandRef);      
      } else {
        outputCollection_unmatched->push_back(CandRef);      
      }
    }
  } else {
    OverlapChecker overlap;
    
    // Loop over the candidates looking for a match
    for (unsigned i=0; i<Cands->size(); i++) {      
      const edm::Ref< collection > CandRef = (*Cands)[i];
      //RefToBase<Candidate> CandRef(Cands, i);
      reco::CandidateBaseRef candBaseRef( CandRef );
      
      bool ppass = false;
      
      for (unsigned j=0; j<Refs->size(); j++) {
        //const edm::Ref< collection > RefRef = (*Refs)[j];
        RefToBase<Candidate> RefRef(Refs, j);
        reco::CandidateBaseRef refBaseRef( RefRef );
        
        if(overlap(*CandRef,*RefRef)) {
           ppass = true; 
        }
      }
      
      if( ppass ) outputCollection_matched->push_back(CandRef);
      else outputCollection_unmatched->push_back(CandRef);
    }  
  }
  
  if( matched_ ) iEvent.put( outputCollection_matched );
  else           iEvent.put( outputCollection_unmatched );
  
}

Member Data Documentation

template<typename T >
edm::InputTag MatchedProbeMaker< T >::m_candidateSource [private]

Definition at line 45 of file MatchedProbeMaker.h.

template<typename T >
edm::InputTag MatchedProbeMaker< T >::m_referenceSource [private]

Definition at line 46 of file MatchedProbeMaker.h.

template<typename T >
edm::InputTag MatchedProbeMaker< T >::m_resMatchMapSource [private]

Definition at line 47 of file MatchedProbeMaker.h.

template<typename T >
bool MatchedProbeMaker< T >::matched_ [private]

Definition at line 49 of file MatchedProbeMaker.h.