19#include "BDSAcceleratorModel.hh"
21#include "BDSExtent.hh"
22#include "BDSElement.hh"
23#include "BDSException.hh"
24#include "BDSGeometryExternal.hh"
25#include "BDSGeometryFactory.hh"
26#include "BDSSDType.hh"
37BDSElement::BDSElement(
const G4String& nameIn,
39 G4double horizontalWidthIn,
40 const G4String& geometryIn,
42 std::vector<G4String>* namedVacuumVolumesIn,
43 G4bool autoColourGeometryIn,
44 G4bool markAsCollimatorIn,
45 G4bool stripOuterVolumeIn):
47 horizontalWidth(horizontalWidthIn),
48 geometryFileName(geometryIn),
49 autoColourGeometry(autoColourGeometryIn),
50 markAsCollimator(markAsCollimatorIn),
51 stripOuterVolume(stripOuterVolumeIn),
54 if (namedVacuumVolumesIn)
55 {namedVacuumVolumes = *namedVacuumVolumesIn;}
70 BDSSDType sensitivityToAttach = markAsCollimator ? BDSSDType::collimatorcomplete : BDSSDType::energydep;
84 BDSSDType::energydepvacuum,
89 {
throw BDSException(__METHOD_NAME__,
"Error loading geometry in component \"" +
name +
"\"");}
103 if (markAsCollimator)
105 auto collimatorVolumeSet = BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators");
107 {collimatorVolumeSet->insert(vol);}
124 G4double tolerance = 1*CLHEP::micrometer;
127 auto flagsCache(G4cerr.flags());
128 G4cerr << std::setprecision(15);
129 G4cerr.setf( std::ios::fixed, std:: ios::floatfield );
130 G4cerr <<
"BDSElement> The loaded geometry is larger than the specified length"
131 <<
" of the element, which will cause overlaps!" << G4endl
132 <<
"Calculated extent along z of geometry: " << extLength <<
" mm" << G4endl;
133 G4cerr <<
"Arc length " <<
arcLength <<
" mm" << G4endl;
134 G4cerr <<
"Bending angle " <<
angle <<
" rad" << G4endl;
135 G4cerr <<
"Chord length " <<
chordLength <<
" mm" << G4endl;
136 G4cerr <<
"Chord length must be >= geometry length" << G4endl;
137 G4cerr <<
"Possible overlaps in element \"" <<
name <<
"\"" << G4endl << G4endl << G4endl;
141 G4cerr.flags(flagsCache);
Abstract class that represents a component of an accelerator.
G4UserLimits * userLimits
Cache of user limits.
const G4double arcLength
Const protected member variable that may not be changed by derived classes.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
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.
virtual void BuildUserLimits()
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.
std::set< G4LogicalVolume * > * VolumeSet(const G4String &name)
Returns pointer to a set of logical volumes. If no set by that name exits, create it.
virtual std::set< BDSGeometryComponent * > GetAllDaughters() const
Overloads of functions in BDSGeometryComponent.
virtual std::set< G4VSolid * > GetAllSolids() const
Overloads of functions in BDSGeometryComponent.
virtual void ExcludeLogicalVolumeFromBiasing(G4LogicalVolume *lv)
Overloads of functions in BDSGeometryComponent.
BDSGeometryExternal * geometry
Cache of the constructed geometry. Used to forward onto various BDSGeometryComponent functions.
virtual std::set< G4LogicalVolume * > GetAllBiasingVolumes() const
Overloads of functions in BDSGeometryComponent.
virtual void BuildContainerLogicalVolume()
This does the full construction. Loads the external geometry and field if there is one.
virtual std::set< G4UserLimits * > GetAllUserLimits() const
Overloads of functions in BDSGeometryComponent.
virtual void AttachSensitiveDetectors()
Overloads of functions in BDSGeometryComponent.
virtual std::map< G4LogicalVolume *, BDSSDType > GetAllSensitiveVolumes() const
Overloads of functions in BDSGeometryComponent.
virtual std::set< G4LogicalVolume * > GetAllLogicalVolumes() const
Overloads of functions in BDSGeometryComponent.
virtual std::set< G4VisAttributes * > GetAllVisAttributes() const
Overloads of functions in BDSGeometryComponent.
virtual std::set< G4RotationMatrix * > GetAllRotationMatrices() const
Overloads of functions in BDSGeometryComponent.
virtual std::set< G4VPhysicalVolume * > GetAllPhysicalVolumes() const
Overloads of functions in BDSGeometryComponent.
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
G4bool TransverselyGreaterThan(const BDSExtent &r) const
Comparison operator for x,y only. Ignores z (length).
G4double DZ() const
The difference in a dimension.
virtual std::set< BDSGeometryComponent * > GetAllDaughters() const
Accessor - see member for more info.
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
G4bool ContainerIsAssembly() const
Whether the container is an assembly. If not, it's a logical volume.
void InheritExtents(BDSGeometryComponent const *const anotherComponent)
Update the extents of this object with those of another object.
BDSExtent GetExtent() const
Accessor - see member for more info.
void SetPlacementOffset(const G4ThreeVector &offsetIn)
Set the offset from 0,0,0 that the object should ideally be placed in its parent.
G4AssemblyVolume * GetContainerAssemblyVolume() const
Accessor - see member for more info.
virtual std::set< G4RotationMatrix * > GetAllRotationMatrices() const
Accessor - see member for more info.
virtual void AttachSensitiveDetectors()
Attach a sensitive detector class to all registered sensitive volumes in this component.
virtual std::set< G4LogicalVolume * > GetAllBiasingVolumes() const
Return all logical volumes that should be used for biasing minus any that are in the excluded set.
virtual std::set< G4UserLimits * > GetAllUserLimits() const
Accessor - see member for more info.
virtual std::map< G4LogicalVolume *, BDSSDType > GetAllSensitiveVolumes() const
Access all sensitive volumes belonging to this component.
virtual std::set< G4LogicalVolume * > GetAllLogicalVolumes() const
Access all logical volumes belonging to this component.
virtual std::set< G4VisAttributes * > GetAllVisAttributes() const
Accessor - see member for more info.
virtual std::set< G4VSolid * > GetAllSolids() const
Accessor - see member for more info.
G4VSolid * GetContainerSolid() const
Accessor - see member for more info.
G4ThreeVector GetPlacementOffset() const
Accessor - see member for more info.
virtual void ExcludeLogicalVolumeFromBiasing(G4LogicalVolume *lv)
virtual std::set< G4VPhysicalVolume * > GetAllPhysicalVolumes() const
Accessor - see member for more info.
void SetExtent(const BDSExtent &extIn)
Set extent.
G4bool containerIsAssembly
True if the 'container' is really an assembly; false if an LV.
const std::set< G4LogicalVolume * > & VacuumVolumes() const
Access the vacuum volumes.
BDSGeometryExternal * BuildGeometry(G4String componentName, const G4String &formatAndFilePath, std::map< G4String, G4Colour * > *colourMapping=nullptr, G4bool autoColour=true, G4double suggestedLength=0, G4double suggestedHorizontalWidth=0, std::vector< G4String > *namedVacuumVolumes=nullptr, G4bool makeSensitive=true, BDSSDType sensitivityType=BDSSDType::energydep, BDSSDType vacuumSensitivityType=BDSSDType::energydepvacuum, G4bool stripOuterVolumeAndMakeAssembly=false, G4UserLimits *userLimitsToAttachToAllLVs=nullptr, G4bool dontReloadGeometry=false)
static BDSGeometryFactory * Instance()
Singleton accessor.
Improve type-safety of native enum data type in C++.