CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositCopyProducer.cc

Go to the documentation of this file.
00001 #include "RecoMuon/MuonIsolationProducers/plugins/MuIsoDepositCopyProducer.h"
00002 
00003 // Framework
00004 #include "FWCore/Framework/interface/EDProducer.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "DataFormats/Common/interface/Handle.h"
00008 
00009 #include "FWCore/Framework/interface/ESHandle.h"
00010 
00011 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
00012 #include "DataFormats/RecoCandidate/interface/IsoDepositFwd.h"
00013 #include "DataFormats/Common/interface/ValueMap.h"
00014 
00015 
00016 #include "FWCore/Utilities/interface/Exception.h"
00017 
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include <string>
00020 
00021 using namespace edm;
00022 using namespace std;
00023 using namespace reco;
00024 
00025 
00027 MuIsoDepositCopyProducer::MuIsoDepositCopyProducer(const ParameterSet& par) :
00028   theConfig(par),
00029   theInputTags(par.getParameter<std::vector<edm::InputTag> >("inputTags")),
00030   theDepositNames(par.getParameter<std::vector<std::string> >("depositNames"))
00031 
00032 {
00033   LogDebug("RecoMuon|MuonIsolation")<<" MuIsoDepositCopyProducer CTOR";
00034   if (theInputTags.size() != theDepositNames.size()){
00035     throw  cms::Exception("MuIsoDepositCopyProducer constructor")<<"the sizes of input/output vectors don't match";
00036   }
00037   
00038   for (unsigned int i = 0; i < theDepositNames.size(); ++i){
00039     std::string alias = theConfig.getParameter<std::string>("@module_label");
00040     if (theDepositNames[i] != "") alias += "_" + theDepositNames[i];
00041     produces<reco::IsoDepositMap>(theDepositNames[i]).setBranchAlias(alias);
00042   }
00043 }
00044 
00046 MuIsoDepositCopyProducer::~MuIsoDepositCopyProducer(){
00047   LogDebug("RecoMuon/MuIsoDepositCopyProducer")<<" MuIsoDepositCopyProducer DTOR";
00048 }
00049 
00051 void MuIsoDepositCopyProducer::produce(Event& event, const EventSetup& eventSetup){
00052   std::string metname = "RecoMuon|MuonIsolationProducers|MuIsoDepositCopyProducer";
00053 
00054   LogDebug(metname)<<" Muon Deposit producing..."
00055                    <<" BEGINING OF EVENT " <<"================================";
00056 
00057   LogTrace(metname)<<" Taking the inputs: ";
00058 
00059   for (unsigned int iDep = 0; iDep < theInputTags.size(); ++iDep){
00060     Handle<reco::IsoDepositMap > inDep;
00061     event.getByLabel(theInputTags[iDep], inDep);
00062 
00063     std::auto_ptr<reco::IsoDepositMap> outDep(new reco::IsoDepositMap(*inDep));
00064     event.put(outDep, theDepositNames[iDep]);
00065   }
00066 
00067   LogTrace(metname) <<" END OF EVENT " <<"================================";
00068 }
00069 
00070 #include "FWCore/PluginManager/interface/ModuleDef.h"
00071 #include "FWCore/Framework/interface/MakerMacros.h"
00072 DEFINE_FWK_MODULE(MuIsoDepositCopyProducer);