CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaHcalExtractor.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/plugins/EgammaHcalExtractor.h"
00017 #include "RecoEgamma/EgammaIsolationAlgos/interface/EgammaRecHitIsolation.h"
00018 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00019 #include "Geometry/CommonDetUnit/interface/TrackingGeometry.h"
00020 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00021 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00022 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00023 #include "DataFormats/GeometryVector/interface/GlobalVector.h"
00024 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
00025 #include "RecoCaloTools/Selectors/interface/CaloDualConeSelector.h"
00026 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00027 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00028 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00029 
00030 using namespace std;
00031 
00032 using namespace egammaisolation;
00033 using namespace reco::isodeposit;
00034 
00035 EgammaHcalExtractor::EgammaHcalExtractor ( const edm::ParameterSet& par ) :
00036     extRadius_(par.getParameter<double>("extRadius")),
00037     intRadius_(par.getParameter<double>("intRadius")),
00038     etLow_(par.getParameter<double>("etMin")),
00039     hcalRecHitProducer_(par.getParameter<edm::InputTag>("hcalRecHits")) { 
00040 }
00041 
00042 EgammaHcalExtractor::~EgammaHcalExtractor(){}
00043 
00044 reco::IsoDeposit EgammaHcalExtractor::deposit(const edm::Event & iEvent, 
00045         const edm::EventSetup & iSetup, const reco::Candidate &emObject ) const {
00046 
00047     //Get MetaRecHit collection
00048     edm::Handle<HBHERecHitCollection> hcalRecHitHandle;
00049     iEvent.getByLabel(hcalRecHitProducer_, hcalRecHitHandle);
00050     HBHERecHitMetaCollection mhbhe =  HBHERecHitMetaCollection(*hcalRecHitHandle); 
00051 
00052     //Get Calo Geometry
00053     edm::ESHandle<CaloGeometry> pG;
00054     iSetup.get<CaloGeometryRecord>().get(pG);
00055     const CaloGeometry* caloGeom = pG.product();
00056     CaloDualConeSelector coneSel(intRadius_, extRadius_, caloGeom, DetId::Hcal);
00057 
00058     //Take the SC position
00059     reco::SuperClusterRef sc = emObject.get<reco::SuperClusterRef>();
00060     math::XYZPoint caloPosition = sc->position();
00061     GlobalPoint point(caloPosition.x(), caloPosition.y() , caloPosition.z());
00062     // needed: coneSel.select(eta,phi,hits) is not the same!
00063 
00064     Direction candDir(caloPosition.eta(), caloPosition.phi());
00065     reco::IsoDeposit deposit( candDir );
00066     deposit.setVeto( reco::IsoDeposit::Veto(candDir, intRadius_) ); 
00067     double sinTheta = sin(2*atan(exp(-sc->eta())));
00068     deposit.addCandEnergy(sc->energy()*sinTheta);
00069 
00070     //Compute the HCAL energy behind ECAL
00071     std::auto_ptr<CaloRecHitMetaCollectionV> chosen = coneSel.select(point, mhbhe);
00072     for (CaloRecHitMetaCollectionV::const_iterator i = chosen->begin (), ed = chosen->end() ; 
00073             i!= ed; ++i) {
00074         const  GlobalPoint & hcalHit_position = caloGeom->getPosition(i->detid());
00075         double hcalHit_eta = hcalHit_position.eta();
00076         double hcalHit_Et = i->energy()*sin(2*atan(exp(-hcalHit_eta)));
00077         if ( hcalHit_Et > etLow_) {
00078             deposit.addDeposit( Direction(hcalHit_eta, hcalHit_position.phi()), hcalHit_Et);
00079         }
00080     }
00081 
00082     return deposit;
00083 }