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) 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 EVENT_H
19#define EVENT_H
20
21#include <map>
22#include <vector>
23
24#include "Rtypes.h" // for classdef
25#include "TChain.h"
26
27#include "BDSOutputROOTEventSampler.hh"
28
29#include "RebdsimTypes.hh"
30
41
48class Event
49{
50public:
51 Event();
52 Event(bool debugIn,
53 bool processSamplersIn = false,
54 int dataVersionIn = 0);
55 void CommonCtor();
56 virtual ~Event();
57
59#ifdef __ROOTDOUBLE__
61#else
63#endif
77#ifdef __ROOTDOUBLE__
78 BDSOutputROOTEventSampler<double>* GetSampler(const std::string& name);
79#else
81#endif
82#ifdef __ROOTDOUBLE__
84#else
86#endif
87 BDSOutputROOTEventSamplerC* GetSamplerC(const std::string& name);
89 BDSOutputROOTEventSamplerS* GetSamplerS(const std::string& name);
91 BDSOutputROOTEventAperture* GetAperture() {return ApertureImpacts;}
92 BDSOutputROOTEventCollimator* GetCollimator(const std::string& name);
94 int DataVersion() const {return dataVersion;}
95 const std::vector<std::string>& GetSamplerNames() const {return samplerNames;}
96 const std::vector<std::string>& GetSamplerCylinderNames() const {return samplerCNames;}
97 const std::vector<std::string>& GetSamplerSphereNames() const {return samplerSNames;}
98 const std::vector<std::string>& GetCollimatorNames() const {return collimatorNames;}
100
102 void Fill(Event* other);
103
105 inline bool UsePrimaries() const {return usePrimaries;}
106
109 inline void SetDataVersion(int dataVersionIn) {dataVersion = dataVersionIn;}
110
113 void SetBranchAddress(TTree* t,
114 const RBDS::VectorString* samplerNames = nullptr,
115 bool allBranchesOn = false,
116 const RBDS::VectorString* branchesToTurnOn = nullptr,
117 const RBDS::VectorString* collimatorNamesIn = nullptr,
118 const RBDS::VectorString* samplerCNamesIn = nullptr,
119 const RBDS::VectorString* samplerSNamesIn = nullptr);
120
122#ifdef __ROOTDOUBLE__
124#else
126#endif
138#ifdef __ROOTDOUBLE__
139 std::vector<BDSOutputROOTEventSampler<double>*> Samplers;
140#else
141 std::vector<BDSOutputROOTEventSampler<float>*> Samplers;
142#endif
143 std::vector<BDSOutputROOTEventSamplerC*> SamplersC;
144 std::vector<BDSOutputROOTEventSamplerS*> SamplersS;
147 std::vector<BDSOutputROOTEventCollimator*> collimators;
150
151 BDSOutputROOTEventAperture* ApertureImpacts;
152
153 std::vector<std::string> samplerNames;
154 std::vector<std::string> samplerCNames;
155 std::vector<std::string> samplerSNames;
156#ifdef __ROOTDOUBLE__
157 std::map<std::string, BDSOutputROOTEventSampler<double>* > samplerMap;
158#else
159 std::map<std::string, BDSOutputROOTEventSampler<float>* > samplerMap;
160#endif
161 std::map<std::string, BDSOutputROOTEventSamplerC*> samplerCMap;
162 std::map<std::string, BDSOutputROOTEventSamplerS*> samplerSMap;
163
164 std::vector<std::string> collimatorNames;
165 std::map<std::string, BDSOutputROOTEventCollimator*> collimatorMap;
166
169 void RelinkSamplers();
170
172 RBDS::VectorString RemoveDuplicates(const RBDS::VectorString& namesIn) const;
173
175 void RegisterCollimator(const std::string& collimatorName);
176 void RegisterSampler(const std::string& samplerName);
178
180 void Flush();
181 void FlushSamplers();
182 void FlushCollimators();
184private:
186 void SetBranchAddressCollimators(TTree* t,
187 const RBDS::VectorString* collimatorNames);
189 const std::string& name,
190 int i);
192
193 TTree* tree;
194 bool debug;
195 bool processSamplers;
196 int dataVersion;
197 bool usePrimaries;
198
199 ClassDef(Event, 3);
200};
201
202#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:49
int DataVersion() const
Accessor.
Definition Event.hh:94
std::vector< BDSOutputROOTEventSampler< float > * > Samplers
Local variable ROOT data is mapped to.
Definition Event.hh:141
BDSOutputROOTEventLoss * GetLossVacuum()
Accessor.
Definition Event.hh:65
BDSOutputROOTEventLoss * PrimaryLastHit
Local variable ROOT data is mapped to.
Definition Event.hh:135
BDSOutputROOTEventLoss * TunnelHit
Local variable ROOT data is mapped to.
Definition Event.hh:136
BDSOutputROOTEventHistograms * GetHistograms()
Accessor.
Definition Event.hh:74
void FlushSamplers()
Flushing functions.
Definition Event.cc:549
BDSOutputROOTEventSampler< double > * GetPrimaries()
Accessor.
Definition Event.hh:60
BDSOutputROOTEventLoss * ElossVacuum
Local variable ROOT data is mapped to.
Definition Event.hh:129
BDSOutputROOTEventSampler< double > * GetSampler(const std::string &name)
Accessor.
Definition Event.cc:115
BDSOutputROOTEventHistograms * Histos
Local variable ROOT data is mapped to.
Definition Event.hh:145
BDSOutputROOTEventSampler< float > * GetPrimaries()
Accessor.
Definition Event.hh:62
BDSOutputROOTEventCollimator * GetCollimator(const std::string &name)
Accessor.
Definition Event.cc:180
BDSOutputROOTEventLossWorld * ElossWorldExit
Local variable ROOT data is mapped to.
Definition Event.hh:133
void RelinkSamplers()
Definition Event.cc:423
BDSOutputROOTEventAperture * GetAperture()
Accessor.
Definition Event.hh:91
BDSOutputROOTEventLoss * GetLossTunnel()
Accessor.
Definition Event.hh:66
RBDS::VectorString RemoveDuplicates(const RBDS::VectorString &namesIn) const
Utility method.
Definition Event.cc:431
BDSOutputROOTEventLossWorld * ElossWorld
Local variable ROOT data is mapped to.
Definition Event.hh:131
BDSOutputROOTEventLossWorld * ElossWorldContents
Local variable ROOT data is mapped to.
Definition Event.hh:132
BDSOutputROOTEventLossWorld * GetLossWorldContents()
Accessor.
Definition Event.hh:68
void FlushCollimators()
Flushing functions.
Definition Event.cc:559
BDSOutputROOTEventLossWorld * GetLossWorld()
Accessor.
Definition Event.hh:67
BDSOutputROOTEventLoss * ElossTunnel
Local variable ROOT data is mapped to.
Definition Event.hh:130
BDSOutputROOTEventSampler< double > * Primary
Local variable ROOT data is mapped to.
Definition Event.hh:123
BDSOutputROOTEventSamplerC * GetSamplerC(const std::string &name)
Accessor.
std::vector< BDSOutputROOTEventSamplerC * > SamplersC
Local variable ROOT data is mapped to.
Definition Event.hh:143
BDSOutputROOTEventSampler< float > * GetSampler(int index)
Accessor.
const std::vector< std::string > & GetSamplerNames() const
Accessor.
Definition Event.hh:95
BDSOutputROOTEventSamplerS * GetSamplerS(const std::string &name)
Accessor.
Definition Event.cc:169
BDSOutputROOTEventSampler< float > * GetSampler(const std::string &name)
Accessor.
void RegisterCollimator(const std::string &collimatorName)
Utility method for interface building events.
Definition Event.cc:438
void Flush()
Flushing functions.
Definition Event.cc:527
BDSOutputROOTEventTrajectory * Trajectory
Local variable ROOT data is mapped to.
Definition Event.hh:137
BDSOutputROOTEventLoss * PrimaryFirstHit
Local variable ROOT data is mapped to.
Definition Event.hh:134
const std::vector< std::string > & GetCollimatorNames() const
Accessor.
Definition Event.hh:98
bool UsePrimaries() const
Whether there is primary data in the output file.
Definition Event.hh:105
const std::vector< std::string > & GetSamplerCylinderNames() const
Accessor.
Definition Event.hh:96
void SetBranchAddressCollimators(TTree *t, const RBDS::VectorString *collimatorNames)
Utility function to avoid repetition of code.
Definition Event.cc:463
std::vector< BDSOutputROOTEventSampler< double > * > Samplers
Local variable ROOT data is mapped to.
Definition Event.hh:139
BDSOutputROOTEventLoss * GetTunnelHit()
Accessor.
Definition Event.hh:72
void Fill(Event *other)
Copy data from another event into this event.
Definition Event.cc:495
BDSOutputROOTEventLoss * GetLoss()
Accessor.
Definition Event.hh:64
BDSOutputROOTEventSampler< float > * Primary
Local variable ROOT data is mapped to.
Definition Event.hh:125
Int_t SetBranchAddressCollimatorSingle(TTree *t, const std::string &name, int i)
Utility function to avoid repetition of code.
Definition Event.cc:478
BDSOutputROOTEventInfo * Summary
Local variable ROOT data is mapped to.
Definition Event.hh:146
std::vector< BDSOutputROOTEventSamplerS * > SamplersS
Local variable ROOT data is mapped to.
Definition Event.hh:144
BDSOutputROOTEventInfo * GetInfo()
Accessor.
Definition Event.hh:76
BDSOutputROOTEventSampler< double > * GetSampler(int index)
Accessor.
BDSOutputROOTEventLoss * GetPrimaryFirstHit()
Accessor.
Definition Event.hh:70
BDSOutputROOTEventLoss * Eloss
Local variable ROOT data is mapped to.
Definition Event.hh:128
BDSOutputROOTEventInfo * GetSummary()
Accessor.
Definition Event.hh:75
void RegisterSampler(const std::string &samplerName)
Utility method for interface building events.
Definition Event.cc:448
BDSOutputROOTEventLossWorld * GetLossWorldExit()
Accessor.
Definition Event.hh:69
BDSOutputROOTEventCoords * PrimaryGlobal
Local variable ROOT data is mapped to.
Definition Event.hh:127
void SetDataVersion(int dataVersionIn)
Definition Event.hh:109
const std::vector< std::string > & GetSamplerSphereNames() const
Accessor.
Definition Event.hh:97
BDSOutputROOTEventLoss * GetPrimaryLastHit()
Accessor.
Definition Event.hh:71
BDSOutputROOTEventInfo * Info
For backwards compatibility.
Definition Event.hh:149
std::vector< BDSOutputROOTEventCollimator * > collimators
Local variable ROOT data is mapped to.
Definition Event.hh:147
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:205
BDSOutputROOTEventTrajectory * GetTrajectory()
Accessor.
Definition Event.hh:73