CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaTowerExtractor.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 //C++ includes
00009 #include <vector>
00010 #include <functional>
00011 #include <math.h>
00012 
00013 //ROOT includes
00014 #include <Math/VectorUtil.h>
00015 
00016 
00017 //CMSSW includes
00018 #include "RecoEgamma/EgammaIsolationAlgos/plugins/EgammaTowerExtractor.h"
00019 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00020 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00021 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00022 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00023 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00024 #include "DataFormats/CaloTowers/interface/CaloTower.h"
00025 
00026 using namespace ROOT::Math::VectorUtil ;
00027 
00028 using namespace egammaisolation;
00029 using namespace reco::isodeposit;
00030 
00031 EgammaTowerExtractor::~EgammaTowerExtractor(){}
00032 
00033 reco::IsoDeposit EgammaTowerExtractor::deposit(const edm::Event & iEvent, 
00034         const edm::EventSetup & iSetup, const reco::Candidate &emObject ) const {
00035 
00036     edm::Handle<CaloTowerCollection> towercollectionH;
00037     iEvent.getByLabel(caloTowerTag_, towercollectionH);
00038  
00039     //Take the SC position
00040     reco::SuperClusterRef sc = emObject.get<reco::SuperClusterRef>();
00041     math::XYZPoint caloPosition = sc->position();
00042 
00043     Direction candDir(caloPosition.eta(), caloPosition.phi());
00044     reco::IsoDeposit deposit( candDir );
00045     deposit.setVeto( reco::IsoDeposit::Veto(candDir, intRadius_) ); 
00046     deposit.addCandEnergy(sc->energy()*sin(2*atan(exp(-sc->eta()))));
00047 
00048     //loop over tracks
00049     for(CaloTowerCollection::const_iterator trItr = towercollectionH->begin(), trEnd = towercollectionH->end(); trItr != trEnd; ++trItr){
00050       double depEt  = 0;
00051       //the hcal can be seperated into different depths
00052       //currently it is setup to check that the depth is valid in constructor
00053       //if the depth is not valid it fails gracefully
00054       //small bug fix, hadEnergyHeInnerLater returns zero for towers which are only depth 1
00055       //but we want Depth1 isolation to include these so we have to manually check for this
00056       if(depth_==AllDepths) depEt = trItr->hadEt();
00057       else if(depth_==Depth1) depEt = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEt() : trItr->hadEnergyHeInnerLayer()*sin(trItr->p4().theta());
00058       else if(depth_==Depth2) depEt = trItr->hadEnergyHeOuterLayer()*sin(trItr->p4().theta());
00059       
00060       if ( depEt < etLow_ )  continue ;  
00061       
00062 
00063         Direction towerDir( trItr->eta(), trItr->phi() );
00064         double dR2 = candDir.deltaR2(towerDir);
00065 
00066         if (dR2 < extRadius2_) {
00067             deposit.addDeposit( towerDir, depEt);
00068         }
00069 
00070     }//end loop over tracks
00071 
00072     return deposit;
00073 }
00074