From 87d3c7160e56cd2cd982399d92a38ef0acd241c0 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Mon, 8 Apr 2024 17:07:58 +0200 Subject: [PATCH 1/9] cherry-pick material mapper --- Core/include/Acts/Material/MaterialMapper.hpp | 98 +++++++ Core/src/Material/CMakeLists.txt | 1 + Core/src/Material/MaterialMapper.cpp | 94 +++++++ Tests/UnitTests/Core/Material/CMakeLists.txt | 1 + .../Core/Material/MaterialMapperTests.cpp | 254 ++++++++++++++++++ 5 files changed, 448 insertions(+) create mode 100644 Core/include/Acts/Material/MaterialMapper.hpp create mode 100644 Core/src/Material/MaterialMapper.cpp create mode 100644 Tests/UnitTests/Core/Material/MaterialMapperTests.cpp diff --git a/Core/include/Acts/Material/MaterialMapper.hpp b/Core/include/Acts/Material/MaterialMapper.hpp new file mode 100644 index 00000000000..2428b1385d4 --- /dev/null +++ b/Core/include/Acts/Material/MaterialMapper.hpp @@ -0,0 +1,98 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/MagneticField/MagneticFieldContext.hpp" +#include "Acts/Material/MaterialInteraction.hpp" +#include "Acts/Material/MaterialInteractionAssignment.hpp" +#include "Acts/Material/interface/IAssignmentFinder.hpp" +#include "Acts/Material/interface/ISurfaceMaterialAccumulater.hpp" +#include "Acts/Utilities/Logger.hpp" + +#include +#include +#include + +namespace Acts { +/// @brief material mapping procedure +class MaterialMapper { + public: + /// @brief The material maps + using SurfaceMaterialMaps = + std::map>; + using VolumeMaterialMaps = + std::map>; + using DetectorMaterialMaps = + std::pair; + + /// @brief nested configuration struct + struct Config { + // The assignment finder + std::shared_ptr assignmentFinder = nullptr; + // The material accumulater for surfaces + std::shared_ptr + surfaceMaterialAccumulater = nullptr; + }; + + /// @brief nested state struct + /// + /// It holds the states of the sub structs + struct State { + std::unique_ptr + surfaceMaterialAccumulaterState; + }; + + /// @brief nested options struct + /// holds some options for the delegated calls + struct Options { + // The assignment options (including vetos and re-assignments) + MaterialInteractionAssignment::Options assignmentOptions; + }; + + /// @brief MaterialMapper constructor + /// + /// @param cfg the configuration struct + /// @param mlogger the logger instance + MaterialMapper(const Config& cfg, + std::unique_ptr mlogger = getDefaultLogger( + "BinnedSurfaceMaterialAccumulater", Logging::INFO)); + + /// @brief Factory for creating the state + std::unique_ptr createState() const; + + /// @brief Map the material interactions to the surfaces + /// + /// @param state the state object holding the sub states + /// @param gctx the geometry context + /// @param mctx the magnetic field context + /// @param rmTrack the recorded material track + /// @param options the call options (see above) + /// + /// @return the mapped and unmapped material tracks + std::pair mapMaterial( + State& state, const GeometryContext& gctx, + const MagneticFieldContext& mctx, const RecordedMaterialTrack& rmTrack, + const Options& options = Options{}) const; + + /// Finalize the maps + DetectorMaterialMaps finalizeMaps(const State& state) const; + + private: + /// Access method to the logger + const Logger& logger() const { return *m_logger; } + + /// The configuration + Config m_cfg; + + /// The logger + std::unique_ptr m_logger; +}; + +} // namespace Acts diff --git a/Core/src/Material/CMakeLists.txt b/Core/src/Material/CMakeLists.txt index 5cea3cd49ec..3d18d50c068 100644 --- a/Core/src/Material/CMakeLists.txt +++ b/Core/src/Material/CMakeLists.txt @@ -15,6 +15,7 @@ target_sources( MaterialGridHelper.cpp MaterialInteractionAssignment.cpp MaterialMapUtils.cpp + MaterialMapper.cpp MaterialSlab.cpp ProtoVolumeMaterial.cpp SurfaceMaterialMapper.cpp diff --git a/Core/src/Material/MaterialMapper.cpp b/Core/src/Material/MaterialMapper.cpp new file mode 100644 index 00000000000..c9ca93bfbcc --- /dev/null +++ b/Core/src/Material/MaterialMapper.cpp @@ -0,0 +1,94 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "Acts/Material/MaterialMapper.hpp" + +#include "Acts/Utilities/Enumerate.hpp" + +Acts::MaterialMapper::MaterialMapper(const Config& cfg, + std::unique_ptr mlogger) + : m_cfg(cfg), m_logger(std::move(mlogger)) { + if (m_cfg.assignmentFinder == nullptr) { + throw std::invalid_argument("The assignment finder is not set"); + } + if (m_cfg.surfaceMaterialAccumulater == nullptr) { + throw std::invalid_argument("The surface material accumulater is not set"); + } +} + +std::unique_ptr Acts::MaterialMapper::createState() + const { + // Create the state + auto state = std::make_unique(); + // Create the surface material accumulater state + state->surfaceMaterialAccumulaterState = + m_cfg.surfaceMaterialAccumulater->createState(); + // Return the state object + return state; +} + +std::pair +Acts::MaterialMapper::mapMaterial(State& state, const GeometryContext& gctx, + const MagneticFieldContext& mctx, + const RecordedMaterialTrack& rmTrack, + const Options& options) const { + // The recorded material track + const auto& [starDir, recordedMaterial] = rmTrack; + const auto& [position, direction] = starDir; + auto [surfaceAssignments, volumeAssignments] = + m_cfg.assignmentFinder->assignmentCandidates(gctx, mctx, position, + direction); + + // The mapped and unmapped material + RecordedMaterialTrack mappedMaterial = {starDir, {}}; + RecordedMaterialTrack unmappedMaterial = {starDir, {}}; + // Assign the surface interactions + auto [assigned, unassigned, emptyBinSurfaces] = + MaterialInteractionAssignment::assign( + gctx, recordedMaterial.materialInteractions, surfaceAssignments, + options.assignmentOptions); + + // Record the assigned ones - as mapped ones + mappedMaterial.second.materialInteractions.insert( + mappedMaterial.second.materialInteractions.end(), assigned.begin(), + assigned.end()); + + // Record the unassigned ones - as unmapped ones + unmappedMaterial.second.materialInteractions.insert( + unmappedMaterial.second.materialInteractions.end(), unassigned.begin(), + unassigned.end()); + + // The material interactions + m_cfg.surfaceMaterialAccumulater->accumulate( + *state.surfaceMaterialAccumulaterState.get(), assigned, emptyBinSurfaces); + + // The calculate the total material before returning + auto calculateTotalMaterial = [](RecordedMaterialTrack& rTrack) -> void { + for (const auto& mi : rTrack.second.materialInteractions) { + rTrack.second.materialInX0 += mi.materialSlab.thicknessInX0(); + rTrack.second.materialInL0 += mi.materialSlab.thicknessInL0(); + } + }; + // Fill the totals to the material tracks (useful for debugging) + calculateTotalMaterial(mappedMaterial); + calculateTotalMaterial(unmappedMaterial); + // Return the mapped and unmapped material + return {mappedMaterial, unmappedMaterial}; +} + +Acts::MaterialMapper::DetectorMaterialMaps Acts::MaterialMapper::finalizeMaps( + const State& state) const { + // The final maps + DetectorMaterialMaps detectorMaterialMaps; + // The surface maps + detectorMaterialMaps.first = + m_cfg.surfaceMaterialAccumulater->finalizeMaterial( + *state.surfaceMaterialAccumulaterState.get()); + + return detectorMaterialMaps; +} diff --git a/Tests/UnitTests/Core/Material/CMakeLists.txt b/Tests/UnitTests/Core/Material/CMakeLists.txt index 2f1ac54c46e..89a4a1f82cb 100644 --- a/Tests/UnitTests/Core/Material/CMakeLists.txt +++ b/Tests/UnitTests/Core/Material/CMakeLists.txt @@ -13,6 +13,7 @@ add_unittest(IntersectionMaterialAssigner IntersectionMaterialAssignerTests.cpp) add_unittest(MaterialComposition MaterialCompositionTests.cpp) add_unittest(MaterialGridHelper MaterialGridHelperTests.cpp) add_unittest(MaterialInteractionAssignment MaterialInteractionAssignmentTests.cpp) +add_unittest(MaterialMapper MaterialMapperTests.cpp) add_unittest(MaterialSlab MaterialSlabTests.cpp) add_unittest(Material MaterialTests.cpp) add_unittest(ProtoSurfaceMaterial ProtoSurfaceMaterialTests.cpp) diff --git a/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp new file mode 100644 index 00000000000..98628abe470 --- /dev/null +++ b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp @@ -0,0 +1,254 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include "Acts/Definitions/Algebra.hpp" +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Geometry/GeometryIdentifier.hpp" +#include "Acts/Material/AccumulatedMaterialSlab.hpp" +#include "Acts/Material/HomogeneousSurfaceMaterial.hpp" +#include "Acts/Material/MaterialInteraction.hpp" +#include "Acts/Material/MaterialMapper.hpp" +#include "Acts/Material/MaterialSlab.hpp" +#include "Acts/Material/interface/IAssignmentFinder.hpp" +#include "Acts/Material/interface/ISurfaceMaterialAccumulater.hpp" +#include "Acts/Propagator/SurfaceCollector.hpp" +#include "Acts/Surfaces/CylinderSurface.hpp" +#include "Acts/Utilities/Enumerate.hpp" +#include "Acts/Utilities/VectorHelpers.hpp" + +#include + +namespace Acts::Test { + +auto tContext = GeometryContext(); + +/// @brief Interface for the material mapping that seeks the possible +/// assignment candidates for the material interactiosn +class IntersectSurfacesFinder : public IAssignmentFinder { + public: + std::vector surfaces; + + /// @brief Interface method for generating assignment candidates for the + /// material interaction assignment to surfaces or volumes + /// + /// @param gctx is the geometry context + /// @param mctx is the magnetic field context + /// @param position is the position of the initial ray + /// @param direction is the direction of initial ray + /// + /// @return a vector of Surface Assignments and Volume Assignments + std::pair, + std::vector> + assignmentCandidates(const GeometryContext& gctx, + const MagneticFieldContext& /*ignored*/, + const Vector3& position, + const Vector3& direction) const override { + std::vector surfaceAssignments; + std::vector volumeAssignments; + // Intersect the surfaces + for (auto& surface : surfaces) { + // Get the intersection + auto sMultiIntersection = surface->intersect(gctx, position, direction, + Acts::BoundaryCheck(true)); + // One solution, take it + if (sMultiIntersection.size() == 1u && + sMultiIntersection[0u].status() >= + Acts::IntersectionStatus::reachable && + sMultiIntersection[0u].pathLength() >= 0.0) { + surfaceAssignments.push_back( + {surface, sMultiIntersection[0u].position(), direction}); + continue; + } + if (sMultiIntersection.size() > 1u) { + // Multiple intersections, take the closest + auto closestForward = sMultiIntersection.closestForward(); + if (closestForward.status() >= Acts::IntersectionStatus::reachable && + closestForward.pathLength() > 0.0) { + surfaceAssignments.push_back( + {surface, closestForward.position(), direction}); + continue; + } + } + } + return {surfaceAssignments, volumeAssignments}; + } +}; + +/// @brief Interface for the material mapping, this is the accumulation step +class MaterialBlender : public ISurfaceMaterialAccumulater { + public: + MaterialBlender(const std::vector>& surfaces = {}) + : m_surfaces(surfaces) {} + + /// The state of the material accumulater, this is used + /// to cache information across tracks/events + class State final : public ISurfaceMaterialAccumulater::State { + public: + std::map accumulatedMaterial; + }; + + /// Factory for creating the state + std::unique_ptr createState() + const override { + auto state = std::make_unique(); + for (auto& surface : m_surfaces) { + state->accumulatedMaterial[surface.get()] = AccumulatedMaterialSlab(); + } + return state; + }; + + /// @brief Accumulate the material interaction on the surface + /// + /// @param state is the state of the accumulater + /// @param interactions is the material interactions, with assigned surfaces + /// @param surfacesWithoutAssignment are the surfaces without assignment + /// + /// @note this the track average over the binned material + void accumulate(ISurfaceMaterialAccumulater::State& state, + const std::vector& interactions, + const std::vector& + /*surfacesWithoutAssignment*/) const override { + auto cState = static_cast(&state); + for (const auto& mi : interactions) { + // Get the surface + const Surface* surface = mi.surface; + // Get the accumulated material + auto accMaterial = cState->accumulatedMaterial.find(surface); + if (accMaterial == cState->accumulatedMaterial.end()) { + throw std::invalid_argument( + "Surface material is not found, inconsistent configuration."); + } + // Accumulate the material + accMaterial->second.accumulate(mi.materialSlab); + } + // Average over the track + for (auto& [surface, accumulatedMaterial] : cState->accumulatedMaterial) { + accumulatedMaterial.trackAverage(); + } + }; + + /// Finalize the surface material maps + /// + /// @param state the state of the accumulator + /// + /// @note this does the run average over the (binned) material + virtual std::map> + finalizeMaterial(ISurfaceMaterialAccumulater::State& state) const override { + auto cState = static_cast(&state); + + std::map> + materialMaps; + for (auto& [surface, accumulatedMaterial] : cState->accumulatedMaterial) { + materialMaps[surface->geometryId()] = + std::make_shared( + accumulatedMaterial.totalAverage().first); + } + return materialMaps; + } + + private: + std::vector> m_surfaces; +}; + +BOOST_AUTO_TEST_SUITE(MaterialMapperTestSuite) + +/// @brief This test checks the data flow of the material mapper, it is not +/// a test of the single components, which are tested individually +/// +/// @note Currently only surface mapping is implemented, volume mapping/assigning +/// is being added in future PRs +BOOST_AUTO_TEST_CASE(MaterialMapperFlowTest) { + // Create a vector of surfaces + std::vector> surfaces = { + Surface::makeShared(Transform3::Identity(), 20.0, 100.0), + Surface::makeShared(Transform3::Identity(), 30.0, 100.0), + Surface::makeShared(Transform3::Identity(), 50.0, + 100.0)}; + + for (auto [is, surface] : enumerate(surfaces)) { + surface->assignGeometryId(GeometryIdentifier().setSensitive(is + 1)); + } + + // The assigner + auto assigner = std::make_shared(); + assigner->surfaces = {surfaces[0].get(), surfaces[1].get(), + surfaces[2].get()}; + + // The accumulater - which blends all the material + auto accumulator = std::make_shared(surfaces); + + // Create the mapper + MaterialMapper::Config mmConfig; + mmConfig.assignmentFinder = assigner; + mmConfig.surfaceMaterialAccumulater = accumulator; + + MaterialMapper mapper(mmConfig); + + auto state = mapper.createState(); + BOOST_CHECK(state.get() != nullptr); + BOOST_CHECK(state->surfaceMaterialAccumulaterState.get() != nullptr); + + std::vector mappedTracks; + std::vector unmappedTracks; + + // Track loop + Vector3 position(0., 0., 0.); + for (unsigned int it = 0; it < 11; ++it) { + Vector3 direction = + Vector3(0.9 + it * 0.02, 1.1 - it * 0.02, 0.).normalized(); + RecordedMaterialTrack mTrack{{position, direction}, {}}; + for (unsigned int im = 0; im < 60; ++im) { + MaterialInteraction mi; + mi.materialSlab = MaterialSlab( + Material::fromMassDensity(it + 1, it + 1, it + 1, it + 1, it + 1), + 0.1); + mi.position = position + (im + 1) * direction; + mi.direction = direction; + mTrack.second.materialInteractions.push_back(mi); + } + auto [mapped, unmapped] = mapper.mapMaterial(*state, tContext, {}, mTrack); + mappedTracks.push_back(mapped); + unmappedTracks.push_back(unmapped); + } + + // Get the maps + auto [surfaceMaps, volumeMaps] = mapper.finalizeMaps(*state); + + BOOST_CHECK(surfaceMaps.size() == 3); + BOOST_CHECK(volumeMaps.size() == 0); +} + +BOOST_AUTO_TEST_CASE(MaterialMapperInvalidTest) { + // The assigner + auto assigner = std::make_shared(); + + // The accumulater - which blends all the material + auto accumulator = std::make_shared(); + + // Create the mapper + MaterialMapper::Config mmConfigInvalid; + mmConfigInvalid.assignmentFinder = nullptr; + mmConfigInvalid.surfaceMaterialAccumulater = accumulator; + + BOOST_CHECK_THROW(auto mapperIA = MaterialMapper(mmConfigInvalid), + std::invalid_argument); + + // BOOST_CHECK_THROW(MaterialMapper(mmConfigInvalid), std::invalid_argument); + + mmConfigInvalid.assignmentFinder = assigner; + mmConfigInvalid.surfaceMaterialAccumulater = nullptr; + + BOOST_CHECK_THROW(auto mapperIS = MaterialMapper(mmConfigInvalid), + std::invalid_argument); +} + +BOOST_AUTO_TEST_SUITE_END() + +} // namespace Acts::Test From 1b8df11f2414c908f6fe41c08e0dbb54ac3fb00e Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Tue, 9 Apr 2024 09:24:41 +0200 Subject: [PATCH 2/9] clang-format fix --- Tests/UnitTests/Core/Material/MaterialMapperTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp index 98628abe470..32e65798afe 100644 --- a/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp +++ b/Tests/UnitTests/Core/Material/MaterialMapperTests.cpp @@ -139,7 +139,7 @@ class MaterialBlender : public ISurfaceMaterialAccumulater { /// @param state the state of the accumulator /// /// @note this does the run average over the (binned) material - virtual std::map> + std::map> finalizeMaterial(ISurfaceMaterialAccumulater::State& state) const override { auto cState = static_cast(&state); @@ -222,7 +222,7 @@ BOOST_AUTO_TEST_CASE(MaterialMapperFlowTest) { auto [surfaceMaps, volumeMaps] = mapper.finalizeMaps(*state); BOOST_CHECK(surfaceMaps.size() == 3); - BOOST_CHECK(volumeMaps.size() == 0); + BOOST_CHECK(volumeMaps.empty()); } BOOST_AUTO_TEST_CASE(MaterialMapperInvalidTest) { From c152b49be1bc006c3f1d091215e7abf9b33066ac Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Wed, 10 Apr 2024 14:19:54 +0200 Subject: [PATCH 3/9] adding first core setup --- .../Material/IntersectionMaterialAssigner.hpp | 15 +- .../Material/IntersectionMaterialAssigner.cpp | 7 + .../Algorithms/MaterialMapping/CMakeLists.txt | 3 +- .../MaterialMapping/CoreMaterialMapping.hpp | 89 ++++++++ .../src/CoreMaterialMapping.cpp | 81 ++++++++ Examples/Python/src/Geometry.cpp | 30 ++- Examples/Python/src/Material.cpp | 110 ++++++++++ .../Scripts/Python/material_mapping_core.py | 191 ++++++++++++++++++ .../Scripts/Python/material_validation.py | 38 +++- 9 files changed, 554 insertions(+), 10 deletions(-) create mode 100644 Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp create mode 100644 Examples/Algorithms/MaterialMapping/src/CoreMaterialMapping.cpp create mode 100644 Examples/Scripts/Python/material_mapping_core.py diff --git a/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp b/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp index aafe9f705ca..408b1a54acd 100644 --- a/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp +++ b/Core/include/Acts/Material/IntersectionMaterialAssigner.hpp @@ -44,7 +44,14 @@ class IntersectionMaterialAssigner final : public IAssignmentFinder { }; /// @brief Construct with the configuration - IntersectionMaterialAssigner(const Config& cfg) : m_cfg(cfg) {} + /// + /// @param cfg is the configuration struct + /// @param mlogger is the logger + IntersectionMaterialAssigner( + const Config& cfg, + std::unique_ptr mlogger = + getDefaultLogger("IntersectionMaterialAssigner", Logging::INFO)) + : m_cfg(cfg), m_logger(std::move(mlogger)) {} /// @brief Method for generating assignment candidates for the /// material interaction assignment to surfaces or volumes @@ -63,8 +70,14 @@ class IntersectionMaterialAssigner final : public IAssignmentFinder { const Vector3& direction) const final; private: + /// Access method to the logger + const Logger& logger() const { return *m_logger; } + /// The configuration Config m_cfg; + + /// The logger + std::unique_ptr m_logger; }; } // namespace Acts diff --git a/Core/src/Material/IntersectionMaterialAssigner.cpp b/Core/src/Material/IntersectionMaterialAssigner.cpp index c1007135363..01b8a95cd3b 100644 --- a/Core/src/Material/IntersectionMaterialAssigner.cpp +++ b/Core/src/Material/IntersectionMaterialAssigner.cpp @@ -10,6 +10,7 @@ #include "Acts/Surfaces/BoundaryCheck.hpp" #include "Acts/Surfaces/Surface.hpp" +#include "Acts/Utilities/StringHelpers.hpp" namespace { @@ -51,6 +52,9 @@ Acts::IntersectionMaterialAssigner::assignmentCandidates( std::vector> candidates; + ACTS_DEBUG("Finding material assignment from position " + << toString(position) << " and direction " << toString(direction)); + // Try the surfaces first auto sIntersections = forwardOrderedIntersections(gctx, position, direction, m_cfg.surfaces); @@ -102,6 +106,9 @@ Acts::IntersectionMaterialAssigner::assignmentCandidates( } } + ACTS_DEBUG("Found " << candidates.first.size() << " surface candidates and " + << candidates.second.size() << " volume candidates"); + // Return the result return candidates; } diff --git a/Examples/Algorithms/MaterialMapping/CMakeLists.txt b/Examples/Algorithms/MaterialMapping/CMakeLists.txt index ce7fde4be46..f5d887955e5 100644 --- a/Examples/Algorithms/MaterialMapping/CMakeLists.txt +++ b/Examples/Algorithms/MaterialMapping/CMakeLists.txt @@ -1,6 +1,7 @@ add_library( ActsExamplesMaterialMapping SHARED - src/MaterialMapping.cpp) + src/MaterialMapping.cpp + src/CoreMaterialMapping.cpp) target_include_directories( ActsExamplesMaterialMapping PUBLIC $) diff --git a/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp new file mode 100644 index 00000000000..9233f67ad5b --- /dev/null +++ b/Examples/Algorithms/MaterialMapping/include/ActsExamples/MaterialMapping/CoreMaterialMapping.hpp @@ -0,0 +1,89 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2024 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#pragma once + +#include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/Material/MaterialMapper.hpp" +#include "Acts/Utilities/Logger.hpp" +#include "ActsExamples/Framework/DataHandle.hpp" +#include "ActsExamples/Framework/IAlgorithm.hpp" +#include "ActsExamples/Framework/ProcessCode.hpp" +#include "ActsExamples/MaterialMapping/IMaterialWriter.hpp" + +namespace ActsExamples { + +/// @class CoreMaterialMapping +/// +/// @brief Initiates and executes material mapping using the MaterialMapper +/// from the core component of ACTS +/// +/// By construction, the material mapping needs inter-event information +/// to build the material maps of accumulated single particle views. +/// However, running it in one single event, puts enormous pressure onto +/// the I/O structure. +/// +/// It therefore saves the mapping state/cache as a private member variable +/// and is designed to be executed in a single threaded mode. +class CoreMaterialMapping : public IAlgorithm { + public: + /// @class nested Config class + /// of the MaterialMapping algorithm + struct Config { + /// Input collection + std::string inputMaterialTracks = "material_tracks"; + + /// The actually mapped material tracks + std::string mappedMaterialTracks = "mapped_material_tracks"; + + /// Theunmapped part of the material tracks + std::string unmappedMaterialTracks = "unmapped_material_tracks"; + + /// The ACTS material mapper from the core component + std::shared_ptr materialMapper = nullptr; + + /// The writer of the material + std::vector> materiaMaplWriters{}; + }; + + /// Constructor + /// + /// @param cfg The configuration struct carrying the used tools + /// @param level The output logging level + CoreMaterialMapping(const Config& cfg, + Acts::Logging::Level level = Acts::Logging::INFO); + + /// Destructor + /// - it also writes out the file + ~CoreMaterialMapping() override; + + /// Framework execute method + /// + /// @param context The algorithm context for event consistency + ActsExamples::ProcessCode execute( + const AlgorithmContext& context) const override; + + /// Readonly access to the config + const Config& config() const { return m_cfg; } + + private: + Config m_cfg; //!< internal config object + + std::unique_ptr m_mappingState{nullptr}; + + ReadDataHandle> + m_inputMaterialTracks{this, "InputMaterialTracks"}; + + WriteDataHandle> + m_outputMappedMaterialTracks{this, "OutputMappedMaterialTracks"}; + + WriteDataHandle> + m_outputUnmappedMaterialTracks{this, "OutputUnmappedMaterialTracks"}; +}; + +} // namespace ActsExamples diff --git a/Examples/Algorithms/MaterialMapping/src/CoreMaterialMapping.cpp b/Examples/Algorithms/MaterialMapping/src/CoreMaterialMapping.cpp new file mode 100644 index 00000000000..b8d4e5df30d --- /dev/null +++ b/Examples/Algorithms/MaterialMapping/src/CoreMaterialMapping.cpp @@ -0,0 +1,81 @@ +// This file is part of the Acts project. +// +// Copyright (C) 2017-2020 CERN for the benefit of the Acts project +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "ActsExamples/MaterialMapping/CoreMaterialMapping.hpp" + +#include "Acts/Material/AccumulatedMaterialSlab.hpp" +#include "Acts/Material/AccumulatedSurfaceMaterial.hpp" +#include "ActsExamples/MaterialMapping/IMaterialWriter.hpp" + +#include +#include + +namespace ActsExamples { + +CoreMaterialMapping::CoreMaterialMapping(const CoreMaterialMapping::Config& cfg, + Acts::Logging::Level level) + : IAlgorithm("CoreMaterialMapping", level), m_cfg(cfg) { + // Prepare the I/O collections + m_inputMaterialTracks.initialize(m_cfg.inputMaterialTracks); + m_outputMappedMaterialTracks.initialize(m_cfg.mappedMaterialTracks); + m_outputUnmappedMaterialTracks.initialize(m_cfg.unmappedMaterialTracks); + + ACTS_INFO("This algorithm requires inter-event information, " + << "run in single-threaded mode!"); + + if (m_cfg.materialMapper == nullptr) { + throw std::invalid_argument("Missing material mapper"); + } + // Create the state object + m_mappingState = m_cfg.materialMapper->createState(); +} + +CoreMaterialMapping::~CoreMaterialMapping() { + Acts::DetectorMaterialMaps detectorMaterial = + m_cfg.materialMapper->finalizeMaps(*m_mappingState); + // Loop over the available writers and write the maps + for (auto& imw : m_cfg.materiaMaplWriters) { + imw->writeMaterial(detectorMaterial); + } +} + +ProcessCode CoreMaterialMapping::execute( + const AlgorithmContext& context) const { + // Take the collection from the EventStore: input collection + std::unordered_map + mtrackCollection = m_inputMaterialTracks(context); + + // Write the output collections to the Event store : mapped and unmapped + std::unordered_map + mappedTrackCollection; + + std::unordered_map + unmappedTrackCollection; + + // To make it work with the framework needs a lock guard + auto mappingState = + const_cast(m_mappingState.get()); + + for (auto& [idTrack, mTrack] : mtrackCollection) { + auto [mapped, unmapped] = m_cfg.materialMapper->mapMaterial( + *mappingState, context.geoContext, context.magFieldContext, mTrack); + + mappedTrackCollection.emplace_hint(mappedTrackCollection.end(), idTrack, + mapped); + unmappedTrackCollection.emplace_hint(unmappedTrackCollection.end(), idTrack, + unmapped); + } + + // Write the mapped and unmapped material tracks to the output + m_outputMappedMaterialTracks(context, std::move(mappedTrackCollection)); + m_outputUnmappedMaterialTracks(context, std::move(unmappedTrackCollection)); + + return ProcessCode::SUCCESS; +} + +} // namespace ActsExamples diff --git a/Examples/Python/src/Geometry.cpp b/Examples/Python/src/Geometry.cpp index a50ff68efc6..57d128447d1 100644 --- a/Examples/Python/src/Geometry.cpp +++ b/Examples/Python/src/Geometry.cpp @@ -59,6 +59,21 @@ struct GeometryIdentifierHookBinding : public Acts::GeometryIdentifierHook { .cast(); } }; + +struct MaterialSurfaceSelector { + std::vector surfaces = {}; + + /// @param surface is the test surface + void operator()(const Acts::Surface* surface) { + if (surface->surfaceMaterial() != nullptr) { + if (std::find(surfaces.begin(), surfaces.end(), surface) == + surfaces.end()) { + surfaces.push_back(surface); + } + } + } +}; + } // namespace namespace Acts::Python { @@ -126,6 +141,12 @@ void addGeometry(Context& ctx) { [](Acts::TrackingGeometry& self, py::function& func) { self.visitSurfaces(func); }) + .def("extractMaterialSurfaces", + [](Acts::TrackingGeometry& self) { + MaterialSurfaceSelector selector; + self.visitSurfaces(selector, false); + return selector.surfaces; + }) .def_property_readonly( "worldVolume", &Acts::TrackingGeometry::highestTrackingVolumeShared); @@ -190,8 +211,13 @@ void addExperimentalGeometry(Context& ctx) { // Detector definition py::class_>(m, "Detector") - .def("number_volumes", - [](Detector& self) { return self.volumes().size(); }); + .def("numberVolumes", + [](Detector& self) { return self.volumes().size(); }) + .def("extractMaterialSurfaces", [](Detector& self) { + MaterialSurfaceSelector selector; + self.visitSurfaces(selector); + return selector.surfaces; + }); // Portal definition py::class_>(m, "Portal"); diff --git a/Examples/Python/src/Material.cpp b/Examples/Python/src/Material.cpp index cdabe0ff2c0..2aad1af3478 100644 --- a/Examples/Python/src/Material.cpp +++ b/Examples/Python/src/Material.cpp @@ -8,13 +8,18 @@ #include "Acts/Geometry/GeometryContext.hpp" #include "Acts/MagneticField/MagneticFieldContext.hpp" +#include "Acts/Material/BinnedSurfaceMaterialAccumulater.hpp" #include "Acts/Material/IMaterialDecorator.hpp" +#include "Acts/Material/IntersectionMaterialAssigner.hpp" +#include "Acts/Material/MaterialMapper.hpp" +#include "Acts/Material/PropagatorMaterialAssigner.hpp" #include "Acts/Material/SurfaceMaterialMapper.hpp" #include "Acts/Material/VolumeMaterialMapper.hpp" #include "Acts/Plugins/Python/Utilities.hpp" #include "Acts/Utilities/Logger.hpp" #include "ActsExamples/Framework/ProcessCode.hpp" #include "ActsExamples/Io/Root/RootMaterialDecorator.hpp" +#include "ActsExamples/MaterialMapping/CoreMaterialMapping.hpp" #include "ActsExamples/MaterialMapping/MappingMaterialDecorator.hpp" #include "ActsExamples/MaterialMapping/MaterialMapping.hpp" @@ -164,5 +169,110 @@ void addMaterial(Context& ctx) { ACTS_PYTHON_MEMBER(mappingStep); ACTS_PYTHON_STRUCT_END(); } + + { + py::class_>(m, + "IAssignmentFinder"); + } + + { + auto isma = + py::class_>( + m, "IntersectionMaterialAssigner") + .def(py::init([](const Acts::IntersectionMaterialAssigner::Config& + config, + Acts::Logging::Level level) { + return std::make_shared( + config, + getDefaultLogger("IntersectionMaterialAssigner", level)); + }), + py::arg("config"), py::arg("level")) + .def("assignmentCandidates", + &Acts::IntersectionMaterialAssigner::assignmentCandidates); + + auto c = + py::class_(isma, "Config") + .def(py::init<>()); + ACTS_PYTHON_STRUCT_BEGIN(c, Acts::IntersectionMaterialAssigner::Config); + ACTS_PYTHON_MEMBER(surfaces); + ACTS_PYTHON_MEMBER(trackingVolumes); + ACTS_PYTHON_MEMBER(detectorVolumes); + ACTS_PYTHON_STRUCT_END(); + } + + { + py::class_>( + m, "ISurfaceMaterialAccumulater"); + } + + { + auto bsma = + py::class_>( + m, "BinnedSurfaceMaterialAccumulater") + .def( + py::init( + [](const BinnedSurfaceMaterialAccumulater::Config& config, + Acts::Logging::Level level) { + return std::make_shared( + config, + getDefaultLogger("BinnedSurfaceMaterialAccumulater", + level)); + }), + py::arg("config"), py::arg("level")) + .def("createState", &BinnedSurfaceMaterialAccumulater::createState) + .def("accumulate", &BinnedSurfaceMaterialAccumulater::accumulate) + .def("finalizeMaterial", + &BinnedSurfaceMaterialAccumulater::finalizeMaterial); + + auto c = + py::class_(bsma, "Config") + .def(py::init<>()); + ACTS_PYTHON_STRUCT_BEGIN(c, BinnedSurfaceMaterialAccumulater::Config); + ACTS_PYTHON_MEMBER(emptyBinCorrection); + ACTS_PYTHON_MEMBER(materialSurfaces); + ACTS_PYTHON_STRUCT_END(); + } + + { + auto mm = py::class_>( + m, "MaterialMapper") + .def(py::init([](const MaterialMapper::Config& config, + Acts::Logging::Level level) { + return std::make_shared( + config, getDefaultLogger("MaterialMapper", level)); + }), + py::arg("config"), py::arg("level")); + + auto c = py::class_(mm, "Config").def(py::init<>()); + ACTS_PYTHON_STRUCT_BEGIN(c, MaterialMapper::Config); + ACTS_PYTHON_MEMBER(assignmentFinder); + ACTS_PYTHON_MEMBER(surfaceMaterialAccumulater); + ACTS_PYTHON_STRUCT_END(); + } + + { + auto mmca = py::class_>( + mex, "CoreMaterialMapping") + .def(py::init(), + py::arg("config"), py::arg("level")); + + auto c = py::class_(mmca, "Config") + .def(py::init<>()); + ACTS_PYTHON_STRUCT_BEGIN(c, CoreMaterialMapping::Config); + ACTS_PYTHON_MEMBER(inputMaterialTracks); + ACTS_PYTHON_MEMBER(mappedMaterialTracks); + ACTS_PYTHON_MEMBER(unmappedMaterialTracks); + ACTS_PYTHON_MEMBER(materialMapper); + ACTS_PYTHON_MEMBER(materiaMaplWriters); + ACTS_PYTHON_STRUCT_END(); + } } + } // namespace Acts::Python diff --git a/Examples/Scripts/Python/material_mapping_core.py b/Examples/Scripts/Python/material_mapping_core.py new file mode 100644 index 00000000000..2dd0bb78860 --- /dev/null +++ b/Examples/Scripts/Python/material_mapping_core.py @@ -0,0 +1,191 @@ +#!/usr/bin/env python3 + +import os +import argparse + +import acts +from acts import ( + MaterialMapper, + IntersectionMaterialAssigner, + BinnedSurfaceMaterialAccumulater, + MaterialMapJsonConverter, +) + +from acts.examples import ( + Sequencer, + WhiteBoard, + AlgorithmContext, + ProcessCode, + RootMaterialTrackReader, + RootMaterialTrackWriter, + CoreMaterialMapping, + JsonMaterialWriter, + RootMaterialWriter, + JsonFormat, +) + +from acts.examples.dd4hep import ( + DD4hepDetector, + DD4hepDetectorOptions, + DD4hepGeometryService, +) + +from acts.examples.odd import getOpenDataDetector, getOpenDataDetectorDirectory + + +def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): + + # Create a sequencer + print("Creating the sequencer with 1 thread (accross event information needed)") + + s = Sequencer(numThreads=1) + + # IO for material tracks reading + wb = WhiteBoard(acts.logging.INFO) + + # Read material step information from a ROOT TTRee + s.addReader( + RootMaterialTrackReader( + level=acts.logging.INFO, + outputMaterialTracks="material-tracks", + fileList=[inputFile], + readCachedSurfaceInformation=False, + ) + ) + + # Assignment setup : Intersection assigner + materialAssingerConfig = IntersectionMaterialAssigner.Config() + materialAssingerConfig.surfaces = surfaces + materialAssinger = IntersectionMaterialAssigner(materialAssingerConfig, loglevel) + + # Accumulation setup : Binned surface material accumulater + materialAccumulaterConfig = BinnedSurfaceMaterialAccumulater.Config() + materialAccumulaterConfig.materialSurfaces = surfaces + materialAccumulater = BinnedSurfaceMaterialAccumulater( + materialAccumulaterConfig, loglevel + ) + + # Mapper setup + materialMapperConfig = MaterialMapper.Config() + materialMapperConfig.assignmentFinder = materialAssinger + materialMapperConfig.surfaceMaterialAccumulater = materialAccumulater + materialMapper = MaterialMapper(materialMapperConfig, loglevel) + + # Add the map writer(s) + mapWriters = [] + # json map writer + context = AlgorithmContext(0, 0, wb) + jmConverterCfg = MaterialMapJsonConverter.Config( + processSensitives=True, + processApproaches=True, + processRepresenting=True, + processBoundaries=True, + processVolumes=True, + context=context.geoContext, + ) + mapWriters.append( + JsonMaterialWriter( + level=loglevel, + converterCfg=jmConverterCfg, + fileName=outputMap + "", + writeFormat=JsonFormat.Json, + ) + ) + mapWriters.append(RootMaterialWriter(level=loglevel, filePath=outputMap + ".root")) + + # Mapping Algorithm + coreMaterialMappingConfig = CoreMaterialMapping.Config() + coreMaterialMappingConfig.materialMapper = materialMapper + coreMaterialMappingConfig.inputMaterialTracks = "material-tracks" + coreMaterialMappingConfig.mappedMaterialTracks = "mapped-material-tracks" + coreMaterialMappingConfig.unmappedMaterialTracks = "unmapped-material-tracks" + coreMaterialMappingConfig.materiaMaplWriters = mapWriters + coreMaterialMapping = CoreMaterialMapping(coreMaterialMappingConfig, loglevel) + s.addAlgorithm(coreMaterialMapping) + + # Add the mapped material tracks writer + s.addWriter( + RootMaterialTrackWriter( + level=acts.logging.INFO, + inputMaterialTracks="mapped-material-tracks", + filePath=outputFile + "_mapped.root", + storeSurface=True, + storeVolume=True, + ) + ) + + # Add the unmapped material tracks writer + s.addWriter( + RootMaterialTrackWriter( + level=acts.logging.INFO, + inputMaterialTracks="unmapped-material-tracks", + filePath=outputFile + "_unmapped.root", + storeSurface=True, + storeVolume=True, + ) + ) + + return s + + +if "__main__" == __name__: + p = argparse.ArgumentParser() + + p.add_argument( + "-n", "--events", type=int, default=1000, help="Number of events to process" + ) + p.add_argument( + "-i", "--input", type=str, default="", help="Input file with material tracks" + ) + p.add_argument( + "-o", "--output", type=str, default="", help="Output file (core) name" + ) + p.add_argument( + "-m", "--map", type=str, default="", help="Output file for the material map" + ) + + p.add_argument( + "--matconfig", type=str, default="", help="Material configuration file" + ) + + p.add_argument( + "--experimental", + action=argparse.BooleanOptionalAction, + help="Construct experimental geometry", + ) + + args = p.parse_args() + + if args.experimental: + + odd_xml = getOpenDataDetectorDirectory() / "xml" / "OpenDataDetector.xml" + + # Create the dd4hep geometry service and detector + dd4hepConfig = DD4hepGeometryService.Config() + dd4hepConfig.logLevel = acts.logging.INFO + dd4hepConfig.xmlFileNames = [str(odd_xml)] + dd4hepGeometryService = DD4hepGeometryService(dd4hepConfig) + dd4hepDetector = DD4hepDetector(dd4hepGeometryService) + + cOptions = DD4hepDetectorOptions(logLevel=acts.logging.INFO, emulateToGraph="") + + # Context and options + geoContext = acts.GeometryContext() + [detector, contextors, store] = dd4hepDetector.finalize(geoContext, cOptions) + + materialSurfaces = detector.extractMaterialSurfaces() + print("Extracted number of material surfaces: ", len(materialSurfaces)) + + else: + matDeco = None + if args.matconfig != "": + matDeco = acts.IMaterialDecorator.fromFile(args.matconfig) + + [detector, trackingGeometry, decorators] = getOpenDataDetector(matDeco) + + materialSurfaces = trackingGeometry.extractMaterialSurfaces() + print("Extracted number of material surfaces: ", len(materialSurfaces)) + + runMaterialMapping( + materialSurfaces, args.input, args.output, args.map, acts.logging.INFO + ).run() diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index 3234471fdb0..51a7ea2f42e 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 import os +import argparse import acts from acts import ( @@ -11,14 +12,17 @@ def runMaterialValidation( + nevents, + ntracks, trackingGeometry, decorators, field, outputDir, outputName="propagation-material", - s=None, ): - s = s or Sequencer(events=1000, numThreads=-1) + + # Create a sequencer + s = Sequencer(events=nevents, numThreads=-1) for decorator in decorators: s.addContextDecorator(decorator) @@ -36,7 +40,7 @@ def runMaterialValidation( propagatorImpl=prop, level=acts.logging.INFO, randomNumberSvc=rnd, - ntests=1000, + ntests=ntracks, sterileLogger=True, propagationStepCollection="propagation-steps", recordMaterialInteractions=True, @@ -60,12 +64,34 @@ def runMaterialValidation( if "__main__" == __name__: - matDeco = acts.IMaterialDecorator.fromFile("material-map.json") + + p = argparse.ArgumentParser() + + p.add_argument( + "-n", "--events", type=int, default=1000, help="Number of events to process" + ) + p.add_argument( + "-t", "--tracks", type=int, default=100, help="Number of tracks per event" + ) + p.add_argument( + "-m", "--map", type=str, default="", help="Input file for the material map" + ) + p.add_argument("-o", "--output", type=str, default="", help="Output file name") + + args = p.parse_args() + + matDeco = acts.IMaterialDecorator.fromFile(args.map) detector, trackingGeometry, decorators = getOpenDataDetector(mdecorator=matDeco) - field = acts.ConstantBField(acts.Vector3(0, 0, 2 * acts.UnitConstants.T)) + field = acts.ConstantBField(acts.Vector3(0, 0, 0 * acts.UnitConstants.T)) runMaterialValidation( - trackingGeometry, decorators, field, outputDir=os.getcwd() + args.events, + args.tracks, + trackingGeometry, + decorators, + field, + outputDir=os.getcwd(), + outputName=args.output, ).run() From 55a0d8d3295fad29b4b352b42dfbfa66a9d0c3c8 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Wed, 10 Apr 2024 21:25:31 +0200 Subject: [PATCH 4/9] Update MaterialMapper.cpp --- Core/src/Material/MaterialMapper.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Core/src/Material/MaterialMapper.cpp b/Core/src/Material/MaterialMapper.cpp index c9ac92a6cc4..1a490a16c18 100644 --- a/Core/src/Material/MaterialMapper.cpp +++ b/Core/src/Material/MaterialMapper.cpp @@ -66,7 +66,6 @@ Acts::MaterialMapper::mapMaterial(State& state, const GeometryContext& gctx, *state.surfaceMaterialAccumulaterState.get(), assigned, emptyBinSurfaces); // The function to calculate the total material before returning - auto calculateTotalMaterial = [](RecordedMaterialTrack& rTrack) -> void { for (const auto& mi : rTrack.second.materialInteractions) { rTrack.second.materialInX0 += mi.materialSlab.thicknessInX0(); From 77e0c089717d29b87ea26458fd4f0568b8e97459 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Wed, 10 Apr 2024 21:28:07 +0200 Subject: [PATCH 5/9] Update material_mapping_core.py --- Examples/Scripts/Python/material_mapping_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/Scripts/Python/material_mapping_core.py b/Examples/Scripts/Python/material_mapping_core.py index 2dd0bb78860..c40d013934e 100644 --- a/Examples/Scripts/Python/material_mapping_core.py +++ b/Examples/Scripts/Python/material_mapping_core.py @@ -36,7 +36,7 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): # Create a sequencer - print("Creating the sequencer with 1 thread (accross event information needed)") + print("Creating the sequencer with 1 thread (inter event information needed)") s = Sequencer(numThreads=1) From 515f288d52d42fcf359a2c2641afebbde5fb4785 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 11 Apr 2024 08:44:27 +0200 Subject: [PATCH 6/9] fix missing keyword argument --- Examples/Scripts/Python/material_validation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index 51a7ea2f42e..13ecab352b6 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -19,10 +19,11 @@ def runMaterialValidation( field, outputDir, outputName="propagation-material", + s=None, ): # Create a sequencer - s = Sequencer(events=nevents, numThreads=-1) + s = s or Sequencer(events=nevents, numThreads=-1) for decorator in decorators: s.addContextDecorator(decorator) From 3f400c520be2398112e4fc3b459548e0d994feab Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 11 Apr 2024 09:08:16 +0200 Subject: [PATCH 7/9] update keyword arguments --- Examples/Scripts/Python/material_validation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index 13ecab352b6..86ba6f3d5e7 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -12,12 +12,12 @@ def runMaterialValidation( - nevents, - ntracks, trackingGeometry, decorators, field, outputDir, + nevents=1000, + ntracks=100, outputName="propagation-material", s=None, ): @@ -88,11 +88,11 @@ def runMaterialValidation( field = acts.ConstantBField(acts.Vector3(0, 0, 0 * acts.UnitConstants.T)) runMaterialValidation( - args.events, - args.tracks, trackingGeometry, decorators, field, + nevents=args.events, + ntracks=args.tracks, outputDir=os.getcwd(), outputName=args.output, ).run() From 461759cd58b2b6c1c9f970d62aaaa991c4f22317 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 11 Apr 2024 09:15:50 +0200 Subject: [PATCH 8/9] black-formatting-done --- Examples/Scripts/Python/material_mapping_core.py | 2 -- Examples/Scripts/Python/material_validation.py | 2 -- 2 files changed, 4 deletions(-) diff --git a/Examples/Scripts/Python/material_mapping_core.py b/Examples/Scripts/Python/material_mapping_core.py index c40d013934e..1bfe3e80c6f 100644 --- a/Examples/Scripts/Python/material_mapping_core.py +++ b/Examples/Scripts/Python/material_mapping_core.py @@ -34,7 +34,6 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): - # Create a sequencer print("Creating the sequencer with 1 thread (inter event information needed)") @@ -157,7 +156,6 @@ def runMaterialMapping(surfaces, inputFile, outputFile, outputMap, loglevel): args = p.parse_args() if args.experimental: - odd_xml = getOpenDataDetectorDirectory() / "xml" / "OpenDataDetector.xml" # Create the dd4hep geometry service and detector diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index 86ba6f3d5e7..3ef85965d72 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -21,7 +21,6 @@ def runMaterialValidation( outputName="propagation-material", s=None, ): - # Create a sequencer s = s or Sequencer(events=nevents, numThreads=-1) @@ -65,7 +64,6 @@ def runMaterialValidation( if "__main__" == __name__: - p = argparse.ArgumentParser() p.add_argument( From c69275185905c8451f26663dce5e06599a2d8502 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Thu, 11 Apr 2024 12:07:37 +0200 Subject: [PATCH 9/9] 1000x1000 --- Examples/Scripts/Python/material_validation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Scripts/Python/material_validation.py b/Examples/Scripts/Python/material_validation.py index 3ef85965d72..0949ff922e6 100755 --- a/Examples/Scripts/Python/material_validation.py +++ b/Examples/Scripts/Python/material_validation.py @@ -17,7 +17,7 @@ def runMaterialValidation( field, outputDir, nevents=1000, - ntracks=100, + ntracks=1000, outputName="propagation-material", s=None, ): @@ -70,7 +70,7 @@ def runMaterialValidation( "-n", "--events", type=int, default=1000, help="Number of events to process" ) p.add_argument( - "-t", "--tracks", type=int, default=100, help="Number of tracks per event" + "-t", "--tracks", type=int, default=1000, help="Number of tracks per event" ) p.add_argument( "-m", "--map", type=str, default="", help="Input file for the material map"