-
Notifications
You must be signed in to change notification settings - Fork 173
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
14 changed files
with
746 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
add_library( | ||
ActsPluginTraccc INTERFACE) | ||
|
||
target_include_directories( | ||
ActsPluginTraccc | ||
INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
target_link_libraries( | ||
ActsPluginTraccc | ||
INTERFACE | ||
ActsCore | ||
traccc::core | ||
traccc::io | ||
vecmem::core | ||
detray::utils | ||
detray::io | ||
ActsPluginCovfie) | ||
|
||
install( | ||
TARGETS ActsPluginTraccc | ||
EXPORT ActsPluginTracccTargets | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
install( | ||
DIRECTORY include/Acts | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
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,41 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 | ||
|
||
// Acts include(s) | ||
#include "Acts/Geometry/GeometryIdentifier.hpp" | ||
|
||
// Detray include(s) | ||
#include "detray/core/detector.hpp" | ||
|
||
// System include(s) | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <map> | ||
#include <memory> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
namespace Acts::TracccPlugin { | ||
|
||
/// @brief Creates a map from Acts geometry ID (value) to detray barcode. | ||
/// @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<std::uint64_t, detray::geometry::barcode> createBarcodeMap( | ||
const detray::detector<metadata_t, container_t>& detector) { | ||
// Construct a map from Acts surface identifiers to Detray barcodes. | ||
std::map<std::uint64_t, detray::geometry::barcode> barcodeMap; | ||
for (const auto& surface : detector.surfaces()) { | ||
barcodeMap[surface.source] = surface.barcode(); | ||
} | ||
return barcodeMap; | ||
} | ||
|
||
} // namespace Acts::TracccPlugin |
96 changes: 96 additions & 0 deletions
96
Plugins/Traccc/include/Acts/Plugins/Traccc/CellConversion.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,96 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 | ||
|
||
// Acts include(s) | ||
#include "Acts/Geometry/GeometryHierarchyMap.hpp" | ||
#include "Acts/Geometry/GeometryIdentifier.hpp" | ||
|
||
// Plugin include(s) | ||
#include "Acts/Plugins/Traccc/BarcodeMap.hpp" | ||
#include "Acts/Plugins/Traccc/Detail/Module.hpp" | ||
|
||
// Detray include(s) | ||
#include "detray/core/detector.hpp" | ||
|
||
// Traccc include(s) | ||
#include "traccc/edm/cell.hpp" | ||
#include "traccc/geometry/geometry.hpp" | ||
#include "traccc/io/digitization_config.hpp" | ||
#include "traccc/io/read_geometry.hpp" | ||
#include "traccc/io/reader_edm.hpp" | ||
|
||
// System include(s) | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <map> | ||
#include <memory> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
namespace { | ||
|
||
/// Comparator used for sorting cells. This sorting is one of the assumptions | ||
/// made in the clusterization algorithm | ||
struct cell_order { | ||
bool operator()(const traccc::cell& lhs, const traccc::cell& rhs) const { | ||
if (lhs.module_link != rhs.module_link) { | ||
return lhs.module_link < rhs.module_link; | ||
} else if (lhs.channel1 != rhs.channel1) { | ||
return (lhs.channel1 < rhs.channel1); | ||
} else { | ||
return (lhs.channel0 < rhs.channel0); | ||
} | ||
} | ||
}; // struct cell_order | ||
|
||
} // namespace | ||
|
||
namespace Acts::TracccPlugin { | ||
|
||
/// @brief Converts a "geometry ID -> traccc cells" map to traccc cells and modules. | ||
/// @param mr The memory resource to use. | ||
/// @param cellsMap A map from Acts geometry ID value to traccc cells. | ||
/// @param geom The traccc geometry. | ||
/// @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). | ||
inline auto createCellsAndModules( | ||
vecmem::memory_resource* mr, | ||
std::map<std::uint64_t, std::vector<traccc::cell>> cellsMap, | ||
const traccc::geometry* geom, const traccc::digitization_config* dconfig, | ||
const std::map<std::uint64_t, detray::geometry::barcode>* barcodeMap) { | ||
traccc::io::cell_reader_output out(mr); | ||
|
||
// Sort the cells. | ||
for (auto& [_, cells] : cellsMap) { | ||
std::sort(cells.begin(), cells.end(), cell_order()); | ||
} | ||
|
||
// Fill the output containers with the ordered cells and modules. | ||
for (const auto& [originalGeometryID, cells] : cellsMap) { | ||
// Modify the geometry ID of the module if a barcode map is | ||
// provided. | ||
std::uint64_t geometryID = (barcodeMap != nullptr) | ||
? barcodeMap->at(originalGeometryID).value() | ||
: originalGeometryID; | ||
|
||
// Add the module and its cells to the output. | ||
out.modules.push_back( | ||
Detail::get_module(geometryID, geom, dconfig, originalGeometryID)); | ||
for (auto& cell : cells) { | ||
out.cells.push_back(cell); | ||
// Set the module link. | ||
out.cells.back().module_link = out.modules.size() - 1; | ||
} | ||
} | ||
return std::make_tuple(std::move(out.cells), std::move(out.modules)); | ||
} | ||
|
||
} // namespace Acts::TracccPlugin |
40 changes: 40 additions & 0 deletions
40
Plugins/Traccc/include/Acts/Plugins/Traccc/Detail/AlgebraConversion.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,40 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 | ||
|
||
// Acts include(s) | ||
#include "Acts/Definitions/Algebra.hpp" | ||
|
||
// System include(s) | ||
#include <cstddef> | ||
|
||
namespace Acts::TracccPlugin::Detail { | ||
|
||
/// @brief Creates a new Acts vector from another vector type. | ||
template <std::size_t N, typename dvector_t> | ||
inline Acts::ActsVector<N> newVector(const dvector_t& dvec) { | ||
Acts::ActsVector<N> res; | ||
for (std::size_t i = 0; i < N; i++) { | ||
res(i) = static_cast<Acts::ActsScalar>(dvec[i]); | ||
} | ||
return res; | ||
} | ||
/// @brief Creates a new Acts square matrix from another square matrix type. | ||
template <std::size_t N, typename matrixNxN_t> | ||
inline Acts::ActsSquareMatrix<N> newSqaureMatrix(const matrixNxN_t& mat) { | ||
Acts::ActsSquareMatrix<N> res; | ||
for (std::size_t x = 0; x < N; x++) { | ||
for (std::size_t y = 0; y < N; y++) { | ||
res(x, y) = static_cast<Acts::ActsScalar>(mat[x][y]); | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
} // namespace Acts::TracccPlugin::Detail |
84 changes: 84 additions & 0 deletions
84
Plugins/Traccc/include/Acts/Plugins/Traccc/Detail/Module.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,84 @@ | ||
// This file is part of the Acts project. | ||
// | ||
// Copyright (C) 2023 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 | ||
|
||
// Acts include(s) | ||
#include "Acts/Geometry/GeometryHierarchyMap.hpp" | ||
#include "Acts/Geometry/GeometryIdentifier.hpp" | ||
|
||
// Detray include(s) | ||
#include "detray/core/detector.hpp" | ||
|
||
// Traccc include(s) | ||
#include "traccc/edm/cell.hpp" | ||
#include "traccc/geometry/geometry.hpp" | ||
#include "traccc/io/digitization_config.hpp" | ||
#include "traccc/io/read_geometry.hpp" | ||
#include "traccc/io/reader_edm.hpp" | ||
|
||
// System include(s) | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <map> | ||
#include <memory> | ||
#include <tuple> | ||
#include <utility> | ||
|
||
namespace Acts::TracccPlugin::Detail { | ||
|
||
/// 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 get_module(const std::uint64_t geometryID, | ||
const traccc::geometry* geom, | ||
const traccc::digitization_config* dconfig, | ||
const std::uint64_t originalGeometryID) { | ||
traccc::cell_module result; | ||
result.surface_link = detray::geometry::barcode{geometryID}; | ||
|
||
// Find/set the 3D position of the detector module. | ||
if (geom != nullptr) { | ||
// Check if the module ID is known. | ||
if (!geom->contains(result.surface_link.value())) { | ||
throw std::runtime_error("Could not find placement for geometry ID " + | ||
std::to_string(result.surface_link.value())); | ||
} | ||
|
||
// Set the value on the module description. | ||
result.placement = (*geom)[result.surface_link.value()]; | ||
} | ||
|
||
// Find/set the digitization configuration of the detector module. | ||
if (dconfig != nullptr) { | ||
// Check if the module ID is known. | ||
const traccc::digitization_config::Iterator geoIt = | ||
dconfig->find(originalGeometryID); | ||
if (geoIt == dconfig->end()) { | ||
throw std::runtime_error( | ||
"Could not find digitization config for geometry ID " + | ||
std::to_string(originalGeometryID)); | ||
} | ||
|
||
// Set the value on the module description. | ||
const auto& binning_data = geoIt->segmentation.binningData(); | ||
assert(binning_data.size() > 0); | ||
result.pixel.min_corner_x = binning_data[0].min; | ||
result.pixel.pitch_x = binning_data[0].step; | ||
if (binning_data.size() > 1) { | ||
result.pixel.min_corner_y = binning_data[1].min; | ||
result.pixel.pitch_y = binning_data[1].step; | ||
} | ||
// result.pixel.dimension = geoIt->dimensions; | ||
// result.pixel.variance_y = geoIt->variance_y; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
} // namespace Acts::TracccPlugin::Detail |
Oops, something went wrong.