00001 /* \class MassKinFitterCandProducer 00002 * 00003 * \author Luca Lista, INFN 00004 * 00005 */ 00006 #include "FWCore/Framework/interface/EDProducer.h" 00007 #include "FWCore/Utilities/interface/InputTag.h" 00008 #include "PhysicsTools/RecoUtils/interface/CandMassKinFitter.h" 00009 #include <vector> 00010 00011 class MassKinFitterCandProducer : public edm::EDProducer { 00012 public: 00013 explicit MassKinFitterCandProducer( const edm::ParameterSet & ); 00014 00015 private: 00016 edm::InputTag src_; 00017 CandMassKinFitter fitter_; 00018 void produce( edm::Event &, const edm::EventSetup & ); 00019 }; 00020 00021 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00022 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" 00023 #include "DataFormats/Common/interface/Handle.h" 00024 #include "FWCore/Framework/interface/ESHandle.h" 00025 #include "FWCore/Framework/interface/Event.h" 00026 #include "DataFormats/Candidate/interface/Candidate.h" 00027 00028 MassKinFitterCandProducer::MassKinFitterCandProducer( const edm::ParameterSet & cfg ) : 00029 src_( cfg.getParameter<edm::InputTag>( "src" ) ), 00030 fitter_( cfg.getParameter<double>( "mass" ) ) { 00031 produces<reco::CandidateCollection>(); 00032 } 00033 00034 void MassKinFitterCandProducer::produce( edm::Event & evt, const edm::EventSetup & es ) { 00035 using namespace edm; 00036 using namespace reco; 00037 Handle<CandidateCollection> cands; 00038 evt.getByLabel( src_, cands ); 00039 std::auto_ptr<CandidateCollection> refitted( new CandidateCollection ); 00040 for( CandidateCollection::const_iterator c = cands->begin(); c != cands->end(); ++ c ) { 00041 Candidate * clone = c->clone(); 00042 fitter_.set( * clone ); 00043 refitted->push_back( clone ); 00044 } 00045 evt.put( refitted ); 00046 } 00047 00048 #include "FWCore/Framework/interface/MakerMacros.h" 00049 00050 DEFINE_FWK_MODULE( MassKinFitterCandProducer ); 00051