File indexing completed on 2024-06-01 07:06:23
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "DD4hep/DetFactoryHelper.h"
0011 #include "DD4hep/Printout.h"
0012 #include "XML/Utilities.h"
0013
0014 #if defined(USE_ACTSDD4HEP)
0015 #include "ActsDD4hep/ActsExtension.hpp"
0016 #else
0017 #include "Acts/Plugins/DD4hep/ActsExtension.hpp"
0018 #endif
0019
0020 using namespace dd4hep;
0021 using namespace dd4hep::detail;
0022
0023 static Ref_t create_element(Detector& description, xml_h e, Ref_t)
0024 {
0025 xml_det_t x_det(e);
0026 const std::string det_name = x_det.nameStr();
0027 DetElement sdet(det_name, x_det.id());
0028 Volume vol;
0029 Position pos;
0030
0031 const bool usePos = x_det.hasChild(_U(position));
0032
0033 sdet.setType("compound");
0034 xml::setDetectorTypeFlag(e, sdet);
0035
0036 const std::string actsType = getAttrOrDefault(x_det, _Unicode(actsType), "endcap");
0037 printout(DEBUG, det_name, "+++ Creating composite tracking detector (type: " + actsType + ")");
0038 assert(actsType == "barrel" || actsType == "endcap");
0039
0040
0041 {
0042 Acts::ActsExtension* detWorldExt = new Acts::ActsExtension();
0043 detWorldExt->addType(actsType, "detector");
0044 sdet.addExtension<Acts::ActsExtension>(detWorldExt);
0045 }
0046
0047 if (usePos) {
0048 pos = Position(x_det.position().x(), x_det.position().y(), x_det.position().z());
0049 }
0050 vol = Assembly(det_name);
0051 vol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
0052
0053 Volume mother = description.pickMotherVolume(sdet);
0054 PlacedVolume pv;
0055 if (usePos) {
0056 pv = mother.placeVolume(vol, pos);
0057 } else {
0058 pv = mother.placeVolume(vol);
0059 }
0060 sdet.setPlacement(pv);
0061 for (xml_coll_t c(x_det, _U(composite)); c; ++c) {
0062 xml_dim_t component = c;
0063 const std::string nam = component.nameStr();
0064 description.declareParent(nam, sdet);
0065 }
0066 return sdet;
0067 }
0068
0069 DECLARE_DETELEMENT(athena_CompositeTracker, create_element)