Skip to content

Commit

Permalink
Merge branch 'main' into kf-holes
Browse files Browse the repository at this point in the history
  • Loading branch information
AJPfleger authored Sep 26, 2024
2 parents 6a8e939 + 319f340 commit 620fef0
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 182 deletions.
9 changes: 5 additions & 4 deletions Core/src/Propagator/detail/SympyCovarianceEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Acts/Propagator/detail/SympyCovarianceEngine.hpp"

#include "Acts/Propagator/detail/JacobianEngine.hpp"
#include "Acts/Propagator/detail/SympyJacobianEngine.hpp"

#include "codegen/sympy_cov_math.hpp"

Expand Down Expand Up @@ -97,9 +98,9 @@ void sympy::transportCovarianceToBound(
const FreeToBoundCorrection& freeToBoundCorrection) {
// Calculate the full jacobian from local parameters at the start surface to
// current bound parameters
boundToBoundTransportJacobian(geoContext, surface, freeParameters,
boundToFreeJacobian, freeTransportJacobian,
freeToPathDerivatives, fullTransportJacobian);
sympy::boundToBoundTransportJacobian(
geoContext, surface, freeParameters, boundToFreeJacobian,
freeTransportJacobian, freeToPathDerivatives, fullTransportJacobian);

bool correction = false;
if (freeToBoundCorrection) {
Expand Down Expand Up @@ -153,7 +154,7 @@ void sympy::transportCovarianceToCurvilinear(
BoundToFreeMatrix& boundToFreeJacobian, const Vector3& direction) {
// Calculate the full jacobian from local parameters at the start surface to
// current curvilinear parameters
boundToCurvilinearTransportJacobian(
sympy::boundToCurvilinearTransportJacobian(
direction, boundToFreeJacobian, freeTransportJacobian,
freeToPathDerivatives, fullTransportJacobian);

Expand Down
68 changes: 57 additions & 11 deletions Examples/Python/src/Svg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ using ViewAndRange =
/// @param portalCache is a portal cache to avoid multiple drawings of the same portal
///
/// Returns an svg object in the right view
actsvg::svg::object viewDetectorVolume(const Svg::ProtoVolume& pVolume,
actsvg::svg::object drawDetectorVolume(const Svg::ProtoVolume& pVolume,
const std::string& identification,
const ViewAndRange& viewAndRange,
PortalCache& portalCache) {
Expand Down Expand Up @@ -154,13 +154,13 @@ actsvg::svg::object viewDetectorVolume(const Svg::ProtoVolume& pVolume,
}

// Helper function to be picked in different access patterns
void viewDetector(
std::vector<actsvg::svg::object> drawDetector(
const Acts::GeometryContext& gctx,
const Acts::Experimental::Detector& detector,
const std::string& identification,
const std::vector<std::tuple<int, Svg::DetectorVolumeConverter::Options>>&
volumeIdxOpts,
const std::vector<ViewAndRange>& viewAndRanges, const std::string& saveAs) {
const std::vector<ViewAndRange>& viewAndRanges) {
PortalCache portalCache;

// The svg object to be returned
Expand All @@ -182,17 +182,13 @@ void viewDetector(
for (auto [iv, var] : Acts::enumerate(viewAndRanges)) {
auto [view, selection, range] = var;
// Get the view and the range
auto svgVolView = viewDetectorVolume(
auto svgVolView = drawDetectorVolume(
pVolume, identification + "_vol" + std::to_string(vidx) + "_" + view,
var, portalCache);
svgDetViews[iv].add_object(svgVolView);
}
}

for (auto [iv, var] : Acts::enumerate(viewAndRanges)) {
auto [view, selection, range] = var;
Svg::toFile({svgDetViews[iv]}, saveAs + "_" + view + ".svg");
}
return svgDetViews;
}

} // namespace
Expand All @@ -206,6 +202,20 @@ void addSvg(Context& ctx) {
// Some basics
py::class_<actsvg::svg::object>(svg, "object");

py::class_<actsvg::svg::file>(svg, "file")
.def(py::init<>())
.def("addObject", &actsvg::svg::file::add_object)
.def("addObjects", &actsvg::svg::file::add_objects)
.def("clip",
[](actsvg::svg::file& self, std::array<actsvg::scalar, 4> box) {
self.set_view_box(box);
})
.def("write", [](actsvg::svg::file& self, const std::string& filename) {
std::ofstream file(filename);
file << self;
file.close();
});

// Core components, added as an acts.svg submodule
{
auto c = py::class_<Svg::Style>(svg, "Style").def(py::init<>());
Expand Down Expand Up @@ -283,6 +293,42 @@ void addSvg(Context& ctx) {
});
}

// Draw primitives
{
svg.def("drawArrow", &actsvg::draw::arrow);

svg.def("drawText", &actsvg::draw::text);
}

// Draw Eta Lines
{
svg.def(
"drawEtaLines",
[](const std::string& id, actsvg ::scalar z, actsvg::scalar r,
const std::vector<actsvg::scalar>& etaMain,
actsvg::scalar strokeWidthMain, unsigned int sizeMain,
bool labelMain, const std::vector<actsvg::scalar>& etaSub,
actsvg::scalar strokeWidthSub, const std::vector<int> strokeDashSub,
unsigned int sizeSub, bool labelSub) {
// The main eta lines
actsvg::style::stroke strokeMain;
strokeMain._width = strokeWidthMain;
actsvg::style::font fontMain;
fontMain._size = sizeMain;

actsvg::style::stroke strokeSub;
strokeSub._width = strokeWidthSub;
strokeSub._dasharray = strokeDashSub;
actsvg::style::font fontSub;
fontSub._size = sizeSub;

return actsvg::display::eta_lines(
id, z, r,
{std::tie(etaMain, strokeMain, labelMain, fontMain),
std::tie(etaSub, strokeSub, labelSub, fontSub)});
});
}

// How detector volumes are drawn: Svg DetectorVolume options & drawning
{
auto c = py::class_<Svg::DetectorVolumeConverter::Options>(
Expand All @@ -304,11 +350,11 @@ void addSvg(Context& ctx) {
svg.def("convertDetectorVolume", &Svg::DetectorVolumeConverter::convert);

// Define the view functions
svg.def("viewDetectorVolume", &viewDetectorVolume);
svg.def("drawDetectorVolume", &drawDetectorVolume);
}

// How a detector is drawn: Svg Detector options & drawning
{ svg.def("viewDetector", &viewDetector); }
{ svg.def("drawDetector", &drawDetector); }

// Legacy geometry drawing
{
Expand Down
58 changes: 29 additions & 29 deletions Examples/Python/tests/root_file_hashes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,22 @@ test_digitization_example_input[smeared]__particles.root: 5fe7dda2933ee6b9615b06
test_digitization_example_input[smeared]__measurements.root: 243c2f69b7b0db9dbeaa7494d4ea0f3dd1691dc90f16e10df6c0491ff4dc7d62
test_digitization_example_input[geometric]__particles.root: 5fe7dda2933ee6b9615b064d192322fe07831133cd998e5ed99a3b992b713a10
test_digitization_example_input[geometric]__measurements.root: 63ec81635979058fb8976f94455bf490cf92b7b142c4a05cc39de6225f5de2fb
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: 5eb5ef380aab8e5334b1d4365b945f21addcea86c569b78171ea1ca8a23dae84
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 18580d384e3ceb126be9c5d8857e176cff6c7d549155012d87939c91dba87015
test_ckf_tracks_example[generic-full_seeding]__trackstates_ckf.root: e041089f5ddf060580f068a951621882082b4659d935965c118b76f6c3944fd2
test_ckf_tracks_example[generic-full_seeding]__tracksummary_ckf.root: 4d2e26c352285aed77e46e09ee1977eb34cd82a29b0cb08f162a61ea76f71f17
test_ckf_tracks_example[generic-full_seeding]__performance_seeding_trees.root: 0e0676ffafdb27112fbda50d1cf627859fa745760f98073261dcf6db3f2f991e
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: afc9984f5b1f0b9d42156a1c3917df68144f1c486dd2b9b9a199309aa958cddc
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: e5db2791d9d09d88705c0dbeba666b4df441ecc920b9e400510df2913766e112
test_ckf_tracks_example[generic-truth_estimated]__trackstates_ckf.root: 71a48e6d22be7f01611394ed7bd5a4a498aade6e20deb7efb0d9bd67dd950970
test_ckf_tracks_example[generic-truth_estimated]__tracksummary_ckf.root: 5a973ec1c159681361ac069809e364cef4ec3e0efcafb05689f1175764f438b4
test_ckf_tracks_example[generic-truth_estimated]__performance_seeding.root: 1facb05c066221f6361b61f015cdf0918e94d9f3fce2269ec7b6a4dffeb2bc7e
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: dbe0181c90f28cc5d7ab7d768afa0462343e4a1491428ea6a68276f3d7ea38cc
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 941c20863e6aa02de92c449e92f855138d55d353eb1371cf4203f030b2f19a12
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 30ae2c78494fb2c7864321501d0e60f6bc7d2023a911d0465b53a8a05565a45d
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 2d3ab3e3e9eb28d38911a6185b99c466a135bf8c3c9bdf81499f7741785b53b4
test_ckf_tracks_example[generic-truth_smeared]__trackstates_ckf.root: b10f61d3b68ecc3d1910a17aeadd01a1e23b31b6418935809d1f12e95eac607a
test_ckf_tracks_example[generic-truth_smeared]__tracksummary_ckf.root: 69733ede1fc08370b5c0d0535f274b59bb51217239bd6645ff62ec9dadaa1f41
test_ckf_tracks_example[odd-full_seeding]__trackstates_ckf.root: 6b9b97545e9c4c833547adcd54c78235165e7e184d52548ecb5f16c421f41b37
test_ckf_tracks_example[odd-full_seeding]__tracksummary_ckf.root: 5144c31f9f5281f1c287de978035c2584e9c7b1d46aece6afaecd5c1c86b0020
test_ckf_tracks_example[odd-full_seeding]__performance_seeding_trees.root: 43c58577aafe07645e5660c4f43904efadf91d8cda45c5c04c248bbe0f59814f
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 49c3d18c4cf524533ec236c2a580087f8c04671fd2bf6bcb401f0ad01fe38ce6
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 7165fe31c6e8148779aa97c74d983f8dfcce0f76e930bffa9645fcf6b924544b
test_ckf_tracks_example[odd-truth_estimated]__trackstates_ckf.root: 7750f58b970c79dc3c937482e2a6e4576bc5d495fd6e4576d63ac2882d8283d4
test_ckf_tracks_example[odd-truth_estimated]__tracksummary_ckf.root: 3754817f9cf0972b92147e80bf36b2dc79a9c96e161b236a483a2104d2e33cd6
test_ckf_tracks_example[odd-truth_estimated]__performance_seeding.root: 1a36b7017e59f1c08602ef3c2cb0483c51df248f112e3780c66594110719c575
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 0af466be1dc2a0ff38be88101278723161eb4ad17b489feee189145db07fa0c5
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: f3439093673952ae9551257dd62b29b53e0141f7a42cbaa75dafc2056a315268
test_ckf_tracks_example[odd-truth_smeared]__trackstates_ckf.root: 33398059bf968f7279d4cc706f3b914fcf6f010ae82c43df8875785bda6f7cbe
test_ckf_tracks_example[odd-truth_smeared]__tracksummary_ckf.root: 3d01335a51fb03c78a174c8b11d473b38ba9c4ed3d6cba201b3925f463411708
test_vertex_fitting_reading[Truth-False-100]__performance_vertexing.root: 76ef6084d758dfdfc0151ddec2170e12d73394424e3dac4ffe46f0f339ec8293
test_vertex_fitting_reading[Iterative-False-100]__performance_vertexing.root: 60372210c830a04f95ceb78c6c68a9b0de217746ff59e8e73053750c837b57eb
test_vertex_fitting_reading[Iterative-True-100]__performance_vertexing.root: e34f217d524a5051dbb04a811d3407df3ebe2cc4bb7f54f6bda0847dbd7b52c3
Expand All @@ -74,23 +74,23 @@ test_exatrkx[cpu-torch]__performance_track_finding.root: 36b3045589c4c17c038dbc8
test_exatrkx[gpu-onnx]__performance_track_finding.root: 9090de10ffb1489d3f1993e2a3081a3038227e3e5c453e98a9a4f33ea3d6d817
test_exatrkx[gpu-torch]__performance_track_finding.root: 36b3045589c4c17c038dbc87943366f4af4440f7eea6887afb763871ac149b05
test_ML_Ambiguity_Solver__performance_ambiML.root: 284ff5c3a08c0b810938e4ac2f8ba8fe2babb17d4c202b624ed69fff731a9006
test_refitting[odd]__trackstates_gsf_refit.root: 33de1e46b05abc450ff89aebc728d7cb85e3f4dc90e5a21fc79a1ed8e9e04d7d
test_refitting[odd]__trackstates_gsf_refit.root: 798a5b2e6d4b6d56e73ad107887f310c9463cc739ca1b69dad4a99d3419943ca
test_refitting[odd]__tracksummary_gsf_refit.root: 16951808df6363d2acb99e385aec35ad723b634403ca0724a552ae9d3a2ae237
test_refitting[generic]__trackstates_gsf_refit.root: ae07a875975a416d323d98b4b16dd3edc5ae672a8993ecb624758a770afdffbd
test_refitting[generic]__tracksummary_gsf_refit.root: 9dd347fcab40d1045bd48e1d7e531fbc9f1e07a2e7e321f196250721befe086c
test_truth_tracking_kalman[generic-False-0.0]__trackstates_kf.root: 4e49258ae95ef7b7c59ef155545323fbee6de3f160a0cd975225c0458ec27912
test_truth_tracking_kalman[generic-False-0.0]__tracksummary_kf.root: 9dd347fcab40d1045bd48e1d7e531fbc9f1e07a2e7e321f196250721befe086c
test_truth_tracking_kalman[generic-False-1000.0]__trackstates_kf.root: 0a2428ff260466f7fe4ea44863664afa3c7e34b0dc388e43ee096d132f3acefb
test_truth_tracking_kalman[generic-False-1000.0]__tracksummary_kf.root: 8be4bcc0f05c90ffeb4ea7bbb517adee217550d59c2eed89a48ed3b4c5145c54
test_truth_tracking_kalman[generic-True-0.0]__trackstates_kf.root: 4e49258ae95ef7b7c59ef155545323fbee6de3f160a0cd975225c0458ec27912
test_truth_tracking_kalman[generic-True-0.0]__tracksummary_kf.root: 9dd347fcab40d1045bd48e1d7e531fbc9f1e07a2e7e321f196250721befe086c
test_truth_tracking_kalman[generic-True-1000.0]__trackstates_kf.root: 0a2428ff260466f7fe4ea44863664afa3c7e34b0dc388e43ee096d132f3acefb
test_truth_tracking_kalman[generic-True-1000.0]__tracksummary_kf.root: 8be4bcc0f05c90ffeb4ea7bbb517adee217550d59c2eed89a48ed3b4c5145c54
test_truth_tracking_kalman[odd-False-0.0]__trackstates_kf.root: a34546ba6cfdbecc3bcf6f02ec782ebcc76f332070e7ff8a64207ed815f65c7e
test_truth_tracking_kalman[odd-False-0.0]__tracksummary_kf.root: 7f1bb68b39e52da7a77ea295819fa3776e947568455338738c3a6436c2d7599c
test_truth_tracking_kalman[odd-False-1000.0]__trackstates_kf.root: 0344aa50ba6c14152cf0f29b6f6da8af88fd61556a99baa62bef2fdbbc121ac8
test_refitting[generic]__trackstates_gsf_refit.root: b044574ab5dec9781ca2a1d72095f2393270766365a0e165904ff628191c284a
test_refitting[generic]__tracksummary_gsf_refit.root: 6f8bd054c663197a5f5523e54ebc9695759b671eb14791f964073ed3c8a6f27f
test_truth_tracking_kalman[generic-False-0.0]__trackstates_kf.root: 64a7f26c30f5a70e323dc5d43142a7cc81ad7ef04033095a1ae11d27c41333f0
test_truth_tracking_kalman[generic-False-0.0]__tracksummary_kf.root: 6f8bd054c663197a5f5523e54ebc9695759b671eb14791f964073ed3c8a6f27f
test_truth_tracking_kalman[generic-False-1000.0]__trackstates_kf.root: e69d1aacacecc3d7d6619605cdd179d9fb0e19734f7c35345284f9a0e01f36d1
test_truth_tracking_kalman[generic-False-1000.0]__tracksummary_kf.root: 055a74d2747d360398cc846cc2791204491528896de78cca66b188e3ff530dc1
test_truth_tracking_kalman[generic-True-0.0]__trackstates_kf.root: 64a7f26c30f5a70e323dc5d43142a7cc81ad7ef04033095a1ae11d27c41333f0
test_truth_tracking_kalman[generic-True-0.0]__tracksummary_kf.root: 6f8bd054c663197a5f5523e54ebc9695759b671eb14791f964073ed3c8a6f27f
test_truth_tracking_kalman[generic-True-1000.0]__trackstates_kf.root: e69d1aacacecc3d7d6619605cdd179d9fb0e19734f7c35345284f9a0e01f36d1
test_truth_tracking_kalman[generic-True-1000.0]__tracksummary_kf.root: 055a74d2747d360398cc846cc2791204491528896de78cca66b188e3ff530dc1
test_truth_tracking_kalman[odd-False-0.0]__trackstates_kf.root: 22c9f39a8e9569499205c024f7075d4125aca111c0e580c0320d6d93696062d5
test_truth_tracking_kalman[odd-False-0.0]__tracksummary_kf.root: a6da8b8ca2cd0f09fcbae5d08885fa2aee39990f2f329ef659ef3c260141643a
test_truth_tracking_kalman[odd-False-1000.0]__trackstates_kf.root: 214f3ded235a0da8d254e34f72253ee8d6dfa5b7f96040bccd760b51ee85a46f
test_truth_tracking_kalman[odd-False-1000.0]__tracksummary_kf.root: 87eaae3192ab29e2c2542c017071b6477c7237c5b8eaff107e84caed2a5e5b7a
test_truth_tracking_kalman[odd-True-0.0]__trackstates_kf.root: a34546ba6cfdbecc3bcf6f02ec782ebcc76f332070e7ff8a64207ed815f65c7e
test_truth_tracking_kalman[odd-True-0.0]__tracksummary_kf.root: 7f1bb68b39e52da7a77ea295819fa3776e947568455338738c3a6436c2d7599c
test_truth_tracking_kalman[odd-True-1000.0]__trackstates_kf.root: 0344aa50ba6c14152cf0f29b6f6da8af88fd61556a99baa62bef2fdbbc121ac8
test_truth_tracking_kalman[odd-True-0.0]__trackstates_kf.root: 22c9f39a8e9569499205c024f7075d4125aca111c0e580c0320d6d93696062d5
test_truth_tracking_kalman[odd-True-0.0]__tracksummary_kf.root: a6da8b8ca2cd0f09fcbae5d08885fa2aee39990f2f329ef659ef3c260141643a
test_truth_tracking_kalman[odd-True-1000.0]__trackstates_kf.root: 214f3ded235a0da8d254e34f72253ee8d6dfa5b7f96040bccd760b51ee85a46f
test_truth_tracking_kalman[odd-True-1000.0]__tracksummary_kf.root: 87eaae3192ab29e2c2542c017071b6477c7237c5b8eaff107e84caed2a5e5b7a
44 changes: 22 additions & 22 deletions Examples/Scripts/Python/detector_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@

# OBJ style output
surfaces = []
viewConfig = acts.ViewConfig()
viewConfig.nSegments = 100
for vol in detector.volumePtrs():
for surf in vol.surfacePtrs():
if surf.geometryId().sensitive() > 0:
surfaces.append(surf)
acts.examples.writeSurfacesObj(
surfaces, geoContext, [0, 120, 120], "odd-surfaces.obj"
)
acts.examples.writeSurfacesObj(surfaces, geoContext, viewConfig, "odd-surfaces.obj")

# SVG style output
surfaceStyle = acts.svg.Style()
Expand All @@ -69,28 +69,28 @@
volumeOptions = acts.svg.DetectorVolumeOptions()
volumeOptions.surfaceOptions = surfaceOptions

for ivol in range(detector.numberVolumes()):
acts.svg.viewDetector(
geoContext,
detector,
"odd-xy",
[[ivol, volumeOptions]],
[["xy", ["sensitives"], viewRange]],
"vol_" + str(ivol),
)

xyRange = acts.Extent([[acts.Binning.z, [-50, 50]]])
zrRange = acts.Extent([[acts.Binning.phi, [-0.1, 0.1]]])

acts.svg.viewDetector(
# Transverse view
xyRange = acts.Extent([[acts.BinningValue.binZ, [-50, 50]]])
xyView = acts.svg.drawDetector(
geoContext,
detector,
"odd",
[[ivol, volumeOptions] for ivol in range(detector.numberVolumes())],
[["xy", ["sensitives"], xyRange], ["zr", ["materials"], zrRange]],
"detector",
[["xy", ["sensitives"], xyRange]],
)
xyFile = acts.svg.file()
xyFile.addObjects(xyView)
xyFile.write("odd_xy.svg")

acts.examples.writeDetectorToJsonDetray(geoContext, detector, "odd-detray")

# det_detector = acts.examples.DetrayConverter(geoContext, detector,"odd-detray")
# Longitudinal view
zrRange = acts.Extent([[acts.BinningValue.binPhi, [-0.1, 0.1]]])
zrView = acts.svg.drawDetector(
geoContext,
detector,
"odd",
[[ivol, volumeOptions] for ivol in range(detector.numberVolumes())],
[["zr", ["sensitives", "portals"], zrRange]],
)
zrFile = acts.svg.file()
zrFile.addObjects(zrView)
zrFile.write("odd_zr.svg")
Loading

0 comments on commit 620fef0

Please sign in to comment.