CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

ElectronMatchedCandidateProducer Class Reference

#include <ElectronMatchedCandidateProducer.h>

Inheritance diagram for ElectronMatchedCandidateProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 ElectronMatchedCandidateProducer (const edm::ParameterSet &)
 ~ElectronMatchedCandidateProducer ()

Private Member Functions

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

Private Attributes

double delRMatchingCut_
edm::InputTag electronCollection_
edm::InputTag scCollection_

Detailed Description

Definition at line 16 of file ElectronMatchedCandidateProducer.h.


Constructor & Destructor Documentation

ElectronMatchedCandidateProducer::ElectronMatchedCandidateProducer ( const edm::ParameterSet params) [explicit]

Definition at line 9 of file ElectronMatchedCandidateProducer.cc.

References delRMatchingCut_, electronCollection_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and scCollection_.

{

  const edm::InputTag allelectrons("gsfElectrons");
  electronCollection_ = 
    params.getUntrackedParameter<edm::InputTag>("ReferenceElectronCollection", 
                                                allelectrons);
  scCollection_ = 
    params.getParameter<edm::InputTag>("src");

  delRMatchingCut_ = params.getUntrackedParameter<double>("deltaR",
                                                           0.30);
  
  produces< edm::PtrVector<reco::Candidate> >();
  produces< edm::RefToBaseVector<reco::Candidate> >();
}
ElectronMatchedCandidateProducer::~ElectronMatchedCandidateProducer ( )

Definition at line 29 of file ElectronMatchedCandidateProducer.cc.

{

}

Member Function Documentation

void ElectronMatchedCandidateProducer::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 99 of file ElectronMatchedCandidateProducer.cc.

{}
void ElectronMatchedCandidateProducer::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDProducer.

Definition at line 103 of file ElectronMatchedCandidateProducer.cc.

{}
void ElectronMatchedCandidateProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
) [private, virtual]

Implements edm::EDProducer.

Definition at line 42 of file ElectronMatchedCandidateProducer.cc.

References delRMatchingCut_, deltaR(), electronCollection_, HI_PhotonSkim_cff::electrons, and scCollection_.

{
   // Create the output collection
  std::auto_ptr< edm::RefToBaseVector<reco::Candidate> > 
    outColRef( new edm::RefToBaseVector<reco::Candidate> );
  std::auto_ptr< edm::PtrVector<reco::Candidate> > 
    outColPtr( new edm::PtrVector<reco::Candidate> );


  // Read electrons
  edm::Handle<edm::View<reco::GsfElectron> > electrons;
  event.getByLabel(electronCollection_, electrons);
   


  //Read candidates
  edm::Handle<edm::View<reco::Candidate> > recoCandColl; 
  event.getByLabel( scCollection_ , recoCandColl); 


  const edm::PtrVector<reco::Candidate>& ptrVect = recoCandColl->ptrVector();
  const edm::RefToBaseVector<reco::Candidate>& refs = recoCandColl->refVector();
  unsigned int counter=0;

  // Loop over candidates
  for(edm::View<reco::Candidate>::const_iterator scIt = recoCandColl->begin();
      scIt != recoCandColl->end(); ++scIt, ++counter){
    // Now loop over electrons
    for(edm::View<reco::GsfElectron>::const_iterator  elec = electrons->begin(); 
        elec != electrons->end();  ++elec) {

      reco::SuperClusterRef eSC = elec->superCluster();

      double dRval = reco::deltaR((float)eSC->eta(), (float)eSC->phi(), 
                                  scIt->eta(), scIt->phi());    
       
      if( dRval < delRMatchingCut_ ) {
        //outCol->push_back( *scIt );
        outColRef->push_back( refs[counter] );
        outColPtr->push_back( ptrVect[counter]  );
      } // end if loop
    } // end electron loop

  } // end candidate loop

  event.put(outColRef);
  event.put(outColPtr);
}

Member Data Documentation

Definition at line 31 of file ElectronMatchedCandidateProducer.h.

Referenced by ElectronMatchedCandidateProducer(), and produce().

Definition at line 29 of file ElectronMatchedCandidateProducer.h.

Referenced by ElectronMatchedCandidateProducer(), and produce().

Definition at line 30 of file ElectronMatchedCandidateProducer.h.

Referenced by ElectronMatchedCandidateProducer(), and produce().