|
MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
|
Abstract base class for objects that deliver output to a file opened by the marley command-line executable. More...
#include <OutputFile.hh>
Public Types | |
| enum class | Format { ASCII , ROOT } |
Public Member Functions | |
| virtual int_fast64_t | bytes_written ()=0 |
| The number of bytes that have been written during the current MARLEY session to this file. | |
| bool | mode_is_resume () const |
| const std::string & | name () const |
| virtual bool | resume (std::unique_ptr< marley::Generator > &gen, long &num_previous_events)=0 |
| 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)=0 |
| Write a new HepMC3::GenEvent to this output file. | |
Static Public Member Functions | |
| static std::shared_ptr< OutputFile > | make_OutputFile (const JSON &output_config) |
Protected Types | |
| enum class | Mode { OVERWRITE , RESUME } |
Protected Member Functions | |
| 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. | |
Static Protected Member Functions | |
| 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. | |
Protected Attributes | |
| 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. | |
Abstract base class for objects that deliver output to a file opened by the marley command-line executable.
Definition at line 35 of file OutputFile.hh.
|
strong |
Definition at line 80 of file OutputFile.hh.
|
strongprotected |
Definition at line 115 of file OutputFile.hh.
|
protected |
Definition at line 36 of file OutputFile.cc.
|
pure virtual |
The number of bytes that have been written during the current MARLEY session to this file.
Implemented in marley::OutputFileAscii, and marley::OutputFileRoot.
|
inlineprotected |
Checks that a given file exists (and is readable)
Definition at line 85 of file OutputFile.hh.
Referenced by marley::OutputFileAscii::open(), marley::OutputFileRoot::open(), and prompt_before_overwrite().
|
static |
Definition at line 120 of file OutputFile.cc.
|
staticprotected |
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.
Definition at line 80 of file OutputFile.cc.
References HepMC3::GenRunInfo::attribute(), marley::Generator::set_weighter(), and HepMC3::IntAttribute::value().
Referenced by marley::OutputFileAscii::resume(), and marley::OutputFileRoot::resume().
|
inline |
Definition at line 74 of file OutputFile.hh.
|
inline |
Definition at line 52 of file OutputFile.hh.
|
protected |
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.
Definition at line 63 of file OutputFile.cc.
References check_if_file_exists(), and name_.
Referenced by marley::OutputFileAscii::open(), and marley::OutputFileRoot::open().
|
protected |
Helper function for resume() that instantiates a marley::Generator object given the previous JSON configuration object.
Definition at line 55 of file OutputFile.cc.
Referenced by marley::OutputFileAscii::resume(), and marley::OutputFileRoot::resume().
|
pure virtual |
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 |
Implemented in marley::OutputFileAscii, and marley::OutputFileRoot.
|
pure virtual |
Write a new HepMC3::GenEvent to this output file.
If a nullptr is passed to this function, then a marley::Error will be thrown
Implemented in marley::OutputFileAscii, and marley::OutputFileRoot.
|
protected |
Definition at line 123 of file OutputFile.hh.
|
protected |
Format to use when writing events to the file.
Definition at line 118 of file OutputFile.hh.
|
protected |
Definition at line 119 of file OutputFile.hh.
|
protected |
Name of the file to receive output.
Definition at line 117 of file OutputFile.hh.
Referenced by marley::OutputFileAscii::open(), marley::OutputFileRoot::open(), prompt_before_overwrite(), marley::OutputFileAscii::resume(), marley::OutputFileRoot::resume(), and marley::OutputFileAscii::write_event().