1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http://www.gnu.org/licenses/>.
18
#ifndef _MAUS_SRC_INPUT_INPUTCPPROOTDATA_INPUTCPPROOTDATA_HH__
19
#define _MAUS_SRC_INPUT_INPUTCPPROOTDATA_INPUTCPPROOTDATA_HH__
25
#include "Rtypes.h" // ROOT
27
#include "json/json.h"
29
#include "Utils/Exception.hh"
30
#include "src/common_cpp/API/InputBase.hh"
36
/** @class InputCppRootData
38
* InputCppRootData enables us to read in ROOT files and emit them as strings
39
* containing json formatted data. InputCppRootData uses irstream from
40
* JsonCppStreamer to read ROOT files and JsonCppConverter to convert from
43
class InputCppRootData : public InputBase<MAUS::Data> {
45
/** Constructor for InputCppRootData, initialises all members to NULL
47
* @param filename if set forces the Inputter to use the filename rather than
48
* pulling a filename from the datacards at birth
50
explicit InputCppRootData(std::string filename = "");
52
/** Destructor for InputCppRootData - calls death()
56
/** Birth function - loads datacards:
57
* - input_root_file_name: the input root file name
58
* - selected_spills: list of ints, that defines specific spills that will
60
* Initialises the ROOT file
62
void birth(const std::string& json_datacards) {
63
InputBase<MAUS::Data>::birth(json_datacards);
66
/** Death function - deletes the root file*/
68
InputBase<MAUS::Data>::death();
71
/** Return true if only loading spills specified in data cards
73
bool useSelectedSpills() const { return _select_spills; }
76
/** Initialise the inputter
78
void _birth(const std::string& json_datacards);
80
/** Deletes inputter member data
84
/** Gets the next event from the root file. If there are no more events,
85
* raises StopIteration.
87
MAUS::Data _emit_cpp();
89
/** Gets an event from the root file; called by _emit_cpp()
91
template <class DataT>
92
bool load_event(std::string branch_name, DataT&);
94
/** Returns true if we are only loading selected spill numbers and
95
* the spill number is found in the data card, or if it is an invalid
96
* spill - there are already methods to handle those cases.
98
* This is a help function to see if the set of loaded spill numbers
99
* contains the spill \"spillNum\".
101
bool is_selected_spill(int spillNum) const;
103
/** _irstream holds root TFile.
106
std::string _infile_tree;
107
std::string _filename;
108
std::string _classname;
110
event_type _event_type;
112
std::set< int > _selected_spill_numbers;
113
int _highest_spill_number;