MARLEY (Model of Argon Reaction Low Energy Yields)  v1.2.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
RootEventFileReader.hh
1 //
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 #include <memory>
19 #include <string>
20 
21 #include "marley/Event.hh"
22 #include "marley/Error.hh"
23 #include "marley/EventFileReader.hh"
24 
25 #include "TFile.h"
26 #include "TTree.h"
27 
28 namespace marley {
29 
33 
34  public:
35 
36  RootEventFileReader( const std::string& file_name );
37 
38  virtual ~RootEventFileReader() = default;
39 
40  virtual bool next_event(marley::Event& ev) override;
41 
42  virtual operator bool() const override;
43 
44  protected:
45 
47  std::unique_ptr<TFile> tfile_;
48 
49  // @brief Pointer to the TTree containing the MARLEY events to be loaded
50  TTree* ttree_;
51 
53  std::unique_ptr<marley::Event> event_;
54 
59 
63  long event_num_ = -1;
64 
65  virtual bool deduce_file_format() override;
66  virtual void initialize() override;
67  };
68 
69 }
Object that parses MARLEY output files written in any of the available formats, except for ROOT forma...
Definition: EventFileReader.hh:34
Container for ingoing and outgoing momentum 4-vectors from a reaction.
Definition: Event.hh:66
Object that parses MARLEY output files written in any of the available formats, including ROOT format...
Definition: RootEventFileReader.hh:32
marley::Event * event_ptr_
Bare pointer used to interface the event_ data member with a branch of ttree_ without requiring a man...
Definition: RootEventFileReader.hh:58
std::unique_ptr< TFile > tfile_
TFile used to read ROOT format output files.
Definition: RootEventFileReader.hh:47
std::unique_ptr< marley::Event > event_
Temporary storage for reading events in from a TFile.
Definition: RootEventFileReader.hh:53
virtual bool deduce_file_format() override
Helper function that auto-detects which of the available output formats is appropriate for the reques...
Definition: RootEventFileReader.cc:31
long event_num_
The index of the last TTree entry that was read.
Definition: RootEventFileReader.hh:63
virtual void initialize() override
Prepares the file for reading the events.
Definition: RootEventFileReader.cc:57
virtual bool next_event(marley::Event &ev) override
Read the next MARLEY event record from the file.
Definition: RootEventFileReader.cc:81