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.
- Loading branch information
Showing
51 changed files
with
1,478 additions
and
724 deletions.
There are no files selected for viewing
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
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
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
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
47 changes: 23 additions & 24 deletions
47
Examples/Algorithms/Digitization/src/MeasurementCreation.cpp
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 |
---|---|---|
@@ -1,43 +1,42 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2021 CERN for the benefit of the Acts project | ||
// Copyright (C) 2021-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 "ActsExamples/Digitization/MeasurementCreation.hpp" | ||
|
||
#include "Acts/EventData/MeasurementHelpers.hpp" | ||
#include "Acts/EventData/SourceLink.hpp" | ||
#include "ActsExamples/EventData/IndexSourceLink.hpp" | ||
#include "ActsExamples/EventData/Measurement.hpp" | ||
|
||
#include <stdexcept> | ||
#include <string> | ||
#include <utility> | ||
|
||
ActsExamples::Measurement ActsExamples::createMeasurement( | ||
const DigitizedParameters& dParams, const IndexSourceLink& isl) { | ||
ActsExamples::VariableBoundMeasurementProxy ActsExamples::createMeasurement( | ||
MeasurementContainer& container, const DigitizedParameters& dParams, | ||
const IndexSourceLink& isl) { | ||
Acts::SourceLink sl{isl}; | ||
switch (dParams.indices.size()) { | ||
case 1u: { | ||
auto [indices, par, cov] = measurementConstituents<1>(dParams); | ||
return ActsExamples::Measurement(std::move(sl), indices, par, cov); | ||
} | ||
case 2u: { | ||
auto [indices, par, cov] = measurementConstituents<2>(dParams); | ||
return ActsExamples::Measurement(std::move(sl), indices, par, cov); | ||
}; | ||
case 3u: { | ||
auto [indices, par, cov] = measurementConstituents<3>(dParams); | ||
return ActsExamples::Measurement(std::move(sl), indices, par, cov); | ||
}; | ||
case 4u: { | ||
auto [indices, par, cov] = measurementConstituents<4>(dParams); | ||
return ActsExamples::Measurement(std::move(sl), indices, par, cov); | ||
}; | ||
default: | ||
std::string errorMsg = "Invalid/mismatching measurement dimension: " + | ||
std::to_string(dParams.indices.size()); | ||
throw std::runtime_error(errorMsg.c_str()); | ||
|
||
if (dParams.indices.size() > 4u) { | ||
std::string errorMsg = "Invalid/mismatching measurement dimension: " + | ||
std::to_string(dParams.indices.size()); | ||
throw std::runtime_error(errorMsg.c_str()); | ||
} | ||
|
||
return Acts::visit_measurement( | ||
dParams.indices.size(), [&](auto dim) -> VariableBoundMeasurementProxy { | ||
auto [indices, par, cov] = measurementConstituents<dim>(dParams); | ||
FixedBoundMeasurementProxy<dim> measurement = | ||
container.makeMeasurement<dim>(); | ||
measurement.setSourceLink(sl); | ||
measurement.setSubspaceIndices(indices); | ||
measurement.parameters() = par; | ||
measurement.covariance() = cov; | ||
return measurement; | ||
}); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
add_library(ActsExamplesTraccc INTERFACE) | ||
|
||
target_include_directories( | ||
ActsExamplesTraccc | ||
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
) | ||
|
||
target_link_libraries( | ||
ActsExamplesTraccc | ||
INTERFACE | ||
ActsCore | ||
ActsExamplesFramework | ||
ActsExamplesPropagation | ||
ActsPluginDetray | ||
) | ||
|
||
install(TARGETS ActsExamplesTraccc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
132 changes: 132 additions & 0 deletions
132
Examples/Algorithms/Traccc/include/ActsExamples/Traccc/DetrayPropagator.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,132 @@ | ||
// 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/GeometryIdentifier.hpp" | ||
#include "Acts/Utilities/Logger.hpp" | ||
#include "Acts/Utilities/Result.hpp" | ||
#include "ActsExamples/EventData/PropagationSummary.hpp" | ||
#include "ActsExamples/Propagation/PropagationAlgorithm.hpp" | ||
#include "ActsExamples/Propagation/PropagatorInterface.hpp" | ||
#include "ActsExamples/Traccc/DetrayStore.hpp" | ||
|
||
#include <detray/navigation/navigator.hpp> | ||
#include <detray/utils/inspectors.hpp> | ||
|
||
namespace ActsExamples { | ||
|
||
/// Define the algebra type | ||
using DetrayAlgebraType = typename Acts::DetrayHostDetector::algebra_type; | ||
|
||
/// Type that holds the intersection information | ||
using DetrayIntersection = | ||
detray::intersection2D<typename Acts::DetrayHostDetector::surface_type, | ||
DetrayAlgebraType>; | ||
|
||
/// Inspector that records all encountered surfaces | ||
using DetrayObjectTracer = | ||
detray::navigation::object_tracer<DetrayIntersection, detray::dvector, | ||
detray::navigation::status::e_on_module, | ||
detray::navigation::status::e_on_portal>; | ||
|
||
/// Inspector that prints the navigator state from within the navigator's | ||
/// method calls (cannot be done with an actor) | ||
using DetrayPrintInspector = detray::navigation::print_inspector; | ||
|
||
template <typename propagator_t, typename detray_store_t> | ||
class DetrayPropagator : public PropagatorInterface { | ||
public: | ||
/// Create a DetrayPropagator | ||
/// | ||
/// @param propagator The actual detray propagator to wrap | ||
/// @param detrayStore The detray store to access the detector | ||
/// @param logger The logger instance | ||
DetrayPropagator(propagator_t&& propagator, | ||
std::shared_ptr<const detray_store_t> detrayStore, | ||
std::unique_ptr<const Acts::Logger> logger = | ||
Acts::getDefaultLogger("DetrayPropagator", | ||
Acts::Logging::INFO)) | ||
: PropagatorInterface(), | ||
m_propagator(std::move(propagator)), | ||
m_detrayStore(std::move(detrayStore)), | ||
m_logger(std::move(logger)) {} | ||
|
||
///@brief Execute a propagation for charged particle parameters | ||
/// | ||
///@param context The algorithm context | ||
///@param cfg The propagation algorithm configuration | ||
///@param logger A logger wrapper instance | ||
///@param startParameters The start parameters | ||
///@return PropagationOutput | ||
Acts::Result<PropagationOutput> execute( | ||
const AlgorithmContext& context, | ||
[[maybe_unused]] const PropagationAlgorithm::Config& cfg, | ||
const Acts::Logger& logger, | ||
const Acts::BoundTrackParameters& startParameters) const final { | ||
// Get the geometry context form the algorithm context | ||
const auto& geoContext = context.geoContext; | ||
// Get the track information | ||
const Acts::Vector3 position = startParameters.position(geoContext); | ||
const Acts::Vector3 direction = startParameters.momentum().normalized(); | ||
|
||
ACTS_VERBOSE("Starting propagation at " << position.transpose() | ||
<< " with direction " | ||
<< direction.transpose()); | ||
|
||
// Now follow that ray with the same track and check, if we find | ||
// the same volumes and distances along the way | ||
detray::free_track_parameters<DetrayAlgebraType> track( | ||
{position.x(), position.y(), position.z()}, 0.f, | ||
{direction.x(), direction.y(), direction.z()}, | ||
startParameters.charge()); | ||
|
||
typename propagator_t::state propagation(track, m_detrayStore->detector); | ||
|
||
// Run the actual propagation | ||
m_propagator.propagate(propagation); | ||
|
||
// Retrieve navigation information | ||
auto& inspector = propagation._navigation.inspector(); | ||
auto& objectTracer = inspector.template get<DetrayObjectTracer>(); | ||
|
||
PropagationSummary summary(startParameters); | ||
// Translate the objects into the steps | ||
for (const auto& object : objectTracer.object_trace) { | ||
// Get the position of the object | ||
const auto& dposition = object.pos; | ||
const auto& sfDesription = object.intersection.sf_desc; | ||
const auto sf = | ||
detray::tracking_surface{m_detrayStore->detector, sfDesription}; | ||
Acts::GeometryIdentifier geoID{sf.source()}; | ||
// Create a step from the object | ||
Acts::detail::Step step; | ||
step.position = Acts::Vector3(dposition[0], dposition[1], dposition[2]); | ||
step.geoID = geoID; | ||
step.navDir = object.intersection.direction ? Acts::Direction::Forward | ||
: Acts::Direction::Backward; | ||
summary.steps.emplace_back(step); | ||
} | ||
RecordedMaterial recordedMaterial; | ||
return std::pair{std::move(summary), std::move(recordedMaterial)}; | ||
} | ||
|
||
private: | ||
/// The propagator @todo fix when propagate() method is const in detray | ||
mutable propagator_t m_propagator; | ||
|
||
/// The detray detector store and memory resource | ||
std::shared_ptr<const detray_store_t> m_detrayStore = nullptr; | ||
|
||
/// The logging instance | ||
std::unique_ptr<const Acts::Logger> m_logger = nullptr; | ||
|
||
const Acts::Logger& logger() const { return *m_logger; } | ||
}; | ||
|
||
} // namespace ActsExamples |
Oops, something went wrong.