From d4baa1cb50313ca65ce30bb962366126d6ec64f0 Mon Sep 17 00:00:00 2001 From: Fabio Cossutti Date: Mon, 28 Oct 2024 14:53:34 +0100 Subject: [PATCH] Update DDD filtering on MTD-related volumes for better memory performance --- .../plugins/DDCmsMTDConstruction.cc | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) 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);