00001 00019 #include "FWCore/Framework/interface/EDProducer.h" 00020 00021 class CandReducer : public edm::EDProducer { 00022 public: 00024 explicit CandReducer( const edm::ParameterSet& ); 00026 ~CandReducer(); 00027 private: 00029 void produce( edm::Event& evt, const edm::EventSetup& ); 00031 std::string src_; 00032 }; 00033 00034 #include "FWCore/Framework/interface/Event.h" 00035 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00036 #include "DataFormats/Candidate/interface/LeafCandidate.h" 00037 #include "FWCore/Utilities/interface/EDMException.h" 00038 00039 using namespace reco; 00040 using namespace edm; 00041 00042 CandReducer::CandReducer( const edm::ParameterSet& cfg ) : 00043 src_( cfg.getParameter<std::string>("src") ) { 00044 produces<CandidateCollection>(); 00045 } 00046 00047 CandReducer::~CandReducer() { 00048 } 00049 00050 void CandReducer::produce( Event& evt, const EventSetup& ) { 00051 Handle<CandidateCollection> cands; 00052 evt.getByLabel( src_, cands ); 00053 std::auto_ptr<CandidateCollection> comp( new CandidateCollection ); 00054 for( CandidateCollection::const_iterator c = cands->begin(); c != cands->end(); ++c ) { 00055 std::auto_ptr<Candidate> cand( new LeafCandidate( * c ) ); 00056 comp->push_back( cand.release() ); 00057 } 00058 evt.put( comp ); 00059 } 00060 00061 #include "FWCore/Framework/interface/MakerMacros.h" 00062 00063 DEFINE_FWK_MODULE( CandReducer );