MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
OutputFileAscii.hh
1
4//
5// This file is part of MARLEY (Model of Argon Reaction Low Energy Yields)
6//
7// MARLEY is free software: you can redistribute it and/or modify it under the
8// terms of version 3 of the GNU General Public License as published by the
9// Free Software Foundation.
10//
11// For the full text of the license please see COPYING or
12// visit http://opensource.org/licenses/GPL-3.0
13//
14// Please respect the MCnet academic usage guidelines. See GUIDELINES
15// or visit https://www.montecarlonet.org/GUIDELINES for details.
16
17#pragma once
18
19// Standard library includes
20#include <memory>
21
22// MARLEY includes
23#include "marley/OutputFile.hh"
24
25namespace HepMC3 {
26 class GenEvent;
27 class ReaderAscii;
28 class WriterAscii;
29}
30
31namespace marley {
32
35 class OutputFileAscii : public OutputFile {
36
37 public:
38
39 OutputFileAscii( const JSON& output_config );
40
41 virtual ~OutputFileAscii() = default;
42
43 virtual bool resume( std::unique_ptr<marley::Generator>& gen,
44 long& num_previous_events ) override;
45
46 virtual int_fast64_t bytes_written() override;
47
48 virtual void write_event( HepMC3::GenEvent* event ) override;
49
50 protected:
51
53 virtual void open();
54
56 std::fstream stream_;
57
60 std::shared_ptr< HepMC3::ReaderAscii > reader_;
61
63 std::shared_ptr< HepMC3::WriterAscii > writer_;
64
66 int_fast64_t byte_count_ = 0;
67
70 std::streampos pending_truncate_pos_ = std::streampos( -1 );
71
74 std::shared_ptr< HepMC3::GenEvent > pending_flush_event_;
75 };
76
77}
Stores event-related information.
Definition GenEvent.h:47
GenEvent I/O parsing for structured text files.
Definition ReaderAscii.h:31
GenEvent I/O serialization for structured text files.
Definition WriterAscii.h:25
virtual void open()
Opens the owned std::fstream with the correct settings.
std::fstream stream_
Stream used to read and write from the output file as needed.
std::shared_ptr< HepMC3::ReaderAscii > reader_
std::shared_ptr< HepMC3::GenEvent > pending_flush_event_
virtual void write_event(HepMC3::GenEvent *event) override
Write a new HepMC3::GenEvent to this output file.
virtual bool resume(std::unique_ptr< marley::Generator > &gen, long &num_previous_events) override
Load a marley::Generator object whose configuration and state were saved to the metadata in the outpu...
int_fast64_t byte_count_
Storage for the number of bytes written to disk.
std::streampos pending_truncate_pos_
std::shared_ptr< HepMC3::WriterAscii > writer_
Helper object used to produce standard ASCII HepMC3 output.
virtual int_fast64_t bytes_written() override
The number of bytes that have been written during the current MARLEY session to this file.