BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIMLink.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef BDSIMLINK_H
20#define BDSIMLINK_H
21#include "BDSHitSamplerLink.hh"
22#include "BDSLinkRunAction.hh"
23
24#include <map>
25#include <string>
26#include <vector>
27
28class BDSBunch;
33class BDSOutput;
34class BDSParser;
38class G4RunManager;
39class G4VModularPhysicsList;
40
41#include "parser/element.h"
42#include "parser/elementtype.h"
43
61{
62public:
65 explicit BDSIMLink(BDSBunch* bunchIn = nullptr);
66
68 int Initialise(int argc,
69 char** argv,
70 bool usualPrintOut = true,
71 double minimumKineticEnergy = 0,
72 bool protonsAndIonsOnly = false);
73
75 BDSIMLink(int argc, char** argv, bool usualPrintOut=true);
76
78 ~BDSIMLink();
79
82 inline bool Initialised() const {return initialised;};
83
84 inline int InitialisationResult() const {return initialisationResult;}
85
89 void BeamOn(int nGenerate=-1);
90
91 void SelectLinkElement(const std::string& elementName, bool debug = false);
92 void SelectLinkElement(int index, bool debug = false);
93
95 int AddLinkCollimatorJaw(const std::string& collimatorName,
96 const std::string& materialName,
97 double length,
98 double halfApertureLeft,
99 double halfApertureRight,
100 double rotation,
101 double xOffset,
102 double yOffset,
103 double jawTiltLeft = 0.0,
104 double jawTiltRight = 0.0,
105 bool buildLeftJaw = true,
106 bool buildRightJaw = true,
107 bool isACrystal = false,
108 double crystalAngle = 0,
109 bool sampleIn = false);
110
111 int AddLinkCollimatorTipJaw(const std::string& collimatorName,
112 const std::string& materialName,
113 const std::string& tipMaterialName,
114 double tipThickness,
115 double length,
116 double halfApertureLeft,
117 double halfApertureRight,
118 double rotation,
119 double xOffset,
120 double yOffset,
121 double jawTiltLeft = 0.0,
122 double jawTiltRight = 0.0,
123 bool buildLeftJaw = true,
124 bool buildRightJaw = true);
125
127
128 BDSHitsCollectionSamplerLink* SamplerHits() const;
129 void ClearSamplerHits() {runAction->ClearSamplerHits();}
130
131 int GetCurrentMaximumSixTrackParticleID() const;
132 void SetCurrentMaximumExternalParticleID(int currentMaximumExternalParticleID);
133
134 inline G4int NSecondariesToReturn() const {return runAction ? runAction->NSecondariesToReturn() : 0;}
135 inline G4int NPrimariesToReturn() const {return runAction ? runAction->NPrimariesToReturn() : 0;}
136
138 int GetLinkIndex(const std::string& elementName) const;
139
140 const BDSLinkComponent* GetLinkComponent(int linkID) const;
142 double GetChordLengthOfLinkElement(int beamlineIndex) const;
143 double GetChordLengthOfLinkElement(const std::string& elementName);
144 double GetArcLengthOfLinkElement(int beamlineIndex) const;
145 double GetArcLengthOfLinkElement(const std::string& elementName);
147
148 BDSBunch* GetBunch() const;
149
151 void RegisterUserPhysicsList(G4VModularPhysicsList* userPhysicsListIn) {userPhysicsList = userPhysicsListIn;}
152 G4VModularPhysicsList* UserPhysicsList() const {return userPhysicsList;}
153
154private:
156 int Initialise(double minimumKineticEnergy = 0,
157 bool protonsAndIonsOnly = false);
158
164 char** argvCache;
165
171 G4RunManager* runManager;
175
176 std::vector<BDSParticleExternal*> externalParticles;
177 std::map<std::string, int> nameToElementIndex;
178 std::map<int, int> linkIDToBeamlineIndex;
180 G4VModularPhysicsList* userPhysicsList;
181};
182
183#endif
The base class for bunch distribution generators.
Definition BDSBunch.hh:47
Interface class the developer should derive to construct their element.
Factory for user specified accelerator components.
A BDSAcceleratorComponent wrapper for BDSLinkOpaqueBox.
Construction of the geometry in the case of a link model.
Simplified run action to hold link hits.
Output base class that defines interface for all output types.
Definition BDSOutput.hh:73
Const entry to parser objects.
Definition BDSParser.hh:37
A set of particle coordinates including energy and weight.
Wrapper for particle definition.
A set of particle coordinates from an external interface.
Element class.
Definition element.h:45