HepMC3 event record library
examples
ConvertExample
src
WriterHEPEVTZEUS.cc
1
// -*- C++ -*-
2
//
3
// This file is part of HepMC
4
// Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
5
//
6
#include "
WriterHEPEVTZEUS.h
"
7
#include "
HepMC3/HEPEVT_Wrapper.h
"
8
#include <array>
9
namespace
HepMC3
10
{
11
WriterHEPEVTZEUS::WriterHEPEVTZEUS
(
const
std::string &filename):
WriterHEPEVT
(filename) {}
12
void
WriterHEPEVTZEUS::write_hepevt_event_header
()
13
{
14
std::array<char,512> buf;
//Note: the format is fixed, so no reason for complicatied tratment
15
char
* cursor = buf.data();
16
cursor += sprintf(cursor,
" E % 12i% 12i% 12i\n"
,
m_hepevt_interface
.event_number(), 0,
m_hepevt_interface
.number_entries());
17
m_stream
->write( buf.data(), cursor - buf.data());
18
}
19
void
WriterHEPEVTZEUS::write_hepevt_particle
(
int
index,
bool
iflong)
20
{
21
if
(!iflong) printf(
"INFO: the parameter is ignored as HEPEVTZEUS always uses long format\n"
);
22
std::array<char,512> buf;
//Note: the format is fixed, so no reason for complicatied tratment
23
char
* cursor = buf.data();
24
cursor += sprintf(cursor,
"% 12i% 8i"
,
m_hepevt_interface
.status(index),
m_hepevt_interface
.id(index));
25
cursor += sprintf(cursor,
"% 8i% 8i"
,
m_hepevt_interface
.first_parent(index),
m_hepevt_interface
.last_parent(index));
26
cursor += sprintf(cursor,
"% 8i% 8i"
,
m_hepevt_interface
.first_child(index),
m_hepevt_interface
.last_child(index));
27
cursor += sprintf(cursor,
"% 19.11E% 19.11E% 19.11E% 19.11E% 19.11E\n"
,
m_hepevt_interface
.px(index),
m_hepevt_interface
.py(index),
m_hepevt_interface
.pz(index),
m_hepevt_interface
.e(index),
m_hepevt_interface
.m(index));
28
cursor += sprintf(cursor,
"%-52s% 19.11E% 19.11E% 19.11E% 19.11E% 19.11E\n"
,
" "
,
m_hepevt_interface
.x(index),
m_hepevt_interface
.y(index),
m_hepevt_interface
.z(index),
m_hepevt_interface
.t(index), 0.0);
29
m_stream
->write( buf.data(), cursor - buf.data() );
30
}
31
}
// namespace HepMC3
HEPEVT_Wrapper.h
Definition of class HEPEVT_Wrapper.
WriterHEPEVTZEUS.h
Definition of class WriterHEPEVTZEUS.
HepMC3::WriterHEPEVTZEUS::write_hepevt_particle
void write_hepevt_particle(int index, bool iflong=true) override
Write particles.
Definition
WriterHEPEVTZEUS.cc:19
HepMC3::WriterHEPEVTZEUS::write_hepevt_event_header
void write_hepevt_event_header() override
Write the header.
Definition
WriterHEPEVTZEUS.cc:12
HepMC3::WriterHEPEVTZEUS::WriterHEPEVTZEUS
WriterHEPEVTZEUS(const std::string &filename)
Constructor.
Definition
WriterHEPEVTZEUS.cc:11
HepMC3::WriterHEPEVT::m_hepevt_interface
HEPEVT_Wrapper_Template< 100000 > m_hepevt_interface
Templated HEPEVT interface.
Definition
WriterHEPEVT.h:89
HepMC3::WriterHEPEVT::WriterHEPEVT
WriterHEPEVT(const std::string &filename, std::shared_ptr< GenRunInfo > run=nullptr)
Default constructor.
Definition
WriterHEPEVT.cc:21
HepMC3::WriterHEPEVT::m_stream
std::ostream * m_stream
Output stream.
Definition
WriterHEPEVT.h:86
HepMC3
HepMC3 main namespace.
Definition
AnalysisExample.h:24
Generated on Sun Mar 9 2025 18:20:55 for HepMC3 event record library by
1.13.2