CMS 3D CMS Logo

HepMCEventWriter.cc
Go to the documentation of this file.
1 #include <algorithm>
2 #include <iostream>
3 #include <iterator>
4 #include <fstream>
5 #include <string>
6 #include <memory>
7 
17 
18 #include "HepMC/IO_GenEvent.h"
19 
21 public:
22  explicit HepMCEventWriter(const edm::ParameterSet &params);
23  ~HepMCEventWriter() override;
24 
25 protected:
26  void beginRun(const edm::Run &run, const edm::EventSetup &es) override;
27  void endRun(const edm::Run &run, const edm::EventSetup &es) override;
28  void analyze(const edm::Event &event, const edm::EventSetup &es) override;
29 
30 private:
33 };
34 
36  : hepMCProduct_(params.getParameter<edm::InputTag>("hepMCProduct")) {}
37 
39 
41  _output = new HepMC::IO_GenEvent("GenEvent_ASCII.dat", std::ios::out);
42 }
43 
45  if (_output)
46  delete _output.get();
47 }
48 
51  event.getByLabel(hepMCProduct_, product);
52 
53  const HepMC::GenEvent *evt = product->GetEvent();
54 
55  _output->write_event(evt);
56 }
57 
~HepMCEventWriter() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr element_type const * get() const
void analyze(const edm::Event &event, const edm::EventSetup &es) override
edm::propagate_const< HepMC::IO_GenEvent * > _output
void endRun(const edm::Run &run, const edm::EventSetup &es) override
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:37
HLT enums.
edm::InputTag hepMCProduct_
HepMCEventWriter(const edm::ParameterSet &params)
Definition: event.py:1
Definition: Run.h:45