-
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
21 changed files
with
705 additions
and
19 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
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,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/Geometry/GeometryIdentifier.hpp" | ||
|
||
// Detray include(s) | ||
#include "detray/core/detector.hpp" | ||
|
||
// System include(s) | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <map> | ||
#include <tuple> | ||
#include <memory> | ||
#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; | ||
} | ||
|
||
} |
97 changes: 97 additions & 0 deletions
97
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,97 @@ | ||
// 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/reader_edm.hpp" | ||
#include "traccc/io/read_geometry.hpp" | ||
|
||
// System include(s) | ||
#include <cstdint> | ||
#include <cstdlib> | ||
#include <map> | ||
#include <tuple> | ||
#include <memory> | ||
#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 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)); | ||
} | ||
|
||
} |
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; | ||
} | ||
|
||
} |
Oops, something went wrong.