-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple DD4hep geo service, and added service bindings to Juggler
- Loading branch information
Showing
8 changed files
with
138 additions
and
32 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
File renamed without changes.
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,39 @@ | ||
#pragma once | ||
|
||
#include <gsl/gsl> | ||
#include <memory> | ||
|
||
#include "DDRec/CellIDPositionConverter.h" | ||
#include <DD4hep/Detector.h> | ||
|
||
#include <algorithms/logger.h> | ||
#include <algorithms/service.h> | ||
|
||
namespace algorithms { | ||
|
||
class GeoSvc : public LoggedService<GeoSvc> { | ||
public: | ||
// Initialize the geometry service, to be called after with a global detector | ||
// pointer (will not re-initialize), or after at least the detectors property was specified | ||
// (will load XML and then fully initialize) | ||
void init(dd4hep::Detector* = nullptr); | ||
|
||
// TODO check const-ness | ||
gsl::not_null<const dd4hep::Detector*> detector() const { return m_detector; } | ||
dd4hep::DetElement world() const { return detector()->world(); } | ||
gsl::not_null<const dd4hep::rec::CellIDPositionConverter*> cellIDPositionConverter() const { | ||
return m_converter.get(); | ||
} | ||
|
||
private: | ||
dd4hep::Detector* m_detector = nullptr; | ||
std::unique_ptr<const dd4hep::rec::CellIDPositionConverter> m_converter; | ||
|
||
// Configuration variables. These only need to be specified if we are actually running | ||
// in "standalone" mode (hence they're optional) | ||
Property<std::vector<std::string>> m_xml_list{this, "detectors", {}}; | ||
|
||
ALGORITHMS_DEFINE_LOGGED_SERVICE(GeoSvc) | ||
}; | ||
|
||
} // namespace algorithms |
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,27 @@ | ||
#include <algorithms/geo.h> | ||
|
||
namespace algorithms { | ||
|
||
void GeoSvc::init(dd4hep::Detector* det) { | ||
if (det) { | ||
info() << "Initializing geometry service from pre-initialized detector" << endmsg; | ||
m_detector = det; | ||
// no detector given, need to self-initialize | ||
} else { | ||
info() << "No external detector provided, self-initializing" << endmsg; | ||
m_detector = &(dd4hep::Detector::getInstance()); | ||
if (m_xml_list.empty()) { | ||
// TODO handle error | ||
} | ||
for (std::string_view name : m_xml_list) { | ||
info() << fmt::format("Loading compact file: {}", "name") << endmsg; | ||
m_detector->fromCompact(std::string(name)); | ||
} | ||
m_detector->volumeManager(); | ||
m_detector->apply("DD4hepVolumeManager", 0, nullptr); | ||
} | ||
// always: instantiate cellIDConverter | ||
m_converter = std::make_unique<const dd4hep::rec::CellIDPositionConverter>(*m_detector); | ||
} | ||
} // namespace algorithms | ||
|