24 static void placeStaves(
DetElement& parent,
DetElement& stave,
double rmin,
int numsides,
double total_thickness,
25 Volume envelopeVolume,
double innerAngle,
Volume sectVolume) {
26 double innerRotation = innerAngle;
27 double offsetRotation = -innerRotation / 2;
28 double sectCenterRadius = rmin + total_thickness / 2;
29 double rotX =
M_PI / 2;
30 double rotY = -offsetRotation;
31 double posX = -sectCenterRadius * std::sin(rotY);
32 double posY = sectCenterRadius * std::cos(rotY);
34 for (
int module = 1; module <= numsides; ++module) {
42 rotY -= innerRotation;
43 posX = -sectCenterRadius * std::sin(rotY);
44 posY = sectCenterRadius * std::cos(rotY);
53 string det_name = x_det.nameStr();
55 double totalThickness = layering.totalThickness();
57 int numSides = dim.numsides();
58 double detZ = dim.z();
59 double rmin = dim.rmin();
69 int repeat = x_layer.repeat();
70 totalRepeat += repeat;
71 totalSlices += x_layer.numChildren(
_U(slice));
75 Volume envelopeVol(det_name, polyhedra, air);
78 double innerAngle = 2 *
M_PI / numSides;
79 double halfInnerAngle = innerAngle / 2;
80 double tan_inner = std::tan(halfInnerAngle) * 2;
81 double innerFaceLen = rmin * tan_inner;
82 double outerFaceLen = (rmin + totalThickness) * tan_inner;
83 double staveThickness = totalThickness;
85 Trapezoid staveTrdOuter(innerFaceLen / 2, outerFaceLen / 2, detZ / 2, detZ / 2, staveThickness / 2);
86 Volume staveOuterVol(
"stave_outer", staveTrdOuter, air);
88 Trapezoid staveTrdInner(innerFaceLen / 2 - gap, outerFaceLen / 2 - gap, detZ / 2, detZ / 2, staveThickness / 2);
89 Volume staveInnerVol(
"stave_inner", staveTrdInner, air);
91 double layerOuterAngle = (
M_PI - innerAngle) / 2;
92 double layerInnerAngle = (
M_PI / 2 - layerOuterAngle);
93 double layer_pos_z = -(staveThickness / 2);
94 double layer_dim_x = innerFaceLen / 2 - gap * 2;
102 int repeat = x_layer.repeat();
103 const Layer* lay = layering.layer(layer_num - 1);
105 for (
int j = 0; j < repeat; j++) {
106 string layer_name =
_toString(layer_num,
"layer%d");
107 double layer_thickness = lay->
thickness();
108 DetElement layer(stave, layer_name, layer_num);
112 layer_pos_z += layer_thickness / 2;
114 Volume layer_vol(layer_name,
Box(layer_dim_x, detZ / 2, layer_thickness / 2), air);
117 double slice_pos_z = -(layer_thickness / 2);
118 int slice_number = 1;
121 string slice_name =
_toString(slice_number,
"slice%d");
122 double slice_thickness = x_slice.thickness();
124 DetElement slice(layer, slice_name, slice_number);
126 slice_pos_z += slice_thickness / 2;
128 Volume slice_vol(slice_name,
Box(layer_dim_x, detZ / 2, slice_thickness / 2), slice_material);
130 if (x_slice.isSensitive()) {
132 slice_vol.setSensitiveDetector(sens);
135 slice_vol.setAttributes(description, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());
140 slice.setPlacement(slice_phv);
142 slice_pos_z += slice_thickness / 2;
147 layer_vol.setAttributes(description, x_layer.regionStr(), x_layer.limitsStr(), x_layer.visStr());
152 layer.setPlacement(layer_phv);
155 layer_dim_x += layer_thickness * std::tan(layerInnerAngle);
157 layer_pos_z += layer_thickness / 2;
164 staveOuterVol.placeVolume(staveInnerVol);
171 placeStaves(sdet, stave, rmin, numSides, totalThickness, envelopeVol, innerAngle, staveOuterVol);
173 envelopeVol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
175 double z_offset = dim.hasAttr(
_U(z_offset)) ? dim.z_offset() : 0.0;
180 sdet.setPlacement(env_phv);