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

Detailed Description

Example analysis. Produces a rapidity distribution of final state particles.

Definition at line 20 of file AnalysisExample.h.

#include <AnalysisExample.h>

+ Inheritance diagram for AnalysisExample:
+ Collaboration diagram for AnalysisExample:

Public Member Functions

 AnalysisExample (const std::string &filename, std::shared_ptr< GenRunInfo > run)
 Constructor.
 
 AnalysisExample (std::ostream &stream, std::shared_ptr< GenRunInfo > run)
 Constructor from ostream.
 
void write_event (const GenEvent &evt) override
 Write event to file.
 
bool failed () override
 Return status of the stream.
 
void close () override
 Close file stream.
 
 ~AnalysisExample ()
 destructor
 
void set_run_info (std::shared_ptr< GenRunInfo > run)
 Set the global GenRunInfo object.
 
std::shared_ptr< GenRunInforun_info () const
 Get the global GenRunInfo object.
 
void set_options (const std::map< std::string, std::string > &options)
 Set options.
 
std::map< std::string, std::string > get_options () const
 Set options.
 

Data Fields

double m_sum_of_weights =0
 Sum of event weights.
 
double m_sum_of_weights2 =0
 Sum of event weights**2.
 
std::map< std::string, std::vector< double > > m_bins
 Binings.
 
std::map< std::string, std::vector< double > > m_vals
 Values.
 
std::map< std::string, std::vector< double > > m_errs
 Uncertainties.
 

Protected Attributes

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

Private Attributes

std::ofstream m_file
 Output file.
 
std::ostream * m_stream
 Output stream.
 
std::shared_ptr< GenRunInfom_run_info
 The global GenRunInfo object.
 

Constructor & Destructor Documentation

◆ AnalysisExample() [1/2]

AnalysisExample ( const std::string &  filename,
std::shared_ptr< GenRunInfo run 
)

Constructor.

Warning
If file already exists, it will be cleared before writing

Definition at line 8 of file AnalysisExample.cc.

References HEPMC3_ERROR.

◆ AnalysisExample() [2/2]

AnalysisExample ( std::ostream &  stream,
std::shared_ptr< GenRunInfo run 
)

◆ ~AnalysisExample()

~AnalysisExample ( )
inline

destructor

Definition at line 39 of file AnalysisExample.h.

References AnalysisExample::close().

Member Function Documentation

◆ close()

void close ( )
overridevirtual

◆ failed()

bool failed ( )
inlineoverridevirtual

Return status of the stream.

Implements Writer.

Definition at line 33 of file AnalysisExample.h.

References AnalysisExample::m_file.

◆ get_options()

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

Set options.

Definition at line 61 of file Writer.h.

References Writer::m_options.

◆ run_info()

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.

◆ set_options()

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.

◆ set_run_info()

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.

◆ write_event()

void write_event ( const GenEvent evt)
overridevirtual

Write event to file.

Parameters
[in]evtEvent to be serialized

Implements Writer.

Definition at line 33 of file AnalysisExample.cc.

References AnalysisExample::m_bins, AnalysisExample::m_errs, AnalysisExample::m_sum_of_weights, AnalysisExample::m_sum_of_weights2, AnalysisExample::m_vals, GenEvent::particles(), and GenEvent::weight().

Field Documentation

◆ m_bins

std::map<std::string, std::vector<double> > m_bins

Binings.

Definition at line 43 of file AnalysisExample.h.

◆ m_errs

std::map<std::string, std::vector<double> > m_errs

Uncertainties.

Definition at line 45 of file AnalysisExample.h.

◆ m_file

std::ofstream m_file
private

Output file.

Definition at line 47 of file AnalysisExample.h.

◆ m_options

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

options

Definition at line 68 of file Writer.h.

◆ m_run_info

std::shared_ptr<GenRunInfo> m_run_info
privateinherited

The global GenRunInfo object.

Definition at line 73 of file Writer.h.

◆ m_stream

std::ostream* m_stream
private

Output stream.

Definition at line 48 of file AnalysisExample.h.

◆ m_sum_of_weights

double m_sum_of_weights =0

Sum of event weights.

Definition at line 41 of file AnalysisExample.h.

◆ m_sum_of_weights2

double m_sum_of_weights2 =0

Sum of event weights**2.

Definition at line 42 of file AnalysisExample.h.

◆ m_vals

std::map<std::string, std::vector<double> > m_vals

Values.

Definition at line 44 of file AnalysisExample.h.


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