Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwand committed May 18, 2022
1 parent 2dfc192 commit 3e35ae1
Show file tree
Hide file tree
Showing 16 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@
#include <memory>
#include <vector>

struct DD4hepDetector : public ActsExamples::IBaseDetector {
namespace ActsExamples {
namespace DD4hep {

struct DD4hepDetector : public IBaseDetector {
std::shared_ptr<DD4hepGeometryService> geometryService;

void addOptions(
boost::program_options::options_description& opt) const override;

std::pair<ActsExamples::IBaseDetector::TrackingGeometryPtr, ContextDecorators>
std::pair<IBaseDetector::TrackingGeometryPtr, ContextDecorators>
finalize(const boost::program_options::variables_map& vm,
std::shared_ptr<const Acts::IMaterialDecorator> mdecorator) override;

std::pair<ActsExamples::IBaseDetector::TrackingGeometryPtr, ContextDecorators>
finalize(ActsExamples::DD4hep::DD4hepGeometryService::Config cfg,
std::pair<IBaseDetector::TrackingGeometryPtr, ContextDecorators>
finalize(DD4hepGeometryService::Config cfg,
std::shared_ptr<const Acts::IMaterialDecorator> mdecorator);
};

}
}
10 changes: 8 additions & 2 deletions Examples/Detectors/DD4hepDetector/src/DD4hepDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

#include <boost/program_options.hpp>

namespace ActsExamples {
namespace DD4hep {

void DD4hepDetector::addOptions(
boost::program_options::options_description& opt) const {
ActsExamples::Options::addDD4hepOptions(opt);
Expand All @@ -37,12 +40,15 @@ auto DD4hepDetector::finalize(
-> std::pair<TrackingGeometryPtr, ContextDecorators> {
Acts::GeometryContext dd4HepContext;
config.matDecorator = mdecorator;
auto geometrySvc =
geometryService =
std::make_shared<ActsExamples::DD4hep::DD4hepGeometryService>(config);
TrackingGeometryPtr dd4tGeometry =
geometrySvc->trackingGeometry(dd4HepContext);
geometryService->trackingGeometry(dd4HepContext);
ContextDecorators dd4ContextDeocrators = {};
// return the pair of geometry and empty decorators
return std::make_pair<TrackingGeometryPtr, ContextDecorators>(
std::move(dd4tGeometry), std::move(dd4ContextDeocrators));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EDM4hepSimHitReader final : public IReader {
std::string inputPath;
/// Output simulated (truth) hits collection.
std::string outputSimHits;

/// DD4hep geometry service for cellID resolution.
std::shared_ptr<DD4hep::DD4hepGeometryService> dd4hepGeometryService;
};

Expand Down
7 changes: 0 additions & 7 deletions Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ ActsFatras::Hit convertEDM4hepSimHit(
ActsExamples::DD4hep::DD4hepGeometryService &geometryService) {
std::ofstream debug("/home/andreas/debug.txt", std::ios::app);

try {
auto test = geometryService.lcdd()->volumeManager().lookupDetElement(1250572);
debug << "EDM4hep found test " << test.volumeID() << std::endl;
} catch (...) {
debug << "EDM4hep test failed" << std::endl;
}

debug << "EDM4hep convert cell id " << sth.getCellID() << std::endl;

try {
Expand Down
9 changes: 6 additions & 3 deletions Examples/Python/src/DD4hepComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,16 @@ PYBIND11_MODULE(ActsPythonBindingsDD4hep, m) {
}

{
auto gd = py::class_<DD4hepDetector, std::shared_ptr<DD4hepDetector>>(
auto gd = py::class_<DD4hep::DD4hepDetector, std::shared_ptr<DD4hep::DD4hepDetector>>(
m, "DD4hepDetector")
.def(py::init<>())
.def("finalize",
py::overload_cast<
DD4hep::DD4hepGeometryService::Config,
std::shared_ptr<const Acts::IMaterialDecorator>>(
&DD4hepDetector::finalize));
&DD4hep::DD4hepDetector::finalize));
ACTS_PYTHON_STRUCT_BEGIN(gd, DD4hep::DD4hepDetector);
ACTS_PYTHON_MEMBER(geometryService);
ACTS_PYTHON_STRUCT_END();
}
}
}
2 changes: 1 addition & 1 deletion Examples/Python/tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def test_edm4hep_simhits_reader(conf_const):
EDM4hepSimHitReader,
level=acts.logging.INFO,
inputPath=str( # TODO
"/home/andreas/cern/source/OpenDataDetector/output_edm4hep.root"
"/home/andreas/cern/output_edm4hep.root"
),
outputSimHits="simhits",
dd4hepGeometryService=geometryService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

int main(int argc, char* argv[]) {
return runDigitizationConfigExample(argc, argv,
std::make_shared<DD4hepDetector>());
std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#include "DigitizationExample.hpp"

int main(int argc, char* argv[]) {
return runDigitizationExample(argc, argv, std::make_shared<DD4hepDetector>());
return runDigitizationExample(argc, argv, std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}
2 changes: 1 addition & 1 deletion Examples/Run/Fatras/DD4hep/DD4hepFatrasExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#include "Fatras.hpp"

int main(int argc, char* argv[]) {
return runFatras(argc, argv, std::make_shared<DD4hepDetector>());
return runFatras(argc, argv, std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}
2 changes: 1 addition & 1 deletion Examples/Run/Geometry/DD4hep/DD4hepGeometryExample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// @param argv The argument list
int main(int argc, char* argv[]) {
// --------------------------------------------------------------------------------
DD4hepDetector detector;
ActsExamples::DD4hep::DD4hepDetector detector;
// now process it
return processGeometry(argc, argv, detector);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// @param argv The argument list
int main(int argc, char* argv[]) {
// --------------------------------------------------------------------------------
DD4hepDetector detector;
ActsExamples::DD4hep::DD4hepDetector detector;
// now process it
return runMaterialMapping(argc, argv, detector);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// @param argv The argument list
int main(int argc, char* argv[]) {
// --------------------------------------------------------------------------------
DD4hepDetector detector;
ActsExamples::DD4hep::DD4hepDetector detector;
// now process it
return materialValidationExample(argc, argv, detector);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// @param argv The argument list
int main(int argc, char* argv[]) {
// --------------------------------------------------------------------------------
DD4hepDetector detector;
ActsExamples::DD4hep::DD4hepDetector detector;

// now process it
return propagationExample(argc, argv, detector);
Expand Down
2 changes: 1 addition & 1 deletion Examples/Run/Reconstruction/DD4hep/DD4hepRecCKFTracks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#include "RecCKFTracks.hpp"

int main(int argc, char* argv[]) {
return runRecCKFTracks(argc, argv, std::make_shared<DD4hepDetector>());
return runRecCKFTracks(argc, argv, std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#include "RecTruthTracks.hpp"

int main(int argc, char* argv[]) {
return runRecTruthTracks(argc, argv, std::make_shared<DD4hepDetector>());
return runRecTruthTracks(argc, argv, std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
#include "SeedingExample.hpp"

int main(int argc, char* argv[]) {
return runSeedingExample(argc, argv, std::make_shared<DD4hepDetector>());
return runSeedingExample(argc, argv, std::make_shared<ActsExamples::DD4hep::DD4hepDetector>());
}

0 comments on commit 3e35ae1

Please sign in to comment.