CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/PhysicsTools/RecoAlgos/src/MassKinFitterCandProducer.cc

Go to the documentation of this file.
00001 #include "PhysicsTools/RecoAlgos/interface/MassKinFitterCandProducer.h"
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 #include "DataFormats/Common/interface/Handle.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/Framework/interface/Event.h"
00006 #include "DataFormats/Candidate/interface/Candidate.h"
00007 
00008 MassKinFitterCandProducer::MassKinFitterCandProducer(const edm::ParameterSet & cfg, CandMassKinFitter * f) :
00009   src_(cfg.getParameter<edm::InputTag>("src")),
00010   fitter_(f) {
00011   if(f == 0) fitter_.reset(new CandMassKinFitter(cfg.getParameter<double>("mass")));
00012   produces<reco::CandidateCollection>();
00013 }
00014 
00015 void MassKinFitterCandProducer::produce( edm::Event & evt, const edm::EventSetup & es ) {
00016   using namespace edm; 
00017   using namespace reco;
00018   Handle<CandidateCollection> cands;
00019   evt.getByLabel(src_, cands);
00020   std::auto_ptr<CandidateCollection> refitted( new CandidateCollection );
00021   for( CandidateCollection::const_iterator c = cands->begin(); c != cands->end(); ++ c ) {
00022     Candidate * clone = c->clone();
00023     fitter_->set( * clone );
00024     refitted->push_back( clone );
00025   }
00026   evt.put( refitted );
00027 }
00028