11 #include "DD4hep/DetFactoryHelper.h"
14 using namespace dd4hep;
22 xml_det_t x_det = xml;
23 string det_name = x_det.nameStr();
25 DetElement cylinderVolume(det_name, x_det.id());
28 barrelExtension->addType(
"barrel",
"detector");
31 dd4hep::xml::Dimension x_det_dim(x_det.dimensions());
32 Tube tube_shape(x_det_dim.rmin(), x_det_dim.rmax(), x_det_dim.dz());
33 Volume tube_vol(det_name, tube_shape,
35 tube_vol.setVisAttributes(lcdd, x_det_dim.visStr());
39 for (xml_coll_t j(xml, _U(
layer)); j; ++j) {
40 xml_comp_t x_layer = j;
41 double l_rmin = x_layer.inner_r();
42 double l_rmax = x_layer.outer_r();
43 double l_length = x_layer.z();
45 string layer_name = det_name + _toString((
int)layer_num,
"layer%d");
46 Volume layer_vol(layer_name, Tube(l_rmin, l_rmax, l_length),
47 lcdd.material(x_layer.materialStr()));
48 DetElement lay_det(cylinderVolume, layer_name, layer_num);
50 layer_vol.setVisAttributes(lcdd, x_layer.visStr());
52 if (x_layer.hasChild(_U(module))) {
53 xml_comp_t x_module = x_layer.child(_U(module));
54 int repeat = x_module.repeat();
55 double deltaphi = 2. *
M_PI / repeat;
57 xml_comp_t x_slice = x_layer.child(_U(slice));
58 int zrepeat = x_slice.repeat();
59 double dz = x_slice.z();
60 double dr = x_slice.dr();
64 Box(x_module.width(), x_module.length(), x_module.thickness()),
65 lcdd.material(x_module.materialStr()));
70 x_module.length(), x_module.width(), x_module.thickness(),
71 sens.readout().segmentation());
74 mod_vol.setVisAttributes(lcdd, x_module.visStr());
75 size_t module_num = 0;
77 for (
int k = -zrepeat;
k <= zrepeat;
k++) {
78 double r = (l_rmax + l_rmin) * 0.5;
79 string zname = _toString((
int)
k,
"z%d");
83 for (
int i = 0; i < repeat; ++i) {
85 string module_name = zname + _toString((
int)i,
"module%d");
86 Position trans(r * cos(phi), r * sin(phi), k * dz);
88 DetElement mod_det(lay_det, module_name, module_num);
90 if (x_module.isSensitive()) {
91 mod_vol.setSensitiveDetector(sens);
97 PlacedVolume placedmodule = layer_vol.placeVolume(
101 placedmodule.addPhysVolID(
"module", module_num);
103 mod_det.setPlacement(placedmodule);
112 layerExtension->
addType(
"active cylinder",
"layer");
113 layerExtension->
addType(
"axes",
"definitions",
"YxZ");
116 PlacedVolume placedLayer = tube_vol.placeVolume(layer_vol);
117 placedLayer.addPhysVolID(
"layer", layer_num);
119 lay_det.setPlacement(placedLayer);
123 Volume mother_vol = lcdd.pickMotherVolume(cylinderVolume);
124 PlacedVolume placedTube = mother_vol.placeVolume(tube_vol);
125 placedTube.addPhysVolID(
"system", cylinderVolume.id());
126 cylinderVolume.setPlacement(placedTube);
128 return cylinderVolume;