CMS 3D CMS Logo

EgammaHcalIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaHcalIsolationProducer.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 
00010 #include "EgammaAnalysis/EgammaIsolationProducers/interface/EgammaHcalIsolationProducer.h"
00011 
00012 // Framework
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 
00017 #include "DataFormats/Candidate/interface/Candidate.h"
00018 #include "DataFormats/Candidate/interface/CandAssociation.h"
00019 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00020 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00021 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00022 
00023 #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
00024 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00025 
00026 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00027 
00028 EgammaHcalIsolationProducer::EgammaHcalIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00029 {
00030  // use configuration file to setup input/output collection names
00031   emObjectProducer_               = conf_.getParameter<edm::InputTag>("emObjectProducer");
00032 
00033   hcalRecHitProducer_           = conf_.getParameter<edm::InputTag>("hcalRecHitProducer");
00034 
00035   egHcalIsoPtMin_               = conf_.getParameter<double>("etMin");
00036   egHcalIsoConeSizeIn_            = conf_.getParameter<double>("intRadius");
00037   egHcalIsoConeSizeOut_            = conf_.getParameter<double>("extRadius");
00038 
00039  absolut_ = conf_.getParameter<bool>("absolut");
00040 
00041   //register your products
00042   produces < reco::CandViewDoubleAssociations >();
00043 }
00044 
00045 
00046 EgammaHcalIsolationProducer::~EgammaHcalIsolationProducer(){}
00047 
00048 
00049 //
00050 // member functions
00051 //
00052 
00053 // ------------ method called to produce the data  ------------
00054 void
00055 EgammaHcalIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00056 {
00057   
00058   // Get the  filtered objects
00059   edm::Handle< edm::View<reco::Candidate> > emObjectHandle;
00060   iEvent.getByLabel(emObjectProducer_,emObjectHandle);
00061   
00062   // Get the barrel hcal hits
00063   edm::Handle<HBHERecHitCollection> hcalRecHitHandle;
00064   iEvent.getByLabel(hcalRecHitProducer_, hcalRecHitHandle);
00065   
00066   HBHERecHitMetaCollection mhbhe =  HBHERecHitMetaCollection(*hcalRecHitHandle); 
00067 
00068   //Get Calo Geometry
00069   edm::ESHandle<CaloGeometry> pG;
00070   iSetup.get<CaloGeometryRecord>().get(pG);
00071   const CaloGeometry* caloGeom = pG.product();
00072 
00073 
00074   reco::CandViewDoubleAssociations* isoMap = new reco::CandViewDoubleAssociations( reco::CandidateBaseRefProd( emObjectHandle ) );
00075 
00076 
00077   EgammaHcalIsolation myHadIsolation(egHcalIsoConeSizeOut_,
00078                               egHcalIsoConeSizeIn_,
00079                               egHcalIsoPtMin_,
00080                               caloGeom,
00081                               &mhbhe) ;
00082 
00083   
00084   for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
00085     double isoValue = myHadIsolation.getHcalEtSum(&(emObjectHandle->at(i)));
00086     if(absolut_==true){
00087       isoMap->setValue(i,isoValue);
00088     }
00089     else{
00090       reco::SuperClusterRef sc = (emObjectHandle->at(i)).get<reco::SuperClusterRef>();
00091       double et = sc.get()->energy()*sin(2*atan(exp(-sc.get()->eta())));
00092       isoMap->setValue(i,isoValue/et);
00093     }
00094   }
00095 
00096 
00097 
00098   std::auto_ptr<reco::CandViewDoubleAssociations> isolMap(isoMap);
00099   iEvent.put(isolMap);
00100 
00101 }
00102 
00103 //define this as a plug-in
00104 //DEFINE_FWK_MODULE(EgammaHcalIsolationProducer);

Generated on Tue Jun 9 17:34:16 2009 for CMSSW by  doxygen 1.5.4