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

Functions

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

Detailed Description

Solid Configurations for RZBuiler.

Function Documentation

◆ AddPlane() [1/3]

RZBuilderPtr AddPlane ( const RZPlane plane)

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

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

Definition at line 130 of file RZBuilder.cc.

130 {
131 if (plane.IR < 0 || plane.OR < 0) {
132 throw std::runtime_error("Error in RZBuilder::AddPlane()"
133 " for builder " + GetBuilderName() + ".\n"
134 "IR and OR must be non-negative.");
135 }
136 IR_.push_back(plane.IR * plane.unit);
137 OR_.push_back(plane.OR * plane.unit);
138 z_.push_back(plane.z * plane.unit);
139 num_planes_++;
140 return shared_from_this();
141 }

◆ AddPlane() [2/3]

RZBuilderPtr 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 149 of file RZBuilder.cc.

149 {
150 auto plane = RZPlane{GetEffectiveDefaultUnit(), IR, OR, z};
151 return AddPlane(plane);
152 }
RZBuilderPtr AddPlane(const RZPlane &plane)
Adds a plane defining one IR,OR,Z triplet in the volume design.
Definition RZBuilder.cc:130
G4double GetEffectiveDefaultUnit() const
Get the builder default unit or global if not set.

◆ AddPlane() [3/3]

RZBuilderPtr AddPlane ( G4double  unit,
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
unitThe unit to use for THIS plane only (ex: CLHEP::mm)
IRInner radius
OROuter radius
zZ position

Definition at line 143 of file RZBuilder.cc.

143 {
144 auto plane = RZPlane{unit, IR, OR, z};
145 return AddPlane(plane);
146 }

◆ AddPlanes() [1/3]

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

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

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

Definition at line 156 of file RZBuilder.cc.

156 {
157 for (const auto &plane : planes) {
158 AddPlane(plane);
159 }
160 return shared_from_this();
161 }

◆ AddPlanes() [2/3]

RZBuilderPtr 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 164 of file RZBuilder.cc.

164 {
165 for (const auto &plane : planes) {
166 G4double unit = this->GetEffectiveDefaultUnit();
167 auto rzplane = RZPlane{unit, plane.IR, plane.OR, plane.z};
168 AddPlane(rzplane);
169 }
170 return shared_from_this();
171 }

◆ AddPlanes() [3/3]

RZBuilderPtr AddPlanes ( G4double  unit,
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
unitThe unit to use for THESE planes only (ex: CLHEP::mm)
planes{{IR, OR, Z},{IR,OR,Z},...}

Definition at line 174 of file RZBuilder.cc.

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

◆ FillSolidConfig()

RZBuilderPtr 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 87 of file RZBuilder.cc.

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

◆ ReflectZSolidConfig()

RZBuilderPtr 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 RZBuilderPtr CreateCylinderBuilder(G4double unit, const G4String &name, G4double endz, G4double height, G4double OR, G4double IR)
Create a simple cylinder builder.
Definition RZBuilder.cc:44

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 102 of file RZBuilder.cc.

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

◆ SetNumSides()

RZBuilderPtr SetNumSides ( G4double  N)
virtual

Set number of sides.

Only relevant for things with sides.

Parameters
NNumber of Sides

Definition at line 115 of file RZBuilder.cc.

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