BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTrajectory.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 BDSTRAJECTORY_H
19#define BDSTRAJECTORY_H
20#include "BDSTrajectoryOptions.hh"
21#include "BDSTrajectoryPoint.hh"
22#include "G4Trajectory.hh"
23
24#include <ostream>
25#include <vector>
26
27class G4Step;
28class G4Track;
29class G4TrajectoryContainer;
30class G4VTrajectoryPoint;
31
32typedef std::vector<BDSTrajectoryPoint*> BDSTrajectoryPointsContainer;
33
42class BDSTrajectory: public G4Trajectory
43{
44public:
45 BDSTrajectory() = delete;
46 BDSTrajectory(const G4Track* aTrack,
47 G4bool interactiveIn,
48 const BDS::TrajectoryOptions& storageOptionsIn);
51
52 virtual ~BDSTrajectory();
53
54 inline void* operator new(size_t);
55 inline void operator delete(void*);
56 inline int operator == (const BDSTrajectory& right) const {return (this==&right);}
57
60 virtual void AppendStep(const G4Step* aStep);
61
64 void AppendStep(const BDSTrajectoryPoint* pointIn);
65
69 void CleanPoint(BDSTrajectoryPoint* point) const;
70
72 virtual void MergeTrajectory(G4VTrajectory* secondTrajectory);
73
75 virtual G4VTrajectoryPoint* GetPoint(G4int i) const {return (*fpBDSPointsContainer)[i];}
76
78 virtual int GetPointEntries() const {return (int)fpBDSPointsContainer->size();}
79
81 virtual G4bool IsPrimary() const {return false;}
82
85 inline void SetTrajIndex(G4int trajIndexIn) {trajIndex = trajIndexIn;}
86 inline G4int GetTrajIndex() const {return trajIndex;}
87
90 inline void SetParentIndex(G4int parentIndexIn) {parentIndex = parentIndexIn;}
91 inline G4int GetParentIndex() const {return parentIndex;}
92
94 inline void SetParentStepIndex(G4int parentStepIndexIn) {parentStepIndex = parentStepIndexIn;}
95 inline G4int GetParentStepIndex() const {return parentStepIndex;}
96
98 inline G4int GetDepth() const {return depth;}
99 inline void SetDepth(G4int depthIn) {depth = depthIn;}
100
102 inline void SetParent(BDSTrajectory* parentIn) {parent = parentIn;}
103 inline BDSTrajectory* GetParent() const {return parent;}
104 inline G4int GetCreatorProcessType() const {return creatorProcessType;}
105 inline G4int GetCreatorProcessSubType() const {return creatorProcessSubType;}
106
108 friend std::ostream& operator<< (std::ostream &out, BDSTrajectory const &t);
109
114 BDSTrajectoryPoint* LastInteraction() const;
115
116protected:
117 G4int creatorProcessType;
118 G4int creatorProcessSubType;
119 G4double weight;
120 G4bool interactive;
121 G4bool suppressTransportationAndNotInteractive;
122 const BDS::TrajectoryOptions storageOptions;
123 BDSTrajectory* parent;
124 G4int trajIndex;
125 G4int parentIndex;
126 G4int parentStepIndex;
127 G4int depth;
128
132 BDSTrajectoryPointsContainer* fpBDSPointsContainer;
133};
134
135extern G4Allocator<BDSTrajectory> bdsTrajectoryAllocator;
136
137inline void* BDSTrajectory::operator new(size_t)
138{
139 void* aTrajectory;
140 aTrajectory = (void*)bdsTrajectoryAllocator.MallocSingle();
141 return aTrajectory;
142}
143
144inline void BDSTrajectory::operator delete(void* aTrajectory)
145{bdsTrajectoryAllocator.FreeSingle((BDSTrajectory*)aTrajectory);}
146
147
148#endif
A Point in a trajectory with extra information.
Trajectory information from track including last scatter etc.
virtual int GetPointEntries() const
Get number of trajectory points in this trajectory.
BDSTrajectoryPoint * FirstInteraction() const
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
Merge another trajectory into this one.
void SetTrajIndex(G4int trajIndexIn)
void SetParentStepIndex(G4int parentStepIndexIn)
The index of the step along the parent trajectory from which this one was created.
virtual G4VTrajectoryPoint * GetPoint(G4int i) const
Access a point - use this class's container.
BDSTrajectory(BDSTrajectory &)=delete
copy constructor is not needed
friend std::ostream & operator<<(std::ostream &out, BDSTrajectory const &t)
Output stream.
void SetParent(BDSTrajectory *parentIn)
Record the parent trajectory.
void CleanPoint(BDSTrajectoryPoint *point) const
virtual void AppendStep(const G4Step *aStep)
virtual G4bool IsPrimary() const
Method to identify which one is a primary. Overridden in derived class.
void SetParentIndex(G4int parentIndexIn)
BDSTrajectoryPointsContainer * fpBDSPointsContainer
G4int GetDepth() const
Depth in the tree. Will be filled later once all trajectories are created and sorted.