11 #include "DD4hep/DetFactoryHelper.h"
12 #include "XML/XMLElements.h"
29 dd4hep::Detector& lcdd, dd4hep::xml::Handle_t xmlElement,
30 dd4hep::SensitiveDetector sensDet) {
31 dd4hep::xml::DetElement xmlDet =
32 static_cast<dd4hep::xml::DetElement
>(xmlElement);
33 std::string
name = xmlDet.nameStr();
34 dd4hep::DetElement detElement(name, xmlDet.id());
37 detvolume->addType(
"barrel",
"detector");
40 dd4hep::Volume experimentalHall = lcdd.pickMotherVolume(detElement);
41 xml_comp_t dimensions(xmlDet.dimensions());
42 dd4hep::Tube envelope(dimensions.rmin(), dimensions.rmax(), dimensions.dz());
43 dd4hep::Volume envVolume(name, envelope,
44 lcdd.material(dimensions.materialStr()));
49 for (xml_coll_t layerIt(xmlDet, _U(
layer)); layerIt; ++layerIt) {
50 xml_comp_t layerDet = layerIt;
51 dd4hep::Tube layerShape(layerDet.rmin(), layerDet.rmax(), layerDet.dz());
52 std::string layerName = dd4hep::xml::_toString(layerIdx,
"layer%d");
53 dd4hep::Volume layerVolume(layerName, layerShape, lcdd.air());
55 dd4hep::DetElement lay_det(detElement, layerName, layerIdx);
61 if (layerDet.hasAttr(_U(vis))) {
62 layerVolume.setVisAttributes(lcdd, layerDet.visStr());
64 if (layerDet.hasAttr(_U(sensitive))) {
65 layerVolume.setSensitiveDetector(sensDet);
69 detlayer->
addType(
"passive cylinder",
"layer");
73 dd4hep::Position transLayer(0., 0., layerDet.z_offset());
74 dd4hep::PlacedVolume placedLayerVolume =
75 envVolume.placeVolume(layerVolume, transLayer);
77 placedLayerVolume.addPhysVolID(
"layer", layerIdx);
78 lay_det.setPlacement(placedLayerVolume);
82 dd4hep::Position trans(0., 0., dimensions.z_offset());
83 dd4hep::PlacedVolume envPhys = experimentalHall.placeVolume(
85 envPhys.addPhysVolID(
"system", detElement.id());
86 detElement.setPlacement(envPhys);
87 detElement.setVisAttributes(lcdd, xmlDet.visStr(), envVolume);