CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoEgamma/EgammaIsolationAlgos/plugins/EgammaElectronTkIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaElectronTkIsolationProducer.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 
00010 // Framework
00011 #include "FWCore/Framework/interface/Event.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 #include "FWCore/Framework/interface/ESHandle.h"
00015 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00016 #include "FWCore/Utilities/interface/Exception.h"
00017 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00018 
00019 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00020 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00021 #include "DataFormats/Candidate/interface/CandAssociation.h"
00022 
00023 
00024 #include "RecoEgamma/EgammaIsolationAlgos/plugins/EgammaElectronTkIsolationProducer.h"
00025 #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
00026 
00027 EgammaElectronTkIsolationProducer::EgammaElectronTkIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00028 {
00029   // use configuration file to setup input/output collection names
00030   electronProducer_               = conf_.getParameter<edm::InputTag>("electronProducer");
00031   
00032   trackProducer_           = conf_.getParameter<edm::InputTag>("trackProducer");
00033   beamspotProducer_        = conf_.getParameter<edm::InputTag>("BeamspotProducer");
00034 
00035   ptMin_                = conf_.getParameter<double>("ptMin");
00036   intRadiusBarrel_      = conf_.getParameter<double>("intRadiusBarrel");
00037   intRadiusEndcap_      = conf_.getParameter<double>("intRadiusEndcap");
00038   stripBarrel_          = conf_.getParameter<double>("stripBarrel");
00039   stripEndcap_          = conf_.getParameter<double>("stripEndcap");
00040   extRadius_            = conf_.getParameter<double>("extRadius");
00041   maxVtxDist_           = conf_.getParameter<double>("maxVtxDist");
00042   drb_                  = conf_.getParameter<double>("maxVtxDistXY");
00043 
00044   //register your products
00045   produces < edm::ValueMap<double> >();
00046 
00047 }
00048 
00049 EgammaElectronTkIsolationProducer::~EgammaElectronTkIsolationProducer(){}
00050 
00051 
00052                                                                        
00053 void EgammaElectronTkIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00054 {
00055   // Get the  filtered objects
00056   edm::Handle< reco::GsfElectronCollection> electronHandle;
00057   iEvent.getByLabel(electronProducer_,electronHandle);
00058   
00059   //get the tracks
00060   edm::Handle<reco::TrackCollection> tracks;
00061   iEvent.getByLabel(trackProducer_,tracks);
00062   const reco::TrackCollection* trackCollection = tracks.product();
00063   
00064   //prepare product
00065   std::auto_ptr<edm::ValueMap<double> > isoMap(new edm::ValueMap<double>());
00066   edm::ValueMap<double>::Filler filler(*isoMap);
00067   std::vector<double> retV(electronHandle->size(),0);
00068  
00069   edm::Handle<reco::BeamSpot> beamSpotH;
00070   iEvent.getByLabel(beamspotProducer_,beamSpotH);
00071   reco::TrackBase::Point beamspot = beamSpotH->position();
00072  
00073   ElectronTkIsolation myTkIsolation (extRadius_,intRadiusBarrel_,intRadiusEndcap_,stripBarrel_,stripEndcap_,ptMin_,maxVtxDist_,drb_,trackCollection,beamspot) ;
00074   
00075   for(unsigned int i = 0 ; i < electronHandle->size(); ++i ){
00076     double isoValue = myTkIsolation.getPtTracks(&(electronHandle->at(i)));
00077     retV[i] = isoValue;
00078   }
00079   
00080   //fill and insert valuemap
00081   filler.insert(electronHandle,retV.begin(),retV.end());
00082   filler.fill();
00083   iEvent.put(isoMap);
00084 }