DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Functions
RZbuilder Configurations

Functions

virtual RZBuilder SetNumSides (G4double N)
 
RZBuilder AddPlane (const RZPlane &plane)
 
RZBuilder AddPlane (G4double IR, G4double OR, G4double z)
 
RZBuilder AddPlane (G4double IR, G4double OR, G4double z, Length unit)
 
RZBuilder AddPlanes (const std::vector< RZPlane > &planes)
 
RZBuilder AddPlanes (const std::vector< RZPlaneUnitless > &planes)
 
RZBuilder AddPlanes (const std::vector< RZPlaneUnitless > &planes, Length unit)
 
RZBuilder ReflectZSolidConfig ()
 
RZBuilder FillSolidConfig ()
 

Detailed Description

Solid Configurations for RZBuiler.

Function Documentation

◆ AddPlane() [1/3]

RZBuilder AddPlane ( const RZPlane plane)

Adds a plane defining one IR,OR,Z triplet in the volume design.

Parameters
plane// the IR, OR, Z, unit data for this "plane"

Definition at line 134 of file RZBuilderCore.cc.

134 {
135 if (plane.IR < 0 || plane.OR < 0) {
136 throw std::runtime_error("Error in RZBuilder::AddPlane()"
137 " for builder " + GetBuilderName() + ".\n"
138 "IR and OR must be non-negative.");
139 }
140 IR_.push_back(plane.IR * plane.unit.Native());
141 OR_.push_back(plane.OR * plane.unit.Native());
142 z_.push_back(plane.z * plane.unit.Native());
143 num_planes_++;
144 return shared_from_this();
145 }
PropertySetter Native
Definition DLG4Units.hh:182

◆ AddPlane() [2/3]

RZBuilder AddPlane ( G4double  IR,
G4double  OR,
G4double  z 
)

Adds a plane defining one IR,OR,Z triplet in the volume design Uses preset unit from default (mm) or SetUnit(unit);.

Parameters
IRInner radius
OROuter radius
zZ position

Definition at line 153 of file RZBuilderCore.cc.

153 {
154 auto plane = RZPlane{ IR, OR, z, Length()};
155 return AddPlane(plane);
156 }
RZBuilder AddPlane(const RZPlane &plane)
Adds a plane defining one IR,OR,Z triplet in the volume design.
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.

◆ AddPlane() [3/3]

RZBuilder AddPlane ( G4double  IR,
G4double  OR,
G4double  z,
Length  unit 
)

Adds a plane defining one IR,OR,Z triplet in the volume design Uses preset unit from default (mm) or SetUnit(unit);.

Parameters
IRInner radius
OROuter radius
zZ position
unitThe unit to use for THIS plane only (ex: VB::Length::mm)

Definition at line 147 of file RZBuilderCore.cc.

147 {
148 auto plane = RZPlane{ IR, OR, z, unit};
149 return AddPlane(plane);
150 }

◆ AddPlanes() [1/3]

RZBuilder AddPlanes ( const std::vector< RZPlane > &  planes)

Adds multiple RZ planes each defining one unit,IR,OR,Z set in the volume design.

Parameters
planes{{IR, OR, Z, unit},{IR,OR,Z,unit},...}, unit ex: VB::Length::mm

Definition at line 160 of file RZBuilderCore.cc.

160 {
161 for (const auto &plane : planes) {
162 AddPlane(plane);
163 }
164 return shared_from_this();
165 }

◆ AddPlanes() [2/3]

RZBuilder AddPlanes ( const std::vector< RZPlaneUnitless > &  planes)

Adds multiple planes each defining one IR,OR,Z triplet in the volume design Uses preset unit from default (mm) or SetUnit(unit);.

Parameters
planes{{IR, OR, Z},{IR,OR,Z},...}

Definition at line 168 of file RZBuilderCore.cc.

168 {
169 for (const auto &plane : planes) {
170 auto rzplane = RZPlane{plane.IR, plane.OR, plane.z, Length()};
171 AddPlane(rzplane);
172 }
173 return shared_from_this();
174 }

◆ AddPlanes() [3/3]

RZBuilder AddPlanes ( const std::vector< RZPlaneUnitless > &  planes,
Length  unit 
)

Adds multiple planes each defining one IR,OR,Z triplet in the volume design Uses preset unit from default (mm) or SetUnit(unit);.

Parameters
planes{{IR, OR, Z},{IR,OR,Z},...}
unitThe unit to use for THESE planes only (ex: VB::Length::mm)

Definition at line 177 of file RZBuilderCore.cc.

177 {
178 for (const auto &plane : planes) {
179 auto rzplane = RZPlane{plane.IR, plane.OR, plane.z, unit};
180 AddPlane(rzplane);
181 }
182 return shared_from_this();
183 }

◆ FillSolidConfig()

RZBuilder FillSolidConfig ( )

Modifies a Solid CONFIGURATION to set all inner diameters (IDs) to 0.


This does NOT copy the solid and does preserve the name.

Let's say you have a hollow cylinder, but you want a mother volume to put it in.

auto cryostat_bot = cryostat_vac_bot->ForkAndReset("cryostat_vac_bot")
->FillSolidConfig()
->SetMaterial(_vacuum);
cryostat_bot->SetMother(cryostat_vac_bot);

Done.

See also
ReflectZSolidConfig() for a detailed example of a similar method.

Definition at line 91 of file RZBuilderCore.cc.

91 {
92 if (solid_ptr_) {
93 throw std::runtime_error("Error in RZBuilder::FillSolidConfig\"\n"
94 "Cannot fill a solid builder CONFIGURATION, when the solid is already built from it."
95 "Use ForkAndReset(\"new_name\") first to get an unbuilt copy.\n\n");
96 }
97
98 // set all ID's to 0.
99 for (int i = 0; i < num_planes_; i++) {
100 this->IR_[i] = 0;
101 }
102 return this->shared_from_this();
103 }

◆ ReflectZSolidConfig()

RZBuilder ReflectZSolidConfig ( )

Flip Solid Configuration.

For use on builders with UNBUILT solids ONLY, preserving the name.
Useful for conditional configuration. Ex:

BuilderRefList builders;; // array of builders to store intermediates or result.
for (int i=0; i<10; i++) {
auto builder = CreateCylinderBuilder("x"+std::to_string(i) // SET INDEXED NAME
,0,10,20,0) // use global units
->SetMaterial("G4_AIR")->SetMother(other_solid)
->SetPhysOffset(i*5,0,0); // position for an array of cylinders.
if (i>4) {
builder->ReflectZSolidConfig(); // half of them are upside down. NO NAME CHANGE.
}
// make and optionally store the physical volumes
builders.emplace_back(builder->MakePlacement());
}
friend RZBuilder VB::CreateCylinderBuilder(VolumeBuilders::Length unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR)

If you use ReflectZCopy(newname) in the loop you'd need to provide a copy name, making your final solid naming harder (still possible) to set up right. You can skin this cat multiple other ways, but this provides options.

Returns
The same builder (allows chaining)

Definition at line 106 of file RZBuilderCore.cc.

106 {
107 if (solid_ptr_) {
108 throw std::runtime_error("Error in RZBuilder::ReflectZSolidConfig\"\n"
109 "Cannot flip a solid builder CONFIGURATION, when the solid is already built from it.\n"
110 "Use ReflectZFinalSolidCopy(\"new_name\") instead to copy and flip the solid.\n\n");
111 }
112 // Mirror z values
113 for (int i = 0; i < num_planes_; i++) {
114 this->z_[i] = -this->z_[i];
115 }
116 return this->shared_from_this();
117 }

◆ SetNumSides()

RZBuilder SetNumSides ( G4double  N)
virtual

Set number of sides.

Only relevant for things with sides.

Parameters
NNumber of Sides

Definition at line 119 of file RZBuilderCore.cc.

119 {
120 if (MakeSolidFunctionPtr_ == &RZBuilderCore::MakePolyhedra) {
121 sides_ = n;
122 } else {
123 G4cout <<
124 "Warning in RZBuilder: Calling SetNumSides() on a builder that makes round things"
125 << " might be as clever as giving a balloon to a hedgehog. \n Ignoring call." <<
126 G4endl;
127 }
128 return shared_from_this();
129 }