CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/RecoEgamma/EgammaIsolationAlgos/plugins/EgammaPhotonTkNumIsolationProducer.cc

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