Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Python/Examples/python/odd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing import Optional
import acts
import acts.examples
import acts.tgeo
from acts import root
import warnings

Expand Down
29 changes: 26 additions & 3 deletions Python/Plugins/src/TGeo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

#include "ActsPlugins/Root/TGeoAxes.hpp"
#include "ActsPlugins/Root/TGeoDetectorElement.hpp"
#include "ActsPlugins/Root/TGeoLayerBuilder.hpp"
#include "ActsPlugins/Root/TGeoParser.hpp"
Expand All @@ -26,6 +27,28 @@ PYBIND11_MODULE(ActsPluginsPythonBindingsTGeo, tgeo) {
using namespace Acts;
using namespace ActsPlugins;

// Basic bindings: detector axes
{
py::class_<TGeoAxes>(tgeo, "TGeoAxes")
.def(py::init([](std::string s) { return TGeoAxes::parse(s); }))
.def("value", &TGeoAxes::value)
.def("__repr__",
[](const TGeoAxes& self) {
return "TGeoAxes('" + std::string(self.value()) + "')";
})
.def("__str__",
[](const TGeoAxes& self) { return std::string(self.value()); })
.def("__eq__",
[](const TGeoAxes& self, const TGeoAxes& other) {
return self.value() == other.value();
})
.def("__ne__", [](const TGeoAxes& self, const TGeoAxes& other) {
return self.value() != other.value();
});

py::implicitly_convertible<std::string, TGeoAxes>();
}

// Basic bindings: detector element
{
py::class_<TGeoDetectorElement, std::shared_ptr<TGeoDetectorElement>>(
Expand All @@ -46,7 +69,7 @@ PYBIND11_MODULE(ActsPluginsPythonBindingsTGeo, tgeo) {
"convertToElements",
[](const std::string& rootFileName,
const std::vector<std::string>& sensitiveMatches,
const std::string& localAxes, double scaleConversion) {
const TGeoAxes& localAxes, double scaleConversion) {
// Return vector
std::vector<std::shared_ptr<const TGeoDetectorElement>> tgElements;
// TGeo import
Expand All @@ -70,8 +93,8 @@ PYBIND11_MODULE(ActsPluginsPythonBindingsTGeo, tgeo) {
for (const auto& snode : tgpState.selectedNodes) {
auto identifier = TGeoDetectorElement::Identifier();
auto tgElement = TGeoLayerBuilder::defaultElementFactory(
identifier, *snode.node, *snode.transform,
TGeoAxes::parse(localAxes), scaleConversion, nullptr);
identifier, *snode.node, *snode.transform, localAxes,
scaleConversion, nullptr);
tgElements.emplace_back(tgElement);
}
}
Expand Down
Loading