Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
update python interaction following cleanup in DetDescr
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeichlersmith committed Sep 16, 2022
1 parent 0bb3022 commit 467b87a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion python/EcalGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self):
else:
super().__init__("EcalGeometryProvider","ecal::EcalGeometryProvider","Ecal")
from LDMX.DetDescr import EcalGeometry
self.EcalGeometry = EcalGeometry.EcalGeometry()
self.geometries = EcalGeometry.geometries()
EcalGeometryProvider.__instance = self

# make sure global instance is created, this registers the condition
Expand Down
24 changes: 8 additions & 16 deletions src/Ecal/EcalGeometryProvider.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ class EcalGeometryProvider : public framework::ConditionsObjectProvider {
}

private:
/** Handle to the parameters, needed for future use during get condition */
framework::config::Parameters params_;
/** parameters for the various geometry versions we can support */
std::vector<framework::config::Parameters> geometries_;
/** Geometry as last used */
std::string detectorGeometry_;
ldmx::EcalGeometry* ecalGeometry_;
Expand All @@ -74,8 +74,8 @@ EcalGeometryProvider::EcalGeometryProvider(
framework::Process& process)
: framework::
ConditionsObjectProvider{ldmx::EcalGeometry::CONDITIONS_OBJECT_NAME,
tagname, parameters, process},
params_{parameters} {
tagname, parameters, process} {
geometries_ = parameters.getParameter<std::vector<framework::config::Parameters>>("geometries");
ecalGeometry_ = 0;
}

Expand All @@ -89,25 +89,17 @@ EcalGeometryProvider::getCondition(const ldmx::EventHeader& context) {
static const std::string KEYNAME("detectors_valid");

if (!ecalGeometry_) {
framework::config::Parameters phex =
(params_.exists("EcalGeometry"))
? (params_.getParameter<framework::config::Parameters>(
"EcalGeometry"))
: (params_);

// search through the subtrees
for (auto key : phex.keys()) {
framework::config::Parameters pver =
phex.getParameter<framework::config::Parameters>(key);

for (auto pver : geometries_) {
if (!pver.exists(KEYNAME)) {
ldmx_log(warn) << "No parameter " << KEYNAME << " found in " << key;
ldmx_log(warn) << "No parameter " << KEYNAME
<< " found one of the detector vesrsions.";
// log strange situation and continue
continue;
}

std::vector<std::string> dets_valid =
pver.getParameter<std::vector<std::string> >(KEYNAME);
pver.getParameter<std::vector<std::string>>(KEYNAME);
for (auto detregex : dets_valid) {
std::string regex(detregex);
if (regex.empty()) continue; // no empty regex allowed
Expand Down

0 comments on commit 467b87a

Please sign in to comment.