00001 #include "FWCore/Framework/interface/Event.h" 00002 #include "FWCore/Framework/interface/MakerMacros.h" 00003 #include "FWCore/ServiceRegistry/interface/Service.h" 00004 00005 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" 00006 00007 #include "RecoParticleFlow/Configuration/plugins/HepMCCopy.h" 00008 #include "HepMC/GenEvent.h" 00009 00010 HepMCCopy::HepMCCopy(edm::ParameterSet const & p) 00011 { 00012 // This producer produces a HepMCProduct, a copy of the original one 00013 produces<edm::HepMCProduct>(); 00014 } 00015 00016 void HepMCCopy::produce(edm::Event & iEvent, const edm::EventSetup & es) 00017 { 00018 00019 edm::Handle<edm::HepMCProduct> theHepMCProduct; 00020 bool source = iEvent.getByLabel("generator",theHepMCProduct); 00021 if ( !source ) { 00022 std::auto_ptr<edm::HepMCProduct> pu_product(new edm::HepMCProduct()); 00023 iEvent.put(pu_product); 00024 } else { 00025 std::auto_ptr<edm::HepMCProduct> pu_product(new edm::HepMCProduct(*theHepMCProduct)); 00026 iEvent.put(pu_product); 00027 } 00028 00029 } 00030 00031 DEFINE_FWK_MODULE(HepMCCopy);