Skip to content

Commit

Permalink
fix: telescope detector python binding + add test (#1689)
Browse files Browse the repository at this point in the history
This fixes the telescope detector which was not working anymore after the last clang-tidy changes.
  • Loading branch information
benjaminhuth committed Nov 23, 2022
1 parent 881b5c0 commit a11ef61
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ struct TelescopeDetector : public IBaseDetector {
std::shared_ptr<const Acts::IMaterialDecorator> mdecorator) override;

std::pair<ActsExamples::IBaseDetector::TrackingGeometryPtr, ContextDecorators>
finalize(const Config& cfg);
finalize(const Config& cfg,
const std::shared_ptr<const Acts::IMaterialDecorator>& /*unused*/);
};

} // namespace Telescope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void ActsExamples::Telescope::TelescopeDetector::addOptions(

auto ActsExamples::Telescope::TelescopeDetector::finalize(
const boost::program_options::variables_map& vm,
std::shared_ptr<const Acts::IMaterialDecorator> /*mdecorator*/)
std::shared_ptr<const Acts::IMaterialDecorator> /*unused*/)
-> std::pair<TrackingGeometryPtr, ContextDecorators> {
Config cfg;

Expand All @@ -43,11 +43,12 @@ auto ActsExamples::Telescope::TelescopeDetector::finalize(
cfg.surfaceType = vm["geo-tele-surface"].template as<int>();
cfg.binValue = vm["geo-tele-alignaxis"].template as<int>();

return finalize(cfg);
return finalize(cfg, {});
}

auto ActsExamples::Telescope::TelescopeDetector::finalize(const Config& cfg)
-> std::pair<TrackingGeometryPtr, ContextDecorators> {
auto ActsExamples::Telescope::TelescopeDetector::finalize(
const Config& cfg, const std::shared_ptr<const Acts::IMaterialDecorator> &
/*unused*/) -> std::pair<TrackingGeometryPtr, ContextDecorators> {
DetectorElement::ContextType nominalContext;

if (cfg.surfaceType > 1) {
Expand Down
9 changes: 6 additions & 3 deletions Examples/Python/src/Detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ void addDetector(Context& ctx) {
py::class_<TelescopeDetector, IBaseDetector,
std::shared_ptr<TelescopeDetector>>(mex, "TelescopeDetector")
.def(py::init<>())
.def("finalize", py::overload_cast<const Config&>(
&TelescopeDetector::finalize));
.def("finalize",
py::overload_cast<
const Config&,
const std::shared_ptr<const Acts::IMaterialDecorator>&>(
&TelescopeDetector::finalize));

py::class_<Config>(td, "Config")
.def(py::init<>())
Expand Down Expand Up @@ -212,4 +215,4 @@ void addDetector(Context& ctx) {
patchKwargsConstructor(c);
}
}
} // namespace Acts::Python
} // namespace Acts::Python
16 changes: 16 additions & 0 deletions Examples/Python/tests/test_detectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@ def test_generic_geometry():
assert count_surfaces(geo) == 18728


def test_telescope_geometry():
n_surfaces = 10

detector, geo, contextDecorators = acts.examples.TelescopeDetector.create(
bounds=[100, 100],
positions=[10 * i for i in range(n_surfaces)],
binValue=0,
)

assert detector is not None
assert geo is not None
assert contextDecorators is not None

assert count_surfaces(geo) == n_surfaces


@pytest.mark.skipif(not dd4hepEnabled, reason="DD4hep is not set up")
def test_odd():
config = acts.MaterialMapJsonConverter.Config()
Expand Down

0 comments on commit a11ef61

Please sign in to comment.