CMS 3D CMS Logo

FetchCollection.h

Go to the documentation of this file.
00001 #ifndef _PhysicsTools_PFCandProducer_FetchCollection_
00002 #define _PhysicsTools_PFCandProducer_FetchCollection_
00003 
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 
00007 namespace pfpat {
00008 
00009 template<class T>
00010 void fetchCollection(T& c,
00011                      const edm::InputTag& tag,
00012                      const edm::Event& iEvent) {
00013   
00014   edm::InputTag empty;
00015   if( tag==empty ) return;
00016   
00017   bool found = iEvent.getByLabel(tag, c);
00018   
00019   if(!found ) {
00020     std::ostringstream  err;
00021     err<<" cannot get collection: "
00022        <<tag<<std::endl;
00023     edm::LogError("PFPAT")<<err.str();
00024     throw cms::Exception( "MissingProduct", err.str());
00025   }
00026   
00027 }
00028  
00029 }
00030 
00031 #endif

Generated on Tue Jun 9 17:41:48 2009 for CMSSW by  doxygen 1.5.4