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) 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 BDSOUTPUTROOTEVENTTRAJECTORY_H
19#define BDSOUTPUTROOTEVENTTRAJECTORY_H
20#include "Rtypes.h"
21#include "TVector3.h"
22
23#include "BDSOutputROOTEventTrajectoryPoint.hh"
24#include "BDSTrajectoryFilter.hh"
25#include "BDSTrajectoriesToStore.hh"
26
27#include <bitset>
28#include <map>
29#include <vector>
30
31#ifndef __ROOTBUILD__
33class BDSTrajectory;
34template <class T> class G4THitsCollection;
36class G4Material;
37namespace BDS
38{
39 struct TrajectoryOptions;
40}
41#endif
42
44
45#if 0
460 fNotDefined,
47 1 fTransportation,
48 91 TRANSPORTATION,
49 92 COUPLED_TRANSPORTATION
50 2 fElectromagnetic,
51 1 fCoulombScattering,
52 2 fIonisation,
53 3 fBremsstrahlung,
54 4 fPairProdByCharged,
55 5 fAnnihilation,
56 6 fAnnihilationToMuMu,
57 7 fAnnihilationToHadrons,
58 8 fNuclearStopping,
59 10 fMultipleScattering,
60 11 fRayleigh,
61 12 fPhotoElectricEffect,
62 13 fComptonScattering,
63 14 fGammaConversion,
64 15 fGammaConversionToMuMu,
65 21 fCerenkov,
66 22 fScintillation,
67 23 fSynchrotronRadiation,
68 24 fTransitionRadiation
69 3 fOptical,
70 0 kCerenkov,
71 1 kScintillation,
72 2 kAbsorption,
73 3 kRayleigh,
74 4 kMieHG,
75 5 kBoundary,
76 6 kWLS,
77 7 kNoProcess
78 4 fHadronic,
79 111 fHadronElastic,
80 121 fHadronInelastic,
81 131 fCapture,
82 141 fFission,
83 151 fHadronAtRest,
84 152 fLeptonAtRest,
85 161 fChargeExchange,
86 210 fRadioactiveDecay
87 5 fPhotolepton_hadron,
88 6 fDecay,
89 201 DECAY = 201,
90 202 DECAY_WithSpin,
91 203 DECAY_PionMakeSpin,
92 210 DECAY_Radioactive,
93 211 DECAY_Unknown,
94 231 DECAY_External = 231
95 7 fGeneral,
96 401 STEP_LIMITER,
97 402 USER_SPECIAL_CUTS,
98 403 NEUTRON_KILLER
99 8 fParameterisation,
100 9 fUserDefined,
101 10 fParallel,
102 491 SBLN_UNKNOWN!
103 11 fPhonon,
104 12 fUCN
105#endif
106
113class BDSOutputROOTEventTrajectory: public TObject
114{
115public:
118#ifndef __ROOTBUILD__
119 void Fill(const BDSTrajectoriesToStore* t,
120 int storeStepPointsN,
121 bool storeStepPointLast,
122 const BDS::TrajectoryOptions& storageOptions,
123 const std::map<G4Material*, short int>& materialToID);
124 void Fill(const BDSHitsCollectionEnergyDeposition* phc);
125
128 {
129 std::vector<int> preProcessType;
130 std::vector<int> preProcessSubType;
131 std::vector<int> postProcessType;
132 std::vector<int> postProcessSubType;
133 std::vector<double> preWeight;
134 std::vector<double> postWeight;
135 std::vector<double> energyDeposit;
136 std::vector<TVector3> XYZ;
137 std::vector<TVector3> PXPYPZ;
138 std::vector<double> S;
139 std::vector<double> T;
140 std::vector<TVector3> xyz;
141 std::vector<TVector3> pxpypz;
142 std::vector<int> charge;
143 std::vector<double> kineticEnergy;
144 std::vector<int> turn;
145 std::vector<double> mass;
146 std::vector<double> rigidity;
147 std::vector<bool> isIon;
148 std::vector<int> ionA;
149 std::vector<int> ionZ;
150 std::vector<int> nElectrons;
151 std::vector<int> modelIndex;
152 std::vector<short int> materialID;
153 };
154
158 BDSTrajectory* traj,
159 int i,
160 const std::map<G4Material*, short int>& materialToID) const;
161#endif
162
165
166 virtual void Flush();
167 void FlushLocal();
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.
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.