forked from acts-project/acts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce material accumulation interface (MM3) (acts-project#3020
) This is the first PR in a series that divides the Material Mapping into logical, unit testable modules: 1) Finding intersections with surfaces and associations to volumes (MM2) 2) Assigning material interactions to those intersections (MM1) 3) Mapping those onto dedicated Surface / Volume Material Mappers (MM3, this PR, partly) 4) Steer that by a chained algorithm (MM4) This PR: It encapsulates the pure accumulation of the material for Surface based materials into a new module. The accumulation is now decoupled from the association, i.e. one can run the mapping with a navigator or with a trial and error method, and still use the exact same material mapper. The code is largely transferred from the 'SurfaceMaterialMapper' which will vanish to exist after this re-organization. @Corentin-Allaire - the State of this Mapper would have all the access to run the optimisation, I have not yet re-introduced the track variance, but that should be a five-line change. This PR is blocked by acts-project#3015 and acts-project#3016. All cases are showcased and tested in a set of UnitTests.
- Loading branch information
1 parent
02adb76
commit 8290d74
Showing
11 changed files
with
617 additions
and
60 deletions.
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
Core/include/Acts/Material/BinnedSurfaceMaterialAccumulater.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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/AccumulatedSurfaceMaterial.hpp" | ||
#include "Acts/Material/interface/ISurfaceMaterialAccumulater.hpp" | ||
#include "Acts/Utilities/Logger.hpp" | ||
|
||
namespace Acts { | ||
|
||
/// @brief The binned surface material accumulater | ||
/// | ||
/// It consumes the assigned material interactions and then accumulates | ||
/// the material on the surfaces in prepared binned containers for averaging | ||
|
||
class BinnedSurfaceMaterialAccumulater final | ||
: public ISurfaceMaterialAccumulater { | ||
public: | ||
/// @brief Nested config struct | ||
struct Config { | ||
GeometryContext geoContext; | ||
|
||
/// Correct for empty bins (recommended) | ||
bool emptyBinCorrection = true; | ||
|
||
/// The surfaces to be used for the accummulation | ||
std::vector<const Surface*> materialSurfaces = {}; | ||
}; | ||
|
||
/// @brief Nested state struct | ||
struct State final : public ISurfaceMaterialAccumulater::State { | ||
/// The accumulated material per geometry ID | ||
std::map<GeometryIdentifier, AccumulatedSurfaceMaterial> | ||
accumulatedMaterial; | ||
}; | ||
|
||
/// Constructor | ||
/// | ||
/// @param cfg the configuration struct | ||
/// @param mlogger the logger | ||
BinnedSurfaceMaterialAccumulater( | ||
const Config& cfg, | ||
std::unique_ptr<const Logger> mlogger = | ||
getDefaultLogger("BinnedSurfaceMaterialAccumulater", Logging::INFO)); | ||
|
||
/// Factory for creating the state | ||
std::unique_ptr<ISurfaceMaterialAccumulater::State> createState() | ||
const override; | ||
|
||
/// @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<MaterialInteraction>& interactions, | ||
const std::vector<IAssignmentFinder::SurfaceAssignment>& | ||
surfacesWithoutAssignment) const override; | ||
|
||
/// Finalize the surface material maps | ||
/// | ||
/// @param state the state of the accumulator | ||
/// | ||
/// @note this does the run average over the (binned) material | ||
std::map<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>> | ||
finalizeMaterial(ISurfaceMaterialAccumulater::State& state) const override; | ||
|
||
private: | ||
/// Access method to the logger | ||
const Logger& logger() const { return *m_logger; } | ||
|
||
/// The configuration | ||
Config m_cfg; | ||
|
||
/// The logger | ||
std::unique_ptr<const Logger> m_logger; | ||
}; | ||
|
||
} // namespace Acts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
Core/include/Acts/Material/interface/ISurfaceMaterialAccumulater.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// 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/Definitions/Algebra.hpp" | ||
#include "Acts/Geometry/GeometryIdentifier.hpp" | ||
#include "Acts/Material/ISurfaceMaterial.hpp" | ||
#include "Acts/Material/MaterialInteraction.hpp" | ||
#include "Acts/Material/interface/IAssignmentFinder.hpp" | ||
|
||
#include <map> | ||
#include <memory> | ||
#include <vector> | ||
|
||
namespace Acts { | ||
|
||
class Surface; | ||
|
||
/// @brief Interface for the material mapping, this is the accumulation step | ||
class ISurfaceMaterialAccumulater { | ||
public: | ||
/// The state of the material accumulater, this is used | ||
/// to cache information across tracks/events | ||
class State { | ||
public: | ||
virtual ~State() = default; | ||
}; | ||
|
||
/// Virtual destructor | ||
virtual ~ISurfaceMaterialAccumulater() = default; | ||
|
||
/// Factory for creating the state | ||
virtual std::unique_ptr<State> createState() const = 0; | ||
|
||
/// @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 | ||
virtual void accumulate( | ||
State& state, const std::vector<MaterialInteraction>& interactions, | ||
const std::vector<IAssignmentFinder::SurfaceAssignment>& | ||
surfacesWithoutAssignment) const = 0; | ||
|
||
/// 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<GeometryIdentifier, std::shared_ptr<const ISurfaceMaterial>> | ||
finalizeMaterial(State& state) const = 0; | ||
}; | ||
|
||
} // namespace Acts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.