19#include "BDSAcceleratorComponentRegistry.hh"
20#include "BDSColours.hh"
22#include "BDSException.hh"
23#include "BDSExtent.hh"
24#include "BDSGeometryComponent.hh"
25#include "BDSGlobalConstants.hh"
26#include "BDSMaterials.hh"
27#include "BDSSDType.hh"
28#include "BDSTunnelInfo.hh"
29#include "BDSTunnelFactoryBase.hh"
30#include "BDSTunnelSection.hh"
31#include "BDSUtilities.hh"
34#include "G4LogicalVolume.hh"
35#include "G4Material.hh"
36#include "G4PVPlacement.hh"
37#include "G4ThreeVector.hh"
38#include "G4VisAttributes.hh"
39#include "G4UserLimits.hh"
44 tunnelComponent(nullptr),
45 tunnelSection(nullptr),
46 containerSolid(nullptr),
50 intersectionSolid(nullptr),
55 floorDisplacement(G4ThreeVector(0,0,0)),
64 G4double tunnelThickness,
65 G4double tunnelSoilThickness,
66 G4Material* tunnelMaterial,
67 G4Material* tunnelSoilMaterial,
69 G4double tunnelFloorOffset,
75 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
76 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
82 G4double tunnelThickness,
83 G4double tunnelSoilThickness,
84 G4Material* tunnelMaterial,
85 G4Material* tunnelSoilMaterial,
87 G4double tunnelFloorOffset,
93 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
94 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
101 G4double tunnelThickness,
102 G4double tunnelSoilThickness,
103 G4Material* tunnelMaterial,
104 G4Material* tunnelSoilMaterial,
106 G4double tunnelFloorOffset,
113 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
114 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
118 G4double& tunnelThickness,
119 G4double& tunnelSoilThickness,
120 G4Material*& tunnelMaterial,
121 G4Material*& tunnelSoilMaterial)
124 {
throw BDSException(__METHOD_NAME__,
"tunnel section too short - length < 4*length safety");}
126 {
throw BDSException(__METHOD_NAME__,
"tunnel section thickness too thin - thickness < 2*length safety");}
128 {
throw BDSException(__METHOD_NAME__,
"tunnel section soil thickness too thin - thickness < 2*length safety");}
130 {tunnelMaterial = defaultModel->material;}
132 if (!tunnelSoilMaterial)
133 {tunnelSoilMaterial = defaultModel->soilMaterial;}
136void BDSTunnelFactoryBase::CommonConstruction(G4String name,
137 G4Material* tunnelMaterial,
138 G4Material* tunnelSoilMaterial,
140 G4double containerXRadius,
141 G4double containerYRadius,
155 G4Material* tunnelMaterial,
156 G4Material* tunnelSoilMaterial)
160 containerLV =
new G4LogicalVolume(containerSolid,
162 name +
"_container_lv");
164 tunnelLV =
new G4LogicalVolume(tunnelSolid,
166 name +
"_tunnel_lv");
170 soilLV =
new G4LogicalVolume(soilSolid,
177 floorLV =
new G4LogicalVolume(floorSolid,
190 G4VisAttributes* tunnelVisAttr =
new G4VisAttributes(*
BDSColours::Instance()->GetColour(
"tunnel"));
192 {tunnelVisAttr->SetVisibility(
true);}
194 tunnelLV->SetVisAttributes(tunnelVisAttr);
195 allVisAttributes.insert(tunnelVisAttr);
198 G4VisAttributes* floorVisAttr =
new G4VisAttributes(*
BDSColours::Instance()->GetColour(
"tunnelfloor"));
200 {floorVisAttr->SetVisibility(
true);}
202 floorLV->SetVisAttributes(floorVisAttr);
203 allVisAttributes.insert(floorVisAttr);
210 {soilVisAttr->SetVisibility(
true);}
212 soilLV->SetVisAttributes(soilVisAttr);
213 allVisAttributes.insert(soilVisAttr);
220 G4double containerYRadius,
221 G4double containerZRadius)
240 tunnelComponent->
SetExtent(
BDSExtent(containerXRadius, containerYRadius, containerZRadius));
244 G4double chordLength)
274 tunnelLV->SetUserLimits(tunnelUserLimits);
276 {soilLV->SetUserLimits(tunnelUserLimits);}
278 {floorLV->SetUserLimits(tunnelUserLimits);}
279 containerLV->SetUserLimits(tunnelUserLimits);
287 new G4PVPlacement(
nullptr,
297 new G4PVPlacement(
nullptr,
308 new G4PVPlacement(
nullptr,
322 tunnelSection =
nullptr;
323 containerSolid =
nullptr;
324 tunnelSolid =
nullptr;
326 floorSolid =
nullptr;
327 intersectionSolid =
nullptr;
328 containerLV =
nullptr;
332 floorDisplacement = G4ThreeVector(0,0,0);
static BDSAcceleratorComponentRegistry * Instance()
Singleton accessor.
void RegisterTunnelComponent(BDSAcceleratorComponent *component)
static BDSColours * Instance()
singleton pattern
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
G4bool checkOverlaps
Cache of global constants variable.
G4double lengthSafety
Cache of global constants variable.
virtual void FactoryBaseCleanUp()
Empty containers for next use - factories are never deleted so can't rely on scope.
A generic geometry component for a bdsim model.
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void SetExtent(const BDSExtent &extIn)
Set extent.
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
void RegisterSensitiveVolume(G4LogicalVolume *sensitiveVolume, BDSSDType sensitivityType)
static BDSGlobalConstants * Instance()
Access method.
static BDSMaterials * Instance()
Singleton pattern access.
G4Material * GetMaterial(G4String material) const
Get material by name.
BDSTunnelFactoryBase()
protected default constructor so only derived classes can use it
virtual BDSTunnelSection * CreateTunnelSectionAngledInOut(G4String name, G4double length, G4double angleIn, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual void PrepareGeometryComponent(G4double containerXRadius, G4double containerYRadius, G4double containerZRadius)
Prepare the assembled geometry component.
virtual void SetSensitiveVolumes()
Set the sensitive volumes.
void CommontTestInputParameters(G4double &length, G4double &tunnelThickness, G4double &tunnelSoilThickness, G4Material *&tunnelMaterial, G4Material *&tunnelSoilMaterial)
virtual void SetUserLimits()
Set user limits for all logical volumes in the tunnel section.
virtual BDSTunnelSection * CreateTunnelSectionAngled(G4String name, G4double length, G4ThreeVector inputFaceIn, G4ThreeVector outputFaceIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)=0
Create a tunnel section with an angled input and output face. Pure virtual.
virtual BDSTunnelSection * CreateTunnelSectionAngledIn(G4String name, G4double length, G4double angleIn, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual void SetVisAttributes(G4bool visible)
Set the visual attributes for each logical volume.
virtual BDSTunnelSection * CreateTunnelSectionAngledOut(G4String name, G4double length, G4double angleOut, G4double tunnelThickness, G4double tunnelSoilThickness, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial, G4bool tunnelFloor, G4double tunnelFloorOffset, G4double tunnel1, G4double tunnel2, G4bool visible)
virtual void PlaceComponents(G4String name)
Place components in container volume.
virtual void PrepareTunnelSection(G4String name, G4double chordLength)
Prepare the output BDSTunnelSection instance.
virtual void BuildLogicalVolumes(G4String name, G4Material *tunnelMaterial, G4Material *tunnelSoilMaterial)
Build logical volumes from solids + materials.
Class that represents a section of tunnel.
std::pair< G4ThreeVector, G4ThreeVector > CalculateFaces(G4double angleInIn, G4double angleOutIn)
Calculate input and output normal vector.