00001 // 00002 // $Id: PATCompositeCandidateProducer.cc,v 1.1 2008/12/02 03:36:03 srappocc Exp $ 00003 // 00004 00005 #include "PhysicsTools/PatAlgos/plugins/PATCompositeCandidateProducer.h" 00006 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00007 #include "DataFormats/Common/interface/View.h" 00008 #include "PhysicsTools/CandUtils/interface/AddFourMomenta.h" 00009 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00010 #include "PhysicsTools/Utilities/interface/StringObjectFunction.h" 00011 #include "FWCore/Utilities/interface/Exception.h" 00012 #include <memory> 00013 00014 00015 #include <iostream> 00016 00017 using namespace pat; 00018 using namespace std; 00019 using namespace edm; 00020 00021 PATCompositeCandidateProducer::PATCompositeCandidateProducer(const ParameterSet & iConfig) : 00022 userDataHelper_( iConfig.getParameter<edm::ParameterSet>("userData") ) 00023 { 00024 // initialize the configurables 00025 src_ = iConfig.getParameter<InputTag>( "src" ); 00026 00027 useUserData_ = false; 00028 if ( iConfig.exists("userData") ) { 00029 useUserData_ = true; 00030 } 00031 00032 // produces vector of particles 00033 produces<vector<pat::CompositeCandidate> >(); 00034 00035 } 00036 00037 PATCompositeCandidateProducer::~PATCompositeCandidateProducer() { 00038 } 00039 00040 void PATCompositeCandidateProducer::produce(Event & iEvent, const EventSetup & iSetup) { 00041 // Get the vector of CompositeCandidate's from the event 00042 Handle<View<reco::CompositeCandidate> > cands; 00043 iEvent.getByLabel(src_, cands); 00044 00045 auto_ptr<vector<pat::CompositeCandidate> > myCompositeCandidates ( new vector<pat::CompositeCandidate>() ); 00046 00047 if ( cands.isValid() ) { 00048 00049 View<reco::CompositeCandidate>::const_iterator ibegin = cands->begin(), 00050 iend = cands->end(), i = ibegin; 00051 for ( ; i != iend; ++i ) { 00052 00053 pat::CompositeCandidate cand(*i); 00054 00055 if ( useUserData_ ) { 00056 userDataHelper_.add( cand, iEvent, iSetup ); 00057 } 00058 00059 myCompositeCandidates->push_back( cand ); 00060 } 00061 00062 }// end if the two handles are valid 00063 00064 iEvent.put(myCompositeCandidates); 00065 00066 } 00067 00068 #include "FWCore/Framework/interface/MakerMacros.h" 00069 00070 DEFINE_FWK_MODULE(PATCompositeCandidateProducer);