CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/RecoEgamma/EgammaIsolationAlgos/plugins/EgammaTowerIsolationProducer.cc

Go to the documentation of this file.
00001 //*****************************************************************************
00002 // File:      EgammaTowerIsolationProducer.cc
00003 // ----------------------------------------------------------------------------
00004 // OrigAuth:  Matthias Mozer
00005 // Institute: IIHE-VUB
00006 //=============================================================================
00007 //*****************************************************************************
00008 
00009 
00010 #include "RecoEgamma/EgammaIsolationAlgos/plugins/EgammaTowerIsolationProducer.h"
00011 
00012 // Framework
00013 #include "DataFormats/Common/interface/Handle.h"
00014 
00015 #include "DataFormats/Candidate/interface/Candidate.h"
00016 #include "DataFormats/Candidate/interface/CandAssociation.h"
00017 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00018 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00019 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00020 
00021 #include "DataFormats/CaloTowers/interface/CaloTowerCollection.h"
00022 
00023 
00024 EgammaTowerIsolationProducer::EgammaTowerIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00025 {
00026  // use configuration file to setup input/output collection names
00027   emObjectProducer_               = conf_.getParameter<edm::InputTag>("emObjectProducer");
00028 
00029   towerProducer_           = conf_.getParameter<edm::InputTag>("towerProducer");
00030 
00031   egHcalIsoPtMin_               = conf_.getParameter<double>("etMin");
00032   egHcalIsoConeSizeIn_          = conf_.getParameter<double>("intRadius");
00033   egHcalIsoConeSizeOut_         = conf_.getParameter<double>("extRadius");
00034   egHcalDepth_                  = conf_.getParameter<int>("Depth");
00035 
00036 
00037   //register your products
00038   produces < edm::ValueMap<double> >();
00039 }
00040 
00041 
00042 EgammaTowerIsolationProducer::~EgammaTowerIsolationProducer(){}
00043 
00044 
00045 //
00046 // member functions
00047 //
00048 
00049 // ------------ method called to produce the data  ------------
00050 void
00051 EgammaTowerIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00052 {
00053   
00054   // Get the  filtered objects
00055   edm::Handle< edm::View<reco::Candidate> > emObjectHandle;
00056   iEvent.getByLabel(emObjectProducer_,emObjectHandle);
00057   
00058   // Get the barrel hcal hits
00059   edm::Handle<CaloTowerCollection> towerHandle;
00060   iEvent.getByLabel(towerProducer_, towerHandle);
00061   const CaloTowerCollection* towers = towerHandle.product();
00062 
00063   std::auto_ptr<edm::ValueMap<double> > isoMap(new edm::ValueMap<double>());
00064   edm::ValueMap<double>::Filler filler(*isoMap);
00065   std::vector<double> retV(emObjectHandle->size(),0);
00066 
00067   EgammaTowerIsolation myHadIsolation(egHcalIsoConeSizeOut_,
00068                               egHcalIsoConeSizeIn_,
00069                               egHcalIsoPtMin_,
00070                               egHcalDepth_,           
00071                               towers) ;
00072 
00073   
00074   for( size_t i = 0 ; i < emObjectHandle->size(); ++i) {
00075     double isoValue = myHadIsolation.getTowerEtSum(&(emObjectHandle->at(i)));
00076     retV[i]=isoValue;
00077   }
00078 
00079   filler.insert(emObjectHandle,retV.begin(),retV.end());
00080   filler.fill();
00081   iEvent.put(isoMap);
00082 
00083 }
00084 
00085 //define this as a plug-in
00086 //DEFINE_FWK_MODULE(EgammaTowerIsolationProducer);