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 - 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 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 virtual void Flush();
168 void FlushLocal();
169 void Fill(const BDSOutputROOTEventTrajectory* other);
170
171
172 int n;
173 std::vector<std::bitset<BDS::NTrajectoryFilters> > filters;
174 std::vector<int> partID;
175 std::vector<unsigned int> trackID;
176 std::vector<unsigned int> parentID;
177 std::vector<unsigned int> parentIndex;
178 std::vector<unsigned int> parentStepIndex;
179 std::vector<int> primaryStepIndex;
180 std::vector<int> depth;
181
182 std::vector<std::vector<int>> preProcessTypes;
183 std::vector<std::vector<int>> preProcessSubTypes;
184 std::vector<std::vector<int>> postProcessTypes;
185 std::vector<std::vector<int>> postProcessSubTypes;
186
187 std::vector<std::vector<double>> preWeights;
188 std::vector<std::vector<double>> postWeights;
189 std::vector<std::vector<double>> energyDeposit;
190
191 std::vector<std::vector<TVector3>> XYZ;
192 std::vector<std::vector<double>> S;
193 std::vector<std::vector<TVector3>> PXPYPZ;
194 std::vector<std::vector<double>> T;
195
197 std::vector<std::vector<TVector3>> xyz;
198 std::vector<std::vector<TVector3>> pxpypz;
200
202 std::vector<std::vector<int>> charge;
203 std::vector<std::vector<double>> kineticEnergy;
204 std::vector<std::vector<int>> turnsTaken;
205 std::vector<std::vector<double>> mass;
206 std::vector<std::vector<double>> rigidity;
208
210 std::vector<std::vector<bool>> isIon;
211 std::vector<std::vector<int>> ionA;
212 std::vector<std::vector<int>> ionZ;
213 std::vector<std::vector<int>> nElectrons;
215
216 std::vector<std::vector<short int>> materialID;
217
218 std::vector<std::vector<int>> modelIndicies;
219
220 std::map<int, int> trackID_trackIndex;// trackID to storage index
221
222 // std::map<int, std::pair<int,int>> trackIndex_trackProcess; // trackProcess pair<trackIndex,trackProcessIndex>
223 // std::map<int, int> trackIndex_modelIndex; // trackIndex to model index map
224 // std::map<int, std::vector<int>> modelIndex_trackIndex; // modelIndex to track index map
225 // std::pair<int,int> findParentProcess(int trackIndex);
226
227 std::vector<BDSOutputROOTEventTrajectoryPoint> trackInteractions(int trackIDIn) const;
228 BDSOutputROOTEventTrajectoryPoint primaryProcessPoint(int trackIDIn) const;
229 BDSOutputROOTEventTrajectoryPoint parentProcessPoint(int trackIDIn) const;
230 std::vector<BDSOutputROOTEventTrajectoryPoint> processHistory(int trackIDIn) const;
231 void printTrajectoryInfoByTrackID(int trackIDIn) const;
232 void printTrajectoryInfo(int storageIndex) const;
233 bool parentIsPrimary(int trackIDIn) const;
234
235 friend std::ostream& operator<< (std::ostream& out, BDSOutputROOTEventTrajectory const &p);
236
238};
239
240#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.
virtual void Flush()
add comment to avoid warning (no need to make persistent, see issue #191)
void FlushLocal()
Non-virtual version for initialising members.
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.