ATLAS Offline Software
Loading...
Searching...
No Matches
IO_GenEvent.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4/* Author: Andrii Verbytskyi andrii.verbytskyi@mpp.mpg.de */
5
6#ifndef ATLASHEPMC_IOGENEVENT_H
7#define ATLASHEPMC_IOGENEVENT_H
8#ifdef HEPMC3
9#include "HepMC3/Version.h"
10#include "HepMC3/Reader.h"
11#include "HepMC3/Writer.h"
12#include "HepMC3/ReaderAsciiHepMC2.h"
13#include "HepMC3/WriterAsciiHepMC2.h"
14
15#include <memory>
16
17namespace HepMC {
18typedef HepMC3::WriterAsciiHepMC2 WriterAsciiHepMC2;
19typedef HepMC3::ReaderAsciiHepMC2 ReaderAsciiHepMC2;
20class IO_GenEvent {
21public:
22 IO_GenEvent( const std::string& filename="IO_GenEvent.dat",
23 std::ios::openmode mode=std::ios::out ) :
24 m_writer(std::make_unique<HepMC3::WriterAsciiHepMC2>(filename))
25 {
26 if (mode!=std::ios::out) printf("In AtlasHepMC/IO_GenEvent.h in IO_GenEvent(filename,mode) mode should be std::ios::out\n");
27 }
28 IO_GenEvent( std::ostream & os ) :
29 m_writer(std::make_unique<HepMC3::WriterAsciiHepMC2>(os))
30 {}
31 ~IO_GenEvent() {
32 m_writer->close();
33 }
34 void write_event( const HepMC3::GenEvent* evt ) {
35 m_writer->write_event(*evt);
36 }
37private:
38 std::unique_ptr<HepMC3::WriterAsciiHepMC2> m_writer;
39};
40}
41#else
42#include "HepMC/IO_GenEvent.h"
43#endif
44#endif