HepMC3 event record library
Public Member Functions | Protected Attributes | Private Attributes
WriterRoot Class Reference

GenEvent I/O serialization for root files. More...

#include <WriterRoot.h>

+ Inheritance diagram for WriterRoot:
+ Collaboration diagram for WriterRoot:

Public Member Functions

 WriterRoot (const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
 Default constructor. More...
 
void write_event (const GenEvent &evt) override
 Write event to file. More...
 
void write_run_info ()
 Write the GenRunInfo object to file. More...
 
void close () override
 Close file stream. More...
 
bool failed () override
 Get stream error state flag. More...
 
void set_run_info (std::shared_ptr< GenRunInfo > run)
 Set the global GenRunInfo object. More...
 
std::shared_ptr< GenRunInforun_info () const
 Get the global GenRunInfo object. More...
 
void set_options (const std::map< std::string, std::string > &options)
 Set options. More...
 
std::map< std::string,
std::string > 
get_options () const
 Set options. More...
 

Protected Attributes

std::map< std::string,
std::string > 
m_options
 options More...
 

Private Attributes

TFile * m_file
 File handler. More...
 
int m_events_count
 Events count. Needed to generate unique object name. More...
 

Detailed Description

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.

Examples:
rootIO_example_write.cc.

Definition at line 35 of file WriterRoot.h.

Constructor & Destructor Documentation

WriterRoot ( const std::string &  filename,
std::shared_ptr< GenRunInfo run = std::shared_ptr<GenRunInfo>() 
)

Default constructor.

Warning
If file exists, it will be overwritten

Definition at line 21 of file WriterRoot.cc.

References HEPMC3_ERROR.

Member Function Documentation

void close ( )
overridevirtual

Close file stream.

Implements Writer.

Examples:
rootIO_example_write.cc.

Definition at line 75 of file WriterRoot.cc.

References WriterRoot::m_file.

bool failed ( )
overridevirtual

Get stream error state flag.

Implements Writer.

Definition at line 79 of file WriterRoot.cc.

References WriterRoot::m_file.

std::map<std::string, std::string> get_options ( ) const
inlineinherited

Set options.

Definition at line 61 of file Writer.h.

References Writer::m_options.

std::shared_ptr<GenRunInfo> run_info ( ) const
inlineinherited

Get the global GenRunInfo object.

Definition at line 47 of file Writer.h.

References Writer::m_run_info.

void set_options ( const std::map< std::string, std::string > &  options)
inlineinherited

Set options.

Definition at line 56 of file Writer.h.

References Writer::m_options.

void set_run_info ( std::shared_ptr< GenRunInfo run)
inlineinherited

Set the global GenRunInfo object.

Definition at line 42 of file Writer.h.

References Writer::m_run_info.

void write_event ( const GenEvent evt)
overridevirtual

Write event to file.

Parameters
[in]evtEvent to be serialized

Implements Writer.

Examples:
rootIO_example_write.cc.

Definition at line 34 of file WriterRoot.cc.

References HEPMC3_ERROR, HEPMC3_WARNING, WriterRoot::m_events_count, WriterRoot::m_file, Writer::run_info(), GenEvent::run_info(), Writer::set_run_info(), GenEvent::write_data(), and WriterRoot::write_run_info().

void write_run_info ( )

Write the GenRunInfo object to file.

Definition at line 61 of file WriterRoot.cc.

References HEPMC3_ERROR, WriterRoot::m_file, and Writer::run_info().

Field Documentation

int m_events_count
private

Events count. Needed to generate unique object name.

Definition at line 70 of file WriterRoot.h.

TFile* m_file
private

File handler.

Definition at line 69 of file WriterRoot.h.

std::map<std::string, std::string> m_options
protectedinherited

options

Definition at line 68 of file Writer.h.


The documentation for this class was generated from the following files: