HepMC3 event record library
examples
ConvertExample
include
WriterDOT.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_WRITERDOT_H
7
#define HEPMC3_WRITERDOT_H
8
///
9
/// @file WriterDOT.h
10
/// @brief Definition of class \b WriterDOT
11
///
12
/// @class HepMC3::WriterDOT
13
/// @brief GenEvent I/O output to dot files that should be processed by graphviz or other software
14
///
15
/// @ingroup Examples
16
///
17
#include <string>
18
#include <fstream>
19
#include "
HepMC3/Writer.h
"
20
#include "
HepMC3/GenEvent.h
"
21
#include "
HepMC3/GenParticle.h
"
22
#include "
HepMC3/GenVertex.h
"
23
#include "
HepMC3/Data/GenEventData.h
"
24
namespace
HepMC3
25
{
26
class
WriterDOT
:
public
Writer
27
{
28
public
:
29
/// @brief Constructor
30
/// @warning If file already exists, it will be cleared before writing
31
WriterDOT
(
const
std::string &filename,std::shared_ptr<GenRunInfo> run = std::shared_ptr<GenRunInfo>());
32
/// @brief Constructor from ostream
33
WriterDOT
(std::ostream& stream,std::shared_ptr<GenRunInfo> run =std:: shared_ptr<GenRunInfo>());
34
/// @brief Write event to file
35
///
36
/// @param[in] evt Event to be serialized
37
void
write_event
(
const
GenEvent
&evt)
override
;
38
/// @brief Return status of the stream
39
bool
failed
()
override
{
40
return
(
bool
)
m_file
.rdstate();
41
}
42
/// @brief Close file stream
43
void
close
()
override
;
44
/// @brief Close file stream
45
void
set_style
(
const
int
& istyle) {
46
m_style
=istyle;
47
};
48
49
private
:
50
void
allocate_buffer
();
//!< allocates buffer for output
51
void
flush
();
//!< flushes output buffer
52
void
forced_flush
();
//!< flushes output buffer
53
std::ofstream
m_file
;
//!< Output file
54
std::ostream*
m_stream
;
//!< Output stream
55
int
m_style
;
//!< style of dot file
56
char
*
m_buffer
;
//!< Stream buffer
57
char
*
m_cursor
;
//!< Cursor inside stream buffer
58
unsigned
long
m_buffer_size
;
//!< Buffer size
59
};
60
}
61
#endif
GenEventData.h
Definition of struct GenEventData.
GenEvent.h
Definition of class GenEvent.
GenParticle.h
Definition of class GenParticle.
GenVertex.h
Definition of class GenVertex.
Writer.h
Definition of interface Writer.
HepMC3::GenEvent
Stores event-related information.
Definition
GenEvent.h:41
HepMC3::WriterDOT
GenEvent I/O output to dot files that should be processed by graphviz or other software.
Definition
WriterDOT.h:27
HepMC3::WriterDOT::allocate_buffer
void allocate_buffer()
allocates buffer for output
Definition
WriterDOT.cc:104
HepMC3::WriterDOT::m_cursor
char * m_cursor
Cursor inside stream buffer.
Definition
WriterDOT.h:57
HepMC3::WriterDOT::failed
bool failed() override
Return status of the stream.
Definition
WriterDOT.h:39
HepMC3::WriterDOT::set_style
void set_style(const int &istyle)
Close file stream.
Definition
WriterDOT.h:45
HepMC3::WriterDOT::m_buffer
char * m_buffer
Stream buffer.
Definition
WriterDOT.h:56
HepMC3::WriterDOT::close
void close() override
Close file stream.
Definition
WriterDOT.cc:30
HepMC3::WriterDOT::m_file
std::ofstream m_file
Output file.
Definition
WriterDOT.h:53
HepMC3::WriterDOT::m_buffer_size
unsigned long m_buffer_size
Buffer size.
Definition
WriterDOT.h:58
HepMC3::WriterDOT::write_event
void write_event(const GenEvent &evt) override
Write event to file.
Definition
WriterDOT.cc:50
HepMC3::WriterDOT::flush
void flush()
flushes output buffer
Definition
WriterDOT.cc:122
HepMC3::WriterDOT::forced_flush
void forced_flush()
flushes output buffer
Definition
WriterDOT.cc:131
HepMC3::WriterDOT::m_stream
std::ostream * m_stream
Output stream.
Definition
WriterDOT.h:54
HepMC3::WriterDOT::m_style
int m_style
style of dot file
Definition
WriterDOT.h:55
HepMC3::WriterDOT::WriterDOT
WriterDOT(const std::string &filename, std::shared_ptr< GenRunInfo > run=std::shared_ptr< GenRunInfo >())
Constructor.
Definition
WriterDOT.cc:9
HepMC3::Writer
Base class for all I/O writers.
Definition
Writer.h:25
HepMC3
HepMC3 main namespace.
Definition
AnalysisExample.h:24
Generated on Wed Nov 20 2024 09:41:56 for HepMC3 event record library by
1.12.0