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
OutputFileRoot.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// ROOT includes
23#include "TFile.h"
24#include "TTree.h"
25
26// MARLEY includes
27#include "marley/OutputFile.hh"
28
29namespace HepMC3 {
30 struct GenEventData;
31 struct GenRunInfoData;
32};
33
34namespace marley {
35
38 class OutputFileRoot : public OutputFile {
39
40 public:
41
42 OutputFileRoot( const JSON& output_config );
43
44 virtual ~OutputFileRoot();
45
46 virtual bool resume( std::unique_ptr<marley::Generator>& gen,
47 long& num_previous_events ) override;
48
49 inline virtual int_fast64_t bytes_written() override
50 { return out_tfile_->GetBytesWritten(); }
51
52 virtual void write_event( HepMC3::GenEvent* event ) override;
53
54 protected:
55
57 virtual void open();
58
60 void clear_event_data();
61
63 std::unique_ptr< TFile > out_tfile_;
64
66 // This is a bare pointer, but ROOT will associate it with out_tfile_, so
67 // we don't want to delete it ourselves or let a smart pointer do it.
68 TTree* out_tree_ = nullptr;
69
71 std::unique_ptr< HepMC3::GenEventData > temp_event_data_;
72
76
78 std::unique_ptr< HepMC3::GenRunInfoData > temp_run_info_data_;
79
81 std::shared_ptr< HepMC3::GenRunInfo > run_info_;
82 };
83
84}
Stores event-related information.
Definition GenEvent.h:47
std::unique_ptr< HepMC3::GenEventData > temp_event_data_
Temporary storage for the events.
HepMC3::GenEventData * temp_event_data_ptr_
virtual void open()
Opens the owned ROOT file with the correct settings.
std::unique_ptr< HepMC3::GenRunInfoData > temp_run_info_data_
Temporary storage for the run information.
TTree * out_tree_
TTree object used to store the events.
std::shared_ptr< HepMC3::GenRunInfo > run_info_
Copy of the run information to check for a mismatch.
virtual void write_event(HepMC3::GenEvent *event) override
Write a new HepMC3::GenEvent to this output file.
void clear_event_data()
Clears the temporary storage for event data.
std::unique_ptr< TFile > out_tfile_
TFile object used to manage input/output.
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...
virtual int_fast64_t bytes_written() override
The number of bytes that have been written during the current MARLEY session to this file.
Stores serializable event information.
Stores serializable run information.