Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <vector>
00010 #include <functional>
00011 #include <math.h>
00012
00013
00014 #include <Math/VectorUtil.h>
00015
00016
00017
00018 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.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/CaloTowers/interface/CaloTower.h"
00023 #include "FWCore/Utilities/interface/Exception.h"
00024
00025 using namespace ROOT::Math::VectorUtil ;
00026
00027 EgammaTowerIsolation::EgammaTowerIsolation (double extRadius,
00028 double intRadius,
00029 double etLow,
00030 signed int depth,
00031 const CaloTowerCollection* towercollection) :
00032 extRadius_(extRadius),
00033 intRadius_(intRadius),
00034 etLow_(etLow),
00035 depth_(depth),
00036 towercollection_(towercollection)
00037 {
00038 }
00039
00040 EgammaTowerIsolation::~EgammaTowerIsolation ()
00041 {
00042 }
00043
00044
00045
00046
00047 double EgammaTowerIsolation::getTowerEtSum(const reco::Candidate* photon, const std::vector<CaloTowerDetId> * detIdToExclude ) const
00048 {
00049 return getTowerEtSum( photon->get<reco::SuperClusterRef>().get(), detIdToExclude );
00050 }
00051
00052 double EgammaTowerIsolation::getTowerEtSum(const reco::SuperCluster* sc, const std::vector<CaloTowerDetId> * detIdToExclude ) const
00053 {
00054 math::XYZPoint theCaloPosition = sc->position();
00055 double candEta=sc->eta();
00056 double candPhi=sc->phi();
00057 double ptSum =0.;
00058
00059
00060 for(CaloTowerCollection::const_iterator trItr = towercollection_->begin(); trItr != towercollection_->end(); ++trItr){
00061
00062
00063 if ( detIdToExclude )
00064 {
00065 std::vector<CaloTowerDetId>::const_iterator itcheck=find(detIdToExclude->begin(),detIdToExclude->end(),trItr->id());
00066 if (itcheck != detIdToExclude->end())
00067 continue;
00068 }
00069
00070 double this_pt=0;
00071 switch(depth_){
00072 case AllDepths: this_pt = trItr->hadEt();break;
00073 case Depth1: this_pt = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEt() : trItr->hadEnergyHeInnerLayer()*sin(trItr->p4().theta());break;
00074 case Depth2: this_pt = trItr->hadEnergyHeOuterLayer()*sin(trItr->p4().theta());break;
00075 default: throw cms::Exception("Configuration Error") << "EgammaTowerIsolation: Depth " << depth_ << " not known. "; break;
00076 }
00077
00078 if ( this_pt < etLow_ )
00079 continue ;
00080
00081 double towerEta=trItr->eta();
00082 double towerPhi=trItr->phi();
00083 double twoPi= 2*M_PI;
00084 if(towerPhi<0) towerPhi+=twoPi;
00085 if(candPhi<0) candPhi+=twoPi;
00086 double deltaPhi=fabs(towerPhi-candPhi);
00087 if(deltaPhi>twoPi) deltaPhi-=twoPi;
00088 if(deltaPhi>M_PI) deltaPhi=twoPi-deltaPhi;
00089 double deltaEta = towerEta - candEta;
00090
00091 double dr = deltaEta*deltaEta + deltaPhi*deltaPhi;
00092 if( dr < extRadius_*extRadius_ &&
00093 dr >= intRadius_*intRadius_ )
00094 { ptSum += this_pt ; }
00095
00096 }
00097
00098 return ptSum ;
00099
00100 }
00101
00102
00103 double EgammaTowerIsolation::getTowerESum(const reco::Candidate* photon, const std::vector<CaloTowerDetId> * detIdToExclude ) const
00104 {
00105 return getTowerESum( photon->get<reco::SuperClusterRef>().get(), detIdToExclude );
00106 }
00107
00108 double EgammaTowerIsolation::getTowerESum(const reco::SuperCluster* sc, const std::vector<CaloTowerDetId> * detIdToExclude ) const
00109 {
00110 math::XYZPoint theCaloPosition = sc->position();
00111 double candEta=sc->eta();
00112 double candPhi=sc->phi();
00113 double eSum =0.;
00114
00115
00116 for(CaloTowerCollection::const_iterator trItr = towercollection_->begin(); trItr != towercollection_->end(); ++trItr){
00117
00118
00119 if( detIdToExclude ) {
00120 std::vector<CaloTowerDetId>::const_iterator itcheck=find(detIdToExclude->begin(),detIdToExclude->end(),trItr->id());
00121 if (itcheck != detIdToExclude->end())
00122 continue;
00123 }
00124
00125 double this_e=0;
00126 switch(depth_){
00127 case AllDepths: this_e = trItr->hadEnergy();break;
00128 case Depth1: this_e = trItr->ietaAbs()<18 || trItr->ietaAbs()>29 ? trItr->hadEnergy() : trItr->hadEnergyHeInnerLayer();break;
00129 case Depth2: this_e = trItr->hadEnergyHeOuterLayer();break;
00130 default: throw cms::Exception("Configuration Error") << "EgammaTowerIsolation: Depth " << depth_ << " not known. "; break;
00131 }
00132
00133 if ( this_e*sin(trItr->p4().theta()) < etLow_ )
00134 continue ;
00135
00136 double towerEta=trItr->eta();
00137 double towerPhi=trItr->phi();
00138 double twoPi= 2*M_PI;
00139 if(towerPhi<0) towerPhi+=twoPi;
00140 if(candPhi<0) candPhi+=twoPi;
00141 double deltaPhi=fabs(towerPhi-candPhi);
00142 if(deltaPhi>twoPi) deltaPhi-=twoPi;
00143 if(deltaPhi>M_PI) deltaPhi=twoPi-deltaPhi;
00144 double deltaEta = towerEta - candEta;
00145
00146
00147 double dr = deltaEta*deltaEta + deltaPhi*deltaPhi;
00148 if( dr < extRadius_*extRadius_ &&
00149 dr >= intRadius_*intRadius_ )
00150 {
00151 eSum += this_e;
00152 }
00153
00154 }
00155
00156 return eSum;
00157 }
00158