CMS 3D CMS Logo

EgammaPhotonTkIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaPhotonTkIsolationProducer.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 
00010 #include "EgammaAnalysis/EgammaIsolationProducers/interface/EgammaPhotonTkIsolationProducer.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 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00019 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00020 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00021 
00022 #include "RecoEgamma/EgammaIsolationAlgos/interface/PhotonTkIsolation.h"
00023 
00024 
00025 EgammaPhotonTkIsolationProducer::EgammaPhotonTkIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00026 {
00027  // use configuration file to setup input/output collection names
00028   photonProducer_               = conf_.getParameter<edm::InputTag>("photonProducer");
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   absolut_              = conf_.getParameter<bool>("absolut");
00037 
00038   //register your products
00039   produces < reco::CandViewDoubleAssociations >();
00040 }
00041 
00042 
00043 EgammaPhotonTkIsolationProducer::~EgammaPhotonTkIsolationProducer(){}
00044 
00045 
00046 //
00047 // member functions
00048 //
00049 
00050 // ------------ method called to produce the data  ------------
00051 void
00052 EgammaPhotonTkIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00053 {
00054   
00055   // Get the  filtered objects
00056   edm::Handle< edm::View<reco::Candidate> > photonHandle;
00057   iEvent.getByLabel(photonProducer_,photonHandle);
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   reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( photonHandle ) );
00065 
00066   PhotonTkIsolation myTkIsolation (extRadius_,intRadius_,ptMin_,maxVtxDist_,trackCollection) ;
00067 
00068   for(unsigned int i = 0 ; i < photonHandle->size(); ++i ){
00069     double isoValue = myTkIsolation.getPtTracks(&(photonHandle->at(i)));
00070     if(absolut_==true){
00071       isoMap->setValue(i,isoValue);
00072     }
00073     else{
00074       reco::SuperClusterRef sc = (photonHandle->at(i)).get<reco::SuperClusterRef>();
00075       double et = sc.get()->energy()*sin(2*atan(exp(-sc.get()->eta())));
00076       isoMap->setValue(i,isoValue/et);
00077     }
00078   }
00079    
00080 
00081 
00082   std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
00083   iEvent.put(isolMap);
00084 
00085 }
00086 
00087 

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