BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTrajectoryPrimary.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 BDSTRAJECTORYPRIMARY_H
19#define BDSTRAJECTORYPRIMARY_H
20
21#include "BDSTrajectory.hh"
22
23#include "G4Allocator.hh"
24#include "G4Types.hh"
25
26#include <ostream>
27
29class G4Step;
30class G4Track;
31
32namespace BDS
33{
34 struct TrajectoryOptions;
35}
36
48{
49public:
50 BDSTrajectoryPrimary(const G4Track* aTrack,
51 G4bool interactive,
52 const BDS::TrajectoryOptions& storageOptionsIn,
53 G4bool storeTrajectoryPointsIn);
54
57
58 virtual ~BDSTrajectoryPrimary();
59
61 virtual G4bool IsPrimary() const {return true;}
62
63 inline void* operator new(size_t);
64 inline void operator delete(void*);
65 inline int operator == (const BDSTrajectoryPrimary& right) const {return (this==&right);}
66
69 virtual void AppendStep(const G4Step* aStep);
70
74 virtual void MergeTrajectory(G4VTrajectory* secondTrajectory);
75
77 friend std::ostream& operator<< (std::ostream &out, BDSTrajectoryPrimary const &t);
78
80 const BDSTrajectoryPoint* FirstHit() const {return firstHit;}
81 const BDSTrajectoryPoint* LastPoint() const {return lastPoint;}
83
86 G4bool HasHitSomething() const {return firstHit;}
87
90 static G4bool hasScatteredThisTurn;
91
92protected:
95
96private:
97 const G4bool storeTrajectoryPoints;
98
100};
101
102extern G4Allocator<BDSTrajectoryPrimary> bdsTrajectoryPrimaryAllocator;
103
104inline void* BDSTrajectoryPrimary::operator new(size_t)
105{
106 void* aTrajectory;
107 aTrajectory = (void*)bdsTrajectoryPrimaryAllocator.MallocSingle();
108 return aTrajectory;
109}
110
111inline void BDSTrajectoryPrimary::operator delete(void* aTrajectory)
112{bdsTrajectoryPrimaryAllocator.FreeSingle((BDSTrajectoryPrimary*)aTrajectory);}
113
114#endif
A Point in a trajectory with extra information.
Trajectory information for only the primary.
friend std::ostream & operator<<(std::ostream &out, BDSTrajectoryPrimary const &t)
Output stream.
const BDSTrajectoryPoint * LastPoint() const
Accessor.
virtual void AppendStep(const G4Step *aStep)
BDSTrajectoryPoint * firstHit
Point owned by this class for the first scattering point.
const BDSTrajectoryPoint * FirstHit() const
Accessor.
BDSTrajectoryPoint * lastPoint
Point owned by this class for the last-most point.
BDSTrajectoryPrimary(BDSTrajectoryPrimary &)=delete
copy constructor is not needed
const G4bool storeTrajectoryPoints
Whether to use base class to store all points.
BDSTrajectoryPrimary()=delete
No default constructor required.
virtual G4bool IsPrimary() const
Override and return true always.
virtual void MergeTrajectory(G4VTrajectory *secondTrajectory)
Trajectory information from track including last scatter etc.
Return either G4Tubs or G4CutTubs depending on flat face.