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