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 - 2023.
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 <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> GetCollimatorNames(){return collimatorNames;}
86 Header* GetHeader() {return hea;}
88 Beam* GetBeam() {return bea;}
89 Options* GetOptions() {return opt;}
90 Model* GetModel() {return mod;}
91 Event* GetEvent() {return evt;}
92 Run* GetRun() {return run;}
93 TChain* GetHeaderTree() {return heaChain;}
94 TChain* GetParticleDataTree() {return parChain;}
95 TChain* GetBeamTree() {return beaChain;}
96 TChain* GetOptionsTree() {return optChain;}
97 TChain* GetModelTree() {return modChain;}
98 TChain* GetEventTree() {return evtChain;}
99 TChain* GetRunTree() {return runChain;}
101
102private:
103 bool debug;
104 bool processSamplers;
105 bool allBranchesOn;
106 const RBDS::BranchMap* branchesToTurnOn;
107 bool backwardsCompatible;
108
109 Header* hea;
110 ParticleData* par;
111 Beam* bea;
112 Options* opt;
113 Model* mod;
114 Event* evt;
115 Run* run;
116
117 std::vector<std::string> fileNames;
118 std::vector<std::string> treeNames;
119 std::vector<std::string> branchNames; // non-sampler branch names
120 std::vector<std::string> samplerNames; // sampler branch names
121 std::vector<std::string> samplerCNames;
122 std::vector<std::string> samplerSNames;
123 std::vector<std::string> allSamplerNames; // used to know what branches are samplers
124 std::vector<std::string> allCSamplerNames;
125 std::vector<std::string> allSSamplerNames;
126 std::vector<std::string> collimatorNames;
127
128 TChain* heaChain;
129 TChain* parChain;
130 TChain* beaChain;
131 TChain* optChain;
132 TChain* modChain;
133 TChain* evtChain;
134 TChain* runChain;
135
137
138 ClassDef(DataLoader, 2);
139};
140
141#endif
Beam loader.
Definition: Beam.hh:37
Loader for a ROOT file using classes used to generate the file.
Definition: DataLoader.hh:46
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.
Definition: DataLoader.cc:272
void BuildEventBranchNameList()
Definition: DataLoader.cc:200
Event * GetEvent()
Accessor.
Definition: DataLoader.hh:91
std::vector< std::string > GetCollimatorNames()
Accessor.
Definition: DataLoader.hh:85
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:88
Header * GetHeader()
Accessor.
Definition: DataLoader.hh:86
ParticleData * GetParticleData()
Accessor.
Definition: DataLoader.hh:87
TChain * GetParticleDataTree()
Accessor.
Definition: DataLoader.hh:94
int dataVersion
Integer version of data loaded.
Definition: DataLoader.hh:136
TChain * GetBeamTree()
Accessor.
Definition: DataLoader.hh:95
void CommonCtor(const std::string &fileName)
Definition: DataLoader.cc:82
TChain * GetOptionsTree()
Accessor.
Definition: DataLoader.hh:96
void BuildTreeNameList()
Open the first file in the file list and map the trees in it.
Definition: DataLoader.cc:179
TChain * GetRunTree()
Accessor.
Definition: DataLoader.hh:99
TChain * GetModelTree()
Accessor.
Definition: DataLoader.hh:97
Options * GetOptions()
Accessor.
Definition: DataLoader.hh:89
Run * GetRun()
Accessor.
Definition: DataLoader.hh:92
void BuildInputFileList(std::string inputPath)
Build up the input file list.
Definition: DataLoader.cc:121
void ChainTrees()
Create a tree for each sampler and add all the files to it.
Definition: DataLoader.cc:256
std::vector< std::string > GetBranchNames()
Accessor.
Definition: DataLoader.hh:83
TChain * GetEventTree()
Accessor.
Definition: DataLoader.hh:98
Model * GetModel()
Accessor.
Definition: DataLoader.hh:90
TChain * GetHeaderTree()
Accessor.
Definition: DataLoader.hh:93
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.
Definition: ParticleData.hh:34
Class to overlay a run from a ROOT file with.
Definition: Run.hh:36