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 - 2023.
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
58{
59public:
62 explicit BDSIMLink(BDSBunch* bunchIn);
63
65 int Initialise(int argc,
66 char** argv,
67 bool usualPrintOut = true,
68 double minimumKineticEnergy = 0,
69 bool protonsAndIonsOnly = true);
70
72 BDSIMLink(int argc, char** argv, bool usualPrintOut=true);
73
75 ~BDSIMLink();
76
79 inline bool Initialised() const {return initialised;};
80
81 inline int InitialisationResult() const {return initialisationResult;}
82
86 void BeamOn(int nGenerate=-1);
87
88 void SelectLinkElement(const std::string& elementName, bool debug = false);
89 void SelectLinkElement(int index, bool debug = false);
90
92 int AddLinkCollimatorJaw(const std::string& collimatorName,
93 const std::string& materialName,
94 double length,
95 double halfApertureLeft,
96 double halfApertureRight,
97 double rotation,
98 double xOffset,
99 double yOffset,
100 double jawTiltLeft = 0.0,
101 double jawTiltRight = 0.0,
102 bool buildLeftJaw = true,
103 bool buildRightJaw = true,
104 bool isACrystal = false,
105 double crystalAngle = 0,
106 bool sampleIn = false);
107
108 BDSHitsCollectionSamplerLink* SamplerHits() const;
109 void ClearSamplerHits() {runAction->ClearSamplerHits();}
110
111 int GetCurrentMaximumSixTrackParticleID() const;
112 void SetCurrentMaximumExternalParticleID(int currentMaximumExternalParticleID);
113
114 inline G4int NSecondariesToReturn() const {return runAction ? runAction->NSecondariesToReturn() : 0;}
115 inline G4int NPrimariesToReturn() const {return runAction ? runAction->NPrimariesToReturn() : 0;}
116
118 int GetLinkIndex(const std::string& elementName) const;
119
120 const BDSLinkComponent* GetLinkComponent(int linkID) const;
122 double GetChordLengthOfLinkElement(int beamlineIndex) const;
123 double GetChordLengthOfLinkElement(const std::string& elementName);
124 double GetArcLengthOfLinkElement(int beamlineIndex) const;
125 double GetArcLengthOfLinkElement(const std::string& elementName);
127
129 void RegisterUserPhysicsList(G4VModularPhysicsList* userPhysicsListIn) {userPhysicsList = userPhysicsListIn;}
130 G4VModularPhysicsList* UserPhysicsList() const {return userPhysicsList;}
131
132private:
134 int Initialise(double minimumKineticEnergy = 0,
135 bool protonsAndIonsOnly = true);
136
142 char** argvCache;
143
148 G4RunManager* runManager;
152
153 std::vector<BDSParticleExternal*> externalParticles;
154 std::map<std::string, int> nameToElementIndex;
155 std::map<int, int> linkIDToBeamlineIndex;
157 G4VModularPhysicsList* userPhysicsList;
158};
159
160#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:36
A set of particle coordinates including energy and weight.
Wrapper for particle definition.
A set of particle coordinates from an external interface.