BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSLinkTrackerInterface.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 BDSLINKTRACKERINTERFACE_H
19#define BDSLINKTRACKERINTERFACE_H
20
21#include <string>
22
23class G4ParticleTable;
24class G4IonTable;
25class BDSLinkBunch;
26class BDSIMLink;
28class BDSParser;
29
31public:
32
33 static BDSLinkTrackerInterface* GetInstance(std::string bdsimConfigFileIn,
34 int referenceParticlePDGIn = 11,
35 double referenceKineticEnergyIn = 100,
36 double relativeEnergyCutIn = 0.01,
37 int seedIn = 1234,
38 int referenceIonChargeIn = 1,
39 bool batchModeIn = true);
40
41 static BDSLinkTrackerInterface* GetInstance(BDSParser* parserIn,
42 int referenceParticlePDGIn = 11,
43 double referenceKineticEnergyIn = 100,
44 double relativeEnergyCutIn = 0.01,
45 int seedIn = 1234,
46 int referenceIonChargeIn = 1,
47 bool batchModeIn = true);
48
49 static BDSLinkTrackerInterface* GetInstance();
50
52 void Reset();
53
54 BDSParticleDefinition* PrepareBDSParticleDefinition(int pdg,
55 double totalEnergy,
56 double momentum,
57 double kineticEnergy,
58 int ionCharge);
59 BDSParticleDefinition* PrepareBDSParticleDefinition_Bjorn(int pdg,
60 double momentum,
61 double kineticEnergy,
62 int ionCharge);
63
64 const BDSParticleDefinition* GetReferenceParticleDefinition() {return referenceParticleDefinition;}
65 void SetReferenceParticleDefinition(BDSParticleDefinition* rpd) {referenceParticleDefinition = rpd;}
66
67 std::string GetBDSIMConfigFile() {return bdsimConfigFile;}
68 int GetReferenceParticlePDG() {return referenceParticlePDG;}
69 double GetReferenceParticleKineticEnergy() {return referenceKineticEnergy;}
70 double GetRelativeEnergyCut() {return relativeEnergyCut;}
71 int GetSeed() {return seed;}
72 int GetReferenceIonCharge() {return referenceIonCharge;}
73 bool GetBatchMode() {return batchMode;}
74 double GetMinimumKineticEnergy() {return minimumKineticEnergy;}
75
76 void SetNoNeutralParticles(bool val) { noNeutralParticles = val; }
77 bool GetNoNeutralParticles() const { return noNeutralParticles; }
78
79 BDSLinkBunch* GetBunchLink() {return linkBunch;}
80 BDSIMLink* GetBDSIMLink() {return linkBDSIM;}
81
85 void AddParticle(double x, double y, double px, double py,
86 double ct, double deltap, double chi,
87 double chargeRatio, double s,
88 int trackid, int pdgid);
90 void AddParticle(double x, double y, double px, double py,
91 double pz, double t, double s,
92 int trackid, int pdgid);
93 void AddParticles(std::vector<double> &x, std::vector<double> &y,
94 std::vector<double> &px, std::vector<double> &py,
95 std::vector<double> &ct, std::vector<double> &deltap,
96 std::vector<double> &chi, std::vector<double> &chargeRatio,
97 std::vector<double> &s, std::vector<int> &trackid,
98 std::vector<int> &pdgid);
99 void AddParticles(std::vector<double> &x, std::vector<double> &y,
100 std::vector<double> &px, std::vector<double> &py,
101 std::vector<double> &pz, std::vector<double> &t,
102 std::vector<double> &s, std::vector<int> &trackid,
103 std::vector<int> &pdgid);
104
105 void ClearData();
106
107 // Geant4 particle definition for pdgid
108 G4ParticleDefinition* GetParticleDefinition(int pdgid);
109 // PDG mass for particle with pdgid
110 double GetParticlePDGMass(int pdgid);
111 // PDG charge for particle with pdgid
112 double GetParticlePDGCharge(int pdgid);
114 double GetChargeRatio(int pdgid);
116 double GetMassRatio(int pdgid);
118 double GetChi(int pdgid);
119
120
121 // TODO is this needed?
122 std::vector<bool>& GetParticleActiveState() { return particleActiveState; }
123
124protected:
125
126 // singleton private constructor
127 BDSLinkTrackerInterface(std::string bdsimConfigFileIn = "trackerInterface.gmad",
128 int referenceParticlePDGIn = 11,
129 double referenceKineticEnergyIn = 100,
130 double relativeEnergyCutIn = 0.01,
131 int seedIn = 1234,
132 int referenceIonChargeIn = 1,
133 bool batchModeIn = true);
134
135 // singleton private constructor
137 int referenceParticlePDGIn = 11,
138 double referenceKineticEnergyIn = 100,
139 double relativeEnergyCutIn = 0.01,
140 int seedIn = 1234,
141 int referenceIonChargeIn = 1,
142 bool batchModeIn = true);
143
144 // singleton pointer
145 static BDSLinkTrackerInterface* singleton;
146
147 // singleton pattern
148 BDSLinkTrackerInterface() = default;
150 BDSLinkTrackerInterface& operator=(const BDSLinkTrackerInterface&) = delete;
151
152 // configuration parameters
153 std::string bdsimConfigFile;
154 int referenceParticlePDG;
155 double referenceKineticEnergy;
156 double relativeEnergyCut;
157 int seed;
158 int referenceIonCharge;
159 bool batchMode;
160
161 // other parameters
162 bool noNeutralParticles = true; // default value
163
164 // derived parmeters
165 double minimumKineticEnergy;
166
167 // Handy G4 objects
168 G4ParticleTable *g4particle_table;
169 G4IonTable *g4ion_table;
170
171 // link objects
172 BDSLinkBunch *linkBunch;
173 BDSIMLink *linkBDSIM;
174
175 // reference particle
176 BDSParticleDefinition* referenceParticleDefinition;
177
178 // todo, what is this for?
179 std::vector<bool> particleActiveState;
180};
181
182#endif
A bunch distribution that holds a bunch from a Link.
double GetChi(int pdgid)
Ratio of charge ratio to mass ratio between pdgid particle and reference particle.
double GetMassRatio(int pdgid)
Ratio of mass between pdgid particle and reference particle.
double GetChargeRatio(int pdgid)
Ratio of charge between pdgid particle and reference particle.
void AddParticle(double x, double y, double px, double py, double ct, double deltap, double chi, double chargeRatio, double s, int trackid, int pdgid)
Const entry to parser objects.
Definition BDSParser.hh:36
Wrapper for particle definition.