BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSAcceleratorComponent.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 BDSACCELERATORCOMPONENT_H
19#define BDSACCELERATORCOMPONENT_H
20
21#include "globals.hh" // geant4 globals / types
22
23#include "BDSGeometryComponent.hh"
24
25#include <list>
26#include <set>
27#include <string>
28#include <vector>
29
30class BDSBeamPipeInfo;
31class BDSFieldInfo;
33class G4LogicalVolume;
34class G4UserLimits;
35class G4VisAttributes;
36
77{
78public:
95 BDSAcceleratorComponent(const G4String& name,
96 G4double arcLength,
97 G4double angle,
98 const G4String& type,
100 const G4ThreeVector& inputFaceNormalIn = G4ThreeVector(0,0,-1),
101 const G4ThreeVector& outputFaceNormalIn = G4ThreeVector(0,0, 1),
102 BDSFieldInfo* fieldInfoIn = nullptr);
103
104 virtual ~BDSAcceleratorComponent();
105
110 virtual void Initialise();
111
112 // Communal constructions tasks
113
115 virtual void SetBiasVacuumList(const std::list<std::string>& biasVacuumListIn)
116 {biasVacuumList = biasVacuumListIn;}
117 virtual void SetBiasMaterialList(const std::list<std::string>& biasMaterialListIn)
118 {biasMaterialList = biasMaterialListIn;}
119 virtual void SetBiasMaterialLVList(const std::list<std::string>& biasMaterialLVListIn)
120 {biasMaterialLVList = biasMaterialLVListIn;}
122
124 virtual void SetRegion(const G4String& regionIn) {region = regionIn;}
125
127 void SetField(BDSFieldInfo* fieldInfoIn);
128
131 virtual void SetMinimumKineticEnergy(G4double /*minimumKineticEnergyIn*/){;}
132
133 // Accessors
134
136 virtual inline G4String GetName() const {return name;}
137
140 virtual G4double GetArcLength() const {return arcLength;}
141 virtual G4double GetChordLength() const {return chordLength;}
143
146 inline G4double GetAngle() const {return angle;}
147
149 G4double Sagitta() const;
150
152 inline G4String GetType() const {return type;}
153
155 G4String GetRegion() const {return region;}
156
158 virtual G4bool HasAField() const {return fieldInfo;}
159
164
169
173 inline G4ThreeVector InputFaceNormal() const {return inputFaceNormal;}
174 inline G4ThreeVector OutputFaceNormal() const {return outputFaceNormal;}
176
178 G4bool AngledInputFace() const;
179 G4bool AngledOutputFace() const;
181
183 virtual G4String Material() const {return "none";}
184
186 virtual std::set<G4LogicalVolume*> GetAcceleratorVacuumLogicalVolumes() const {return acceleratorVacuumLV;}
187
189 virtual std::set<G4LogicalVolume*> GetAcceleratorMaterialLogicalVolumes() const;
190
193
195 inline G4int GetCopyNumber() const {return copyNumber;}
196
198 std::list<std::string> GetBiasVacuumList() const {return biasVacuumList;}
199 std::list<std::string> GetBiasMaterialList() const {return biasMaterialList;}
200 std::list<std::string> GetBiasMaterialLVList() const {return biasMaterialLVList;}
202
205 BDSSimpleComponent* EndPieceBefore() const {return endPieceBefore;}
206 BDSSimpleComponent* EndPieceAfter() const {return endPieceAfter;}
207
209 virtual void SetInputFaceNormal(const G4ThreeVector& input) {inputFaceNormal = input.unit();}
210 virtual void SetOutputFaceNormal(const G4ThreeVector& output) {outputFaceNormal = output.unit();}
212
215 static G4double lengthSafetyLarge;
216
217protected:
224 virtual void Build();
225
228 virtual void BuildContainerLogicalVolume() = 0;
229
235 inline void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume* accVacLVIn)
236 {acceleratorVacuumLV.insert(accVacLVIn);}
237
238 inline void SetAcceleratorVacuumLogicalVolume(const std::set<G4LogicalVolume*>& accVacLVIn)
239 {acceleratorVacuumLV.insert(accVacLVIn.begin(), accVacLVIn.end());}
240
247 virtual void BuildUserLimits();
248
250 virtual void AttachUserLimits() const;
251
253 const G4String name;
254 const G4double arcLength;
255 const G4String type;
257
259 G4double chordLength;
260 G4double angle;
261 G4String region;
263
266
268 static G4double lengthSafety;
269 static G4Material* emptyMaterial;
270 static G4Material* worldMaterial;
271 static G4bool checkOverlaps;
272 static G4bool sensitiveOuter;
273 static G4bool sensitiveVacuum;
274 static G4VisAttributes* containerVisAttr;
276
278 std::set<G4LogicalVolume*> acceleratorVacuumLV;
279
280 BDSSimpleComponent* endPieceBefore;
281 BDSSimpleComponent* endPieceAfter;
282
283 G4UserLimits* userLimits;
284
286
287private:
292
297
298 //A vector containing the physical volumes in the accelerator component- to be used for geometric importance sampling etc.
299
304
307
309 std::list<std::string> biasVacuumList;
310 std::list<std::string> biasMaterialList;
311 std::list<std::string> biasMaterialLVList;
313
314 G4ThreeVector inputFaceNormal;
315 G4ThreeVector outputFaceNormal;
316};
317
318#endif
Abstract class that represents a component of an accelerator.
BDSFieldInfo * fieldInfo
Recipe for field that could overlay this whole component.
G4UserLimits * userLimits
Cache of user limits.
G4bool AngledInputFace() const
Whether the face normal is angled at all w.r.t. the incoming / outgoing reference trajectory.
std::list< std::string > biasVacuumList
Copy of bias list from parser for this particular component.
G4double Sagitta() const
Calculate the sagitta - ie the distance between the chord and the arc at the centre.
std::list< std::string > GetBiasMaterialLVList() const
Access the bias list copied from parser.
virtual G4String Material() const
Return the name of a material associated with the component - ie the primary material.
virtual void SetBiasMaterialLVList(const std::list< std::string > &biasMaterialLVListIn)
Copy the bias list to this element.
virtual G4String GetName() const
The name of the component without modification.
G4ThreeVector outputFaceNormal
Output face unit normal vector in outgoing reference coordinate frame.
G4String GetRegion() const
Get the region name for this component.
BDSAcceleratorComponent & operator=(const BDSAcceleratorComponent &)=delete
Assignment and copy constructor not implemented nor used.
G4ThreeVector inputFaceNormal
Input face unit normal vector in incoming reference coordinate frame.
const G4double arcLength
Const protected member variable that may not be changed by derived classes.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
BDSSimpleComponent * EndPieceBefore() const
virtual G4bool HasAField() const
Whether this component has a field or not (ie is active). Implicit cast of pointer to bool.
BDSAcceleratorComponent(BDSAcceleratorComponent &)=delete
Assignment and copy constructor not implemented nor used.
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4Material * emptyMaterial
Useful variable often used in construction.
static G4bool sensitiveOuter
Useful variable often used in construction.
virtual void SetOutputFaceNormal(const G4ThreeVector &output)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
static G4double lengthSafety
Useful variable often used in construction.
G4int copyNumber
Record of how many times this component has been copied.
virtual void SetMinimumKineticEnergy(G4double)
virtual G4double GetChordLength() const
static G4bool checkOverlaps
Useful variable often used in construction.
const G4String type
Const protected member variable that may not be changed by derived classes.
G4ThreeVector OutputFaceNormal() const
G4int GetCopyNumber() const
Get the number of times this component has been copied.
G4double angle
Protected member variable that can be modified by derived classes.
virtual G4double GetArcLength() const
std::list< std::string > biasMaterialLVList
Copy of bias list from parser for this particular component.
virtual std::set< G4LogicalVolume * > GetAcceleratorVacuumLogicalVolumes() const
Access the 'vacuum' volume(s) in this component if any. Default is empty set.
G4ThreeVector InputFaceNormal() const
virtual std::set< G4LogicalVolume * > GetAcceleratorMaterialLogicalVolumes() const
Return a set of logical volumes excluding the ones in the 'vacuum' set.
static G4Material * worldMaterial
Useful variable often used in construction.
BDSAcceleratorComponent()=delete
BDSBeamPipeInfo * GetBeamPipeInfo() const
std::list< std::string > GetBiasVacuumList() const
Access the bias list copied from parser.
virtual void SetInputFaceNormal(const G4ThreeVector &input)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
virtual void BuildContainerLogicalVolume()=0
G4String region
Protected member variable that can be modified by derived classes.
virtual void SetBiasVacuumList(const std::list< std::string > &biasVacuumListIn)
Copy the bias list to this element.
void SetField(BDSFieldInfo *fieldInfoIn)
Set the field definition for the whole component.
virtual void AttachUserLimits() const
Doesn't change member variables, but may change their contents.
void IncrementCopyNumber()
Increment (+1) the number of times this component has been copied.
virtual void SetBiasMaterialList(const std::list< std::string > &biasMaterialListIn)
Copy the bias list to this element.
G4double chordLength
Protected member variable that can be modified by derived classes.
G4bool AngledOutputFace() const
Whether the face normal is angled at all w.r.t. the incoming / outgoing reference trajectory.
G4String GetType() const
Get a string describing the type of the component.
std::list< std::string > GetBiasMaterialList() const
Access the bias list copied from parser.
std::set< G4LogicalVolume * > acceleratorVacuumLV
A set of logical volumes we classify as 'vacuum' for biasing purposes.
std::list< std::string > biasMaterialList
Copy of bias list from parser for this particular component.
virtual void SetRegion(const G4String &regionIn)
Set the region name for this component.
static G4VisAttributes * containerVisAttr
Useful variable often used in construction.
static G4bool sensitiveVacuum
Useful variable often used in construction.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
virtual void SetFieldUsePlacementWorldTransform()
Holder class for all information required to describe a beam pipe model.
All info required to build complete field of any type.
A generic geometry component for a bdsim model.
A BDSAcceleratorComponent wrapper for BDSGeometryComponent.