CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoEgamma/EgammaIsolationAlgos/src/EgammaHcalIsolation.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaHcalIsolation.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 //C++ includes
00009 #include <vector>
00010 #include <functional>
00011 
00012 //ROOT includes
00013 #include <Math/VectorUtil.h>
00014 
00015 //CMSSW includes
00016 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaHcalIsolation.h"
00017 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00018 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00019 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00020 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
00021 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00022 
00023 using namespace std;
00024 
00025 double scaleToE(const double& eta) { return 1.0; }
00026 double scaleToEt(const double& eta) { return sin(2*atan(exp(-eta))); }
00027 
00028 EgammaHcalIsolation::EgammaHcalIsolation (
00029         double extRadius,
00030         double intRadius,
00031         double eLowB,
00032         double eLowE,
00033         double etLowB,
00034         double etLowE,
00035         edm::ESHandle<CaloGeometry> theCaloGeom ,
00036         HBHERecHitMetaCollection*  mhbhe
00037 ) :
00038   extRadius_(extRadius),
00039   intRadius_(intRadius),
00040   eLowB_(eLowB),
00041   eLowE_(eLowE),
00042   etLowB_(etLowB),
00043   etLowE_(etLowE),
00044   theCaloGeom_(theCaloGeom) ,  
00045   mhbhe_(mhbhe)
00046 {
00047     //set up the geometry and selector
00048     const CaloGeometry* caloGeom = theCaloGeom_.product();
00049     doubleConeSel_ = new CaloDualConeSelector (intRadius_ ,extRadius_, caloGeom, DetId::Hcal);
00050 }
00051 
00052 EgammaHcalIsolation::~EgammaHcalIsolation ()
00053 {
00054     delete doubleConeSel_;
00055 }
00056 
00057 double EgammaHcalIsolation::getHcalSum(const GlobalPoint &pclu, const HcalDepth &depth,
00058                                        double(*scale)(const double&) ) const
00059 {
00060     double sum = 0.;
00061     if (mhbhe_) 
00062     {
00063         //Compute the HCAL energy behind ECAL
00064         double eta;
00065         std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_->select(pclu,*mhbhe_);
00066         CaloRecHitMetaCollectionV::const_iterator i;
00067         for (i = chosen->begin () ; i!= chosen->end () ; ++i) 
00068         {
00069             eta = theCaloGeom_.product()->getPosition(i->detid()).eta();
00070             HcalDetId hcalDetId(i->detid());
00071             if(hcalDetId.subdet() == HcalBarrel &&              //Is it in the barrel?
00072                i->energy() > eLowB_ &&                          //Does it pass the min energy?
00073                i->energy()*scaleToEt(eta) > etLowB_ &&          //Does it pass the min et?
00074                (depth == AllDepths || depth == Depth1)) {                    //Are we asking for the first depth?
00075                     sum += i->energy() * scale(eta);
00076             }
00077             if(hcalDetId.subdet() == HcalEndcap &&              //Is it in the endcap?
00078                i->energy() > eLowE_ &&                          //Does it pass the min energy?
00079                i->energy()*scaleToEt(eta) > etLowE_ ) {         //Does it pass the min et?
00080                switch(depth) {                                  //Which depth?
00081                     case AllDepths: sum += i->energy() * scale(eta); break;
00082                     case Depth1: sum += (isDepth2(i->detid())) ? 0 : i->energy() * scale(eta); break;
00083                     case Depth2: sum += (isDepth2(i->detid())) ? i->energy() * scale(eta) : 0; break;
00084                }
00085             }
00086         }
00087     } 
00088     return sum ;
00089 }
00090 
00091 bool EgammaHcalIsolation::isDepth2(const DetId& detId) const {
00092     
00093     if( (HcalDetId(detId).depth()==2 && HcalDetId(detId).ietaAbs()>=18 && HcalDetId(detId).ietaAbs()<27) ||
00094         (HcalDetId(detId).depth()==3 && HcalDetId(detId).ietaAbs()==27) ) {
00095 
00096         return true;
00097 
00098    } else {
00099         return false;
00100    }
00101 }