HepMC3 event record library
Public Member Functions | Data Fields | Private Member Functions | Private Attributes
WriterRootTree Class Reference

Detailed Description

GenEvent I/O serialization for root files based on root TTree.

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:
convert_example.cc.

Definition at line 38 of file WriterRootTree.h.

#include <WriterRootTree.h>

+ Inheritance diagram for WriterRootTree:
+ Collaboration diagram for WriterRootTree:

Public Member Functions

 WriterRootTree (const std::string &filename, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >())
 Default constructor. More...
 
 WriterRootTree (const std::string &filename, const std::string &treename, const std::string &branchname, shared_ptr< GenRunInfo > run=shared_ptr< GenRunInfo >())
 Constructor with tree name. More...
 
void write_event (const GenEvent &evt)
 Write event to file. More...
 
void write_run_info ()
 Write the GenRunInfo object to file. More...
 
void close ()
 Close file stream. More...
 
bool failed ()
 Get stream error state flag. More...
 
void set_run_info (shared_ptr< GenRunInfo > run)
 Set the global GenRunInfo object. More...
 
shared_ptr< GenRunInforun_info () const
 Get the global GenRunInfo object. More...
 

Data Fields

TTree * m_tree
 Tree handler. Public to allow simple access, e.g. custom branches. More...
 

Private Member Functions

bool init (shared_ptr< GenRunInfo > run)
 init routine More...
 

Private Attributes

TFile * m_file
 File handler. More...
 
int m_events_count
 Events count. Needed to read the tree. More...
 
GenEventDatam_event_data
 Pointer to structure that holds event data. More...
 
GenRunInfoDatam_run_info_data
 Pointer to structure that holds run info data. More...
 
std::string m_tree_name
 Name of TTree. More...
 
std::string m_branch_name
 Name of TBranch in TTree. More...
 

Constructor & Destructor Documentation

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

Default constructor.

Warning
If file exists, it will be overwritten

Definition at line 20 of file WriterRootTree.cc.

References WriterRootTree::init(), and WriterRootTree::m_file.

WriterRootTree ( const std::string &  filename,
const std::string &  treename,
const std::string &  branchname,
shared_ptr< GenRunInfo run = shared_ptr<GenRunInfo>() 
)

Constructor with tree name.

Definition at line 30 of file WriterRootTree.cc.

References WriterRootTree::init(), and WriterRootTree::m_file.

Member Function Documentation

void close ( )
virtual

Close file stream.

Implements Writer.

Definition at line 91 of file WriterRootTree.cc.

References WriterRootTree::m_event_data, WriterRootTree::m_file, WriterRootTree::m_run_info_data, and WriterRootTree::m_tree.

bool failed ( )
virtual

Get stream error state flag.

Implements Writer.

Definition at line 100 of file WriterRootTree.cc.

References WriterRootTree::m_file.

bool init ( shared_ptr< GenRunInfo run)
private
shared_ptr<GenRunInfo> run_info ( ) const
inlineinherited

Get the global GenRunInfo object.

Definition at line 44 of file Writer.h.

References Writer::m_run_info.

void set_run_info ( shared_ptr< GenRunInfo run)
inlineinherited

Set the global GenRunInfo object.

Definition at line 39 of file Writer.h.

References Writer::m_run_info.

void write_event ( const GenEvent evt)
virtual
void write_run_info ( )

Write the GenRunInfo object to file.

Definition at line 89 of file WriterRootTree.cc.

Field Documentation

std::string m_branch_name
private

Name of TBranch in TTree.

Definition at line 87 of file WriterRootTree.h.

GenEventData* m_event_data
private

Pointer to structure that holds event data.

Definition at line 84 of file WriterRootTree.h.

int m_events_count
private

Events count. Needed to read the tree.

Definition at line 83 of file WriterRootTree.h.

TFile* m_file
private

File handler.

Definition at line 79 of file WriterRootTree.h.

GenRunInfoData* m_run_info_data
private

Pointer to structure that holds run info data.

Definition at line 85 of file WriterRootTree.h.

TTree* m_tree

Tree handler. Public to allow simple access, e.g. custom branches.

Definition at line 81 of file WriterRootTree.h.

std::string m_tree_name
private

Name of TTree.

Definition at line 86 of file WriterRootTree.h.


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