HepMC3 event record library
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
examples
ConvertExample
include
AnalysisExample.h
Go to the documentation of this file.
1
#ifndef HEPMC3_ANALYSISEXAMPLE_H
2
#define HEPMC3_ANALYSISEXAMPLE_H
3
///
4
/// @file AnalysisExample.h
5
/// @brief Definition of class \b AnalysisExample
6
///
7
/// @class HepMC3::AnalysisExample
8
/// @brief Example analysis. Produces a rapidity distribution of final state particles.
9
///
10
/// @ingroup Examples
11
///
12
#include <string>
13
#include <fstream>
14
#include "
HepMC3/Writer.h
"
15
#include "HepMC3/Version.h"
16
#include "
HepMC3/GenEvent.h
"
17
#include "
HepMC3/GenParticle.h
"
18
namespace
HepMC3
19
{
20
class
AnalysisExample
:
public
Writer
21
{
22
public
:
23
/// @brief Constructor
24
/// @warning If file already exists, it will be cleared before writing
25
AnalysisExample
(
const
std::string &filename,std::shared_ptr<GenRunInfo> run);
26
/// @brief Constructor from ostream
27
AnalysisExample
(std::ostream& stream,std::shared_ptr<GenRunInfo> run);
28
/// @brief Write event to file
29
///
30
/// @param[in] evt Event to be serialized
31
void
write_event
(
const
GenEvent
&evt)
override
;
32
/// @brief Return status of the stream
33
bool
failed
()
override
{
34
return
(
bool
)
m_file
.rdstate();
35
}
36
/// @brief Close file stream
37
void
close
()
override
;
38
/// @brief destructor
39
~AnalysisExample
(){
close
(); }
40
41
double
m_sum_of_weights
=0;
//!< Sum of event weights
42
double
m_sum_of_weights2
=0;
//!< Sum of event weights**2
43
std::map<std::string, std::vector<double> >
m_bins
;
//!< Binings
44
std::map<std::string, std::vector<double> >
m_vals
;
//!< Values
45
std::map<std::string, std::vector<double> >
m_errs
;
//!< Uncertainties
46
private
:
47
std::ofstream
m_file
;
//!< Output file
48
std::ostream*
m_stream
;
//!< Output stream
49
};
50
}
51
#endif
HepMC3::AnalysisExample::failed
bool failed() override
Return status of the stream.
Definition:
AnalysisExample.h:33
HepMC3::AnalysisExample::m_file
std::ofstream m_file
Output file.
Definition:
AnalysisExample.h:47
HepMC3::AnalysisExample::m_bins
std::map< std::string, std::vector< double > > m_bins
Binings.
Definition:
AnalysisExample.h:43
GenParticle.h
Definition of class GenParticle.
HepMC3::AnalysisExample
Example analysis. Produces a rapidity distribution of final state particles.
Definition:
AnalysisExample.h:20
HepMC3::AnalysisExample::m_errs
std::map< std::string, std::vector< double > > m_errs
Uncertainties.
Definition:
AnalysisExample.h:45
HepMC3::AnalysisExample::m_vals
std::map< std::string, std::vector< double > > m_vals
Values.
Definition:
AnalysisExample.h:44
HepMC3::AnalysisExample::write_event
void write_event(const GenEvent &evt) override
Write event to file.
Definition:
AnalysisExample.cc:33
HepMC3::AnalysisExample::AnalysisExample
AnalysisExample(const std::string &filename, std::shared_ptr< GenRunInfo > run)
Constructor.
Definition:
AnalysisExample.cc:8
HepMC3::GenEvent
Stores event-related information.
Definition:
GenEvent.h:41
HepMC3::AnalysisExample::m_sum_of_weights
double m_sum_of_weights
Sum of event weights.
Definition:
AnalysisExample.h:41
Writer.h
Definition of interface Writer.
HepMC3::AnalysisExample::m_stream
std::ostream * m_stream
Output stream.
Definition:
AnalysisExample.h:48
HepMC3::Writer
Base class for all I/O writers.
Definition:
Writer.h:25
HepMC3::AnalysisExample::~AnalysisExample
~AnalysisExample()
destructor
Definition:
AnalysisExample.h:39
GenEvent.h
Definition of class GenEvent.
HepMC3::AnalysisExample::m_sum_of_weights2
double m_sum_of_weights2
Sum of event weights**2.
Definition:
AnalysisExample.h:42
HepMC3::AnalysisExample::close
void close() override
Close file stream.
Definition:
AnalysisExample.cc:49
Generated on Mon Jan 4 2021 09:07:22 for HepMC3 event record library by
1.8.5