DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Functions
Volume/Structure Builder Factories

Functions

BoxBuilderPtr CreateBoxBuilder (const G4String &name)
 
BoxBuilderPtr CreateBoxBuilder (const G4String &name, G4double unit)
 
BoxBuilderPtr CreateCenteredBoxBuilder (const G4String &name, G4double x_full_size, G4double y_full_size, G4double z_full_size)
 
BoxBuilderPtr CreateCenteredBoxBuilder (G4double unit, const G4String &name, G4double x_full_size, G4double y_full_size, G4double z_full_size)
 
BoxBuilderPtr CreateZDeltaBoxBuilder (const G4String &name, G4double x_full_size, G4double y_full_size, G4double edge_z, G4double z_delta)
 
BoxBuilderPtr CreateZDeltaBoxBuilder (G4double unit, const G4String &name, G4double x_full_size, G4double y_full_size, G4double edge_z, G4double z_delta)
 
BoxBuilderPtr CreateDeltasBoxBuilder (const G4String &name, G4double edge_x, G4double x_delta, G4double edge_y, G4double y_delta, G4double edge_z, G4double z_delta)
 
BoxBuilderPtr CreateDeltasBoxBuilder (G4double unit, const G4String &name, G4double edge_x, G4double x_delta, G4double edge_y, G4double y_delta, G4double edge_z, G4double z_delta)
 
BoxBuilderPtr CreateEdgesBoxBuilder (const G4String &name, G4double x_edge1, G4double x_edge2, G4double y_edge1, G4double y_edge2, G4double z_edge1, G4double z_edge2)
 
BoxBuilderPtr CreateEdgesBoxBuilder (G4double unit, const G4String &name, G4double x_edge1, G4double x_edge2, G4double y_edge1, G4double y_edge2, G4double z_edge1, G4double z_edge2)
 
AssemblyPtr CreateAssembly (G4String name)
 
FromG4VSolidPtr CreateFromG4VSolid (G4VSolid *solid)
 
RZBuilderPtr CreatePolyhedraBuilder (const G4String &name, int sides, G4double phi_start=0., G4double phi_tot=360)
 
RZBuilderPtr CreatePolyconeBuilder (const G4String &name, G4double phi_start=0., G4double phi_tot=360)
 
RZBuilderPtr CreateCylinderBuilder (G4double unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
 
RZBuilderPtr CreateCylinderBuilder (const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
 

Detailed Description

Factories for creating VolumeBuilder and StructureBuilder objects.

Factories for creating VolumeBuilder and StructureBuilder objects.

Function Documentation

◆ CreateAssembly()

AssemblyPtr CreateAssembly ( G4String  name)

Assembly of strucures, ie builders and/or other assemblies.

Definition at line 18 of file Assembly.cc.

18 {
19 // Haha... assemblies actually are builders!!!
20 auto object = AssemblyPtr(new Assembly());
21 // ... with is_builder set to false.
22 object->placement_configs_->is_builder = false;
23 //We're storing a pointer to the view in the builder by writing to the builder through that same view!
24 BuilderView builder_view = object->ToBuilderView();
25 builder_view->StoreBuilderView(builder_view);
26 // Then store itself in its new builder (that links to its data).
27 //object->builder_configs_->builder_view->StoreIStructurePtr(IStructurePtr(object.get())); // this is the owning copy.
28 // ... and viewed through a reduced StructureView interface:
29 object->SetName(name);
30 auto return_obj = AssemblyPtr(object);
31 return return_obj;
32
33 // This let's us reuse builder methods!
34 }
A type-erased (data shared view) view of a builder or assembly, ie a "structure.".
Definition Assembly.hh:38

◆ CreateBoxBuilder() [1/2]

BoxBuilderPtr CreateBoxBuilder ( const G4String &  name)

Create an unconfigured Box Solid, for use with SetXEdges() etc... Uses the global default unit unless you call SetDefaultUnit() before setting sizes.

Parameters
nameBase name to derive geometry object names from.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 33 of file BoxBuilder.cc.

33 {
34 auto object = BoxBuilderPtr(new BoxBuilder(name));
35 return object;
36 }
Builder class for simple Box solids.

◆ CreateBoxBuilder() [2/2]

BoxBuilderPtr CreateBoxBuilder ( const G4String &  name,
G4double  unit 
)

Create an unconfigured Box Solid, for use with SetXEdges() etc...

Parameters
nameBase name to derive geometry object names from.
unitunit for this call only (ex: CLHEP::mm)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 38 of file BoxBuilder.cc.

38 {
39 auto object = BoxBuilderPtr(new BoxBuilder(name));
40 object->SetDefaultUnit(unit);
41 return object;
42 }

◆ CreateCenteredBoxBuilder() [1/2]

BoxBuilderPtr CreateCenteredBoxBuilder ( const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  z_full_size 
)

Create a Box solid.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
z_full_sizeFULL Z size
name
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 111 of file BoxBuilder.cc.

113 {
114 if (x_full_size <= 0 || y_full_size <= 0 || z_full_size <= 0) {
115 throw std::invalid_argument("Error in CreateCenteredBoxBuilder(): for volume " + name
116 + ": Sizes provided must be positive.\n");
117 }
118 auto object = BoxBuilderPtr(new BoxBuilder(name));
119 object->SetXSize(x_full_size)
120 ->SetYSize(y_full_size)
121 ->SetZSize(z_full_size);
122 return object;
123 }

◆ CreateCenteredBoxBuilder() [2/2]

BoxBuilderPtr CreateCenteredBoxBuilder ( G4double  unit,
const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  z_full_size 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
z_full_sizeFULL Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 97 of file BoxBuilder.cc.

99 {
100 if (x_full_size <= 0 || y_full_size <= 0 || z_full_size <= 0) {
101 throw std::invalid_argument("Error in CreateCenteredBoxBuilder(): for volume " + name
102 + ": Sizes provided must be positive.\n");
103 }
104 auto object = BoxBuilderPtr(new BoxBuilder(name));
105 object->SetXSize(unit, x_full_size)
106 ->SetYSize(unit, y_full_size)
107 ->SetZSize(unit, z_full_size);
108 return object;
109 }

◆ CreateCylinderBuilder() [1/2]

RZBuilderPtr CreateCylinderBuilder ( const G4String &  name,
G4double  endz,
G4double  height,
G4double  OR,
G4double  IR = 0 
)

Create a simple cylinder builder using global default unit.

Parameters
nameName used to derive all product names.
endzThe z reference of one end (either one)
heightHeight, can be positive or negative (from z reference)
OROuter radius.
IROptional inner radius. Default=0
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 62 of file RZBuilder.cc.

63 {
65 }
RZBuilderPtr CreateCylinderBuilder(G4double unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR=0)
Create a simple cylinder builder.
Definition RZBuilder.cc:46

◆ CreateCylinderBuilder() [2/2]

RZBuilderPtr CreateCylinderBuilder ( G4double  unit,
const G4String &  name,
G4double  endz,
G4double  height,
G4double  OR,
G4double  IR = 0 
)

Create a simple cylinder builder.

Parameters
nameName used to derive all product names.
unitUnit applied to all values.
endzThe z reference of one end (either one)
heightHeight, can be positive or negative (from z reference)
OROuter radius.
IROptional inner radius. Default=0
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 46 of file RZBuilder.cc.

47 {
48 // ReSharper disable once CppDFAMemoryLeak
49 auto object = RZBuilderPtr(new RZBuilder(name));
50 object->MakeSolidFunctionPtr_ = &RZBuilder::MakePolycone;
51 RZPlane plane;
52 plane.unit = unit;
53 plane.z = endz;
54 plane.IR = IR;
55 plane.OR = OR;
56 object->AddPlane(plane);
57 plane.z += h;
58 object->AddPlane(plane);
59 return RZBuilderPtr(object);
60 }
Builder class for RZ mult-plane defined solids.
Definition RZBuilder.hh:131
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.
Definition RZBuilder.hh:44

◆ CreateDeltasBoxBuilder() [1/2]

BoxBuilderPtr CreateDeltasBoxBuilder ( const G4String &  name,
G4double  edge_x,
G4double  x_delta,
G4double  edge_y,
G4double  y_delta,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
edge_xThe x reference of one end (either one)
x_deltaFULL X size, + or - from end_x.
edge_yThe y reference of one end (either one)
y_deltaFULL Y size. + or - from end_y.
edge_zThe z reference of one end (either one)
z_deltaHeight, can be positive or negative (from z reference)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 57 of file BoxBuilder.cc.

60 {
61 auto object = BoxBuilderPtr(new BoxBuilder(name));
62 object->SetXEdgeDelta(edge_x, x_delta)
63 ->SetYEdgeDelta(edge_y, y_delta)
64 ->SetZEdgeDelta(edge_z, z_delta);
65 return object;
66 }

◆ CreateDeltasBoxBuilder() [2/2]

BoxBuilderPtr CreateDeltasBoxBuilder ( G4double  unit,
const G4String &  name,
G4double  edge_x,
G4double  x_delta,
G4double  edge_y,
G4double  y_delta,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
edge_xThe x reference of one end (either one)
x_deltaFULL X size, + or - from end_x.
edge_yThe y reference of one end (either one)
y_deltaFULL Y size. + or - from end_y.
edge_zThe z reference of one end (either one)
z_deltaHeight, can be positive or negative (from z reference)
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 45 of file BoxBuilder.cc.

49 {
50 auto object = BoxBuilderPtr(new BoxBuilder(name));
51 object->SetXEdgeDelta(unit, edge_x, x_delta)
52 ->SetYEdgeDelta(unit, edge_y, y_delta)
53 ->SetZEdgeDelta(unit, edge_z, z_delta);
54 return object;
55 }

◆ CreateEdgesBoxBuilder() [1/2]

BoxBuilderPtr CreateEdgesBoxBuilder ( const G4String &  name,
G4double  x_edge1,
G4double  x_edge2,
G4double  y_edge1,
G4double  y_edge2,
G4double  z_edge1,
G4double  z_edge2 
)

Create a Box solid from edge coordinates.

Uses the global default unit

Parameters
nameBase name to derive geometry object names from.
x_edge1One end of the box in the x-dimension.
x_edge2The other end of the box in the x-dimension.
y_edge1One end of the box in the y-dimension.
y_edge2The other end of the box in the y-dimension.
z_edge1One end of the box in the z-dimension.
z_edge2The other end of the box in the z-dimension.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 125 of file BoxBuilder.cc.

127 {
128 auto object = BoxBuilderPtr(new BoxBuilder(name));
129 object->SetXEdges(x_edge1, x_edge2)
130 ->SetYEdges(y_edge1, y_edge2)
131 ->SetZEdges(z_edge1, z_edge2);
132 return object;
133 }

◆ CreateEdgesBoxBuilder() [2/2]

BoxBuilderPtr CreateEdgesBoxBuilder ( G4double  unit,
const G4String &  name,
G4double  x_edge1,
G4double  x_edge2,
G4double  y_edge1,
G4double  y_edge2,
G4double  z_edge1,
G4double  z_edge2 
)

Create a Box solid from edge coordinates using a specified unit.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_edge1One end of the box in the x-dimension.
x_edge2The other end of the box in the x-dimension.
y_edge1One end of the box in the y-dimension.
y_edge2The other end of the box in the y-dimension.
z_edge1One end of the box in the z-dimension.
z_edge2The other end of the box in the z-dimension.
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 135 of file BoxBuilder.cc.

138 {
139 auto object = BoxBuilderPtr(new BoxBuilder(name));
140 object->SetXEdges(unit, x_edge1, x_edge2)
141 ->SetYEdges(unit, y_edge1, y_edge2)
142 ->SetZEdges(unit, z_edge1, z_edge2);
143 return object;
144 }

◆ CreateFromG4VSolid()

FromG4VSolidPtr CreateFromG4VSolid ( G4VSolid *  solid)

Constructor to make a builder from an Existing Geant solid.

Parameters
solidG4VSolid pointer
Returns

Definition at line 25 of file FromG4VSolid.cc.

25 {
26 auto object = FromG4VSolidPtr();
27 object.get()->SetSolid(solid);
28 object.get()->SetName(solid->GetName());
29 return FromG4VSolidPtr(object);
30 }
SharedPtr< FromG4VSolid > FromG4VSolidPtr

◆ CreatePolyconeBuilder()

RZBuilderPtr CreatePolyconeBuilder ( const G4String &  name,
G4double  phi_start = 0.,
G4double  phi_tot = 360 
)

Create a builder for associated IR,OR,Z defined object.

Parameters
nameBase name to derive geometry object names from.
phi_startOptional Start angle
phi_totOptional Total degrees
sidesOptional number of sides, for CreatePoyhedra only, (can set it later, dflt = 4 )
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 28 of file RZBuilder.cc.

28 {
29 // We could actually construct these as RZBuilderPtr without using new, vis i_shared_ptr constructor.
30 // But maybe we can unfriend i_shared_ptr in the future if we use new here, and avoid exposing
31 // a backdoor to the general ctor, which doesn't select a MakeSolidFunctionPtr.
32 // ReSharper disable once CppDFAMemoryLeak
33 auto object = RZBuilderPtr(new RZBuilder(name, phi_start, phi_tot, 0));
34 object->MakeSolidFunctionPtr_ = &RZBuilder::MakePolycone;
35 return RZBuilderPtr(object);
36 }

◆ CreatePolyhedraBuilder()

RZBuilderPtr CreatePolyhedraBuilder ( const G4String &  name,
int  sides,
G4double  phi_start = 0.,
G4double  phi_tot = 360 
)

Create a builder for associated IR,OR,Z defined object.

Parameters
nameBase name to derive geometry object names from.
phi_startOptional Start angle
phi_totOptional Total degrees
sidesOptional number of sides, for CreatePoyhedra only, (can set it later, dflt = 4 )
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 38 of file RZBuilder.cc.

39 {
40 // ReSharper disable once CppDFAMemoryLeak
41 auto object = new RZBuilder(name, phi_start, phi_tot, sides);
42 object->MakeSolidFunctionPtr_ = &RZBuilder::MakePolyhedra;
43 return RZBuilderPtr(object);
44 }

◆ CreateZDeltaBoxBuilder() [1/2]

BoxBuilderPtr CreateZDeltaBoxBuilder ( const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Uses the global default unit.

Parameters
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
edge_zFull Z size
z_deltaFull Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 83 of file BoxBuilder.cc.

85 {
86 if (x_full_size <= 0 || y_full_size <= 0) {
87 throw std::invalid_argument("Error in CreateZDeltaBoxBuilder(): for volume " + name
88 + ": Sizes provided without end offsets must be positive.\n");
89 }
90 auto object = BoxBuilderPtr(new BoxBuilder(name));
91 object->SetXSize(x_full_size)
92 ->SetYSize(y_full_size)
93 ->SetZEdgeDelta(edge_z, z_delta);
94 return object;
95 }

◆ CreateZDeltaBoxBuilder() [2/2]

BoxBuilderPtr CreateZDeltaBoxBuilder ( G4double  unit,
const G4String &  name,
G4double  x_full_size,
G4double  y_full_size,
G4double  edge_z,
G4double  z_delta 
)

Create a Box solid.

Parameters
unitThe unit to use for this call only (ex: CLHEP::mm)
nameBase name to derive geometry object names from.
x_full_sizeFULL X size
y_full_sizeFULL Y size
edge_zFull Z size
z_deltaFull Z size
Returns
The builder. Set configurations and then call .MakeSolid() and .MakeLogicalVolume() on it. See VolumeBuilder for inherited public methods including Union/Subtraction.

Definition at line 68 of file BoxBuilder.cc.

71 {
72 if (x_full_size <= 0 || y_full_size <= 0) {
73 throw std::invalid_argument("Error in CreateZDeltaBoxBuilder(): for volume " + name
74 + ": Sizes provided without end offsets must be positive.\n");
75 }
76 auto object = BoxBuilderPtr(new BoxBuilder(name));
77 object->SetXSize(unit, x_full_size)
78 ->SetYSize(unit, y_full_size)
79 ->SetZEdgeDelta(unit, edge_z, z_delta);
80 return object;
81 }