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 "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00020 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00021 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00022 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00023 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
00024 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00025 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00026 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00027
00028 using namespace std;
00029
00030 EgammaRecHitIsolation::EgammaRecHitIsolation (double extRadius,
00031 double intRadius,
00032 double etaSlice,
00033 double etLow,
00034 edm::ESHandle<CaloGeometry> theCaloGeom,
00035 CaloRecHitMetaCollectionV* caloHits,
00036 DetId::Detector detector):
00037 extRadius_(extRadius),
00038 intRadius_(intRadius),
00039 etaSlice_(etaSlice),
00040 etLow_(etLow),
00041 theCaloGeom_(theCaloGeom) ,
00042 caloHits_(caloHits)
00043 {
00044
00045 const CaloGeometry* caloGeom = theCaloGeom_.product();
00046
00047 if(detector == DetId::Ecal ){
00048 doubleConeSel_[0] = new CaloDualConeSelector (intRadius_ ,extRadius_, caloGeom, detector, EcalEndcap);
00049 doubleConeSel_[1] = new CaloDualConeSelector (intRadius_ ,extRadius_, caloGeom, detector, EcalBarrel);
00050 }else{
00051 doubleConeSel_[0] = new CaloDualConeSelector (intRadius_ ,extRadius_, caloGeom, detector);
00052 doubleConeSel_[1] = NULL;
00053 }
00054 }
00055
00056 EgammaRecHitIsolation::~EgammaRecHitIsolation ()
00057 {
00058 for(int i=0; i<=1 ; i++){
00059 if(doubleConeSel_[i]){
00060 delete doubleConeSel_[i];
00061 }
00062 }
00063 }
00064
00065 double EgammaRecHitIsolation::getSum_(const reco::Candidate* emObject,bool returnEt) const
00066 {
00067
00068 double energySum = 0.;
00069 if (caloHits_){
00070 for(int selnr=0; selnr<=1 ; selnr++){
00071 if(doubleConeSel_[selnr]){
00072
00073 reco::SuperClusterRef sc = emObject->get<reco::SuperClusterRef>();
00074 math::XYZPoint theCaloPosition = sc.get()->position();
00075
00076 GlobalPoint pclu (theCaloPosition.x () ,
00077 theCaloPosition.y () ,
00078 theCaloPosition.z () );
00079
00080 std::auto_ptr<CaloRecHitMetaCollectionV> chosen = doubleConeSel_[selnr]->select(pclu,*caloHits_);
00081 for (CaloRecHitMetaCollectionV::const_iterator i = chosen->begin () ;
00082 i!= chosen->end () ;
00083 ++i)
00084 {
00085 double eta = theCaloGeom_.product()->getPosition(i->detid()).eta();
00086 double etaDiff = eta - pclu.eta();
00087
00088 if ( fabs(etaDiff) < etaSlice_) continue;
00089
00090 double et = i->energy()*sin(2*atan(exp(-eta)));
00091 if ( et > etLow_){
00092 if(returnEt) energySum+=et;
00093 else energySum+=i->energy();
00094 }
00095 }
00096
00097 }
00098 }
00099 }
00100 return energySum;
00101 }
00102