00001 //***************************************************************************** 00002 // File: EgammaPhotonTkNumIsolationProducer.cc 00003 // ---------------------------------------------------------------------------- 00004 // OrigAuth: Matthias Mozer 00005 // Institute: IIHE-VUB 00006 //============================================================================= 00007 //***************************************************************************** 00008 00009 00010 #include "EgammaAnalysis/EgammaIsolationProducers/interface/EgammaPhotonTkNumIsolationProducer.h" 00011 00012 // Framework 00013 #include "DataFormats/Common/interface/Handle.h" 00014 00015 #include "DataFormats/Candidate/interface/Candidate.h" 00016 #include "DataFormats/Candidate/interface/CandAssociation.h" 00017 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00018 00019 #include "RecoEgamma/EgammaIsolationAlgos/interface/PhotonTkIsolation.h" 00020 00021 00022 EgammaPhotonTkNumIsolationProducer::EgammaPhotonTkNumIsolationProducer(const edm::ParameterSet& config) : conf_(config) 00023 { 00024 // use configuration file to setup input/output collection names 00025 photonProducer_ = conf_.getParameter<edm::InputTag>("photonProducer"); 00026 00027 trackProducer_ = conf_.getParameter<edm::InputTag>("trackProducer"); 00028 00029 ptMin_ = conf_.getParameter<double>("ptMin"); 00030 intRadius_ = conf_.getParameter<double>("intRadius"); 00031 extRadius_ = conf_.getParameter<double>("extRadius"); 00032 maxVtxDist_ = conf_.getParameter<double>("maxVtxDist"); 00033 00034 //register your products 00035 produces < reco::CandViewIntAssociations >(); 00036 } 00037 00038 00039 EgammaPhotonTkNumIsolationProducer::~EgammaPhotonTkNumIsolationProducer(){} 00040 00041 00042 // 00043 // member functions 00044 // 00045 00046 // ------------ method called to produce the data ------------ 00047 void 00048 EgammaPhotonTkNumIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) 00049 { 00050 00051 // Get the filtered objects 00052 edm::Handle< edm::View<reco::Candidate> > photonHandle; 00053 iEvent.getByLabel(photonProducer_,photonHandle); 00054 00055 //get the tracks 00056 edm::Handle<reco::TrackCollection> tracks; 00057 iEvent.getByLabel(trackProducer_,tracks); 00058 const reco::TrackCollection* trackCollection = tracks.product(); 00059 00060 reco::CandViewIntAssociations* isoMap = new reco::CandViewIntAssociations( reco::CandidateBaseRefProd( photonHandle ) ); 00061 00062 PhotonTkIsolation myTkIsolation (extRadius_,intRadius_,ptMin_,maxVtxDist_,trackCollection) ; 00063 00064 for(unsigned int i = 0 ; i < photonHandle->size(); ++i ){ 00065 int isoValue = myTkIsolation.getNumberTracks(&(photonHandle->at(i))); 00066 isoMap->setValue(i,isoValue); 00067 } 00068 00069 00070 00071 std::auto_ptr<reco::CandViewIntAssociations> isolMap(isoMap); 00072 iEvent.put(isolMap); 00073 00074 } 00075 00076