24 #include "DD4hep/DetFactoryHelper.h"
28 using namespace dd4hep;
37 std::string
name = x_det.nameStr();
42 Assembly assembly(name +
"_assembly");
44 DetElement
tracker(name, x_det.id());
48 detvolume->addType(
"barrel",
"detector");
56 double minZhalf = 1e99;
61 for (xml_coll_t
c(e, _U(
layer));
c; ++
c) {
62 xml_comp_t x_layer(
c);
65 xml_comp_t x_sensitive(x_layer.child(_U(sensitive)));
66 xml_comp_t x_ladder(x_layer.child(_U(ladder)));
68 int layer_id = x_layer.id();
69 int nLadders = x_layer.attr<
double>(_Unicode(nLadders));
71 double dphi = 2. *
M_PI / double(nLadders);
73 std::string layername = name + _toString(layer_id,
"_layer%d");
77 Assembly layer_assembly(
"layer_assembly" + _toString(layer_id,
"_%d"));
79 DetElement layerDE(
tracker, _toString(layer_id,
"layer_%d"), x_det.id());
85 detlayer->addType(
"sensitive plane",
"layer");
88 pv = assembly.placeVolume(layer_assembly);
90 pv.addPhysVolID(
"layer", layer_id);
92 layerDE.setPlacement(pv);
96 double supp_zhalf = x_ladder.length();
97 double supp_offset = x_ladder.offset();
98 double supp_distance = x_ladder.distance();
99 double supp_thickness = x_ladder.thickness();
100 double supp_width = x_ladder.width();
102 std::string supp_vis = x_ladder.visStr();
103 std::string supp_matS = x_ladder.materialStr();
105 double sens_zhalf = x_sensitive.length();
106 double sens_offset = x_sensitive.offset();
107 double sens_distance = x_sensitive.distance();
108 double sens_thickness = x_sensitive.thickness();
109 double sens_width = x_sensitive.width();
111 std::string sens_view = x_sensitive.visStr();
112 std::string sens_matS = x_sensitive.materialStr();
114 double phi0 = x_layer.phi0();
116 if (sens_distance < minRadius)
117 minRadius = sens_distance;
118 if (supp_distance < minRadius)
119 minRadius = supp_distance;
120 if (sens_zhalf < minZhalf)
121 minZhalf = sens_zhalf;
122 if (supp_zhalf < minZhalf)
123 minZhalf = supp_zhalf;
150 Material supp_mat = lcdd.material(supp_matS);
151 Material sens_mat = lcdd.material(sens_matS);
154 Box sens_box(sens_thickness / 2., sens_width / 2., sens_zhalf);
155 Box supp_box(supp_thickness / 2., supp_width / 2., supp_zhalf);
157 Volume supp_vol(layername +
"_supp", supp_box, supp_mat);
158 Volume sens_vol(layername +
"_sens", sens_box, sens_mat);
191 sens.setType(
"tracker");
192 sens_vol.setSensitiveDetector(sens);
194 sens_vol.setAttributes(lcdd, x_det.regionStr(), x_det.limitsStr(),
196 supp_vol.setAttributes(lcdd, x_det.regionStr(), x_det.limitsStr(),
201 for (
int j = 0; j < nLadders; ++j) {
202 double phi = phi0 + j * dphi;
204 std::string laddername = layername + _toString(j,
"_ladder%d");
206 RotationZYX rot(phi, 0, 0);
209 double lthick = supp_thickness;
210 double radius = supp_distance;
211 double offset = supp_offset;
213 layer_assembly.placeVolume(
217 Position((radius + lthick / 2.) *
cos(phi) - offset * sin(phi),
218 (radius + lthick / 2.) * sin(phi) + offset *
cos(phi),
222 lthick = sens_thickness;
223 radius = sens_distance;
224 offset = sens_offset;
226 pv = layer_assembly.placeVolume(
230 Position((radius + lthick / 2.0) *
cos(phi) - offset * sin(phi),
231 (radius + lthick / 2.0) * sin(phi) + offset *
cos(phi),
236 pv.addPhysVolID(
"module", j).addPhysVolID(
"sensor", 0);
238 DetElement ladderDE(layerDE, laddername, x_det.id());
239 ladderDE.setPlacement(pv);
247 layer_assembly->GetShape()->ComputeBBox();
250 #if 0 //-------- add an inscribing cylinder of air for tracking purposes
271 #endif //----------------------------------------------------------------------------------
275 Volume mother = lcdd.pickMotherVolume(
tracker);
277 pv = mother.placeVolume(assembly);
279 pv.addPhysVolID(
"system", x_det.id()).addPhysVolID(
"side", 0);
283 assembly->GetShape()->ComputeBBox();