CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTHcalIsolationProducersRegional.cc

Go to the documentation of this file.
00001 
00009 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTHcalIsolationProducersRegional.h"
00010 #include "RecoEgamma/EgammaHLTAlgos/interface/EgammaHLTHcalIsolation.h"
00011 
00012 // Framework
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018 #include "FWCore/Utilities/interface/Exception.h"
00019 
00020 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00021 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00022 #include "DataFormats/Common/interface/RefToBase.h"
00023 #include "DataFormats/Common/interface/Ref.h"
00024 #include "DataFormats/Common/interface/RefProd.h"
00025 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00026 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00027 
00028 
00029 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00030 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00031 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00032 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00033 
00034 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00035 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00036 
00037 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00038 
00039 EgammaHLTHcalIsolationProducersRegional::EgammaHLTHcalIsolationProducersRegional(const edm::ParameterSet& config)
00040 {
00041  // use configuration file to setup input/output collection names
00042   recoEcalCandidateProducer_               = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00043 
00044   hbheRecHitProducer_           = config.getParameter<edm::InputTag>("hbheRecHitProducer");
00045   //hfRecHitProducer_           = conf_.getParameter<edm::InputTag>("hfRecHitProducer"); 
00046 
00047   
00048   double eMinHB               = config.getParameter<double>("eMinHB");
00049   double eMinHE               = config.getParameter<double>("eMinHE");
00050   double etMinHB              = config.getParameter<double>("etMinHB");  
00051   double etMinHE             = config.getParameter<double>("etMinHE");
00052 
00053   double innerCone            = config.getParameter<double>("innerCone");
00054   double outerCone            = config.getParameter<double>("outerCone");
00055   int depth = config.getParameter<int>("depth");
00056 
00057   doEtSum_ = config.getParameter<bool>("doEtSum");
00058   isolAlgo_ = new EgammaHLTHcalIsolation(eMinHB,eMinHE,etMinHB,etMinHE,innerCone,outerCone,depth);
00059  
00060   
00061   //register your products
00062   produces < reco::RecoEcalCandidateIsolationMap >();
00063 }
00064 
00065 EgammaHLTHcalIsolationProducersRegional::~EgammaHLTHcalIsolationProducersRegional()
00066 {
00067   delete isolAlgo_;
00068 }
00069 
00070 
00071 
00072 //
00073 // member functions
00074 //
00075 
00076 // ------------ method called to produce the data  ------------
00077 void
00078 EgammaHLTHcalIsolationProducersRegional::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00079 {
00080   
00081   // Get the HLT filtered objects
00082   edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
00083   iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle);
00084   // Get the barrel hcal hits
00085   edm::Handle<HBHERecHitCollection>  hbheRecHitHandle;
00086   iEvent.getByLabel(hbheRecHitProducer_, hbheRecHitHandle);
00087   const HBHERecHitCollection* hbheRecHitCollection = hbheRecHitHandle.product();
00088   
00089   edm::ESHandle<HcalChannelQuality> hcalChStatus;
00090   iSetup.get<HcalChannelQualityRcd>().get(hcalChStatus);
00091   
00092   edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComp;
00093   iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComp);
00094 
00095   
00096 
00097   // Get the forward hcal hits
00098   //edm::Handle<HFRecHitCollection> hhitEndcapHandle;
00099   //iEvent.getByLabel(hfRecHitProducer_, hhitEndcapHandle);
00100   //const HFRecHitCollection* hcalhitEndcapCollection = hhitEndcapHandle.product();
00101   //Get Calo Geometry
00102   
00103   edm::ESHandle<CaloGeometry> caloGeomHandle;
00104   iSetup.get<CaloGeometryRecord>().get(caloGeomHandle);
00105   const CaloGeometry* caloGeom = caloGeomHandle.product();
00106   
00107   reco::RecoEcalCandidateIsolationMap isoMap;
00108   
00109    
00110   for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
00111     
00112     reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand -recoEcalCandHandle ->begin());
00113     
00114     float isol = 0;
00115     if(doEtSum_) isol = isolAlgo_->getEtSum(recoEcalCandRef->superCluster()->eta(),
00116                                             recoEcalCandRef->superCluster()->phi(),hbheRecHitCollection,caloGeom,
00117                                             hcalSevLvlComp.product(),hcalChStatus.product());
00118     else isol = isolAlgo_->getESum(recoEcalCandRef->superCluster()->eta(),recoEcalCandRef->superCluster()->phi(),
00119                                    hbheRecHitCollection,caloGeom,
00120                                    hcalSevLvlComp.product(),hcalChStatus.product());
00121     
00122     isoMap.insert(recoEcalCandRef, isol);
00123     
00124   }
00125 
00126   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00127   iEvent.put(isolMap);
00128 
00129 }
00130 
00131 //define this as a plug-in
00132 //DEFINE_FWK_MODULE(EgammaHLTHcalIsolationProducersRegional);