Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
fredevb committed Jun 20, 2024
1 parent 26d2c6e commit ef69927
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 47 deletions.
7 changes: 4 additions & 3 deletions Plugins/Traccc/include/Acts/Plugins/Traccc/BarcodeMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ namespace Acts::TracccPlugin {
/// @param detector the detray detector.
/// @return A map (key = geometry ID value, value = detray geometry barcode).
template <typename metadata_t, typename container_t>
inline std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode> createBarcodeMap(
const detray::detector<metadata_t, container_t>& detector) {
inline std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>
createBarcodeMap(const detray::detector<metadata_t, container_t>& detector) {
// Construct a map from Acts surface identifiers to Detray barcodes.
std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode> barcodeMap;
std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>
barcodeMap;
for (const auto& surface : detector.surfaces()) {
barcodeMap[surface.source] = surface.barcode();
}
Expand Down
10 changes: 7 additions & 3 deletions Plugins/Traccc/include/Acts/Plugins/Traccc/CellConversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ namespace Acts::TracccPlugin {
/// @param dconfig The traccc digitization configuration.
/// @param barcode_map A map from Acts geometry ID value to detray barcode.
/// @return A tuple containing the traccc cells (first item) and traccc modules (second item).
std::tuple<traccc::cell_collection_types::host, traccc::cell_module_collection_types::host> createCellsAndModules(
std::tuple<traccc::cell_collection_types::host,
traccc::cell_module_collection_types::host>
createCellsAndModules(
vecmem::memory_resource* mr,
std::map<Acts::GeometryIdentifier::Value, std::vector<traccc::cell>> cellsMap,
std::map<Acts::GeometryIdentifier::Value, std::vector<traccc::cell>>
cellsMap,
const traccc::geometry* geom, const traccc::digitization_config* dconfig,
const std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>* barcodeMap);
const std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>*
barcodeMap);

} // namespace Acts::TracccPlugin
8 changes: 4 additions & 4 deletions Plugins/Traccc/include/Acts/Plugins/Traccc/Detail/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ namespace Acts::TracccPlugin::detail {
/// @brief Helper function which finds module from csv::cell in the geometry and
/// digitization config, and initializes the modules limits with the cell's
/// properties.
traccc::cell_module getModule(const Acts::GeometryIdentifier::Value geometryID,
const traccc::geometry* geom,
const traccc::digitization_config* dconfig,
const Acts::GeometryIdentifier::Value originalGeometryID);
traccc::cell_module getModule(
const Acts::GeometryIdentifier::Value geometryID,
const traccc::geometry* geom, const traccc::digitization_config* dconfig,
const Acts::GeometryIdentifier::Value originalGeometryID);

} // namespace Acts::TracccPlugin::detail
62 changes: 36 additions & 26 deletions Plugins/Traccc/include/Acts/Plugins/Traccc/TrackConversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
// Acts include(s)
#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/detail/ParameterTraits.hpp"
#include "Acts/EventData/SourceLink.hpp"
#include "Acts/EventData/ParticleHypothesis.hpp"
#include "Acts/EventData/SourceLink.hpp"
#include "Acts/EventData/TrackContainer.hpp"
#include "Acts/EventData/TrackParameters.hpp"
#include "Acts/EventData/TrackProxy.hpp"
#include "Acts/EventData/detail/ParameterTraits.hpp"
#include "Acts/Geometry/TrackingGeometry.hpp"
#include "Acts/Utilities/detail/Subspace.hpp"

Expand Down Expand Up @@ -49,7 +49,8 @@ template <typename algebra_t, typename metadata_t, typename container_t>
inline auto newParams(const detray::bound_track_parameters<algebra_t>& dparams,
const detray::detector<metadata_t, container_t>& detector,
const Acts::TrackingGeometry& trackingGeometry) {
constexpr std::size_t kFullSize = Acts::detail::kParametersSize<Acts::BoundIndices>;
constexpr std::size_t kFullSize =
Acts::detail::kParametersSize<Acts::BoundIndices>;
Acts::ActsVector<kFullSize> parameterVector =
detail::toActsVector<kFullSize>(dparams.vector()[0]);
typename Acts::BoundTrackParameters::CovarianceMatrix cov =
Expand Down Expand Up @@ -109,8 +110,8 @@ inline void copyTrackState(
Acts::TrackStateProxy<trajectory_t, M, false>& destination,
const detray::detector<metadata_t, container_t>& detector,
const Acts::TrackingGeometry& trackingGeometry) {

constexpr std::size_t kFullSize = Acts::detail::kParametersSize<Acts::BoundIndices>;
constexpr std::size_t kFullSize =
Acts::detail::kParametersSize<Acts::BoundIndices>;
constexpr std::size_t kSize = 2UL;

auto geoID =
Expand All @@ -123,23 +124,26 @@ inline void copyTrackState(
using Covariance =
typename Acts::TrackStateProxy<trajectory_t, M, false>::Covariance;

destination.predicted() =
Parameters(detail::toActsVector<kFullSize>(source.predicted().vector()[0]).data());
destination.predicted() = Parameters(
detail::toActsVector<kFullSize>(source.predicted().vector()[0]).data());
destination.predictedCovariance() = Covariance(
detail::toActsSquareMatrix<kFullSize>(source.predicted().covariance()).data());
detail::toActsSquareMatrix<kFullSize>(source.predicted().covariance())
.data());

destination.smoothed() =
Parameters(detail::toActsVector<kFullSize>(source.smoothed().vector()[0]).data());
destination.smoothed() = Parameters(
detail::toActsVector<kFullSize>(source.smoothed().vector()[0]).data());
destination.smoothedCovariance() = Covariance(
detail::toActsSquareMatrix<kFullSize>(source.smoothed().covariance()).data());
detail::toActsSquareMatrix<kFullSize>(source.smoothed().covariance())
.data());

destination.filtered() =
Parameters(detail::toActsVector<kFullSize>(source.filtered().vector()[0]).data());
destination.filtered() = Parameters(
detail::toActsVector<kFullSize>(source.filtered().vector()[0]).data());
destination.filteredCovariance() = Covariance(
detail::toActsSquareMatrix<kFullSize>(source.filtered().covariance()).data());
detail::toActsSquareMatrix<kFullSize>(source.filtered().covariance())
.data());

destination.jacobian() =
Covariance(detail::toActsSquareMatrix<kFullSize>(source.jacobian()).data());
destination.jacobian() = Covariance(
detail::toActsSquareMatrix<kFullSize>(source.jacobian()).data());

destination.chi2() = source.smoothed_chi2();

Expand All @@ -158,15 +162,17 @@ inline void copyTrackState(
destination.setUncalibratedSourceLink(Acts::SourceLink{measurement});

destination.allocateCalibrated(kSize);

destination.template calibrated<kSize>() = detail::toActsVector<kSize>(measurement.local);

destination.template calibrated<kSize>() =
detail::toActsVector<kSize>(measurement.local);

auto cov = Eigen::DiagonalMatrix<Acts::ActsScalar, kSize>(
detail::toActsVector<kSize>(measurement.variance))
.toDenseMatrix();
destination.template calibratedCovariance<kSize>() = cov;

Acts::detail::FixedSizeSubspace<kFullSize, kSize> subspace(measurement.subs.get_indices());
Acts::detail::FixedSizeSubspace<kFullSize, kSize> subspace(
measurement.subs.get_indices());
destination.setProjector(subspace.template projector<Acts::ActsScalar>());
}

Expand Down Expand Up @@ -214,15 +220,19 @@ inline auto makeTrack(
/// @param detector The detray detector.
/// @param trackingGeometry The Acts tracking geometry.
/// @note Sets the uncalibrated source link and calibrated measurement to the traccc measurement.
template <typename traccc_track_container_t, typename track_container_t, typename trajectory_t, template <typename> class holder_t, typename metadata_t, typename container_t>
template <typename traccc_track_container_t, typename track_container_t,
typename trajectory_t, template <typename> class holder_t,
typename metadata_t, typename container_t>
inline void makeTracks(
const traccc_track_container_t& tracccTrackContainer,
Acts::TrackContainer<track_container_t, trajectory_t, holder_t>& trackContainer,
const detray::detector<metadata_t, container_t>& detector,
const traccc_track_container_t& tracccTrackContainer,
Acts::TrackContainer<track_container_t, trajectory_t, holder_t>&
trackContainer,
const detray::detector<metadata_t, container_t>& detector,
const Acts::TrackingGeometry& trackingGeometry) {
for (std::size_t i = 0; i < tracccTrackContainer.size(); i++) {
makeTrack(tracccTrackContainer[i], trackContainer, detector, trackingGeometry);
}
for (std::size_t i = 0; i < tracccTrackContainer.size(); i++) {
makeTrack(tracccTrackContainer[i], trackContainer, detector,
trackingGeometry);
}
}

} // namespace Acts::TracccPlugin
17 changes: 10 additions & 7 deletions Plugins/Traccc/src/CellConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ struct CellOrder {

namespace Acts::TracccPlugin {

std::tuple<traccc::cell_collection_types::host, traccc::cell_module_collection_types::host> createCellsAndModules(
std::tuple<traccc::cell_collection_types::host,
traccc::cell_module_collection_types::host>
createCellsAndModules(
vecmem::memory_resource* mr,
std::map<Acts::GeometryIdentifier::Value, std::vector<traccc::cell>> cellsMap,
std::map<Acts::GeometryIdentifier::Value, std::vector<traccc::cell>>
cellsMap,
const traccc::geometry* geom, const traccc::digitization_config* dconfig,
const std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>* barcodeMap) {

const std::map<Acts::GeometryIdentifier::Value, detray::geometry::barcode>*
barcodeMap) {
traccc::io::cell_reader_output out(mr);

// Sort the cells.
Expand All @@ -72,9 +75,9 @@ std::tuple<traccc::cell_collection_types::host, traccc::cell_module_collection_t
for (const auto& [originalGeometryID, cells] : cellsMap) {
// Modify the geometry ID of the module if a barcode map is
// provided.
Acts::GeometryIdentifier::Value geometryID = (barcodeMap != nullptr)
? barcodeMap->at(originalGeometryID).value()
: originalGeometryID;
Acts::GeometryIdentifier::Value geometryID =
(barcodeMap != nullptr) ? barcodeMap->at(originalGeometryID).value()
: originalGeometryID;

// Add the module and its cells to the output.
out.modules.push_back(
Expand Down
8 changes: 4 additions & 4 deletions Plugins/Traccc/src/Detail/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

namespace Acts::TracccPlugin::detail {

traccc::cell_module getModule(const Acts::GeometryIdentifier::Value geometryID,
const traccc::geometry* geom,
const traccc::digitization_config* dconfig,
const Acts::GeometryIdentifier::Value originalGeometryID) {
traccc::cell_module getModule(
const Acts::GeometryIdentifier::Value geometryID,
const traccc::geometry* geom, const traccc::digitization_config* dconfig,
const Acts::GeometryIdentifier::Value originalGeometryID) {
traccc::cell_module result;
result.surface_link = detray::geometry::barcode{geometryID};

Expand Down

0 comments on commit ef69927

Please sign in to comment.