CMS 3D CMS Logo

Public Member Functions | Private Attributes

EgammaHLTElectronTrackIsolationProducers Class Reference

#include <RecoEgamma/EgammaHLTProducers/interface/EgammaHLTElectronTrackIsolationProducers.h>

Inheritance diagram for EgammaHLTElectronTrackIsolationProducers:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EgammaHLTElectronTrackIsolationProducers (const edm::ParameterSet &)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EgammaHLTElectronTrackIsolationProducers ()

Private Attributes

edm::InputTag beamSpotProducer_
double egTrkIsoConeSize_
double egTrkIsoPtMin_
double egTrkIsoRSpan_
double egTrkIsoStripBarrel_
double egTrkIsoStripEndcap_
double egTrkIsoVetoConeSizeBarrel_
double egTrkIsoVetoConeSizeEndcap_
double egTrkIsoZSpan_
edm::InputTag electronProducer_
edm::InputTag recoEcalCandidateProducer_
edm::InputTag trackProducer_
bool useGsfTrack_
bool useSCRefs_

Detailed Description

Author:
Monica Vazquez Acosta (CERN)
Id:
EgammaHLTElectronTrackIsolationProducers.cc,v 1.10 2012/01/23 12:56:38 sharper Exp

Definition at line 34 of file EgammaHLTElectronTrackIsolationProducers.h.


Constructor & Destructor Documentation

EgammaHLTElectronTrackIsolationProducers::EgammaHLTElectronTrackIsolationProducers ( const edm::ParameterSet config) [explicit]

Definition at line 34 of file EgammaHLTElectronTrackIsolationProducers.cc.

References beamSpotProducer_, egTrkIsoConeSize_, egTrkIsoPtMin_, egTrkIsoRSpan_, egTrkIsoStripBarrel_, egTrkIsoStripEndcap_, egTrkIsoVetoConeSizeBarrel_, egTrkIsoVetoConeSizeEndcap_, egTrkIsoZSpan_, electronProducer_, edm::ParameterSet::getParameter(), recoEcalCandidateProducer_, trackProducer_, useGsfTrack_, and useSCRefs_.

{

  electronProducer_             = config.getParameter<edm::InputTag>("electronProducer");
  trackProducer_                = config.getParameter<edm::InputTag>("trackProducer");
  recoEcalCandidateProducer_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer"); 
  beamSpotProducer_ = config.getParameter<edm::InputTag>("beamSpotProducer");

  useGsfTrack_ = config.getParameter<bool>("useGsfTrack");
  useSCRefs_ = config.getParameter<bool>("useSCRefs");
  
  egTrkIsoPtMin_                = config.getParameter<double>("egTrkIsoPtMin");
  egTrkIsoConeSize_             = config.getParameter<double>("egTrkIsoConeSize");
  egTrkIsoZSpan_                = config.getParameter<double>("egTrkIsoZSpan");
  egTrkIsoRSpan_                = config.getParameter<double>("egTrkIsoRSpan");
  egTrkIsoVetoConeSizeBarrel_         = config.getParameter<double>("egTrkIsoVetoConeSizeBarrel");
  egTrkIsoVetoConeSizeEndcap_         = config.getParameter<double>("egTrkIsoVetoConeSizeEndcap");
  // egCheckForOtherEleInCone_     = config.getUntrackedParameter<bool>("egCheckForOtherEleInCone",false);
  egTrkIsoStripBarrel_   = config.getParameter<double>("egTrkIsoStripBarrel");
  egTrkIsoStripEndcap_   = config.getParameter<double>("egTrkIsoStripEndcap");

 


  //register your products
  if(useSCRefs_) produces < reco::RecoEcalCandidateIsolationMap >();
  else produces < reco::ElectronIsolationMap >();
}
EgammaHLTElectronTrackIsolationProducers::~EgammaHLTElectronTrackIsolationProducers ( )

Definition at line 64 of file EgammaHLTElectronTrackIsolationProducers.cc.

{}

Member Function Documentation

void EgammaHLTElectronTrackIsolationProducers::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 73 of file EgammaHLTElectronTrackIsolationProducers.cc.

References beamSpotProducer_, egTrkIsoConeSize_, egTrkIsoPtMin_, egTrkIsoRSpan_, egTrkIsoStripBarrel_, egTrkIsoStripEndcap_, egTrkIsoVetoConeSizeBarrel_, egTrkIsoVetoConeSizeEndcap_, egTrkIsoZSpan_, electronProducer_, edm::Event::getByLabel(), ElectronTkIsolation::getIso(), edm::AssociationMap< Tag >::insert(), edm::Handle< T >::product(), edm::Event::put(), recoEcalCandidateProducer_, trackProducer_, useGsfTrack_, and useSCRefs_.

{

  edm::Handle<reco::ElectronCollection> electronHandle;
  iEvent.getByLabel(electronProducer_,electronHandle);


 // Get the general tracks
  edm::Handle<reco::TrackCollection> trackHandle;
  iEvent.getByLabel(trackProducer_, trackHandle);
  const reco::TrackCollection* trackCollection = trackHandle.product();

  reco::ElectronIsolationMap eleMap;
  reco::RecoEcalCandidateIsolationMap recoEcalCandMap;

  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
  iEvent.getByLabel(beamSpotProducer_,recoBeamSpotHandle);
  
  const reco::BeamSpot::Point& beamSpotPosition = recoBeamSpotHandle->position(); 

  ElectronTkIsolation isoAlgo(egTrkIsoConeSize_,egTrkIsoVetoConeSizeBarrel_,egTrkIsoVetoConeSizeEndcap_,egTrkIsoStripBarrel_,egTrkIsoStripEndcap_,egTrkIsoPtMin_, egTrkIsoZSpan_ ,egTrkIsoRSpan_,trackCollection,beamSpotPosition);
  
  if(useSCRefs_){
    edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
    iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle);
    for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
      
      reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand-recoEcalCandHandle->begin());
      
      reco::ElectronRef eleRef;
      for(reco::ElectronCollection::const_iterator eleIt = electronHandle->begin(); eleIt != electronHandle->end(); eleIt++){
        if(eleIt->superCluster()==recoEcalCandRef->superCluster()){
          eleRef = reco::ElectronRef(electronHandle,eleIt - electronHandle->begin());
          break;
      }
      }
      float isol=999999;
      if(eleRef.isNonnull()){
        const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
        isol = isoAlgo.getIso(eleTrk).second;
      }
      recoEcalCandMap.insert(recoEcalCandRef,isol);
    }//end reco ecal candidate ref
  }else{ //we are going to loop over electron instead
    for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
      reco::ElectronRef eleRef(reco::ElectronRef(electronHandle,iElectron - electronHandle->begin()));
      const reco::Track* eleTrk = useGsfTrack_ ? &*eleRef->gsfTrack() : &*eleRef->track();
      float isol = isoAlgo.getIso(eleTrk).second;
      eleMap.insert(eleRef, isol);
    }
  }

  if(useSCRefs_){
    std::auto_ptr<reco::RecoEcalCandidateIsolationMap> mapForEvent(new reco::RecoEcalCandidateIsolationMap(recoEcalCandMap));
    iEvent.put(mapForEvent);
  }else{
    std::auto_ptr<reco::ElectronIsolationMap> mapForEvent(new reco::ElectronIsolationMap(eleMap));
    iEvent.put(mapForEvent);
  }
  

}

Member Data Documentation