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