BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSPTCOneTurnMap.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 BDSPTCONETURNMAP_H
19#define BDSPTCONETURNMAP_H
20
21#include "BDSParticleCoordsFullGlobal.hh"
22
23#include "globals.hh" // Geant4 typedefs
24#include "G4Track.hh"
25
26#include <vector>
27#include <set>
28
30
40{
41public:
43 {
44 G4double coefficient;
45 G4int nx;
46 G4int npx;
47 G4int ny;
48 G4int npy;
49 G4int ndeltaP;
50 };
51
52 BDSPTCOneTurnMap() = delete;
53 BDSPTCOneTurnMap(const BDSPTCOneTurnMap &other) = default;
54 BDSPTCOneTurnMap(BDSPTCOneTurnMap &&other) noexcept = default;
55 virtual ~BDSPTCOneTurnMap() {;}
56
58 BDSPTCOneTurnMap(const G4String& maptableFile,
59 const BDSParticleDefinition* designParticle);
60
62 G4bool ShouldApplyToPrimary(G4double momentum, G4int turnstaken);
63
66 G4bool offsetS0);
67
69 void UpdateCoordinates(G4ThreeVector localPosition,
70 G4ThreeVector localMomentum,
71 G4int turnstaken);
72
74 void GetThisTurn(G4double& x,
75 G4double& px,
76 G4double& y,
77 G4double& py,
78 G4double& pz,
79 G4int turnstaken);
80
81private:
82 G4double Evaluate(std::vector<PTCMapTerm>& terms,
83 G4double x,
84 G4double px,
85 G4double y,
86 G4double py,
87 G4double deltaP) const;
88
89 G4double initialPrimaryMomentum;
90 G4bool beamOffsetS0;
91 G4double referenceMomentum;
92 G4double mass;
93
94 std::set<G4int> turnsScattered;
95
96 G4int lastTurnNumber;
97 G4double xLastTurn;
98 G4double pxLastTurn;
99 G4double yLastTurn;
100 G4double pyLastTurn;
101 G4double deltaPLastTurn;
102
103 std::vector<PTCMapTerm> xTerms;
104 std::vector<PTCMapTerm> yTerms;
105 std::vector<PTCMapTerm> pxTerms;
106 std::vector<PTCMapTerm> pyTerms;
107 std::vector<PTCMapTerm> deltaPTerms;
108};
109
110#endif
Class to load and use PTC 1 turn map.
G4bool ShouldApplyToPrimary(G4double momentum, G4int turnstaken)
Decides whether or not this should be applied. Can add more.
virtual ~BDSPTCOneTurnMap()
Destructor.
BDSPTCOneTurnMap(BDSPTCOneTurnMap &&other) noexcept=default
Move constructor.
void GetThisTurn(G4double &x, G4double &px, G4double &y, G4double &py, G4double &pz, G4int turnstaken)
Return the coordinates for this turn.
BDSPTCOneTurnMap()=delete
Default constructor.
void UpdateCoordinates(G4ThreeVector localPosition, G4ThreeVector localMomentum, G4int turnstaken)
Update coordinates if the last turn is greater than the number of turns taken.
void SetInitialPrimaryCoordinates(const BDSParticleCoordsFullGlobal &coords, G4bool offsetS0)
Load initial coordinates where the beam started and convert to PTC coordinates.
BDSPTCOneTurnMap(const BDSPTCOneTurnMap &other)=default
Copy constructor.
A set of particle coordinates in both local and global.
Wrapper for particle definition.