Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <vector>
00010 #include <functional>
00011
00012
00013 #include <Math/VectorUtil.h>
00014
00015
00016 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaRecHitIsolation.h"
00017 #include "DataFormats/DetId/interface/DetId.h"
00018 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00019 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00020 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00021 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00022 #include "DataFormats/EgammaReco/interface/BasicClusterFwd.h"
00023 #include "DataFormats/CaloRecHit/interface/CaloCluster.h"
00024 #include "DataFormats/CaloRecHit/interface/CaloClusterFwd.h"
00025 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00026 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00027 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00028 #include "DataFormats/Math/interface/deltaPhi.h"
00029
00030 using namespace std;
00031
00032 EgammaRecHitIsolation::EgammaRecHitIsolation (double extRadius,
00033 double intRadius,
00034 double etaSlice,
00035 double etLow,
00036 double eLow,
00037 edm::ESHandle<CaloGeometry> theCaloGeom,
00038 CaloRecHitMetaCollectionV* caloHits,
00039 const EcalSeverityLevelAlgo* sl,
00040 DetId::Detector detector):
00041 extRadius_(extRadius),
00042 intRadius_(intRadius),
00043 etaSlice_(etaSlice),
00044 etLow_(etLow),
00045 eLow_(eLow),
00046 theCaloGeom_(theCaloGeom) ,
00047 caloHits_(caloHits),
00048 sevLevel_(sl),
00049 useNumCrystals_(false),
00050 vetoClustered_(false),
00051 ecalBarHits_(0),
00052 chStatus_(0),
00053 severityLevelCut_(-1),
00054
00055
00056
00057 v_chstatus_(0)
00058 {
00059
00060 const CaloGeometry* caloGeom = theCaloGeom_.product();
00061 subdet_[0] = caloGeom->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
00062 subdet_[1] = caloGeom->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
00063
00064 }
00065
00066 EgammaRecHitIsolation::~EgammaRecHitIsolation ()
00067 {
00068 }
00069
00070 double EgammaRecHitIsolation::getSum_(const reco::Candidate* emObject,bool returnEt) const
00071 {
00072
00073 double energySum = 0.;
00074 if (caloHits_){
00075
00076 reco::SuperClusterRef sc = emObject->get<reco::SuperClusterRef>();
00077 math::XYZPoint theCaloPosition = sc.get()->position();
00078 GlobalPoint pclu (theCaloPosition.x () ,
00079 theCaloPosition.y () ,
00080 theCaloPosition.z () );
00081 double etaclus = pclu.eta();
00082 double phiclus = pclu.phi();
00083 double r2 = intRadius_*intRadius_;
00084
00085
00086 std::vector< std::pair<DetId, float> >::const_iterator rhIt;
00087
00088
00089 for(int subdetnr=0; subdetnr<=1 ; subdetnr++){
00090 CaloSubdetectorGeometry::DetIdSet chosen = subdet_[subdetnr]->getCells(pclu,extRadius_);
00091 CaloRecHitMetaCollectionV::const_iterator j=caloHits_->end();
00092 for (CaloSubdetectorGeometry::DetIdSet::const_iterator i = chosen.begin ();i!= chosen.end ();++i){
00093
00094 j=caloHits_->find(*i);
00095 if( j!=caloHits_->end()){
00096 const GlobalPoint & position = theCaloGeom_.product()->getPosition(*i);
00097 double eta = position.eta();
00098 double phi = position.phi();
00099 double etaDiff = eta - etaclus;
00100 double phiDiff= reco::deltaPhi(phi,phiclus);
00101 double energy = j->energy();
00102
00103 if(useNumCrystals_) {
00104 if( fabs(etaclus) < 1.479 ) {
00105 if ( fabs(etaDiff) < 0.0174*etaSlice_) continue;
00106 if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.0174*intRadius_) continue;
00107 } else {
00108 if ( fabs(etaDiff) < 0.00864*fabs(sinh(eta))*etaSlice_) continue;
00109 if ( sqrt(etaDiff*etaDiff + phiDiff*phiDiff) < 0.00864*fabs(sinh(eta))*intRadius_) continue;
00110 }
00111 } else {
00112 if ( fabs(etaDiff) < etaSlice_) continue;
00113 if ( etaDiff*etaDiff + phiDiff*phiDiff < r2) continue;
00114 }
00115
00116
00117 if(vetoClustered_) {
00118
00119
00120 bool isClustered = false;
00121 for(reco::CaloCluster_iterator bcIt = sc->clustersBegin();bcIt != sc->clustersEnd(); ++bcIt) {
00122 for(rhIt = (*bcIt)->hitsAndFractions().begin();rhIt != (*bcIt)->hitsAndFractions().end(); ++rhIt) {
00123 if( rhIt->first == *i ) isClustered = true;
00124 if( isClustered ) break;
00125 }
00126 if( isClustered ) break;
00127 }
00128
00129 if(isClustered) continue;
00130 }
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143 if( severityLevelCut_!=-1 && ecalBarHits_ &&
00144 sevLevel_->severityLevel(EBDetId(j->detid()), *ecalBarHits_) >= severityLevelCut_)
00145 continue;
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157 std::vector<int>::const_iterator vit = std::find( v_chstatus_.begin(), v_chstatus_.end(), ((EcalRecHit*)(&*j))->recoFlag() );
00158 if ( vit != v_chstatus_.end() ) continue;
00159
00160
00161 double et = energy*position.perp()/position.mag();
00162 if ( fabs(et) > etLow_ && fabs(energy) > eLow_){
00163 if(returnEt) energySum+=et;
00164 else energySum+=energy;
00165 }
00166
00167 }
00168 }
00169 }
00170 }
00171 return energySum;
00172 }
00173