CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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   hbheRecHitProducer_        = config.getParameter<edm::InputTag>("hbheRecHitProducer");
00044   rhoProducer_               = config.getParameter<edm::InputTag>("rhoProducer");
00045   doRhoCorrection_           = config.getParameter<bool>("doRhoCorrection");
00046   rhoMax_                    = config.getParameter<double>("rhoMax"); 
00047   rhoScale_                  = config.getParameter<double>("rhoScale"); 
00048   
00049   double eMinHB              = config.getParameter<double>("eMinHB");
00050   double eMinHE              = config.getParameter<double>("eMinHE");
00051   double etMinHB             = config.getParameter<double>("etMinHB");  
00052   double etMinHE             = config.getParameter<double>("etMinHE");
00053   double innerCone           = config.getParameter<double>("innerCone");
00054   double outerCone           = config.getParameter<double>("outerCone");
00055   int depth                  = config.getParameter<int>("depth");
00056   doEtSum_                   = config.getParameter<bool>("doEtSum");
00057   effectiveAreaBarrel_       = config.getParameter<double>("effectiveAreaBarrel");
00058   effectiveAreaEndcap_       = config.getParameter<double>("effectiveAreaEndcap");
00059   isolAlgo_                  = new EgammaHLTHcalIsolation(eMinHB,eMinHE,etMinHB,etMinHE,innerCone,outerCone,depth);
00060  
00061   
00062   //register your products
00063   produces < reco::RecoEcalCandidateIsolationMap >();  
00064 }
00065 
00066 EgammaHLTHcalIsolationProducersRegional::~EgammaHLTHcalIsolationProducersRegional()
00067 {
00068   delete isolAlgo_;
00069 }
00070 
00071 
00072 
00073 //
00074 // member functions
00075 //
00076 
00077 // ------------ method called to produce the data  ------------
00078 void
00079 EgammaHLTHcalIsolationProducersRegional::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00080 {
00081   
00082   // Get the HLT filtered objects
00083   edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
00084   iEvent.getByLabel(recoEcalCandidateProducer_,recoEcalCandHandle);
00085 
00086   // Get the barrel hcal hits
00087   edm::Handle<HBHERecHitCollection>  hbheRecHitHandle;
00088   iEvent.getByLabel(hbheRecHitProducer_, hbheRecHitHandle);
00089   const HBHERecHitCollection* hbheRecHitCollection = hbheRecHitHandle.product();
00090   
00091   edm::ESHandle<HcalChannelQuality> hcalChStatus;
00092   iSetup.get<HcalChannelQualityRcd>().get(hcalChStatus);
00093   
00094   edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComp;
00095   iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComp);
00096 
00097   edm::Handle<double> rhoHandle;
00098   double rho = 0.0;
00099   if (doRhoCorrection_) {
00100     iEvent.getByLabel(rhoProducer_, rhoHandle);
00101     rho = *(rhoHandle.product());
00102   }
00103 
00104   if (rho > rhoMax_)
00105     rho = rhoMax_;
00106 
00107   rho = rho*rhoScale_;
00108 
00109   edm::ESHandle<CaloGeometry> caloGeomHandle;
00110   iSetup.get<CaloGeometryRecord>().get(caloGeomHandle);
00111   const CaloGeometry* caloGeom = caloGeomHandle.product();
00112   
00113   reco::RecoEcalCandidateIsolationMap isoMap;
00114   
00115    
00116   for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoEcalCandHandle->begin(); iRecoEcalCand != recoEcalCandHandle->end(); iRecoEcalCand++){
00117     
00118     reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle,iRecoEcalCand -recoEcalCandHandle ->begin());
00119     
00120     float isol = 0;
00121     if(doEtSum_) {
00122       isol = isolAlgo_->getEtSum(recoEcalCandRef->superCluster()->eta(),
00123                                  recoEcalCandRef->superCluster()->phi(),hbheRecHitCollection,caloGeom,
00124                                  hcalSevLvlComp.product(),hcalChStatus.product());      
00125      
00126       if (doRhoCorrection_) {
00127         if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442) 
00128           isol = isol - rho*effectiveAreaBarrel_;
00129         else
00130           isol = isol - rho*effectiveAreaEndcap_;
00131       }
00132     } else {
00133       isol = isolAlgo_->getESum(recoEcalCandRef->superCluster()->eta(),recoEcalCandRef->superCluster()->phi(),
00134                                 hbheRecHitCollection,caloGeom,
00135                                 hcalSevLvlComp.product(),hcalChStatus.product());      
00136     }
00137 
00138     isoMap.insert(recoEcalCandRef, isol);   
00139   }
00140 
00141   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00142   iEvent.put(isolMap);
00143 
00144 }
00145 
00146 //define this as a plug-in
00147 //DEFINE_FWK_MODULE(EgammaHLTHcalIsolationProducersRegional);