CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationDoubleConeProducers.cc

Go to the documentation of this file.
00001 
00011 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationDoubleConeProducers.h"
00012 
00013 // Framework
00014 #include "FWCore/Framework/interface/Event.h"
00015 #include "FWCore/Framework/interface/EventSetup.h"
00016 // For160 #include "FWCore/Framework/interface/Handle.h"
00017 #include "DataFormats/Common/interface/Handle.h" //For160
00018 #include "FWCore/Framework/interface/ESHandle.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 #include "FWCore/Utilities/interface/Exception.h"
00021 
00022 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00023 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00024 
00025 #include "DataFormats/Common/interface/RefToBase.h"
00026 #include "DataFormats/Common/interface/Ref.h"
00027 #include "DataFormats/Common/interface/RefProd.h"
00028 
00029 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00030 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00031 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00032 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00033 
00034 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00035 
00036 EgammaHLTHcalIsolationDoubleConeProducers::EgammaHLTHcalIsolationDoubleConeProducers(const edm::ParameterSet& config) : conf_(config)
00037 {
00038  // use configuration file to setup input/output collection names
00039   recoEcalCandidateProducer_               = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00040 
00041   hbRecHitProducer_           = conf_.getParameter<edm::InputTag>("hbRecHitProducer");
00042   hfRecHitProducer_           = conf_.getParameter<edm::InputTag>("hfRecHitProducer");
00043 
00044   egHcalIsoPtMin_               = conf_.getParameter<double>("egHcalIsoPtMin");
00045   egHcalIsoConeSize_            = conf_.getParameter<double>("egHcalIsoConeSize");
00046   egHcalExclusion_            = conf_.getParameter<double>("egHcalExclusion");
00047 
00048   test_ = new EgammaHLTHcalIsolationDoubleCone(egHcalIsoPtMin_,egHcalIsoConeSize_,egHcalExclusion_);
00049 
00050 
00051   //register your products
00052   produces < reco::RecoEcalCandidateIsolationMap >();
00053 }
00054 
00055 
00056 EgammaHLTHcalIsolationDoubleConeProducers::~EgammaHLTHcalIsolationDoubleConeProducers(){delete test_;}
00057 
00058 
00059 //
00060 // member functions
00061 //
00062 
00063 // ------------ method called to produce the data  ------------
00064 void
00065 EgammaHLTHcalIsolationDoubleConeProducers::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00066 {
00067   //  std::cout << "YYY" << egHcalIsoConeSize_  << "  " << egHcalExclusion_ <<std::endl;
00068   // Get the HLT filtered objects
00069   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
00070   iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
00071   
00072   // Get the barrel hcal hits
00073   edm::Handle<HBHERecHitCollection> hhitBarrelHandle;
00074   iEvent.getByLabel(hbRecHitProducer_, hhitBarrelHandle);
00075   const HBHERecHitCollection* hcalhitBarrelCollection = hhitBarrelHandle.product();
00076   // Get the forward hcal hits
00077   edm::Handle<HFRecHitCollection> hhitEndcapHandle;
00078   iEvent.getByLabel(hfRecHitProducer_, hhitEndcapHandle);
00079   const HFRecHitCollection* hcalhitEndcapCollection = hhitEndcapHandle.product();
00080   //Get Calo Geometry
00081   edm::ESHandle<CaloGeometry> pG;
00082   iSetup.get<CaloGeometryRecord>().get(pG);
00083   const CaloGeometry* caloGeom = pG.product();
00084   
00085   reco::RecoEcalCandidateIsolationMap isoMap;
00086   
00087    
00088   for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
00089     
00090     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand -recoecalcandHandle ->begin());
00091     
00092     const reco::RecoCandidate *tempiRecoEcalCand = &(*recoecalcandref);
00093     float isol =  test_->isolPtSum(tempiRecoEcalCand,hcalhitBarrelCollection,hcalhitEndcapCollection,caloGeom);
00094     
00095     isoMap.insert(recoecalcandref, isol);
00096     //    std::cout << isol << std::endl;
00097   }
00098 
00099   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00100   iEvent.put(isolMap);
00101 
00102 }
00103 
00104 //define this as a plug-in
00105 //DEFINE_FWK_MODULE(EgammaHLTHcalIsolationDoubleConeProducers);