52 CSSSLayer::CSSSLayer(EGS_Float t, EGS_Float rit, EGS_Float rot, EGS_Float rib, EGS_Float rob, EGS_Float z):
53 thick(t), ri_top(rit), ro_top(rot), ri_bot(rib), ro_bot(rob), zo(z) {
55 ro_max = max(ro_top, ro_bot);
56 ro_min = min(ro_top, ro_bot);
58 ri_max = max(ri_top, ri_bot);
59 ri_min = min(ri_top, ri_bot);
61 o_slope = (ro_bot - ro_top)/thick;
62 i_slope = (ri_bot - ri_top)/thick;
64 const_width = ((ro_bot - ri_bot) - (ro_top - ri_top)) < 1E-5;
66 vout = M_PI/3.*(3*ro_max+thick*fabs(o_slope))*thick*thick*fabs(o_slope);
67 vout += M_PI*ro_min*ro_min*thick;
69 vin = M_PI/3.*(3*ri_max+thick*fabs(i_slope))*thick*thick*fabs(i_slope);
70 vin += M_PI*ri_min*ri_min*thick;
81 getRZEqualWidth(rndm, r, z);
84 getRZRejection(rndm, r, z);
88 EGS_Vector point = getPointInCircleAtZ(rndm, r, z);
96 EGS_Float ri = getRiAtZ(z);
97 EGS_Float ro = getRoAtZ(z);
107 r = ri_min+(ro_max-ri_min)*rndm->
getUniform();
109 if (r <= getRoAtZ(z) && r >= getRiAtZ(z)) {
110 EGS_Vector point = getPointInCircleAtZ(rndm, r, z);
115 if (count++ > 1000) {
116 egsWarning(
"egs_conical_shell: Less than .1%% of random points are being accepted");
126 EGS_Float cphi, sphi;
132 EGS_Float CSSSLayer::getRoAtZ(EGS_Float z) {
133 return o_slope*z+ro_top;
136 EGS_Float CSSSLayer::getRiAtZ(EGS_Float z) {
137 return i_slope*z+ri_top;
145 otype =
"conicalShellStack";
152 int lyr= layer_sampler->
sample(rndm) ;
159 void EGS_ConicalShellStackShape::addLayer(EGS_Float thick,
160 EGS_Float ri_top, EGS_Float ro_top, EGS_Float ri_bot,EGS_Float ro_bot) {
163 layers.push_back(layer);
164 total_thick += thick;
166 volumes.push_back(layer->volume);
173 void EGS_ConicalShellStackShape::addLayer(EGS_Float thick, EGS_Float ri_bot,EGS_Float ro_bot) {
175 EGS_Float ri_top = layers[layers.size()-1]->ri_bot;
176 EGS_Float ro_top = layers[layers.size()-1]->ro_bot;
178 addLayer(thick, ri_top, ro_top, ri_bot, ro_bot);
182 void EGS_ConicalShellStackShape::setLayerSampler() {
185 delete layer_sampler;
197 egsWarning(
"createShape(conicalShell): null input?\n");
202 vector<EGS_Float> xo;
203 int err = input->
getInput(
"midpoint", xo);
204 if (err || xo.size() != 3) {
217 vector<EGS_Float> rtop, rbot;
219 err = layer->
getInput(
"thickness", thick);
222 "createShape(EGS_ConicalShellStackShape): missing 'thickness'"
223 " input for layer %d\n --> layer ignored\n", nl
228 err = layer->
getInput(
"top radii",rtop);
230 egsWarning(
"createGeometry(EGS_ConeStack): missing 'top radii' input for 1st layer\n");
236 int err1 = layer->
getInput(
"bottom radii",rbot);
238 egsWarning(
"createGeometry(EGS_ConeStack): missing 'bottom radii' input for layer %d\n",nl);
245 EGS_Float rit, rot, rib, rob;
246 if (rbot.size() < 2) {
255 if (rtop.size() == 0) {
256 result->addLayer(thick, rib, rob);
258 else if (rtop.size() < 2) {
261 result->addLayer(thick, rit, rot, rib, rob);
266 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.