19#include "BDSAcceleratorComponent.hh"
20#include "BDSBeamPipeInfo.hh"
22#include "BDSException.hh"
23#include "BDSFieldBuilder.hh"
24#include "BDSFieldInfo.hh"
25#include "BDSGlobalConstants.hh"
26#include "BDSMaterials.hh"
27#include "BDSTunnelInfo.hh"
28#include "BDSUtilities.hh"
30#include "G4AssemblyVolume.hh"
31#include "G4LogicalVolume.hh"
32#include "G4Material.hh"
33#include "G4ThreeVector.hh"
34#include "G4UserLimits.hh"
52 const G4String& typeIn,
54 const G4ThreeVector& inputFaceNormalIn,
55 const G4ThreeVector& outputFaceNormalIn,
59 arcLength(arcLengthIn),
62 beamPipeInfo(beamPipeInfoIn),
63 endPieceBefore(nullptr),
64 endPieceAfter(nullptr),
66 fieldInfo(fieldInfoIn),
68 inputFaceNormal(inputFaceNormalIn),
69 outputFaceNormal(outputFaceNormalIn)
72 G4cout << __METHOD_NAME__ <<
"(" <<
name <<
")" << G4endl;
91 G4String message =
"Negative length for component named \"" +
name +
"\" with length " + std::to_string(
arcLength);
97 {
chordLength = 2.0 * arcLengthIn * std::sin(0.5*angleIn) / angleIn;}
101 G4cout << __METHOD_NAME__ <<
"angle: " << angleIn << G4endl;
102 G4cout << __METHOD_NAME__ <<
"arc length: " << arcLengthIn << G4endl;
103 G4cout << __METHOD_NAME__ <<
"chord length: " <<
chordLength << G4endl;
109BDSAcceleratorComponent::~BDSAcceleratorComponent()
121 G4cout << __METHOD_NAME__ << G4endl;
130 containerLogicalVolume,
141 if (containerLogicalVolume)
155 G4double sagitta = bendingRadius - std::sqrt(std::pow(bendingRadius,2) - std::pow(
chordLength, 2));
161 G4ThreeVector zeroAngle = G4ThreeVector(0,0,-1);
163 G4double det = cross.mag2();
169 G4ThreeVector zeroAngle = G4ThreeVector(0,0,1);
171 G4double det = cross.mag2();
190 if (containerLogicalVolume || containerAssembly)
194 else if (containerLogicalVolume)
195 {containerLogicalVolume->SetUserLimits(
userLimits);}
212 {
fieldInfo->SetUsePlacementWorldTransform(
true);}
virtual void Initialise()
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.
G4double Sagitta() const
Calculate the sagitta - ie the distance between the chord and the arc at the centre.
G4ThreeVector outputFaceNormal
Output face unit normal vector in outgoing reference coordinate frame.
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.
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.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
G4double angle
Protected member variable that can be modified by derived classes.
virtual std::set< G4LogicalVolume * > GetAcceleratorMaterialLogicalVolumes() const
Return a set of logical volumes excluding the ones in the 'vacuum' set.
static G4double lengthSafetyLarge
static G4Material * worldMaterial
Useful variable often used in construction.
BDSAcceleratorComponent()=delete
virtual void BuildContainerLogicalVolume()=0
virtual void BuildUserLimits()
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.
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.
std::set< G4LogicalVolume * > acceleratorVacuumLV
A set of logical volumes we classify as 'vacuum' for biasing purposes.
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.
General exception with possible name of object and message.
void RegisterFieldForConstruction(const BDSFieldInfo *info, G4LogicalVolume *logicalVolume, const G4bool propagateToDaughters=false, const BDSMagnetStrength *magnetStrengthForScaling=nullptr, const G4String &scalingKey="none")
static BDSFieldBuilder * Instance()
Singleton pattern accessor.
All info required to build complete field of any type.
A generic geometry component for a bdsim model.
virtual std::set< G4LogicalVolume * > GetAllBiasingVolumes() const
Return all logical volumes that should be used for biasing minus any that are in the excluded set.
static void AttachUserLimitsToAssembly(G4AssemblyVolume *av, G4UserLimits *ul)
Utility function to apply user limits to an assembly volume as there's not interface.
void RegisterUserLimits(G4UserLimits *userLimit)
G4bool containerIsAssembly
True if the 'container' is really an assembly; false if an LV.
static BDSGlobalConstants * Instance()
Access method.
static BDSMaterials * Instance()
Singleton pattern access.
G4Material * GetMaterial(G4String material) const
Get material by name.
G4UserLimits * CreateUserLimits(G4UserLimits *defaultUL, G4double length, G4double fraction=1.6)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())