diff --git a/Geometry/MTDNumberingBuilder/plugins/DDCmsMTDConstruction.cc b/Geometry/MTDNumberingBuilder/plugins/DDCmsMTDConstruction.cc index 5aaa56179fb83..c4c6d038c5de1 100644 --- a/Geometry/MTDNumberingBuilder/plugins/DDCmsMTDConstruction.cc +++ b/Geometry/MTDNumberingBuilder/plugins/DDCmsMTDConstruction.cc @@ -22,23 +22,40 @@ using angle_units::operators::convertRadToDeg; class DDNameFilter : public DDFilter { public: + void addNS(const std::string& addNS) { allowedNS_.emplace_back(addNS); } void add(const std::string& add) { allowed_.emplace_back(add); } void veto(const std::string& veto) { veto_.emplace_back(veto); } bool accept(const DDExpandedView& ev) const final { - std::string currentName(ev.logicalPart().name().fullname()); - for (const auto& test : veto_) { - if (currentName.find(test) != std::string::npos) - return false; + if (allowedNS_.size() == 0 && allowed_.size() == 0 && veto_.size() == 0) { + return true; } - for (const auto& test : allowed_) { - if (currentName.find(test) != std::string::npos) - return true; + bool out(false); + std::string_view currentNSName(ev.logicalPart().name().ns()); + for (const auto& test : allowedNS_) { + if (currentNSName.find(test) != std::string::npos) { + out = true; + if (allowed_.size() > 0 || veto_.size() > 0) { + std::string_view currentName(ev.logicalPart().name().name()); + for (const auto& test : veto_) { + if (currentName.find(test) != std::string::npos) { + return false; + } + } + for (const auto& test : allowed_) { + if (currentName.find(test) != std::string::npos) { + return true; + } + } + } + break; + } } - return false; + return out; } private: + std::vector allowedNS_; std::vector allowed_; std::vector veto_; }; @@ -46,14 +63,9 @@ class DDNameFilter : public DDFilter { std::unique_ptr DDCmsMTDConstruction::construct(const DDCompactView& cpv) { std::string attribute{"CMSCutsRegion"}; DDNameFilter filter; - filter.add("mtd:"); - filter.add("btl:"); - filter.add("etl:"); - - std::vector volnames = {"FSide", "SupportPlate"}; - for (auto const& theVol : volnames) { - filter.veto(theVol); - } + filter.addNS("mtd"); + filter.addNS("btl"); + filter.addNS("etl"); DDFilteredView fv(cpv, filter);