CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTPhotonTrackIsolationProducersRegional.cc

Go to the documentation of this file.
00001 
00009 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTPhotonTrackIsolationProducersRegional.h"
00010 
00011 // Framework
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 #include "FWCore/Utilities/interface/Exception.h"
00018 
00019 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00020 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00021 
00022 #include "DataFormats/Common/interface/RefToBase.h"
00023 #include "DataFormats/Common/interface/Ref.h"
00024 #include "DataFormats/Common/interface/RefProd.h"
00025 
00026 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00027 #include "DataFormats/TrackReco/interface/Track.h"
00028 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00029 
00030 
00031 
00032 
00033 EgammaHLTPhotonTrackIsolationProducersRegional::EgammaHLTPhotonTrackIsolationProducersRegional(const edm::ParameterSet& config) : conf_(config)
00034 {
00035 
00036   recoEcalCandidateProducer_    = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00037   trackProducer_                = conf_.getParameter<edm::InputTag>("trackProducer");
00038 
00039   countTracks_                  = conf_.getParameter<bool>("countTracks");
00040 
00041   egTrkIsoPtMin_                = conf_.getParameter<double>("egTrkIsoPtMin");
00042   egTrkIsoConeSize_             = conf_.getParameter<double>("egTrkIsoConeSize");
00043   egTrkIsoZSpan_                = conf_.getParameter<double>("egTrkIsoZSpan");
00044   egTrkIsoRSpan_                = conf_.getParameter<double>("egTrkIsoRSpan");
00045   egTrkIsoVetoConeSize_         = conf_.getParameter<double>("egTrkIsoVetoConeSize");
00046  double egTrkIsoStripBarrel    = conf_.getParameter<double>("egTrkIsoStripBarrel");
00047   double egTrkIsoStripEndcap    = conf_.getParameter<double>("egTrkIsoStripEndcap");
00048 
00049   test_ = new EgammaHLTTrackIsolation(egTrkIsoPtMin_,egTrkIsoConeSize_,
00050                                       egTrkIsoZSpan_,egTrkIsoRSpan_,egTrkIsoVetoConeSize_,
00051                                       egTrkIsoStripBarrel,egTrkIsoStripEndcap);
00052 
00053 
00054   //register your products
00055   produces < reco::RecoEcalCandidateIsolationMap >();
00056 
00057 }
00058 
00059 
00060 EgammaHLTPhotonTrackIsolationProducersRegional::~EgammaHLTPhotonTrackIsolationProducersRegional(){delete test_;}
00061 
00062 
00063 //
00064 // member functions
00065 //
00066 
00067 // ------------ method called to produce the data  ------------
00068 void
00069 EgammaHLTPhotonTrackIsolationProducersRegional::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00070 {
00071 
00072   // Get the HLT filtered objects
00073   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
00074   iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
00075 
00076  // Get the barrel hcal hits
00077   edm::Handle<reco::TrackCollection> trackHandle;
00078   iEvent.getByLabel(trackProducer_, trackHandle);
00079   const reco::TrackCollection* trackCollection = trackHandle.product();
00080 
00081 
00082   reco::RecoEcalCandidateIsolationMap isoMap;
00083 
00084 
00085 
00086  for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
00087     
00088     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin());
00089     const reco::RecoCandidate *tempiRecoEcalCand = &(*recoecalcandref);
00090 
00091     bool usePhotonVertex = false;
00092      
00093     float isol;
00094     if (countTracks_) {
00095       isol = test_->photonTrackCount(tempiRecoEcalCand,trackCollection,usePhotonVertex);
00096     } else {
00097       isol = test_->photonPtSum(tempiRecoEcalCand,trackCollection,usePhotonVertex);
00098     }
00099 
00100     isoMap.insert(recoecalcandref, isol);
00101 
00102   }
00103 
00104   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00105   iEvent.put(isolMap);
00106 
00107 }
00108 
00109 //define this as a plug-in
00110 //DEFINE_FWK_MODULE(EgammaHLTTrackIsolationProducers);