BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSOutputROOTEventTrajectory.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 BDSOUTPUTROOTEVENTTRAJECTORY_H
20#define BDSOUTPUTROOTEVENTTRAJECTORY_H
21#include "Rtypes.h"
22#include "TVector3.h"
23
24#include "BDSOutputROOTEventTrajectoryPoint.hh"
25#include "BDSTrajectoryFilter.hh"
26#include "BDSTrajectoriesToStore.hh"
27
28#include <bitset>
29#include <map>
30#include <vector>
31
32#ifndef __ROOTBUILD__
34class BDSTrajectory;
35template <class T> class G4THitsCollection;
37class G4Material;
38namespace BDS
39{
40 struct TrajectoryOptions;
41}
42#endif
43
45
46#if 0
470 fNotDefined,
48 1 fTransportation,
49 91 TRANSPORTATION,
50 92 COUPLED_TRANSPORTATION
51 2 fElectromagnetic,
52 1 fCoulombScattering,
53 2 fIonisation,
54 3 fBremsstrahlung,
55 4 fPairProdByCharged,
56 5 fAnnihilation,
57 6 fAnnihilationToMuMu,
58 7 fAnnihilationToHadrons,
59 8 fNuclearStopping,
60 10 fMultipleScattering,
61 11 fRayleigh,
62 12 fPhotoElectricEffect,
63 13 fComptonScattering,
64 14 fGammaConversion,
65 15 fGammaConversionToMuMu,
66 21 fCerenkov,
67 22 fScintillation,
68 23 fSynchrotronRadiation,
69 24 fTransitionRadiation
70 3 fOptical,
71 0 kCerenkov,
72 1 kScintillation,
73 2 kAbsorption,
74 3 kRayleigh,
75 4 kMieHG,
76 5 kBoundary,
77 6 kWLS,
78 7 kNoProcess
79 4 fHadronic,
80 111 fHadronElastic,
81 121 fHadronInelastic,
82 131 fCapture,
83 141 fFission,
84 151 fHadronAtRest,
85 152 fLeptonAtRest,
86 161 fChargeExchange,
87 210 fRadioactiveDecay
88 5 fPhotolepton_hadron,
89 6 fDecay,
90 201 DECAY = 201,
91 202 DECAY_WithSpin,
92 203 DECAY_PionMakeSpin,
93 210 DECAY_Radioactive,
94 211 DECAY_Unknown,
95 231 DECAY_External = 231
96 7 fGeneral,
97 401 STEP_LIMITER,
98 402 USER_SPECIAL_CUTS,
99 403 NEUTRON_KILLER
100 8 fParameterisation,
101 9 fUserDefined,
102 10 fParallel,
103 491 SBLN_UNKNOWN!
104 11 fPhonon,
105 12 fUCN
106#endif
107
114class BDSOutputROOTEventTrajectory: public TObject
115{
116public:
119#ifndef __ROOTBUILD__
120 void Fill(const BDSTrajectoriesToStore* t,
121 int storeStepPointsN,
122 bool storeStepPointLast,
123 const BDS::TrajectoryOptions& storageOptions,
124 const std::map<G4Material*, short int>& materialToID);
125 void Fill(const BDSHitsCollectionEnergyDeposition* phc);
126
129 {
130 std::vector<int> preProcessType;
131 std::vector<int> preProcessSubType;
132 std::vector<int> postProcessType;
133 std::vector<int> postProcessSubType;
134 std::vector<double> preWeight;
135 std::vector<double> postWeight;
136 std::vector<double> energyDeposit;
137 std::vector<TVector3> XYZ;
138 std::vector<TVector3> PXPYPZ;
139 std::vector<double> S;
140 std::vector<double> T;
141 std::vector<TVector3> xyz;
142 std::vector<TVector3> pxpypz;
143 std::vector<int> charge;
144 std::vector<double> kineticEnergy;
145 std::vector<int> turn;
146 std::vector<double> mass;
147 std::vector<double> rigidity;
148 std::vector<bool> isIon;
149 std::vector<int> ionA;
150 std::vector<int> ionZ;
151 std::vector<int> nElectrons;
152 std::vector<int> modelIndex;
153 std::vector<short int> materialID;
154 };
155
159 BDSTrajectory* traj,
160 int i,
161 const std::map<G4Material*, short int>& materialToID) const;
162#endif
163
166
167 void Flush();
168 void Fill(const BDSOutputROOTEventTrajectory* other);
169
170
171 int n;
172 std::vector<std::bitset<BDS::NTrajectoryFilters> > filters;
173 std::vector<int> partID;
174 std::vector<unsigned int> trackID;
175 std::vector<unsigned int> parentID;
176 std::vector<unsigned int> parentIndex;
177 std::vector<unsigned int> parentStepIndex;
178 std::vector<int> primaryStepIndex;
179 std::vector<int> depth;
180
181 std::vector<std::vector<int>> preProcessTypes;
182 std::vector<std::vector<int>> preProcessSubTypes;
183 std::vector<std::vector<int>> postProcessTypes;
184 std::vector<std::vector<int>> postProcessSubTypes;
185
186 std::vector<std::vector<double>> preWeights;
187 std::vector<std::vector<double>> postWeights;
188 std::vector<std::vector<double>> energyDeposit;
189
190 std::vector<std::vector<TVector3>> XYZ;
191 std::vector<std::vector<double>> S;
192 std::vector<std::vector<TVector3>> PXPYPZ;
193 std::vector<std::vector<double>> T;
194
196 std::vector<std::vector<TVector3>> xyz;
197 std::vector<std::vector<TVector3>> pxpypz;
199
201 std::vector<std::vector<int>> charge;
202 std::vector<std::vector<double>> kineticEnergy;
203 std::vector<std::vector<int>> turnsTaken;
204 std::vector<std::vector<double>> mass;
205 std::vector<std::vector<double>> rigidity;
207
209 std::vector<std::vector<bool>> isIon;
210 std::vector<std::vector<int>> ionA;
211 std::vector<std::vector<int>> ionZ;
212 std::vector<std::vector<int>> nElectrons;
214
215 std::vector<std::vector<short int>> materialID;
216
217 std::vector<std::vector<int>> modelIndicies;
218
219 std::map<int, int> trackID_trackIndex;// trackID to storage index
220
221 // std::map<int, std::pair<int,int>> trackIndex_trackProcess; // trackProcess pair<trackIndex,trackProcessIndex>
222 // std::map<int, int> trackIndex_modelIndex; // trackIndex to model index map
223 // std::map<int, std::vector<int>> modelIndex_trackIndex; // modelIndex to track index map
224 // std::pair<int,int> findParentProcess(int trackIndex);
225
226 std::vector<BDSOutputROOTEventTrajectoryPoint> trackInteractions(int trackIDIn) const;
227 BDSOutputROOTEventTrajectoryPoint primaryProcessPoint(int trackIDIn) const;
228 BDSOutputROOTEventTrajectoryPoint parentProcessPoint(int trackIDIn) const;
229 std::vector<BDSOutputROOTEventTrajectoryPoint> processHistory(int trackIDIn) const;
230 void printTrajectoryInfoByTrackID(int trackIDIn) const;
231 void printTrajectoryInfo(int storageIndex) const;
232 bool parentIsPrimary(int trackIDIn) const;
233
234 friend std::ostream& operator<< (std::ostream& out, BDSOutputROOTEventTrajectory const &p);
235
237};
238
239#endif
Extra G4Navigator to get coordinate transforms.
Information recorded for a single piece of energy deposition.
Structure to record a trajectory point.
Structure to record a trajectory.
std::vector< std::vector< int > > nElectrons
Ion trajectory information.
std::vector< std::vector< int > > charge
Link trajectory information.
std::vector< std::vector< TVector3 > > pxpypz
Local coordinates.
std::vector< std::vector< bool > > isIon
Ion trajectory information.
void Flush()
add comment to avoid warning (no need to make persistent, see issue #191)
void FillIndividualTrajectory(IndividualTrajectory &itj, BDSTrajectory *traj, int i, const std::map< G4Material *, short int > &materialToID) const
BDSAuxiliaryNavigator * auxNavigator
Required to find beamline index careful including in streamer.
std::vector< std::vector< double > > mass
Link trajectory information.
std::vector< std::vector< int > > ionZ
Ion trajectory information.
std::vector< std::vector< TVector3 > > xyz
Local coordinates.
std::vector< std::vector< int > > turnsTaken
Link trajectory information.
std::vector< std::vector< double > > rigidity
Link trajectory information.
std::vector< std::vector< int > > ionA
Ion trajectory information.
std::vector< std::vector< double > > kineticEnergy
Link trajectory information.
Double map of trajectories to bitset of which filters matched whether to store them.
Trajectory information from track including last scatter etc.
Return either G4Tubs or G4CutTubs depending on flat face.
Temporary structure for an individual trajectory used to convert types.