20#include "BDSBLMFactory.hh"
21#include "BDSBLMType.hh"
23#include "BDSException.hh"
24#include "BDSExtent.hh"
25#include "BDSGeometryExternal.hh"
26#include "BDSGeometryFactory.hh"
27#include "BDSMaterials.hh"
28#include "BDSUtilities.hh"
30#include "parser/blmplacement.h"
34#include "G4LogicalVolume.hh"
40BDSBLMFactory::BDSBLMFactory()
43BDSBLMFactory::~BDSBLMFactory()
46void BDSBLMFactory::PositiveFinite(G4double value,
47 const G4String& parameterName,
48 const G4String& blmName)
const
51 {
throw BDSException(__METHOD_NAME__,
"\"" + parameterName +
"\" must be +ve finite for blm named \"" + blmName +
"\"");}
55 G4VSensitiveDetector* sd)
57 return CreateBLM(G4String(bp.
name),
58 G4String(bp.geometryFile),
59 G4String(bp.geometryType),
60 G4String(bp.blmMaterial),
69BDSBLM* BDSBLMFactory::CreateBLM(
const G4String& name,
70 const G4String& geometryFile,
71 const G4String& geometryType,
72 const G4String& material,
77 G4VSensitiveDetector* sd,
82 if (!geometryFile.empty())
85 result =
new BDSBLM(blmGeom);
92 case BDSBLMType::cylinder:
94 case BDSBLMType::cube:
95 {result =
BuildBLMCube(name, material, blm1, blm2, blm3);
break;}
96 case BDSBLMType::sphere:
107 {lv->SetSensitiveDetector(sd);}
116 const G4String& material,
120 PositiveFinite(halfLength,
"blm1 (half length)", name);
121 PositiveFinite(radius,
"blm2 (radius)", name);
122 G4Tubs* shape =
new G4Tubs(name +
"_solid",
133 const G4String& material,
134 G4double halfLengthX,
135 G4double halfLengthY,
136 G4double halfLengthZ)
138 PositiveFinite(halfLengthX,
"blm1 (half length in x)", name);
139 PositiveFinite(halfLengthY,
"blm2 (half length in y)", name);
140 PositiveFinite(halfLengthZ,
"blm3 (half length in z)", name);
141 G4Box* shape =
new G4Box(name +
"_solid", halfLengthX, halfLengthY, halfLengthZ);
147 const G4String& material,
150 PositiveFinite(radius,
"blm1 (radius)", name);
151 G4Orb* shape =
new G4Orb(name +
"_solid", radius);
157 const G4String& material,
162 G4LogicalVolume* lv =
new G4LogicalVolume(shape, mat, name +
"_lv");
BDSBLM * BuildBLMCylinder(const G4String &name, const G4String &material, G4double halfLength, G4double radius)
Build the geometry for a cylinder.
BDSBLM * BuildBLMCube(const G4String &name, const G4String &material, G4double halfLengthX, G4double halfLengthY, G4double halfLengthZ)
Build the geometry for a cube.
BDSBLM * CommonConstruction(const G4String &name, const G4String &material, G4VSolid *shape, const BDSExtent &extent)
BDSBLM * BuildBLMSphere(const G4String &name, const G4String &material, G4double radius)
Build the geometry for a sphere.
void SetBias(const G4String &biasIn)
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
virtual std::set< G4LogicalVolume * > GetAllLogicalVolumes() const
Access all logical volumes belonging to this component.
A loaded piece of externally provided geometry.
static BDSGeometryFactory * Instance()
Singleton accessor.
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, G4bool stripOuterVolumeAndMakeAssembly=false, G4UserLimits *userLimitsToAttachToAllLVs=nullptr, G4bool dontReloadGeometry=false)
static BDSMaterials * Instance()
Singleton pattern access.
G4Material * GetMaterial(G4String material) const
Get material by name.
Improve type-safety of native enum data type in C++.
type underlying() const
return underlying value (can be used in switch statement)
std::string name
Name of this samplerplacement.
BDSBLMType DetermineBLMType(G4String blmType)
function that gives corresponding enum value for string (case-insensitive)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())