HepMC3 event record library
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"
8#include <array>
9namespace HepMC3
10{
11WriterHEPEVTZEUS::WriterHEPEVTZEUS(const std::string &filename):WriterHEPEVT(filename) {}
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}
19void 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
Definition of class HEPEVT_Wrapper.
Definition of class WriterHEPEVTZEUS.
int first_child(const int index) const
Get index of 1st daughter.
int last_parent(const int index) const
Get index of last mother.
int event_number() const
Get event number.
int last_child(const int index) const
Get index of last daughter.
int first_parent(const int index) const
Get index of 1st mother.
double pz(const int index) const
Get Z momentum.
double py(const int index) const
Get Y momentum.
int id(const int index) const
Get PDG particle id.
double t(const int index) const
Get production time.
double y(const int index) const
Get Y Production vertex.
int number_entries() const
Get number of entries.
double m(const int index) const
Get generated mass.
int status(const int index) const
Get status code.
double px(const int index) const
Get X momentum.
double z(const int index) const
Get Z Production vertex.
double x(const int index) const
Get X Production vertex.
double e(const int index) const
Get Energy.
void write_hepevt_particle(int index, bool iflong=true) override
Write particles.
void write_hepevt_event_header() override
Write the header.
WriterHEPEVTZEUS(const std::string &filename)
Constructor.
GenEvent I/O serialization for HEPEVT files.
Definition: WriterHEPEVT.h:28
HEPEVT_Wrapper_Template< 100000 > m_hepevt_interface
Templated HEPEVT interface.
Definition: WriterHEPEVT.h:89
std::ostream * m_stream
Output stream.
Definition: WriterHEPEVT.h:86
HepMC3 main namespace.