11 #include <DD4hep/DetFactoryHelper.h>
12 #include <DD4hep/Objects.h>
13 #include <XML/Utilities.h>
18 using namespace dd4hep;
29 xml_det_t x_det = xml;
30 string detName = x_det.nameStr();
33 xml_comp_t x_det_tubs = x_det.child(_U(tubs));
36 DetElement cylinderElement(detName, x_det.id());
37 dd4hep::xml::setDetectorTypeFlag(xml, cylinderElement);
39 string shapeName = x_det_tubs.nameStr();
40 double phiMin = Acts::getAttrValueOr<double>(x_det_tubs,
"phimin", 0.);
41 double phiMax = Acts::getAttrValueOr<double>(x_det_tubs,
"phimax", 360.);
42 Tube tubeShape(shapeName, x_det_tubs.rmin(), x_det_tubs.rmax(),
43 x_det_tubs.dz(),
phiMin, phiMax);
44 Volume tubeVolume(detName, tubeShape, dd.material(x_det_tubs.materialStr()));
45 tubeVolume.setVisAttributes(dd, x_det.visStr());
48 Volume motherVolume = dd.pickMotherVolume(cylinderElement);
49 PlacedVolume placedTube = motherVolume.placeVolume(
51 placedTube.addPhysVolID(detName, cylinderElement.id());
52 cylinderElement.setPlacement(placedTube);
55 return cylinderElement;
67 static Ref_t
create_disc(Detector &dd, xml_h xml, SensitiveDetector ) {
68 xml_det_t x_det = xml;
69 string detName = x_det.nameStr();
72 xml_comp_t x_det_tubs = x_det.child(_U(tubs));
75 DetElement discElement(detName, x_det.id());
76 dd4hep::xml::setDetectorTypeFlag(xml, discElement);
78 string shapeName = x_det_tubs.nameStr();
79 double phiMin = Acts::getAttrValueOr<double>(x_det_tubs,
"phimin", 0.);
80 double phiMax = Acts::getAttrValueOr<double>(x_det_tubs,
"phimax", 360.);
82 Tube discShape = Tube(shapeName, x_det_tubs.rmin(), x_det_tubs.rmax(),
83 x_det_tubs.dz(),
phiMin, phiMax);
85 Volume discVolume(detName, discShape, dd.material(x_det_tubs.materialStr()));
86 discVolume.setVisAttributes(dd, x_det.visStr());
89 Volume motherVolume = dd.pickMotherVolume(discElement);
90 PlacedVolume placedTube = motherVolume.placeVolume(
92 placedTube.addPhysVolID(detName, discElement.id());
93 discElement.setPlacement(placedTube);
109 SensitiveDetector ) {
110 xml_det_t x_det = xml;
111 string detName = x_det.nameStr();
114 xml_comp_t x_det_box = x_det.child(_U(
box));
117 DetElement rectElement(detName, x_det.id());
118 dd4hep::xml::setDetectorTypeFlag(xml, rectElement);
120 string shapeName = x_det_box.nameStr();
121 Box rectShape(shapeName, 0.5 * x_det_box.dx(), 0.5 * x_det_box.dy(),
122 0.5 * x_det_box.dz());
124 Volume rectVolume(detName, rectShape, dd.material(x_det_box.materialStr()));
125 rectVolume.setVisAttributes(dd, x_det.visStr());
128 Volume motherVolume = dd.pickMotherVolume(rectElement);
129 PlacedVolume placedRect = motherVolume.placeVolume(
131 placedRect.addPhysVolID(detName, rectElement.id());
132 rectElement.setPlacement(placedRect);
148 SensitiveDetector ) {
149 xml_det_t x_det = xml;
150 string detName = x_det.nameStr();
153 xml_comp_t x_det_trap = x_det.child(_U(trap));
156 DetElement trapElement(detName, x_det.id());
157 dd4hep::xml::setDetectorTypeFlag(xml, trapElement);
159 string shapeName = x_det_trap.nameStr();
162 Trapezoid trapShape(x_det_trap.x1(), x_det_trap.x2(), 0.5 * x_det_trap.dz(),
163 0.5 * x_det_trap.dz(), 0.5 * x_det_trap.dy());
165 Volume trapVolume(detName, trapShape, dd.material(x_det_trap.materialStr()));
166 trapVolume.setVisAttributes(dd, x_det.visStr());
169 Volume motherVolume = dd.pickMotherVolume(trapElement);
170 PlacedVolume placedTrap = motherVolume.placeVolume(
172 placedTrap.addPhysVolID(detName, trapElement.id());
173 trapElement.setPlacement(placedTrap);