18#include "BDSAcceleratorComponentRegistry.hh"
19#include "BDSColours.hh"
21#include "BDSException.hh"
22#include "BDSExtent.hh"
23#include "BDSGeometryComponent.hh"
24#include "BDSGlobalConstants.hh"
25#include "BDSMaterials.hh"
26#include "BDSSDType.hh"
27#include "BDSTunnelInfo.hh"
28#include "BDSTunnelFactoryBase.hh"
29#include "BDSTunnelSection.hh"
30#include "BDSUtilities.hh"
33#include "G4LogicalVolume.hh"
34#include "G4Material.hh"
35#include "G4PVPlacement.hh"
36#include "G4ThreeVector.hh"
37#include "G4VisAttributes.hh"
38#include "G4UserLimits.hh"
43 tunnelComponent(nullptr),
44 tunnelSection(nullptr),
45 containerSolid(nullptr),
49 intersectionSolid(nullptr),
54 floorDisplacement(G4ThreeVector(0,0,0)),
63 G4double tunnelThickness,
64 G4double tunnelSoilThickness,
65 G4Material* tunnelMaterial,
66 G4Material* tunnelSoilMaterial,
68 G4double tunnelFloorOffset,
74 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
75 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
81 G4double tunnelThickness,
82 G4double tunnelSoilThickness,
83 G4Material* tunnelMaterial,
84 G4Material* tunnelSoilMaterial,
86 G4double tunnelFloorOffset,
92 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
93 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
100 G4double tunnelThickness,
101 G4double tunnelSoilThickness,
102 G4Material* tunnelMaterial,
103 G4Material* tunnelSoilMaterial,
105 G4double tunnelFloorOffset,
112 tunnelSoilThickness, tunnelMaterial, tunnelSoilMaterial,
113 tunnelFloor, tunnelFloorOffset, tunnel1, tunnel2, visible);
117 G4double& tunnelThickness,
118 G4double& tunnelSoilThickness,
119 G4Material*& tunnelMaterial,
120 G4Material*& tunnelSoilMaterial)
123 {
throw BDSException(__METHOD_NAME__,
"tunnel section too short - length < 4*length safety");}
125 {
throw BDSException(__METHOD_NAME__,
"tunnel section thickness too thin - thickness < 2*length safety");}
127 {
throw BDSException(__METHOD_NAME__,
"tunnel section soil thickness too thin - thickness < 2*length safety");}
129 {tunnelMaterial = defaultModel->material;}
131 if (!tunnelSoilMaterial)
132 {tunnelSoilMaterial = defaultModel->soilMaterial;}
135void BDSTunnelFactoryBase::CommonConstruction(G4String name,
136 G4Material* tunnelMaterial,
137 G4Material* tunnelSoilMaterial,
139 G4double containerXRadius,
140 G4double containerYRadius,
154 G4Material* tunnelMaterial,
155 G4Material* tunnelSoilMaterial)
159 containerLV =
new G4LogicalVolume(containerSolid,
161 name +
"_container_lv");
163 tunnelLV =
new G4LogicalVolume(tunnelSolid,
165 name +
"_tunnel_lv");
169 soilLV =
new G4LogicalVolume(soilSolid,
176 floorLV =
new G4LogicalVolume(floorSolid,
189 G4VisAttributes* tunnelVisAttr =
new G4VisAttributes(*
BDSColours::Instance()->GetColour(
"tunnel"));
191 {tunnelVisAttr->SetVisibility(
true);}
193 tunnelLV->SetVisAttributes(tunnelVisAttr);
194 allVisAttributes.insert(tunnelVisAttr);
197 G4VisAttributes* floorVisAttr =
new G4VisAttributes(*
BDSColours::Instance()->GetColour(
"tunnelfloor"));
199 {floorVisAttr->SetVisibility(
true);}
201 floorLV->SetVisAttributes(floorVisAttr);
202 allVisAttributes.insert(floorVisAttr);
209 {soilVisAttr->SetVisibility(
true);}
211 soilLV->SetVisAttributes(soilVisAttr);
212 allVisAttributes.insert(soilVisAttr);
219 G4double containerYRadius,
220 G4double containerZRadius)
239 tunnelComponent->
SetExtent(
BDSExtent(containerXRadius, containerYRadius, containerZRadius));
243 G4double chordLength)
273 tunnelLV->SetUserLimits(tunnelUserLimits);
275 {soilLV->SetUserLimits(tunnelUserLimits);}
277 {floorLV->SetUserLimits(tunnelUserLimits);}
278 containerLV->SetUserLimits(tunnelUserLimits);
286 new G4PVPlacement(
nullptr,
296 new G4PVPlacement(
nullptr,
307 new G4PVPlacement(
nullptr,
321 tunnelSection =
nullptr;
322 containerSolid =
nullptr;
323 tunnelSolid =
nullptr;
325 floorSolid =
nullptr;
326 intersectionSolid =
nullptr;
327 containerLV =
nullptr;
331 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.