diff --git a/Examples/Scripts/Python/detector_creation.py b/Examples/Scripts/Python/detector_creation.py index 62e5bbe000f..e2f1e5ce3aa 100644 --- a/Examples/Scripts/Python/detector_creation.py +++ b/Examples/Scripts/Python/detector_creation.py @@ -78,7 +78,7 @@ detector, "odd", [[ivol, volumeOptions] for ivol in range(detector.number_volumes())], - [["xy", ["sensitives"], xyRange], ["zr", ["sensitives"], zrRange]], + [["xy", ["sensitives"], xyRange], ["zr", ["materials"], zrRange]], "detector", ) diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp index cbc6d6679c5..ff9b84612b9 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepBlueprintFactory.hpp @@ -37,6 +37,9 @@ class DD4hepBlueprintFactory { struct Config { std::shared_ptr layerStructure = nullptr; + + /// The maximum number of portals to be checked for protal material + unsigned int maxPortals = 8u; }; /// @brief Nested cache object for the detector store diff --git a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp index 56433bc74d2..4c660dd6d5e 100644 --- a/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp +++ b/Plugins/DD4hep/include/Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp @@ -82,9 +82,7 @@ class DD4hepDetectorSurfaceFactory { /// Convert passive surfaces bool convertPassive = true; /// Convert material directly - bool convertMaterial = true; - /// Convert proxy material - overrides convertMaterial if present - bool convertProxyMaterial = true; + bool convertMaterial = false; /// New reference material thickness for surfaces ActsScalar surfaceMaterialThickness = 1_mm; }; @@ -161,6 +159,8 @@ class DD4hepDetectorSurfaceFactory { /// Attach surface material if present /// + /// @param gctx the geometry context + /// @param prefix the acts prefix for the variant parameter string /// @param dd4hepElement the detector element /// @param surface the surface to attach the material to /// @param thickness the thickness of the condensed component @@ -170,7 +170,9 @@ class DD4hepDetectorSurfaceFactory { /// extent of the sensitive surface and register it /// /// @note void function that also checks the options if the attachment should be applied - void attachSurfaceMaterial(const dd4hep::DetElement& dd4hepElement, + void attachSurfaceMaterial(const GeometryContext& gctx, + const std::string& prefix, + const dd4hep::DetElement& dd4hepElement, Acts::Surface& surface, ActsScalar thickness, const Options& options) const; }; diff --git a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp index ce2abd5c683..f185fbcb31c 100644 --- a/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp +++ b/Plugins/DD4hep/src/DD4hepBinningHelpers.cpp @@ -37,11 +37,12 @@ Acts::DD4hepBinningHelpers::convertBinning( Experimental::ProtoBinning(bVal, bType, nBins, nExpansion)); } else { // Equidistant binning + ActsScalar minDefault = bVal == binPhi ? -M_PI : 0.; + ActsScalar maxDefault = bVal == binPhi ? M_PI : 0.; auto min = getParamOr(bname + "_" + ab + "_min", - dd4hepElement, 0.); + dd4hepElement, minDefault); auto max = getParamOr(bname + "_" + ab + "_max", - dd4hepElement, 0.); - + dd4hepElement, maxDefault); // Check for closed phi binning if (bVal == binPhi && (max - min) > 1.9 * M_PI) { bType = Acts::detail::AxisBoundaryType::Closed; diff --git a/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp b/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp index d919e3db6a4..322e0bf1335 100644 --- a/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp +++ b/Plugins/DD4hep/src/DD4hepBlueprintFactory.cpp @@ -111,6 +111,23 @@ void Acts::Experimental::DD4hepBlueprintFactory::recursiveParse( current->rootVolumeFinderBuilder = rootsFinderBuilder; } + // Check for proto material for the portals, max portal number + // can be changed in configuration + for (unsigned int p = 0u; p < m_cfg.maxPortals; ++p) { + std::string pmName = "acts_portal_proto_material_" + std::to_string(p); + auto protoMaterial = getParamOr(pmName, dd4hepElement, false); + if (protoMaterial) { + ACTS_VERBOSE(ofs << " - proto material binning for portal " << p + << " found"); + auto pmProtoBinnings = DD4hepBinningHelpers::convertBinning( + dd4hepElement, pmName + "_binning"); + current->portalMaterialBinning[p] = + BinningDescription{pmProtoBinnings}; + ACTS_VERBOSE(ofs << " - binning description is " + << current->portalMaterialBinning[p].toString()); + } + } + // Adding geo Id generator - if present if (geoIdGenerator != nullptr) { ACTS_VERBOSE(ofs << " - " << auxInt[2u]); @@ -225,6 +242,11 @@ Acts::Experimental::DD4hepBlueprintFactory::extractInternals( // Create a new layer builder DD4hepLayerStructure::Options lOptions; lOptions.name = dd4hepElement.name(); + // Check whether internal/sensitive surfaces should have directly + // translated material + auto convertMaterial = Acts::getParamOr( + "acts_surface_material_conversion", dd4hepElement, false); + lOptions.conversionOptions.convertMaterial = convertMaterial; // Check if the extent should be measured auto interenalsMeasure = Acts::getParamOr( baseName + "_internals_measure", dd4hepElement, ""); diff --git a/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp b/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp index cf0124cd11e..99d55278b21 100644 --- a/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp +++ b/Plugins/DD4hep/src/DD4hepDetectorSurfaceFactory.cpp @@ -9,6 +9,7 @@ #include "Acts/Plugins/DD4hep/DD4hepDetectorSurfaceFactory.hpp" #include "Acts/Definitions/Units.hpp" +#include "Acts/Detector/detail/ProtoMaterialHelper.hpp" #include "Acts/Material/HomogeneousSurfaceMaterial.hpp" #include "Acts/Plugins/DD4hep/DD4hepBinningHelpers.hpp" #include "Acts/Plugins/DD4hep/DD4hepConversionHelpers.hpp" @@ -112,7 +113,8 @@ Acts::DD4hepDetectorSurfaceFactory::constructSensitiveComponents( cache.sExtent.value().extend(sExtent, cache.extentConstraints); } - attachSurfaceMaterial(dd4hepElement, *sSurface.get(), + // Attach surface material if present + attachSurfaceMaterial(gctx, "acts_surface_", dd4hepElement, *sSurface.get(), dd4hepDetElement->thickness(), options); // return the surface return {dd4hepDetElement, sSurface}; @@ -139,15 +141,30 @@ Acts::DD4hepDetectorSurfaceFactory::constructPassiveComponents( .extent(); cache.pExtent.value().extend(sExtent, cache.extentConstraints); } - attachSurfaceMaterial(dd4hepElement, *pSurface.get(), thickness, options); + attachSurfaceMaterial(gctx, "acts_passive_surface", dd4hepElement, + *pSurface.get(), thickness, options); // Return a passive surface return {pSurface, assignToAll}; } void Acts::DD4hepDetectorSurfaceFactory::attachSurfaceMaterial( + const GeometryContext& gctx, const std::string& prefix, const dd4hep::DetElement& dd4hepElement, Acts::Surface& surface, ActsScalar thickness, const Options& options) const { - if (options.convertMaterial) { + // Bool proto material overrules converted material + bool protoMaterial = + getParamOr(prefix + "_proto_material", dd4hepElement, false); + if (protoMaterial) { + ACTS_VERBOSE(" - proto material binning for passive surface found."); + Experimental::BinningDescription pmBinning{ + DD4hepBinningHelpers::convertBinning( + dd4hepElement, prefix + "_proto_material_binning")}; + ACTS_VERBOSE(" - converted binning is " << pmBinning.toString()); + Experimental::detail::ProtoMaterialHelper::attachProtoMaterial( + gctx, surface, pmBinning); + + } else if (options.convertMaterial) { + ACTS_VERBOSE(" - direct conversion of DD4hep material triggered."); // Extract the material const auto& tgeoNode = *(dd4hepElement.placement().ptr()); auto tgeoMaterial = tgeoNode.GetMedium()->GetMaterial(); diff --git a/Tests/UnitTests/Core/Geometry/ExtentTests.cpp b/Tests/UnitTests/Core/Geometry/ExtentTests.cpp index 38d00727829..41abb1860a2 100644 --- a/Tests/UnitTests/Core/Geometry/ExtentTests.cpp +++ b/Tests/UnitTests/Core/Geometry/ExtentTests.cpp @@ -159,6 +159,27 @@ BOOST_AUTO_TEST_CASE(ExtentTest) { BOOST_CHECK(!gExtVertexCheck.contains(Vector3(6., 0., 0.))); } +// Test that the constrains() check advances when the extend() method +// is used with a new binning type +BOOST_AUTO_TEST_CASE(ProtoSupportCaseTests) { + std::vector vertices = { + Vector3(15_mm, -3_mm, -10_mm), Vector3(18_mm, 0_mm, -10_mm), + Vector3(15_mm, 3_mm, -10_mm), Vector3(15_mm, -3_mm, 10_mm), + Vector3(18_mm, 0_mm, 10_mm), Vector3(15_mm, 3_mm, 10_mm)}; + + Extent volumeExtent; + volumeExtent.set(binZ, -300_mm, 300_mm); + + BOOST_CHECK(volumeExtent.constrains(binZ)); + BOOST_CHECK(!volumeExtent.constrains(binR)); + + for (const auto& v : vertices) { + volumeExtent.extend(v, {binR}); + } + + BOOST_CHECK(volumeExtent.constrains(binR)); +} + BOOST_AUTO_TEST_SUITE_END() } // namespace Test