CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTCombinedIsolationProducer.cc

Go to the documentation of this file.
00001 
00009 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTCombinedIsolationProducer.h"
00010 
00011 // Framework
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/EventSetup.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 #include "FWCore/Framework/interface/ESHandle.h"
00016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00017 #include "FWCore/Utilities/interface/Exception.h"
00018 
00019 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00020 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateIsolation.h"
00021 
00022 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00023 #include "RecoEcal/EgammaCoreTools/interface/EcalClusterLazyTools.h"
00024 
00025 EgammaHLTCombinedIsolationProducer::EgammaHLTCombinedIsolationProducer(const edm::ParameterSet& config) : conf_(config)
00026 {
00027  // use configuration file to setup input/output collection names
00028   recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
00029 
00030   IsolTag_ = conf_.getParameter< std::vector<edm::InputTag> > ("IsolationMapTags");
00031   IsolWeight_ = conf_.getParameter< std::vector<double> > ("IsolationWeight");
00032 
00033   //register your products
00034   produces < reco::RecoEcalCandidateIsolationMap >();
00035 
00036   if ( IsolTag_.size() != IsolWeight_.size()){ 
00037     throw cms::Exception("BadConfig") << "vectors IsolationMapTags and IsolationWeight need to have the same size";
00038   }
00039 
00040 }
00041 
00042 
00043 EgammaHLTCombinedIsolationProducer::~EgammaHLTCombinedIsolationProducer(){}
00044 
00045 
00046 //
00047 // member functions
00048 //
00049 
00050 // ------------ method called to produce the data  ------------
00051 void
00052 EgammaHLTCombinedIsolationProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00053 {
00054   
00055   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcandHandle;
00056   iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
00057 
00058   reco::RecoEcalCandidateIsolationMap TotalIsolMap;
00059   double TotalIso=0;
00060 
00061   std::vector< edm::Handle<reco::RecoEcalCandidateIsolationMap> > IsoMap;
00062   for( unsigned int u=0; u < IsolWeight_.size(); u++){
00063     edm::Handle<reco::RecoEcalCandidateIsolationMap> depMapTemp;
00064     if(IsolWeight_[u] != 0){ iEvent.getByLabel (IsolTag_[u],depMapTemp);}
00065     IsoMap.push_back(depMapTemp);
00066   }
00067   
00068   for(reco::RecoEcalCandidateCollection::const_iterator iRecoEcalCand = recoecalcandHandle->begin(); iRecoEcalCand != recoecalcandHandle->end(); iRecoEcalCand++){
00069     reco::RecoEcalCandidateRef recoecalcandref(recoecalcandHandle,iRecoEcalCand-recoecalcandHandle->begin());
00070     TotalIso = 0;  
00071     for( unsigned int u=0; u < IsolWeight_.size(); u++){
00072       if(IsolWeight_[u]==0){continue;}
00073       reco::RecoEcalCandidateIsolationMap::const_iterator mapi = (*IsoMap[u]).find( recoecalcandref );    
00074       TotalIso += mapi->val * IsolWeight_[u];
00075     }
00076     TotalIsolMap.insert(recoecalcandref, TotalIso);
00077     
00078   }
00079 
00080   std::auto_ptr<reco::RecoEcalCandidateIsolationMap> Map(new reco::RecoEcalCandidateIsolationMap(TotalIsolMap));
00081   iEvent.put(Map);
00082 
00083 }
00084 
00085 //define this as a plug-in
00086 //DEFINE_FWK_MODULE(EgammaHLTCombinedIsolationProducer);