CMS 3D CMS Logo

HepMCCopy.cc
Go to the documentation of this file.
7 
8 #include "HepMC/GenEvent.h"
9 
10 class HepMCCopy : public edm::one::EDProducer<> {
11 public:
12  explicit HepMCCopy(edm::ParameterSet const& p);
13  ~HepMCCopy() override = default;
14  void produce(edm::Event& e, const edm::EventSetup& c) override;
15  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
16 
17 private:
19 };
20 
23  desc.add<edm::InputTag>("src", {"generatorSmeared"});
24  descriptions.addWithDefaultLabel(desc);
25 }
26 
28  : hepMCToken_(consumes<edm::HepMCProduct>(p.getParameter<edm::InputTag>("src"))) {
29  // This producer produces a HepMCProduct, a copy of the original one
30  produces<edm::HepMCProduct>();
31 }
32 
34  const auto& theHepMCProduct = iEvent.getHandle(hepMCToken_);
35  if (theHepMCProduct.isValid()) {
36  auto pu_product = std::make_unique<edm::HepMCProduct>();
37  iEvent.put(std::move(pu_product));
38  } else {
39  auto pu_product = std::make_unique<edm::HepMCProduct>(*theHepMCProduct);
40  iEvent.put(std::move(pu_product));
41  }
42 }
43 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: HepMCCopy.cc:33
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HepMCCopy.cc:21
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~HepMCCopy() override=default
HepMCCopy(edm::ParameterSet const &p)
Definition: HepMCCopy.cc:27
HLT enums.
const edm::EDGetTokenT< edm::HepMCProduct > hepMCToken_
Definition: HepMCCopy.cc:18
def move(src, dest)
Definition: eostools.py:511