Loading [MathJax]/jax/output/SVG/config.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
17 namespace HepMC {
18 typedef HepMC3::WriterAsciiHepMC2 WriterAsciiHepMC2;
19 typedef HepMC3::ReaderAsciiHepMC2 ReaderAsciiHepMC2;
20 class IO_GenEvent {
21 public:
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  }
37 private:
38  std::unique_ptr<HepMC3::WriterAsciiHepMC2> m_writer;
39 };
40 }
41 #else
42 #include "HepMC/IO_GenEvent.h"
43 #endif
44 #endif
IO_GenEvent.h
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LArG4FSStartPointFilter.evt
evt
Definition: LArG4FSStartPointFilter.py:42
Preparation.mode
mode
Definition: Preparation.py:107
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
HepMC
Definition: Barcode.h:14
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24