CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTBcHcalIsolationProducersRegional.cc

Go to the documentation of this file.
00001 /* \class EgammaHLTBcHcalIsolationProducersRegional
00002  *
00003  * \author Matteo Sani (UCSD)
00004  *
00005  */
00006 
00007 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTBcHcalIsolationProducersRegional.h"
00008 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h"
00009 
00010 #include "FWCore/Framework/interface/Event.h"
00011 #include "FWCore/Framework/interface/EventSetup.h"
00012 #include "DataFormats/Common/interface/Handle.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00015 #include "FWCore/Utilities/interface/Exception.h"
00016 
00017 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00018 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00019 #include "DataFormats/Common/interface/RefToBase.h"
00020 #include "DataFormats/Common/interface/Ref.h"
00021 #include "DataFormats/Common/interface/RefProd.h"
00022 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00023 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00024 
00025 
00026 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputer.h"
00027 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalSeverityLevelComputerRcd.h"
00028 #include "CondFormats/HcalObjects/interface/HcalChannelQuality.h"
00029 #include "CondFormats/DataRecord/interface/HcalChannelQualityRcd.h"
00030 
00031 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00032 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00033 
00034 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00035 
00036 EgammaHLTBcHcalIsolationProducersRegional::EgammaHLTBcHcalIsolationProducersRegional(const edm::ParameterSet& config) {
00037 
00038   recoEcalCandidateProducer_ = config.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00039   caloTowerProducer_         = config.getParameter<edm::InputTag>("caloTowerProducer");
00040   rhoProducer_               = config.getParameter<edm::InputTag>("rhoProducer");
00041   doRhoCorrection_           = config.getParameter<bool>("doRhoCorrection");
00042   rhoMax_                    = config.getParameter<double>("rhoMax"); 
00043   rhoScale_                  = config.getParameter<double>("rhoScale"); 
00044 
00045   etMin_                     = config.getParameter<double>("etMin");  
00046   innerCone_                 = config.getParameter<double>("innerCone");
00047   outerCone_                 = config.getParameter<double>("outerCone");
00048   depth_                     = config.getParameter<int>("depth");
00049   doEtSum_                   = config.getParameter<bool>("doEtSum"); //this variable (which I cant change the name of) switches between hcal isolation and H for H/E
00050   effectiveAreaBarrel_       = config.getParameter<double>("effectiveAreaBarrel");
00051   effectiveAreaEndcap_       = config.getParameter<double>("effectiveAreaEndcap");
00052   
00053   hcalCfg_.hOverEConeSize = 0.15;
00054   hcalCfg_.useTowers = true;
00055   hcalCfg_.hcalTowers = caloTowerProducer_;
00056   hcalCfg_.hOverEPtMin = etMin_;
00057 
00058   hcalHelper_ = new ElectronHcalHelper(hcalCfg_);
00059 
00060   produces <reco::RecoEcalCandidateIsolationMap>(); 
00061 }
00062 
00063 EgammaHLTBcHcalIsolationProducersRegional::~EgammaHLTBcHcalIsolationProducersRegional() {
00064   delete hcalHelper_;
00065 }
00066 
00067 
00068 void EgammaHLTBcHcalIsolationProducersRegional::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00069 
00070   // Get the HLT filtered objects
00071   edm::Handle<reco::RecoEcalCandidateCollection> recoEcalCandHandle;
00072   iEvent.getByLabel(recoEcalCandidateProducer_, recoEcalCandHandle);
00073 
00074   edm::Handle<CaloTowerCollection> caloTowersHandle;
00075   iEvent.getByLabel(caloTowerProducer_, caloTowersHandle);
00076 
00077   edm::Handle<double> rhoHandle;
00078   double rho = 0.0;
00079 
00080   if (doRhoCorrection_) {
00081     iEvent.getByLabel(rhoProducer_, rhoHandle);
00082     rho = *(rhoHandle.product());
00083   }
00084 
00085   if (rho > rhoMax_)
00086     rho = rhoMax_;
00087   
00088   rho = rho*rhoScale_;
00089   
00090   hcalHelper_->checkSetup(iSetup);
00091   hcalHelper_->readEvent(iEvent);
00092 
00093   reco::RecoEcalCandidateIsolationMap isoMap;
00094   
00095   for(unsigned int iRecoEcalCand=0; iRecoEcalCand <recoEcalCandHandle->size(); iRecoEcalCand++) {
00096     
00097     reco::RecoEcalCandidateRef recoEcalCandRef(recoEcalCandHandle, iRecoEcalCand);
00098     
00099     float isol = 0;
00100     
00101     std::vector<CaloTowerDetId> towersBehindCluster = hcalHelper_->hcalTowersBehindClusters(*(recoEcalCandRef->superCluster()));
00102     
00103     if (doEtSum_) { //calculate hcal isolation excluding the towers behind the cluster which will be used for H for H/E
00104       EgammaTowerIsolation isolAlgo(outerCone_, innerCone_, etMin_, depth_, caloTowersHandle.product());
00105       isol = isolAlgo.getTowerEtSum(&(*recoEcalCandRef), &(towersBehindCluster)); // towersBehindCluster are excluded from the isolation sum
00106       
00107       if (doRhoCorrection_) {
00108         if (fabs(recoEcalCandRef->superCluster()->eta()) < 1.442) 
00109           isol = isol - rho*effectiveAreaBarrel_;
00110         else
00111           isol = isol - rho*effectiveAreaEndcap_;
00112       }
00113     } else { //calcuate H for H/E
00114       isol = hcalHelper_->hcalESumDepth1BehindClusters(towersBehindCluster) + hcalHelper_->hcalESumDepth2BehindClusters(towersBehindCluster); //towers beind the cluster are for H for H/E
00115     }
00116 
00117     isoMap.insert(recoEcalCandRef, isol);
00118   }
00119   
00120   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
00121   iEvent.put(isolMap);
00122 }