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