CMS 3D CMS Logo

EgammaElectronTkNumIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaElectronTkNumIsolationProducer.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 
00018 #include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h"
00019 #include "DataFormats/Candidate/interface/CandAssociation.h"
00020 
00021 
00022 #include "EgammaAnalysis/EgammaIsolationProducers/interface/EgammaElectronTkNumIsolationProducer.h"
00023 #include "RecoEgamma/EgammaIsolationAlgos/interface/ElectronTkIsolation.h"
00024 
00025 EgammaElectronTkNumIsolationProducer::EgammaElectronTkNumIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00026 {
00027   // use configuration file to setup input/output collection names
00028   electronProducer_               = conf_.getParameter<edm::InputTag>("electronProducer");
00029   
00030   trackProducer_           = conf_.getParameter<edm::InputTag>("trackProducer");
00031 
00032   ptMin_                = conf_.getParameter<double>("ptMin");
00033   intRadius_            = conf_.getParameter<double>("intRadius");
00034   extRadius_            = conf_.getParameter<double>("extRadius");
00035   maxVtxDist_           = conf_.getParameter<double>("maxVtxDist");
00036 
00037   //register your products
00038   produces < reco::CandViewDoubleAssociations>();
00039 
00040 }
00041 
00042 EgammaElectronTkNumIsolationProducer::~EgammaElectronTkNumIsolationProducer(){}
00043 
00044 
00045                                                                        
00046 void EgammaElectronTkNumIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00047 {
00048   // Get the  filtered objects
00049   edm::Handle< reco::PixelMatchGsfElectronCollection> electronHandle;
00050   iEvent.getByLabel(electronProducer_,electronHandle);
00051   
00052   //get the tracks
00053   edm::Handle<reco::TrackCollection> tracks;
00054   iEvent.getByLabel(trackProducer_,tracks);
00055   const reco::TrackCollection* trackCollection = tracks.product();
00056   
00057   reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations(reco::PixelMatchGsfElectronRefProd( electronHandle ));
00058   
00059   ElectronTkIsolation myTkIsolation (extRadius_,intRadius_,ptMin_,maxVtxDist_,trackCollection) ;
00060   
00061   for(unsigned int i = 0 ; i < electronHandle->size(); ++i ){
00062     int isoValue = myTkIsolation.getNumberTracks(&(electronHandle->at(i)));
00063     isoMap->setValue(i,isoValue);    
00064   }
00065   
00066   std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
00067   iEvent.put(isolMap);
00068 }

Generated on Tue Jun 9 17:34:16 2009 for CMSSW by  doxygen 1.5.4