|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
Class that represents an output file in the standard ASCII format for HepMC3 events. More...
#include <OutputFileAscii.hh>
Public Member Functions | |
| OutputFileAscii (const JSON &output_config) | |
| virtual int_fast64_t | bytes_written () override |
| The number of bytes that have been written during the current MARLEY session to this 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 output file. | |
| virtual void | write_event (HepMC3::GenEvent *event) override |
| Write a new HepMC3::GenEvent to this output file. | |
Public Member Functions inherited from marley::OutputFile | |
| bool | mode_is_resume () const |
| const std::string & | name () const |
Protected Member Functions | |
| virtual void | open () |
| Opens the owned std::fstream with the correct settings. | |
Protected Member Functions inherited from marley::OutputFile | |
| OutputFile (const JSON &output_config) | |
| bool | check_if_file_exists (const std::string &filename) |
| Checks that a given file exists (and is readable) | |
| void | prompt_before_overwrite () |
| If mode_ is OVERWRITE and the output file already exists and force_ is false, prompt the user before overwriting. If the user declines, throw a marley::Error with a diagnostic message suggesting the "force" and "mode" configuration keys. | |
| std::unique_ptr< marley::Generator > | restore_generator (const marley::JSON &config) |
| Helper function for resume() that instantiates a marley::Generator object given the previous JSON configuration object. | |
Protected Attributes | |
| int_fast64_t | byte_count_ = 0 |
| Storage for the number of bytes written to disk. | |
| std::shared_ptr< HepMC3::GenEvent > | pending_flush_event_ |
| std::streampos | pending_truncate_pos_ = std::streampos( -1 ) |
| std::shared_ptr< HepMC3::ReaderAscii > | reader_ |
| std::fstream | stream_ |
| Stream used to read and write from the output file as needed. | |
| std::shared_ptr< HepMC3::WriterAscii > | writer_ |
| Helper object used to produce standard ASCII HepMC3 output. | |
Protected Attributes inherited from marley::OutputFile | |
| bool | force_ |
| Format | format_ |
| Format to use when writing events to the file. | |
| Mode | mode_ |
| std::string | name_ |
| Name of the file to receive output. | |
Additional Inherited Members | |
Public Types inherited from marley::OutputFile | |
| enum class | Format { ASCII , ROOT } |
Static Public Member Functions inherited from marley::OutputFile | |
| static std::shared_ptr< OutputFile > | make_OutputFile (const JSON &output_config) |
Protected Types inherited from marley::OutputFile | |
| enum class | Mode { OVERWRITE , RESUME } |
Static Protected Member Functions inherited from marley::OutputFile | |
| static void | merge_reweight_provenance_weights (HepMC3::GenRunInfo &run_info, marley::Generator &gen) |
| When resuming from a file that has been through one or more reweight passes, merge the reweight provenance weight calculator configurations with the original generate-time weights. Builds a combined Weighter and gives the Generator ownership. If no reweight provenance is found, this function is a no-op. | |
Class that represents an output file in the standard ASCII format for HepMC3 events.
Definition at line 35 of file OutputFileAscii.hh.
| marley::OutputFileAscii::OutputFileAscii | ( | const JSON & | output_config | ) |
Definition at line 65 of file OutputFileAscii.cc.
|
overridevirtual |
The number of bytes that have been written during the current MARLEY session to this file.
Implements marley::OutputFile.
Definition at line 211 of file OutputFileAscii.cc.
References byte_count_, and stream_.
|
protectedvirtual |
Opens the owned std::fstream with the correct settings.
Definition at line 78 of file OutputFileAscii.cc.
References marley::OutputFile::check_if_file_exists(), marley::OutputFile::name_, marley::OutputFile::prompt_before_overwrite(), and stream_.
|
overridevirtual |
Load a marley::Generator object whose configuration and state were saved to the metadata in the output file.
| [out] | gen | A std::unique_ptr that will be filled with a restored Generator object constructed using the saved metadata |
| [out] | num_previous_events | The number of events previously saved to the output file |
Implements marley::OutputFile.
Definition at line 99 of file OutputFileAscii.cc.
References marley::OutputFile::merge_reweight_provenance_weights(), marley::OutputFile::name_, pending_flush_event_, pending_truncate_pos_, reader_, marley::OutputFile::restore_generator(), and stream_.
|
overridevirtual |
Write a new HepMC3::GenEvent to this output file.
If a nullptr is passed to this function, then a marley::Error will be thrown
Implements marley::OutputFile.
Definition at line 221 of file OutputFileAscii.cc.
References marley::OutputFile::name_, pending_flush_event_, pending_truncate_pos_, stream_, and writer_.
|
protected |
Storage for the number of bytes written to disk.
Definition at line 66 of file OutputFileAscii.hh.
Referenced by bytes_written().
|
protected |
Last event without its GeneratorState, to be flushed on the first write() call after resume
Definition at line 74 of file OutputFileAscii.hh.
Referenced by resume(), and write_event().
|
protected |
Stream position at which to truncate on the first write after resume, removing the stale GeneratorState and HepMC3 footer
Definition at line 70 of file OutputFileAscii.hh.
Referenced by resume(), and write_event().
|
protected |
Helper object used to read back HepMC3 events for restoring the generator state, etc.
Definition at line 60 of file OutputFileAscii.hh.
Referenced by resume().
|
protected |
Stream used to read and write from the output file as needed.
Definition at line 56 of file OutputFileAscii.hh.
Referenced by bytes_written(), open(), resume(), and write_event().
|
protected |
Helper object used to produce standard ASCII HepMC3 output.
Definition at line 63 of file OutputFileAscii.hh.
Referenced by write_event().