41 OutputFile(
const JSON& output_config );
47 static std::shared_ptr< OutputFile > make_OutputFile(
48 const JSON& output_config );
50 virtual ~OutputFile() =
default;
52 const std::string& name()
const {
return name_; }
62 virtual bool resume( std::unique_ptr<marley::Generator>& gen,
63 long& num_previous_events ) = 0;
74 bool mode_is_resume()
const {
return mode_ == Mode::RESUME; }
80 enum class Format { ASCII, ROOT };
86 std::ifstream test_stream( filename );
87 return test_stream.good();
115 enum class Mode { OVERWRITE, RESUME };
Stores event-related information.
Stores run-related information.
The MARLEY Event generator.
virtual int_fast64_t bytes_written()=0
The number of bytes that have been written during the current MARLEY session to this file.
virtual void write_event(HepMC3::GenEvent *event)=0
Write a new HepMC3::GenEvent to this output file.
Format format_
Format to use when writing events to the file.
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 con...
void prompt_before_overwrite()
If mode_ is OVERWRITE and the output file already exists and force_ is false, prompt the user before ...
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 prove...
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 outpu...
bool check_if_file_exists(const std::string &filename)
Checks that a given file exists (and is readable)
std::string name_
Name of the file to receive output.