| 1 |
// -*- C++ -*- |
| 2 |
// |
| 3 |
// This file is part of HepMC |
| 4 |
// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details) |
| 5 |
// |
| 6 |
#ifndef HEPMC3_WRITERHEPEVT_H |
| 7 |
#define HEPMC3_WRITERHEPEVT_H |
| 8 |
/** |
| 9 |
* @file WriterHEPEVT.h |
| 10 |
* @brief Definition of \b class WriterHEPEVT |
| 11 |
* |
| 12 |
* @class HepMC3::WriterHEPEVT |
| 13 |
* @brief GenEvent I/O serialization for HEPEVT files |
| 14 |
* |
| 15 |
* |
| 16 |
* @ingroup IO |
| 17 |
* |
| 18 |
*/ |
| 19 |
#include "HepMC3/Writer.h" |
| 20 |
#include "HepMC3/GenEvent.h" |
| 21 |
#include "HepMC3/Data/GenEventData.h" |
| 22 |
|
| 23 |
#include <fstream> |
| 24 |
namespace HepMC3 |
| 25 |
{ |
| 26 |
|
| 27 |
class WriterHEPEVT : public Writer |
| 28 |
{ |
| 29 |
// |
| 30 |
// Constructors |
| 31 |
// |
| 32 |
public: |
| 33 |
/** @brief Default constructor |
| 34 |
* @warning If file exists, it will be overwritten |
| 35 |
*/ |
| 36 |
WriterHEPEVT(const std::string &filename); |
| 37 |
|
| 38 |
/// @brief Constructor from ostream |
| 39 |
WriterHEPEVT(std::ostream& stream); |
| 40 |
|
| 41 |
// |
| 42 |
// Functions |
| 43 |
// |
| 44 |
public: |
| 45 |
|
| 46 |
/** @brief Write particle to file |
| 47 |
* |
| 48 |
* @param[in] index Particle to be serialized |
| 49 |
* @param[in] iflong Format of record |
| 50 |
*/ |
| 51 |
|
| 52 |
virtual void write_hepevt_particle( int index, bool iflong=true ); |
| 53 |
/** @brief Write event header to file |
| 54 |
* |
| 55 |
*/ |
| 56 |
virtual void write_hepevt_event_header(); |
| 57 |
|
| 58 |
/** @brief Write event to file |
| 59 |
* |
| 60 |
* @param[in] evt Event to be serialized |
| 61 |
*/ |
| 62 |
void write_event(const GenEvent &evt); |
| 63 |
|
| 64 |
/** @brief Close file stream */ |
| 65 |
void close(); |
| 66 |
|
| 67 |
/** @brief Get stream error state flag */ |
| 68 |
bool failed(); |
| 69 |
/** @brief set flag if vertex positions are available */ |
| 70 |
void set_vertices_positions_present(bool iflong); |
| 71 |
|
| 72 |
/** @brief get flag if vertex positions are available */ |
| 73 |
bool get_vertices_positions_present() const; |
| 74 |
|
| 75 |
protected: |
| 76 |
std::ofstream m_file; //!< Output file |
| 77 |
std::ostream* m_stream; //!< Output stream |
| 78 |
char* hepevtbuffer; //!< Pointer to HEPEVT Fortran common block/C struct |
| 79 |
int m_events_count; //!< Events count. Needed to generate unique object name |
| 80 |
bool m_vertices_positions_present; //!< true if vertex positions are available |
| 81 |
}; |
| 82 |
|
| 83 |
} // namespace HepMC3 |
| 84 |
#endif |