52 static bool EGS_CONICAL_SHELL_LOCAL inputSet =
false;
53 static shared_ptr<EGS_BlockInput> EGS_CONICAL_SHELL_LOCAL shapeBlockInput = make_shared<EGS_BlockInput>(
"shape");
55 CSSSLayer::CSSSLayer(EGS_Float t, EGS_Float rit, EGS_Float rot, EGS_Float rib, EGS_Float rob, EGS_Float z):
56 thick(t), ri_top(rit), ro_top(rot), ri_bot(rib), ro_bot(rob), zo(z) {
58 ro_max = max(ro_top, ro_bot);
59 ro_min = min(ro_top, ro_bot);
61 ri_max = max(ri_top, ri_bot);
62 ri_min = min(ri_top, ri_bot);
64 o_slope = (ro_bot - ro_top)/thick;
65 i_slope = (ri_bot - ri_top)/thick;
67 const_width = ((ro_bot - ri_bot) - (ro_top - ri_top)) < 1E-5;
69 vout = M_PI/3.*(3*ro_max+thick*fabs(o_slope))*thick*thick*fabs(o_slope);
70 vout += M_PI*ro_min*ro_min*thick;
72 vin = M_PI/3.*(3*ri_max+thick*fabs(i_slope))*thick*thick*fabs(i_slope);
73 vin += M_PI*ri_min*ri_min*thick;
84 getRZEqualWidth(rndm, r, z);
87 getRZRejection(rndm, r, z);
91 EGS_Vector point = getPointInCircleAtZ(rndm, r, z);
99 EGS_Float ri = getRiAtZ(z);
100 EGS_Float ro = getRoAtZ(z);
110 r = ri_min+(ro_max-ri_min)*rndm->
getUniform();
112 if (r <= getRoAtZ(z) && r >= getRiAtZ(z)) {
113 EGS_Vector point = getPointInCircleAtZ(rndm, r, z);
118 if (count++ > 1000) {
119 egsWarning(
"egs_conical_shell: Less than .1%% of random points are being accepted");
129 EGS_Float cphi, sphi;
135 EGS_Float CSSSLayer::getRoAtZ(EGS_Float z) {
136 return o_slope*z+ro_top;
139 EGS_Float CSSSLayer::getRiAtZ(EGS_Float z) {
140 return i_slope*z+ri_top;
148 otype =
"conicalShellStack";
155 int lyr= layer_sampler->
sample(rndm) ;
162 void EGS_ConicalShellStackShape::addLayer(EGS_Float thick,
163 EGS_Float ri_top, EGS_Float ro_top, EGS_Float ri_bot,EGS_Float ro_bot) {
166 layers.push_back(layer);
167 total_thick += thick;
169 volumes.push_back(layer->volume);
176 void EGS_ConicalShellStackShape::addLayer(EGS_Float thick, EGS_Float ri_bot,EGS_Float ro_bot) {
178 EGS_Float ri_top = layers[layers.size()-1]->ri_bot;
179 EGS_Float ro_top = layers[layers.size()-1]->ro_bot;
181 addLayer(thick, ri_top, ro_top, ri_bot, ro_bot);
185 void EGS_ConicalShellStackShape::setLayerSampler() {
188 delete layer_sampler;
197 static void setInputs() {
200 setShapeInputs(shapeBlockInput);
201 shapeBlockInput->getSingleInput(
"library")->setValues({
"egs_conical_shell"});
203 shapeBlockInput->addSingleInput(
"midpoint",
false,
"The midpoint of the conical shell, (x, y, z). Defaults to '0 0 0'.");
205 auto blockPtr = shapeBlockInput->addBlockInput(
"layer");
206 blockPtr->addSingleInput(
"thickness",
true,
"The thickness of the layer");
207 blockPtr->addSingleInput(
"top radii",
false,
"1 (outer radius, inner radius assumed to be 0) or 2 (outer and inner radius) inputs, only required for top layer");
208 blockPtr->addSingleInput(
"bottom radii",
true,
"1 (outer radius, inner radius assumed to be 0) or 2 (outer and inner radius) inputs");
211 EGS_CONICAL_SHELL_EXPORT
string getExample() {
215 # Example of egs_conical_shell
217 library = egs_conical_shell
226 bottom radii = 0.25 1
241 EGS_CONICAL_SHELL_EXPORT shared_ptr<EGS_BlockInput> getInputs() {
245 return shapeBlockInput;
251 egsWarning(
"createShape(conicalShell): null input?\n");
256 vector<EGS_Float> xo;
257 int err = input->
getInput(
"midpoint", xo);
258 if (err || xo.size() != 3) {
271 vector<EGS_Float> rtop, rbot;
273 err = layer->
getInput(
"thickness", thick);
276 "createShape(EGS_ConicalShellStackShape): missing 'thickness'"
277 " input for layer %d\n --> layer ignored\n", nl
282 err = layer->
getInput(
"top radii",rtop);
284 egsWarning(
"createGeometry(EGS_ConeStack): missing 'top radii' input for 1st layer\n");
290 int err1 = layer->
getInput(
"bottom radii",rbot);
292 egsWarning(
"createGeometry(EGS_ConeStack): missing 'bottom radii' input for layer %d\n",nl);
299 EGS_Float rit, rot, rib, rob;
300 if (rbot.size() < 2) {
309 if (rtop.size() == 0) {
310 result->addLayer(thick, rib, rob);
312 else if (rtop.size() < 2) {
315 result->addLayer(thick, rit, rot, rib, rob);
320 result->addLayer(thick, rit, rot, rib, rob);
Base shape class. All shapes in the EGSnrc C++ class library are derived from EGS_BaseShape.
EGS_ConicalShellStackShape(const EGS_Vector &Xo, const string &Name="", EGS_ObjectFactory *f=0)
Construct a sphere of radius r with midpoint Xo.
EGS_Vector getPoint(EGS_RandomGenerator *rndm)
Returns a random point within the conical shell.
void setName(EGS_Input *inp)
Set the name of the object from the information provided by inp.
string otype
The object type.
Base random number generator class. All random number generators should be derived from this class.
void getAzimuth(EGS_Float &cphi, EGS_Float &sphi)
Sets cphi and sphi to the cosine and sine of a random angle uniformely distributed between 0 and .
EGS_Float getUniform()
Returns a random number uniformly distributed between zero (inclusive) and 1 (exclusive).
A class for sampling random bins from a given probability distribution using the alias table techniqu...
int sample(EGS_RandomGenerator *rndm) const
Sample a random bin.
A class representing 3D vectors.
a conical stack shell shape
Global egspp functions header file.
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.