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 
MessageLogger.h
propagate_const.h
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
edm::Run
Definition: Run.h:45
edm
HLT enums.
Definition: AlignableModifier.h:19
HepMCEventWriter::HepMCEventWriter
HepMCEventWriter(const edm::ParameterSet &params)
Definition: HepMCEventWriter.cc:35
HepMCEventWriter::_output
edm::propagate_const< HepMC::IO_GenEvent * > _output
Definition: HepMCEventWriter.cc:31
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::propagate_const::get
constexpr element_type const * get() const
Definition: propagate_const.h:64
EDAnalyzer.h
edm::Handle< edm::HepMCProduct >
HepMC::GenEvent
Definition: hepmc_rootio.cc:9
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
HepMCEventWriter
Definition: HepMCEventWriter.cc:20
edm::propagate_const< HepMC::IO_GenEvent * >
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Run.h
HepMCEventWriter::endRun
void endRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: HepMCEventWriter.cc:44
edm::ParameterSet
Definition: ParameterSet.h:47
HepMCEventWriter::analyze
void analyze(const edm::Event &event, const edm::EventSetup &es) override
Definition: HepMCEventWriter.cc:49
Event.h
edm::EventSetup
Definition: EventSetup.h:57
edm::HepMCProduct::GetEvent
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:34
InputTag.h
HepMCEventWriter::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &es) override
Definition: HepMCEventWriter.cc:40
writedatasetfile.run
run
Definition: writedatasetfile.py:27
HepMCEventWriter::~HepMCEventWriter
~HepMCEventWriter() override
Definition: HepMCEventWriter.cc:38
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ParameterSet.h
HepMCProduct.h
HepMCEventWriter::hepMCProduct_
edm::InputTag hepMCProduct_
Definition: HepMCEventWriter.cc:32
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15