11 #include "DD4hep/DetFactoryHelper.h"
14 using namespace dd4hep;
23 xml_det_t x_det = xml;
24 string det_name = x_det.nameStr();
26 DetElement cylinderVolume(det_name, x_det.id());
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.dz();
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());
51 int module_num_num = 0;
53 if (x_layer.hasChild(_U(module))) {
54 for (xml_coll_t i(x_layer, _U(module)); i; i++) {
55 xml_comp_t x_module = i;
56 int repeat = x_module.repeat();
57 double deltaphi = 2. *
M_PI / repeat;
58 double radius = x_module.radius();
59 double slicedz = x_module.dz();
61 size_t module_num = 0;
66 Trapezoid(x_module.x1(), x_module.x2(), x_module.thickness(),
67 x_module.thickness(), x_module.length()),
68 lcdd.material(x_module.materialStr()));
69 mod_vol.setVisAttributes(lcdd, x_module.visStr());
75 x_module.x1(), x_module.x2(), x_module.length(),
76 x_module.thickness(), sens.readout().segmentation());
80 std::vector<PlacedVolume> sensComponents;
82 std::shared_ptr<const Acts::DigitizationModule> digiComponent =
nullptr;
85 for (xml_coll_t comp(x_module, _U(module_component)); comp; comp++) {
86 xml_comp_t x_comp = comp;
89 _toString((
int)comp_num,
"component%d") + x_comp.materialStr();
92 Trapezoid(x_comp.x1(), x_comp.x2(), x_comp.thickness(),
93 x_comp.thickness(), x_comp.length()),
94 lcdd.material(x_comp.materialStr()));
95 comp_vol.setVisAttributes(lcdd, x_comp.visStr());
102 x_comp.x1(), x_comp.x2(), x_comp.length(), x_comp.thickness(),
103 sens.readout().segmentation());
106 if (x_comp.isSensitive())
107 comp_vol.setSensitiveDetector(sens);
110 Position translation(0., x_comp.z(), 0.);
111 PlacedVolume placed_comp = mod_vol.placeVolume(comp_vol, translation);
112 if (x_comp.isSensitive())
113 sensComponents.push_back(placed_comp);
114 placed_comp.addPhysVolID(
"component", module_num);
119 for (
int k = 0;
k < repeat;
k++) {
120 string zname = _toString((
int)
k,
"z%d");
124 zname + _toString((
int)(repeat * module_num_num + module_num),
126 Position trans(radius * cos(phi), radius * sin(phi), slicedz);
128 DetElement mod_det(lay_det, module_name,
129 repeat * module_num_num + module_num);
131 if (x_module.isSensitive()) {
132 mod_vol.setSensitiveDetector(sens);
139 for (
auto& sensComp : sensComponents) {
141 DetElement comp_det(mod_det,
"component", scomp_num);
145 comp_det.setPlacement(sensComp);
148 Rotation3D rotation1(1., 0., 0., 0., 1., 0., 0., 0., 1.);
151 RotationY(phi + 0.5 *
M_PI) *
152 RotationZ(0.1 *
M_PI),
154 PlacedVolume placedmodule =
155 layer_vol.placeVolume(mod_vol, rotation1 * transf1);
156 placedmodule.addPhysVolID(
"module",
157 repeat * module_num_num + module_num);
159 mod_det.setPlacement(placedmodule);
169 layerExtension->
addType(
"sensitive disk",
"layer");
173 Position layer_pos(0., 0., x_layer.z());
174 PlacedVolume placedLayer = tube_vol.placeVolume(layer_vol, layer_pos);
175 placedLayer.addPhysVolID(
"layer", layer_num);
176 lay_det.setPlacement(placedLayer);
182 Position endcap_translation(0., 0., x_det_dim.z());
183 Rotation3D rotation(1., 0., 0., 0., 1., 0., 0., 0., 1.);
184 if (x_det_dim.z() < 0.) {
185 rotation.SetComponents(1., 0., 0., 0., -1., 0., 0., 0., -1.);
187 Transform3D endcap_transform(rotation, endcap_translation);
188 Volume mother_vol = lcdd.pickMotherVolume(cylinderVolume);
189 PlacedVolume placedTube = mother_vol.placeVolume(tube_vol, endcap_transform);
190 placedTube.addPhysVolID(
"system", cylinderVolume.id());
191 cylinderVolume.setPlacement(placedTube);
193 return cylinderVolume;