BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Event.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 EVENT_H
20#define EVENT_H
21
22#include <map>
23#include <vector>
24
25#include "Rtypes.h" // for classdef
26#include "TChain.h"
27
28#include "BDSOutputROOTEventSampler.hh"
29
30#include "RebdsimTypes.hh"
31
42
49class Event
50{
51public:
52 Event();
53 Event(bool debugIn,
54 bool processSamplersIn = false,
55 int dataVersionIn = 0);
56 void CommonCtor();
57 virtual ~Event();
58
60#ifdef __ROOTDOUBLE__
62#else
64#endif
78#ifdef __ROOTDOUBLE__
79 BDSOutputROOTEventSampler<double>* GetSampler(const std::string& name);
80#else
82#endif
83#ifdef __ROOTDOUBLE__
85#else
87#endif
88 BDSOutputROOTEventSamplerC* GetSamplerC(const std::string& name);
90 BDSOutputROOTEventSamplerS* GetSamplerS(const std::string& name);
92 BDSOutputROOTEventAperture* GetAperture() {return ApertureImpacts;}
93 BDSOutputROOTEventCollimator* GetCollimator(const std::string& name);
95 int DataVersion() const {return dataVersion;}
96 const std::vector<std::string>& GetSamplerNames() const {return samplerNames;}
97 const std::vector<std::string>& GetSamplerCylinderNames() const {return samplerCNames;}
98 const std::vector<std::string>& GetSamplerSphereNames() const {return samplerSNames;}
99 const std::vector<std::string>& GetCollimatorNames() const {return collimatorNames;}
101
103 void Fill(Event* other);
104
106 inline bool UsePrimaries() const {return usePrimaries;}
107
110 inline void SetDataVersion(int dataVersionIn) {dataVersion = dataVersionIn;}
111
114 void SetBranchAddress(TTree* t,
115 const RBDS::VectorString* samplerNames = nullptr,
116 bool allBranchesOn = false,
117 const RBDS::VectorString* branchesToTurnOn = nullptr,
118 const RBDS::VectorString* collimatorNamesIn = nullptr,
119 const RBDS::VectorString* samplerCNamesIn = nullptr,
120 const RBDS::VectorString* samplerSNamesIn = nullptr);
121
123#ifdef __ROOTDOUBLE__
125#else
127#endif
139#ifdef __ROOTDOUBLE__
140 std::vector<BDSOutputROOTEventSampler<double>*> Samplers;
141#else
142 std::vector<BDSOutputROOTEventSampler<float>*> Samplers;
143#endif
144 std::vector<BDSOutputROOTEventSamplerC*> SamplersC;
145 std::vector<BDSOutputROOTEventSamplerS*> SamplersS;
148 std::vector<BDSOutputROOTEventCollimator*> collimators;
151
152 BDSOutputROOTEventAperture* ApertureImpacts;
153
154 std::vector<std::string> samplerNames;
155 std::vector<std::string> samplerCNames;
156 std::vector<std::string> samplerSNames;
157#ifdef __ROOTDOUBLE__
158 std::map<std::string, BDSOutputROOTEventSampler<double>* > samplerMap;
159#else
160 std::map<std::string, BDSOutputROOTEventSampler<float>* > samplerMap;
161#endif
162 std::map<std::string, BDSOutputROOTEventSamplerC*> samplerCMap;
163 std::map<std::string, BDSOutputROOTEventSamplerS*> samplerSMap;
164
165 std::vector<std::string> collimatorNames;
166 std::map<std::string, BDSOutputROOTEventCollimator*> collimatorMap;
167
170 void RelinkSamplers();
171
173 RBDS::VectorString RemoveDuplicates(const RBDS::VectorString& namesIn) const;
174
176 void RegisterCollimator(const std::string& collimatorName);
177 void RegisterSampler(const std::string& samplerName);
179
181 void Flush();
182 void FlushSamplers();
183 void FlushCollimators();
185private:
187 void SetBranchAddressCollimators(TTree* t,
188 const RBDS::VectorString* collimatorNames);
190 const std::string& name,
191 int i);
193
194 TTree* tree;
195 bool debug;
196 bool processSamplers;
197 int dataVersion;
198 bool usePrimaries;
199
200 ClassDef(Event, 3);
201};
202
203#endif
Data stored for energy deposition hits per event.
Data stored for each collimator per event.
Holder for a set of histograms to be stored.
Information pertaining to an individual event.
Data stored for world hits per event.
Data stored for energy deposition hits per event.
Information stored per cylindrical sampler per event.
Information stored per spherical sampler per event.
Information stored per sampler per event.
Structure to record a trajectory.
Event loader.
Definition Event.hh:50
int DataVersion() const
Accessor.
Definition Event.hh:95
std::vector< BDSOutputROOTEventSampler< float > * > Samplers
Local variable ROOT data is mapped to.
Definition Event.hh:142
BDSOutputROOTEventLoss * GetLossVacuum()
Accessor.
Definition Event.hh:66
BDSOutputROOTEventLoss * PrimaryLastHit
Local variable ROOT data is mapped to.
Definition Event.hh:136
BDSOutputROOTEventLoss * TunnelHit
Local variable ROOT data is mapped to.
Definition Event.hh:137
BDSOutputROOTEventHistograms * GetHistograms()
Accessor.
Definition Event.hh:75
void FlushSamplers()
Flushing functions.
Definition Event.cc:550
BDSOutputROOTEventSampler< double > * GetPrimaries()
Accessor.
Definition Event.hh:61
BDSOutputROOTEventLoss * ElossVacuum
Local variable ROOT data is mapped to.
Definition Event.hh:130
BDSOutputROOTEventSampler< double > * GetSampler(const std::string &name)
Accessor.
Definition Event.cc:116
BDSOutputROOTEventHistograms * Histos
Local variable ROOT data is mapped to.
Definition Event.hh:146
BDSOutputROOTEventSampler< float > * GetPrimaries()
Accessor.
Definition Event.hh:63
BDSOutputROOTEventCollimator * GetCollimator(const std::string &name)
Accessor.
Definition Event.cc:181
BDSOutputROOTEventLossWorld * ElossWorldExit
Local variable ROOT data is mapped to.
Definition Event.hh:134
void RelinkSamplers()
Definition Event.cc:424
BDSOutputROOTEventAperture * GetAperture()
Accessor.
Definition Event.hh:92
BDSOutputROOTEventLoss * GetLossTunnel()
Accessor.
Definition Event.hh:67
RBDS::VectorString RemoveDuplicates(const RBDS::VectorString &namesIn) const
Utility method.
Definition Event.cc:432
BDSOutputROOTEventLossWorld * ElossWorld
Local variable ROOT data is mapped to.
Definition Event.hh:132
BDSOutputROOTEventLossWorld * ElossWorldContents
Local variable ROOT data is mapped to.
Definition Event.hh:133
BDSOutputROOTEventLossWorld * GetLossWorldContents()
Accessor.
Definition Event.hh:69
void FlushCollimators()
Flushing functions.
Definition Event.cc:560
BDSOutputROOTEventLossWorld * GetLossWorld()
Accessor.
Definition Event.hh:68
BDSOutputROOTEventLoss * ElossTunnel
Local variable ROOT data is mapped to.
Definition Event.hh:131
BDSOutputROOTEventSampler< double > * Primary
Local variable ROOT data is mapped to.
Definition Event.hh:124
BDSOutputROOTEventSamplerC * GetSamplerC(const std::string &name)
Accessor.
std::vector< BDSOutputROOTEventSamplerC * > SamplersC
Local variable ROOT data is mapped to.
Definition Event.hh:144
BDSOutputROOTEventSampler< float > * GetSampler(int index)
Accessor.
const std::vector< std::string > & GetSamplerNames() const
Accessor.
Definition Event.hh:96
BDSOutputROOTEventSamplerS * GetSamplerS(const std::string &name)
Accessor.
Definition Event.cc:170
BDSOutputROOTEventSampler< float > * GetSampler(const std::string &name)
Accessor.
void RegisterCollimator(const std::string &collimatorName)
Utility method for interface building events.
Definition Event.cc:439
void Flush()
Flushing functions.
Definition Event.cc:528
BDSOutputROOTEventTrajectory * Trajectory
Local variable ROOT data is mapped to.
Definition Event.hh:138
BDSOutputROOTEventLoss * PrimaryFirstHit
Local variable ROOT data is mapped to.
Definition Event.hh:135
const std::vector< std::string > & GetCollimatorNames() const
Accessor.
Definition Event.hh:99
bool UsePrimaries() const
Whether there is primary data in the output file.
Definition Event.hh:106
const std::vector< std::string > & GetSamplerCylinderNames() const
Accessor.
Definition Event.hh:97
void SetBranchAddressCollimators(TTree *t, const RBDS::VectorString *collimatorNames)
Utility function to avoid repetition of code.
Definition Event.cc:464
std::vector< BDSOutputROOTEventSampler< double > * > Samplers
Local variable ROOT data is mapped to.
Definition Event.hh:140
BDSOutputROOTEventLoss * GetTunnelHit()
Accessor.
Definition Event.hh:73
void Fill(Event *other)
Copy data from another event into this event.
Definition Event.cc:496
BDSOutputROOTEventLoss * GetLoss()
Accessor.
Definition Event.hh:65
BDSOutputROOTEventSampler< float > * Primary
Local variable ROOT data is mapped to.
Definition Event.hh:126
Int_t SetBranchAddressCollimatorSingle(TTree *t, const std::string &name, int i)
Utility function to avoid repetition of code.
Definition Event.cc:479
BDSOutputROOTEventInfo * Summary
Local variable ROOT data is mapped to.
Definition Event.hh:147
std::vector< BDSOutputROOTEventSamplerS * > SamplersS
Local variable ROOT data is mapped to.
Definition Event.hh:145
BDSOutputROOTEventInfo * GetInfo()
Accessor.
Definition Event.hh:77
BDSOutputROOTEventSampler< double > * GetSampler(int index)
Accessor.
BDSOutputROOTEventLoss * GetPrimaryFirstHit()
Accessor.
Definition Event.hh:71
BDSOutputROOTEventLoss * Eloss
Local variable ROOT data is mapped to.
Definition Event.hh:129
BDSOutputROOTEventInfo * GetSummary()
Accessor.
Definition Event.hh:76
void RegisterSampler(const std::string &samplerName)
Utility method for interface building events.
Definition Event.cc:449
BDSOutputROOTEventLossWorld * GetLossWorldExit()
Accessor.
Definition Event.hh:70
BDSOutputROOTEventCoords * PrimaryGlobal
Local variable ROOT data is mapped to.
Definition Event.hh:128
void SetDataVersion(int dataVersionIn)
Definition Event.hh:110
const std::vector< std::string > & GetSamplerSphereNames() const
Accessor.
Definition Event.hh:98
BDSOutputROOTEventLoss * GetPrimaryLastHit()
Accessor.
Definition Event.hh:72
BDSOutputROOTEventInfo * Info
For backwards compatibility.
Definition Event.hh:150
std::vector< BDSOutputROOTEventCollimator * > collimators
Local variable ROOT data is mapped to.
Definition Event.hh:148
void SetBranchAddress(TTree *t, const RBDS::VectorString *samplerNames=nullptr, bool allBranchesOn=false, const RBDS::VectorString *branchesToTurnOn=nullptr, const RBDS::VectorString *collimatorNamesIn=nullptr, const RBDS::VectorString *samplerCNamesIn=nullptr, const RBDS::VectorString *samplerSNamesIn=nullptr)
Definition Event.cc:206
BDSOutputROOTEventTrajectory * GetTrajectory()
Accessor.
Definition Event.hh:74