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 
20 
22 public:
23  explicit HepMCEventWriter(const edm::ParameterSet &params);
24  ~HepMCEventWriter() override;
25 
26 protected:
27  void beginRun(const edm::Run &run, const edm::EventSetup &es) override;
28  void endRun(const edm::Run &run, const edm::EventSetup &es) override;
29  void analyze(const edm::Event &event, const edm::EventSetup &es) override;
30 
31 private:
34 };
35 
37  hepMCProduct_(params.getParameter<edm::InputTag>("hepMCProduct"))
38 {
39 }
40 
42 {
43 }
44 
46 {
47 
48  _output = new HepMC::IO_GenEvent("GenEvent_ASCII.dat",std::ios::out);
49 
50 }
51 
52 
54 {
55  if (_output) delete _output.get();
56 }
57 
59 {
60 
62  event.getByLabel(hepMCProduct_, product);
63 
64  const HepMC::GenEvent* evt = product->GetEvent();
65 
66  _output->write_event(evt);
67 
68 }
69 
~HepMCEventWriter() override
void analyze(const edm::Event &event, const edm::EventSetup &es) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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
element_type const * get() const
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
HLT enums.
edm::InputTag hepMCProduct_
HepMCEventWriter(const edm::ParameterSet &params)
Definition: event.py:1
Definition: Run.h:45