File indexing completed on 2025-01-18 09:15:54
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include "DD4hep/DetFactoryHelper.h"
0014 #include "DD4hep/Printout.h"
0015 #include "XML/Utilities.h"
0016 #include "DD4hepDetectorHelper.h"
0017
0018 using namespace dd4hep;
0019 using namespace dd4hep::detail;
0020
0021 static Ref_t create_element(Detector& description, xml_h e, Ref_t) {
0022 xml_det_t x_det(e);
0023 const std::string det_name = x_det.nameStr();
0024 DetElement sdet(det_name, x_det.id());
0025 Volume vol;
0026 Position pos;
0027
0028 const bool usePos = x_det.hasChild(_U(position));
0029
0030
0031 dd4hep::xml::setDetectorTypeFlag(x_det, sdet);
0032 auto& params = DD4hepDetectorHelper::ensureExtension<dd4hep::rec::VariantParameters>(sdet);
0033
0034
0035 for (xml_coll_t bmat(x_det, _Unicode(boundary_material)); bmat; ++bmat) {
0036 xml_comp_t x_boundary_material = bmat;
0037 DD4hepDetectorHelper::xmlToProtoSurfaceMaterial(x_boundary_material, params,
0038 "boundary_material");
0039 }
0040
0041 if (usePos) {
0042 pos = Position(x_det.position().x(), x_det.position().y(), x_det.position().z());
0043 }
0044 vol = Assembly(det_name);
0045 vol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
0046
0047 Volume mother = description.pickMotherVolume(sdet);
0048 PlacedVolume pv;
0049 if (usePos) {
0050 pv = mother.placeVolume(vol, pos);
0051 } else {
0052 pv = mother.placeVolume(vol);
0053 }
0054 sdet.setPlacement(pv);
0055 for (xml_coll_t c(x_det, _U(composite)); c; ++c) {
0056 xml_dim_t component = c;
0057 const std::string nam = component.nameStr();
0058 description.declareParent(nam, sdet);
0059 }
0060 return sdet;
0061 }
0062
0063 DECLARE_DETELEMENT(epic_CompositeTracker, create_element)