-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TrackingCellIDEncodingSvc: add service to set the Cell ID encoding st…
…ring for iLCSoft track reconstruction
- Loading branch information
1 parent
c7f4d40
commit 6b51950
Showing
7 changed files
with
196 additions
and
0 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
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
51 changes: 51 additions & 0 deletions
51
k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h
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,51 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Key4hep-Project. | ||
* | ||
* This file is part of Key4hep. | ||
* See https://key4hep.github.io/key4hep-doc/ for further info. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#ifndef CELLIDSVC_H | ||
#define CELLIDSVC_H | ||
|
||
#include <GaudiKernel/Service.h> | ||
|
||
//LCIO Includes | ||
#include "UTIL/LCTrackerConf.h" | ||
|
||
#include <string> | ||
|
||
class IGeoSvc; | ||
|
||
class TrackingCellIDEncodingSvc : public extends<Service, IService> { | ||
public: | ||
TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc); | ||
|
||
/// Destructor | ||
virtual ~TrackingCellIDEncodingSvc(); | ||
/// Initialize function | ||
virtual StatusCode initialize() final; | ||
/// Finalize function | ||
virtual StatusCode finalize() final; | ||
|
||
/// CellIDEncodingStringVariable | ||
Gaudi::Property<std::string> m_encodingStringVariable{ | ||
this, "EncodingStringParameterName", "GlobalTrackerReadoutID", | ||
"The name of the DD4hep constant that contains the Encoding string for tracking detectors"}; | ||
|
||
private: | ||
SmartIF<IGeoSvc> m_geoSvc; | ||
}; | ||
|
||
#endif // CELLIDSVC_H |
53 changes: 53 additions & 0 deletions
53
k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp
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,53 @@ | ||
/* | ||
* Copyright (c) 2019-2023 Key4hep-Project. | ||
* | ||
* This file is part of Key4hep. | ||
* See https://key4hep.github.io/key4hep-doc/ for further info. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "k4MarlinWrapper/TrackingCellIDEncodingSvc.h" | ||
|
||
// k4fwcore | ||
#include <k4Interface/IGeoSvc.h> | ||
|
||
#include <GaudiKernel/MsgStream.h> | ||
|
||
DECLARE_COMPONENT(TrackingCellIDEncodingSvc); | ||
|
||
TrackingCellIDEncodingSvc::TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc) | ||
: base_class(name, svc), m_geoSvc(svc->service("GeoSvc")) {} | ||
|
||
TrackingCellIDEncodingSvc::~TrackingCellIDEncodingSvc() {} | ||
|
||
StatusCode TrackingCellIDEncodingSvc::initialize() { | ||
try { | ||
info() << "Taking the encoding string as specified in dd4hep constant: " << m_encodingStringVariable.value() | ||
<< endmsg; | ||
|
||
auto encodingString = m_geoSvc->constantAsString(m_encodingStringVariable.value()); | ||
|
||
info() << "LCTrackerCellID::_encoding will be set to " << encodingString << endmsg; | ||
|
||
UTIL::LCTrackerCellID::instance().set_encoding_string(encodingString); | ||
|
||
return StatusCode::SUCCESS; | ||
|
||
} catch (std::exception& e) { | ||
error() << "Failed to set the encoding string!\n"; | ||
error() << e.what() << endmsg; | ||
return StatusCode::FAILURE; | ||
} | ||
} | ||
|
||
StatusCode TrackingCellIDEncodingSvc::finalize() { return StatusCode::SUCCESS; } |
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,42 @@ | ||
# | ||
# Copyright (c) 2019-2023 Key4hep-Project. | ||
# | ||
# This file is part of Key4hep. | ||
# See https://key4hep.github.io/key4hep-doc/ for further info. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
from Gaudi.Configuration import * | ||
|
||
from Configurables import TrackingCellIDEncodingSvc, GeoSvc | ||
algList = [] | ||
svcList = [] | ||
|
||
geoservice = GeoSvc("GeoSvc") | ||
geoservice.detectors = [os.environ["K4GEO"]+"/CLIC/compact/CLIC_o3_v15/CLIC_o3_v15.xml"] | ||
geoservice.OutputLevel = INFO | ||
geoservice.EnableGeant4Geo = False | ||
svcList.append(geoservice) | ||
|
||
cellIDSvc = TrackingCellIDEncodingSvc("CellIDSvc") | ||
cellIDSvc.EncodingStringParameterName = "GlobalTrackerReadoutID" | ||
cellIDSvc.OutputLevel = DEBUG | ||
svcList.append(cellIDSvc) | ||
|
||
from Configurables import ApplicationMgr | ||
ApplicationMgr( TopAlg = algList, | ||
EvtSel = 'NONE', | ||
EvtMax = 3, | ||
ExtSvc = svcList, | ||
OutputLevel=WARNING | ||
) |
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,24 @@ | ||
#!/bin/bash | ||
## | ||
## Copyright (c) 2019-2023 Key4hep-Project. | ||
## | ||
## This file is part of Key4hep. | ||
## See https://key4hep.github.io/key4hep-doc/ for further info. | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
|
||
# exit if command or variable fails | ||
set -eu | ||
|
||
k4run $TEST_DIR/gaudi_opts/geoTest_cld.py |