1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
// -*- C++ -*-
//
// This file is part of HepMC
// Copyright (C) 2014-2019 The HepMC collaboration (see AUTHORS for details)
//
#ifndef HEPMC3_WRITERROOT_H
#define HEPMC3_WRITERROOT_H
/**
* @file WriterRoot.h
* @brief Definition of \b class WriterRoot
*
* @class HepMC3::WriterRoot
* @brief GenEvent I/O serialization for root files
*
* If HepMC was compiled with path to ROOT available, this class can be used
* for root writing in the same manner as with HepMC::WriterAscii class.
*
* @ingroup IO
*
*/
#include "HepMC3/Writer.h"
#include "HepMC3/GenEvent.h"
#include "HepMC3/Data/GenEventData.h"
#include "HepMC3/Data/GenRunInfoData.h"
// ROOT header files
#ifdef __CINT__
#include "TFile.h"
#else
class TFile;
#endif
namespace HepMC3 {
class WriterRoot : public Writer {
//
// Constructors
//
public:
/** @brief Default constructor
* @warning If file exists, it will be overwritten
*/
WriterRoot(const std::string& filename,
shared_ptr<GenRunInfo> run = shared_ptr<GenRunInfo>());
//
// Functions
//
public:
/** @brief Write event to file
*
* @param[in] evt Event to be serialized
*/
void write_event(const GenEvent &evt);
/** @brief Write the GenRunInfo object to file. */
void write_run_info();
/** @brief Close file stream */
void close();
/** @brief Get stream error state flag */
bool failed();
//
// Fields
//
private:
TFile* m_file; //!< File handler
int m_events_count; //!< Events count. Needed to generate unique object name
};
} // namespace HepMC3
#endif
|