27 bool reflect = x_det.reflect();
29 string det_name = x_det.nameStr();
37 double rmax = dim.outer_r();
38 double rmin = dim.inner_r();
39 double zinner = dim.inner_z();
40 double outgoingR = beam.outgoing_r();
41 double incomingR = beam.incoming_r();
42 double xangle = beam.crossing_angle();
43 double xangleHalf = xangle/2;
44 double thickness = layering.totalThickness();
45 double zpos = zinner + thickness/2;
47 double beamPosX = std::tan(xangleHalf) * zpos;
50 Tube envelopeTube(rmin,rmax,thickness/2);
54 Tube beamInTube(0,outgoingR,thickness);
63 Tube beamOutTube(0,incomingR,thickness);
72 SubtractionSolid envelopeSubtraction2(envelopeSubtraction1,beamOutTube,beamOutTrans);
75 Volume envelopeVol(det_name+
"_envelope", envelopeSubtraction2, air);
78 double layerPosZ = -thickness / 2;
79 double layerDisplZ = 0;
84 double layerThickness = layering.singleLayerThickness(x_layer);
88 Tube layerTube(rmin,rmax,layerThickness * 0.5);
90 for(
int i=0, repeat=x_layer.repeat(); i<repeat; ++i) {
91 string layer_nam =
_toString(layerCount,
"layer%d");
93 layerDisplZ += layerThickness / 2;
94 layerPosZ += layerThickness / 2;
98 double layerGlobalZ = zinner + layerDisplZ;
99 double layerPosX = std::tan(xangleHalf) * layerGlobalZ;
100 Position layer1SubPos( layerPosX,0,0);
101 Position layer2SubPos(-layerPosX,0,0);
107 Volume layerVol(det_name+
"_"+layer_nam,layerSubtraction2,air);
111 double slicePosZ = -layerThickness / 2;
112 double sliceDisplZ = 0;
115 string slice_nam =
_toString(sliceCount,
"slice%d");
117 double sliceThickness = x_slice.thickness();
121 sliceDisplZ += sliceThickness / 2;
122 slicePosZ += sliceThickness / 2;
125 Tube sliceTube(rmin,rmax,sliceThickness * 0.5);
127 double sliceGlobalZ = zinner + (layerDisplZ - layerThickness / 2) + sliceDisplZ;
128 double slicePosX = std::tan(xangleHalf) * sliceGlobalZ;
135 Volume sliceVol(det_name+
"_"+layer_nam+
"_"+slice_nam, sliceSubtraction2, slice_mat);
137 if ( x_slice.isSensitive() ) {
139 sliceVol.setSensitiveDetector(sens);
142 slice.setAttributes(description, sliceVol, x_slice.regionStr(), x_slice.limitsStr(), x_slice.visStr());
147 slice.setPlacement(pv);
150 sliceDisplZ += sliceThickness / 2;
151 slicePosZ += sliceThickness / 2;
155 layer.setAttributes(description, layerVol, x_layer.regionStr(), x_layer.limitsStr(), x_layer.visStr());
160 layer.setPlacement(layerPV);
163 layerDisplZ += layerThickness / 2;
164 layerPosZ += layerThickness / 2;
168 sdet.setVisAttributes(description, x_det.visStr(), envelopeVol);
172 Assembly assembly(det_name+
"_assembly");
175 sdet.setPlacement(pv);
177 DetElement sdetA(sdet,det_name+
"_A",x_det.id());
180 sdetA.setPlacement(pv);
192 sdet.setPlacement(pv);