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.
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.
HEPEVT_Wrapper_Template< 100000 > m_hepevt_interface
Templated HEPEVT interface.
WriterHEPEVT(const std::string &filename, std::shared_ptr< GenRunInfo > run=nullptr)
Default constructor.
std::ostream * m_stream
Output stream.
HepMC3 main namespace.