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 134 of file RZBuilder.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);
141 OR_.push_back(plane.OR * plane.unit);
142 z_.push_back(plane.z * plane.unit);
143 num_planes_++;
144 return shared_from_this();
145 }

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

153 {
154 auto plane = RZPlane{GetEffectiveDefaultUnit(), IR, OR, z};
155 return AddPlane(plane);
156 }
RZBuilderPtr AddPlane(const RZPlane &plane)
Adds a plane defining one IR,OR,Z triplet in the volume design.
Definition RZBuilder.cc:134
G4double GetEffectiveDefaultUnit() const
Get the builder default unit or global if not set.
Struct for adding planes to GeantMultiPlane –DSLeonard 2024 Overloads make this not strictly needed.
Definition RZBuilder.hh:44

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

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

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

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

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

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

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

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

◆ 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 91 of file RZBuilder.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()

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 VB::CreateCylinderBuilder(G4double 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 RZBuilder.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()

RZBuilderPtr SetNumSides ( G4double  N)
virtual

Set number of sides.

Only relevant for things with sides.

Parameters
NNumber of Sides

Definition at line 119 of file RZBuilder.cc.

119 {
120 if (MakeSolidFunctionPtr_ == &RZBuilder::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 }