BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventModel.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 BDSOUTPUTROOTEVENTMODEL_H
20#define BDSOUTPUTROOTEVENTMODEL_H
21
22#include "BDSOutputROOTEventCavityInfo.hh"
23#include "BDSOutputROOTEventCollimatorInfo.hh"
24
25#include <map>
26#include <string>
27#include <vector>
28
29#include "Rtypes.h"
30#include "TObject.h"
31#include "TVector3.h"
32#include "TRotation.h"
33
34#ifndef __ROOTBUILD__
35#include "G4RotationMatrix.hh"
36#include "G4String.hh"
37#include "G4Transform3D.hh"
38#include "G4Types.hh"
39#endif
40
47class BDSOutputROOTEventModel: public TObject
48{
49public:
54
56 void Flush();
57
59 int findNearestElement(const TVector3& point) const;
60
61#ifndef __ROOTBUILD__
63 explicit BDSOutputROOTEventModel(G4bool storeCollimatorInfoIn,
64 G4bool storeCavityInfoIn);
65
67 TRotation ConvertToROOT(const G4RotationMatrix* rm) const;
68 TRotation ConvertToROOT(const G4RotationMatrix& rm) const;
69 TVector3 ConvertToROOT(const G4ThreeVector& v) const;
70
72 virtual void Fill(const std::vector<G4int>& collimatorIndicesIn = {},
73 const std::map<G4String, G4int>& collimatorIndicesByNameIn = {},
74 const std::vector<BDSOutputROOTEventCollimatorInfo>& collimatorInfoIn = {},
75 const std::vector<G4String>& collimatorBranchNamesIn = {},
76 const std::vector<G4int>& cavityIndicesIn = {},
77 const std::map<G4String, G4int>& cavityIndicesByNameIn = {},
78 const std::vector<BDSOutputROOTEventCavityInfo>& cavityInfoIn = {},
79 const std::vector<G4String>& cavityBranchNamesIn = {},
80 const std::map<G4String, G4Transform3D>* scorerMeshPlacements = nullptr,
81 const std::map<short int, G4String>* materialIDToNameUnique = nullptr,
82 G4bool storeTrajectory = false);
83#endif
84
85 int n;
86 std::vector<std::string> componentName;
87 std::vector<std::string> placementName;
88 std::vector<std::string> componentType;
89 std::vector<float> length;
90 std::vector<float> angle;
91 std::vector<TVector3> staPos;
92 std::vector<TVector3> midPos;
93 std::vector<TVector3> endPos;
94 std::vector<TRotation> staRot;
95 std::vector<TRotation> midRot;
96 std::vector<TRotation> endRot;
97 std::vector<TVector3> staRefPos;
98 std::vector<TVector3> midRefPos;
99 std::vector<TVector3> endRefPos;
100 std::vector<TRotation> staRefRot;
101 std::vector<TRotation> midRefRot;
102 std::vector<TRotation> endRefRot;
103 std::vector<float> tilt;
104 std::vector<float> offsetX;
105 std::vector<float> offsetY;
106 std::vector<float> staS;
107 std::vector<float> midS;
108 std::vector<float> endS;
109 std::vector<std::string> beamPipeType;
110 std::vector<double> beamPipeAper1;
111 std::vector<double> beamPipeAper2;
112 std::vector<double> beamPipeAper3;
113 std::vector<double> beamPipeAper4;
114 std::vector<std::string> material;
115 std::vector<float> k1;
116 std::vector<float> k2;
117 std::vector<float> k3;
118 std::vector<float> k4;
119 std::vector<float> k5;
120 std::vector<float> k6;
121 std::vector<float> k7;
122 std::vector<float> k8;
123 std::vector<float> k9;
124 std::vector<float> k10;
125 std::vector<float> k11;
126 std::vector<float> k12;
127 std::vector<float> k1s;
128 std::vector<float> k2s;
129 std::vector<float> k3s;
130 std::vector<float> k4s;
131 std::vector<float> k5s;
132 std::vector<float> k6s;
133 std::vector<float> k7s;
134 std::vector<float> k8s;
135 std::vector<float> k9s;
136 std::vector<float> k10s;
137 std::vector<float> k11s;
138 std::vector<float> k12s;
139 std::vector<float> ks;
140 std::vector<float> hkick;
141 std::vector<float> vkick;
142 std::vector<float> bField;
143 std::vector<float> eField;
144 std::vector<float> e1;
145 std::vector<float> e2;
146 std::vector<float> hgap;
147 std::vector<float> fint;
148 std::vector<float> fintx;
149 std::vector<float> fintk2;
150 std::vector<float> fintxk2;
151 std::vector<std::vector<std::string>> pvName;
152 std::vector<std::vector<std::string>> pvNameWPointer;
153
156
159
162 std::vector<int> cavityIndices;
163
165 std::map<std::string, int> cavityIndicesByName;
166
168 std::vector<BDSOutputROOTEventCavityInfo> cavityInfo;
169
171 std::vector<std::string> cavityBranchNamesUnique;
172
175 std::vector<int> collimatorIndices;
176
178 std::map<std::string, int> collimatorIndicesByName;
179
181 std::vector<BDSOutputROOTEventCollimatorInfo> collimatorInfo;
182
184 std::vector<std::string> collimatorBranchNamesUnique;
185
186 std::map<std::string, TVector3> scoringMeshTranslation;
187 std::map<std::string, TRotation> scoringMeshRotation;
188 std::vector<std::string> scoringMeshName;
189
190 std::map<short int, std::string> materialIDToName;
191 std::map<std::string, short int> materialNameToID;
192
193 std::vector<std::string> samplerNamesUnique;
194 std::vector<double> samplerSPosition;
195 std::vector<std::string> samplerCNamesUnique;
196 std::vector<std::string> samplerSNamesUnique;
197 std::map<std::string, double> samplerCRadius;
198 std::map<std::string, double> samplerSRadius;
199
200 ClassDef(BDSOutputROOTEventModel, 6);
201};
202
203#endif
Information stored per model representing accelerator.
std::vector< BDSOutputROOTEventCollimatorInfo > collimatorInfo
Collimator information explicitly.
bool storeCollimatorInfo
Whether optional collimator information was stored.
std::vector< float > vkick
Vertical fractional momentum kick.
std::vector< float > eField
E field in V/m.
std::vector< std::string > collimatorBranchNamesUnique
Vector of all collimator branch names in event tree used to load data.
int nCollimators
Number of collimators in beam line.
int nCavities
Number of cavities in beam line.
virtual ~BDSOutputROOTEventModel()
Destructor.
int findNearestElement(const TVector3 &point) const
Find element index closest to point.
std::vector< float > bField
B field in T.
std::vector< float > hkick
Horizontal fractional momentum kick.
std::vector< int > collimatorIndices
std::vector< std::string > material
Material associated with element if any.
std::vector< BDSOutputROOTEventCavityInfo > cavityInfo
cavity information explicitly.
void Flush()
Initialise all members.
virtual void Fill(const std::vector< G4int > &collimatorIndicesIn={}, const std::map< G4String, G4int > &collimatorIndicesByNameIn={}, const std::vector< BDSOutputROOTEventCollimatorInfo > &collimatorInfoIn={}, const std::vector< G4String > &collimatorBranchNamesIn={}, const std::vector< G4int > &cavityIndicesIn={}, const std::map< G4String, G4int > &cavityIndicesByNameIn={}, const std::vector< BDSOutputROOTEventCavityInfo > &cavityInfoIn={}, const std::vector< G4String > &cavityBranchNamesIn={}, const std::map< G4String, G4Transform3D > *scorerMeshPlacements=nullptr, const std::map< short int, G4String > *materialIDToNameUnique=nullptr, G4bool storeTrajectory=false)
Fill root output.
std::vector< std::string > cavityBranchNamesUnique
Vector of all cavity branch names in event tree used to load data.
BDSOutputROOTEventModel()
Default constructor.
std::map< std::string, int > collimatorIndicesByName
Similar cache but by name of collimator as built by BDSIM.
std::vector< float > ks
Solenoid strength.
bool storeCavityInfo
Whether optional cavity information was stored.
TRotation ConvertToROOT(const G4RotationMatrix *rm) const
Utility function.
std::map< std::string, int > cavityIndicesByName
Similar cache but by name of cavity as built by BDSIM.