Skip to content

Commit

Permalink
TrackingCellIDEncodingSvc: add GeoSvcName parameter to allow picking …
Browse files Browse the repository at this point in the history
…the correct geosvc
  • Loading branch information
andresailer committed Sep 8, 2023
1 parent d0b3d2b commit 330841c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions doc/starterkit/k4MarlinWrapperCLIC/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ The ``MarlinDD4hep::InitializeDD4hep`` processor can be replaced by the ``k4SimG
For example:

```python
from Configurables import GeoSvc, TrackingCellIDEncodingSvc
svcList = []
geoservice = GeoSvc("GeoSvc")
geoservice.detectors = [os.environ["K4GEO"]+"/CLIC/compact/CLIC_o3_v15/CLIC_o3_v15.xml"]
Expand All @@ -174,6 +175,7 @@ svcList.append(geoservice)

cellIDSvc = TrackingCellIDEncodingSvc("CellIDSvc")
cellIDSvc.EncodingStringParameterName = "GlobalTrackerReadoutID"
cellIDSvc.GeoSvcName = geoservice.name()
cellIDSvc.OutputLevel = INFO
svcList.append(cellIDSvc)
```
8 changes: 5 additions & 3 deletions k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ class TrackingCellIDEncodingSvc : public extends<Service, IService> {
public:
TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc);

virtual ~TrackingCellIDEncodingSvc();
virtual StatusCode initialize() final;
virtual StatusCode finalize() final;
~TrackingCellIDEncodingSvc();
StatusCode initialize() final;
StatusCode finalize() final;

/// Property to configure which DD4hep constant to use for the encodingString
Gaudi::Property<std::string> m_encodingStringVariable{
this, "EncodingStringParameterName", "GlobalTrackerReadoutID",
"The name of the DD4hep constant that contains the Encoding string for tracking detectors"};

Gaudi::Property<std::string> m_geoSvcName{this, "GeoSvcName", "GeoSvc", "The name of the GeoSvc instance"};

private:
SmartIF<IGeoSvc> m_geoSvc;
};
Expand Down
6 changes: 5 additions & 1 deletion k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
DECLARE_COMPONENT(TrackingCellIDEncodingSvc);

TrackingCellIDEncodingSvc::TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc)
: base_class(name, svc), m_geoSvc(svc->service("GeoSvc")) {}
: base_class(name, svc) {}

TrackingCellIDEncodingSvc::~TrackingCellIDEncodingSvc() {}

StatusCode TrackingCellIDEncodingSvc::initialize() {
try {
info() << "Looking for GeoSvc with the name" << m_geoSvcName.value() << endmsg;

m_geoSvc = serviceLocator()->service(m_geoSvcName);

info() << "Taking the encoding string as specified in dd4hep constant: " << m_encodingStringVariable.value()
<< endmsg;

Expand Down
1 change: 1 addition & 0 deletions test/gaudi_opts/geoTest_cld.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

cellIDSvc = TrackingCellIDEncodingSvc("CellIDSvc")
cellIDSvc.EncodingStringParameterName = "GlobalTrackerReadoutID"
cellIDSvc.GeoSvcName = geoservice.name()
cellIDSvc.OutputLevel = DEBUG
svcList.append(cellIDSvc)

Expand Down

0 comments on commit 330841c

Please sign in to comment.