HepMC3 event record library
AnalysisExample Class Reference

Detailed Description

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

Definition at line 25 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
 
virtual void set_run_info (std::shared_ptr< GenRunInfo > run)
 Set the global GenRunInfo object.
 
virtual std::shared_ptr< GenRunInforun_info () const
 Get the global GenRunInfo object.
 
virtual void set_options (const std::map< std::string, std::string > &options)
 Set options.
 
virtual 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 =nullptr
 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 17 of file AnalysisExample.cc.

References AnalysisExample(), m_bins, m_errs, m_file, m_stream, m_sum_of_weights, m_sum_of_weights2, and m_vals.

◆ AnalysisExample() [2/2]

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

Constructor from ostream.

Definition at line 30 of file AnalysisExample.cc.

References m_bins, m_errs, m_stream, m_sum_of_weights, m_sum_of_weights2, and m_vals.

◆ ~AnalysisExample()

~AnalysisExample ( )
inline

destructor

Definition at line 44 of file AnalysisExample.h.

References close().

Member Function Documentation

◆ close()

void close ( )
overridevirtual

Close file stream.

Implements Writer.

Definition at line 57 of file AnalysisExample.cc.

References m_bins, m_errs, m_stream, m_sum_of_weights, and m_vals.

◆ failed()

bool failed ( )
inlineoverridevirtual

Return status of the stream.

Implements Writer.

Definition at line 38 of file AnalysisExample.h.

References m_file.

◆ get_options()

virtual std::map< std::string, std::string > get_options ( ) const
inlinevirtualinherited

Set options.

Reimplemented in WriterPlugin.

Definition at line 54 of file Writer.h.

References m_options.

◆ run_info()

virtual std::shared_ptr< GenRunInfo > run_info ( ) const
inlinevirtualinherited

Get the global GenRunInfo object.

Reimplemented in WriterGZ< T, C >, and WriterPlugin.

Definition at line 45 of file Writer.h.

References m_run_info.

◆ set_options()

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

Set options.

Reimplemented in WriterPlugin.

Definition at line 52 of file Writer.h.

References m_options.

◆ set_run_info()

virtual void set_run_info ( std::shared_ptr< GenRunInfo > run)
inlinevirtualinherited

Set the global GenRunInfo object.

Reimplemented in WriterGZ< T, C >, and WriterPlugin.

Definition at line 42 of file Writer.h.

References 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 41 of file AnalysisExample.cc.

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

Field Documentation

◆ m_bins

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

Binings.

Definition at line 48 of file AnalysisExample.h.

◆ m_errs

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

Uncertainties.

Definition at line 50 of file AnalysisExample.h.

◆ m_file

std::ofstream m_file
private

Output file.

Definition at line 52 of file AnalysisExample.h.

◆ m_options

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

options

Definition at line 59 of file Writer.h.

◆ m_run_info

std::shared_ptr<GenRunInfo> m_run_info
privateinherited

The global GenRunInfo object.

Definition at line 64 of file Writer.h.

◆ m_stream

std::ostream* m_stream =nullptr
private

Output stream.

Definition at line 53 of file AnalysisExample.h.

◆ m_sum_of_weights

double m_sum_of_weights =0

Sum of event weights.

Definition at line 46 of file AnalysisExample.h.

◆ m_sum_of_weights2

double m_sum_of_weights2 =0

Sum of event weights**2.

Definition at line 47 of file AnalysisExample.h.

◆ m_vals

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

Values.

Definition at line 49 of file AnalysisExample.h.


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