BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
DataLoader.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef DATALOADER_H
20#define DATALOADER_H
21
22#include "Rtypes.h" // for classdef
23
24#include "RebdsimTypes.hh"
25
26#include <map>
27#include <set>
28#include <string>
29#include <vector>
30
31class Beam;
32class Event;
33class ParticleData;
34class Header;
35class Options;
36class Model;
37class Run;
38class TChain;
39
47{
48public:
49 DataLoader() = default;
50 DataLoader(const std::string& fileName,
51 bool debugIn = false,
52 bool processSamplersIn = true,
53 bool allBranchesOn = true,
54 const RBDS::BranchMap* branchesToTurnOn = nullptr,
55 bool backwardsCompatibleIn = true);
56 virtual ~DataLoader();
57
60 void CommonCtor(const std::string& fileName);
61
63 void BuildInputFileList(std::string inputPath);
64
66 void BuildTreeNameList();
67
71
73 void ChainTrees();
74
76 void SetBranchAddress(bool allOn = true,
77 const RBDS::BranchMap* bToTurnOn = nullptr);
78
79 inline int DataVersion() const {return dataVersion;}
80
82 std::vector<std::string> GetFileNames() {return fileNames;}
83 std::vector<std::string> GetTreeNames() {return treeNames;};
84 std::vector<std::string> GetBranchNames() {return branchNames;}
85 std::vector<std::string> GetSamplerNames() {return samplerNames;}
86 std::vector<std::string> GetSamplerCNames() {return samplerCNames;}
87 std::vector<std::string> GetSamplerSNames() {return samplerSNames;}
88 std::vector<std::string> GetCollimatorNames(){return collimatorNames;}
89 Header* GetHeader() {return hea;}
91 Beam* GetBeam() {return bea;}
92 Options* GetOptions() {return opt;}
93 Model* GetModel() {return mod;}
94 Event* GetEvent() {return evt;}
95 Run* GetRun() {return run;}
96 TChain* GetHeaderTree() {return heaChain;}
97 TChain* GetParticleDataTree() {return parChain;}
98 TChain* GetBeamTree() {return beaChain;}
99 TChain* GetOptionsTree() {return optChain;}
100 TChain* GetModelTree() {return modChain;}
101 TChain* GetEventTree() {return evtChain;}
102 TChain* GetRunTree() {return runChain;}
104
105 const std::set<std::string>& GetAllCylindricalAndSphericalSamplerNames() const {return allSamplerCAndSNames;}
106 const std::set<std::string>& GetAllCylindricalSamplerNames() const {return allSamplerCNamesSet;}
107 const std::set<std::string>& GetAllSphericalSamplerNames() const {return allSamplerSNamesSet;}
108
109private:
110 bool debug;
111 bool processSamplers;
112 bool allBranchesOn;
113 const RBDS::BranchMap* branchesToTurnOn;
114 bool backwardsCompatible;
115
116 Header* hea;
117 ParticleData* par;
118 Beam* bea;
119 Options* opt;
120 Model* mod;
121 Event* evt;
122 Run* run;
123
124 std::vector<std::string> fileNames;
125 std::vector<std::string> treeNames;
126 std::vector<std::string> branchNames; // non-sampler branch names
127 std::vector<std::string> samplerNames; // sampler branch names
128 std::vector<std::string> samplerCNames;
129 std::vector<std::string> samplerSNames;
130 std::vector<std::string> allSamplerNames; // used to know what branches are samplers
131 std::vector<std::string> allCSamplerNames;
132 std::vector<std::string> allSSamplerNames;
133 std::vector<std::string> collimatorNames;
134
137 std::set<std::string> allSamplerCAndSNames;
138 std::set<std::string> allSamplerCNamesSet;
139 std::set<std::string> allSamplerSNamesSet;
140
141 TChain* heaChain;
142 TChain* parChain;
143 TChain* beaChain;
144 TChain* optChain;
145 TChain* modChain;
146 TChain* evtChain;
147 TChain* runChain;
148
150
151 ClassDef(DataLoader, 2);
152};
153
154#endif
Beam loader.
Definition Beam.hh:37
Loader for a ROOT file using classes used to generate the file.
Definition DataLoader.hh:47
std::vector< std::string > GetSamplerCNames()
Accessor.
Definition DataLoader.hh:86
std::vector< std::string > GetFileNames()
Accessor.
Definition DataLoader.hh:82
void SetBranchAddress(bool allOn=true, const RBDS::BranchMap *bToTurnOn=nullptr)
Map each chain to the member instance of each storage class in this class.
void BuildEventBranchNameList()
Event * GetEvent()
Accessor.
Definition DataLoader.hh:94
std::set< std::string > allSamplerCAndSNames
std::vector< std::string > GetCollimatorNames()
Accessor.
Definition DataLoader.hh:88
std::vector< std::string > GetSamplerNames()
Accessor.
Definition DataLoader.hh:85
std::vector< std::string > GetTreeNames()
Accessor.
Definition DataLoader.hh:83
Beam * GetBeam()
Accessor.
Definition DataLoader.hh:91
Header * GetHeader()
Accessor.
Definition DataLoader.hh:89
ParticleData * GetParticleData()
Accessor.
Definition DataLoader.hh:90
TChain * GetParticleDataTree()
Accessor.
Definition DataLoader.hh:97
int dataVersion
Integer version of data loaded.
TChain * GetBeamTree()
Accessor.
Definition DataLoader.hh:98
void CommonCtor(const std::string &fileName)
Definition DataLoader.cc:82
TChain * GetOptionsTree()
Accessor.
Definition DataLoader.hh:99
void BuildTreeNameList()
Open the first file in the file list and map the trees in it.
TChain * GetRunTree()
Accessor.
TChain * GetModelTree()
Accessor.
std::vector< std::string > GetSamplerSNames()
Accessor.
Definition DataLoader.hh:87
Options * GetOptions()
Accessor.
Definition DataLoader.hh:92
Run * GetRun()
Accessor.
Definition DataLoader.hh:95
void BuildInputFileList(std::string inputPath)
Build up the input file list.
void ChainTrees()
Create a tree for each sampler and add all the files to it.
std::vector< std::string > GetBranchNames()
Accessor.
Definition DataLoader.hh:84
TChain * GetEventTree()
Accessor.
Model * GetModel()
Accessor.
Definition DataLoader.hh:93
TChain * GetHeaderTree()
Accessor.
Definition DataLoader.hh:96
Event loader.
Definition Event.hh:50
Header loader.
Definition Header.hh:34
Model loader.
Definition Model.hh:36
Options loader.
Definition Options.hh:36
Particle Data loader.
Class to overlay a run from a ROOT file with.
Definition Run.hh:36