Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DD4hep] Tests Cleanup and 2021 Production Scenario Update #30093

Merged
merged 16 commits into from
Jun 9, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# Ideal geometry, needed for simulation
DDDetectorESProducer = cms.ESSource("DDDetectorESProducer",
confGeomXMLFiles = cms.FileInPath('DetectorDescription/DDCMS/data/cms-geometry-2021.xml'),
confGeomXMLFiles = cms.FileInPath('Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml'),
appendToDataLabel = cms.string('')
)

Expand Down
308 changes: 0 additions & 308 deletions DetectorDescription/DDCMS/data/cms-geometry-2021.xml

This file was deleted.

This file was deleted.

38 changes: 0 additions & 38 deletions DetectorDescription/DDCMS/data/cms-test-ddhgcalcell-algorithm.xml

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 5 additions & 5 deletions DetectorDescription/DDCMS/data/cms-test-ddvectors.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0"?>
<DDDefinition>
<debug>
<debug_shapes/>
<!--debug_includes/>
<!--debug_shapes/>
<debug_includes/>
<debug_rotations/>
<debug_includes/-->
<debug_includes/>
<debug_volumes/>
<debug_constants/>
<debug_materials/>
<debug_namespaces/>
<debug_placements/>
<debug_algorithms/>
<!--debug_visattr/-->
<debug_specpars/>
<debug_visattr/>
<debug_specpars/-->
</debug>

<open_geometry/>
Expand Down
4 changes: 2 additions & 2 deletions DetectorDescription/DDCMS/data/cms-test-shapes.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<DDDefinition>
<debug>
<debug_shapes/>
<!--debug_shapes/>
<debug_includes/>
<debug_rotations/>
<debug_includes/>
Expand All @@ -11,7 +11,7 @@
<debug_placements/>
<debug_algorithms/>
<debug_materials/>
<debug_visattr/>
<debug_visattr/-->
</debug>

<open_geometry/>
Expand Down

This file was deleted.

1 change: 1 addition & 0 deletions DetectorDescription/DDCMS/interface/DDAlgoArguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace cms {
double dble(const std::string& nam) const;
int integer(const std::string& nam) const;
std::vector<double> vecDble(const std::string& nam) const;
std::vector<float> vecFloat(const std::string& nam) const;
std::vector<int> vecInt(const std::string& nam) const;
std::vector<std::string> vecStr(const std::string& nam) const;
std::string resolveValue(const std::string& value) const;
Expand Down
1 change: 1 addition & 0 deletions DetectorDescription/DDCMS/interface/DDNamespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ namespace cms {
std::string_view name() const { return m_name; }

std::vector<double> vecDbl(const std::string& name) const;
std::vector<float> vecFloat(const std::string& name) const;

private:
DDParsingContext* m_context = nullptr;
Expand Down
3 changes: 1 addition & 2 deletions DetectorDescription/DDCMS/interface/Filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace cms {
});
}

std::vector<std::string> skeys;
std::vector<std::string_view> skeys;
std::vector<std::regex> keys;
std::unique_ptr<Filter> next;
struct Filter* up;
Expand All @@ -61,7 +61,6 @@ namespace cms {

namespace dd {
bool accepted(std::vector<std::regex> const&, std::string_view);
int contains(std::string_view, std::string_view);
bool isRegex(std::string_view);
bool isMatch(std::string_view, std::string_view);
bool compareEqual(std::string_view, std::string_view);
Expand Down
3 changes: 3 additions & 0 deletions DetectorDescription/DDCMS/src/DDAlgoArguments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ int DDAlgoArguments::integer(const string& nam) const { return this->value<int>(
/// Shortcut to access vector<double> arguments
vector<double> DDAlgoArguments::vecDble(const string& nam) const { return this->value<vector<double> >(nam); }

/// Shortcut to access vector<float> arguments
vector<float> DDAlgoArguments::vecFloat(const string& nam) const { return this->value<vector<float> >(nam); }

/// Shortcut to access vector<int> arguments
vector<int> DDAlgoArguments::vecInt(const string& nam) const { return this->value<vector<int> >(nam); }

Expand Down
36 changes: 18 additions & 18 deletions DetectorDescription/DDCMS/src/DDFilteredView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,22 +165,20 @@ void DDFilteredView::mergedSpecifics(DDSpecParRefs const& specs) {
for (const auto& j : i->paths) {
vector<string_view> toks = split(j, "/");
auto const& filter = find_if(begin(filters_), end(filters_), [&](auto const& f) {
auto const& k = find_if(begin(f->skeys), end(f->skeys), [&](auto const& p) {
return std::string({toks.front().data(), toks.front().size()}) == p;
});
auto const& k = find_if(begin(f->skeys), end(f->skeys), [&](auto const& p) { return toks.front() == p; });
if (k != end(f->skeys)) {
currentFilter_ = f.get();
return true;
}
return false;
});
if (filter == end(filters_)) {
filters_.emplace_back(
unique_ptr<Filter>(new Filter{{std::string(toks.front().data(), toks.front().size())},
{std::regex(std::string(toks.front().data(), toks.front().size()))},
nullptr,
nullptr,
i}));
filters_.emplace_back(unique_ptr<Filter>(
new Filter{{toks.front()},
{std::regex(std::string("^").append({toks.front().data(), toks.front().size()}).append("$"))},
nullptr,
nullptr,
i}));
// initialize current filter if it's empty
if (currentFilter_ == nullptr) {
currentFilter_ = filters_.back().get();
Expand All @@ -191,18 +189,20 @@ void DDFilteredView::mergedSpecifics(DDSpecParRefs const& specs) {
if (currentFilter_->next != nullptr) {
currentFilter_ = currentFilter_->next.get();
auto const& l = find_if(begin(currentFilter_->skeys), end(currentFilter_->skeys), [&](auto const& p) {
return std::string({toks.front().data(), toks.front().size()}) == p;
return toks.front() == p;
});
if (l == end(currentFilter_->skeys)) {
currentFilter_->skeys.emplace_back(std::string(toks[pos].data(), toks[pos].size()));
currentFilter_->keys.emplace_back(std::string(toks[pos].data(), toks[pos].size()));
currentFilter_->skeys.emplace_back(toks[pos]);
currentFilter_->keys.emplace_back(
std::regex(std::string("^").append({toks[pos].data(), toks[pos].size()}).append("$")));
}
} else {
currentFilter_->next.reset(new Filter{{std::string(toks[pos].data(), toks[pos].size())},
{std::regex(std::string(toks[pos].data(), toks[pos].size()))},
nullptr,
currentFilter_,
i});
currentFilter_->next.reset(
new Filter{{toks[pos]},
{std::regex(std::string("^").append({toks[pos].data(), toks[pos].size()}).append("$"))},
nullptr,
currentFilter_,
i});
}
}
}
Expand Down Expand Up @@ -303,7 +303,7 @@ std::vector<std::vector<Node*>> DDFilteredView::children(const std::string& sele
auto rit = names.rbegin();
Node* node = it_.back().Next();
while (node != nullptr) {
if (node->GetVolume()->GetName() == std::string({rit->first.data(), rit->first.size()})) {
if (node->GetVolume()->GetName() == rit->first) {
std::string pathToNode = path();
std::string::size_type n = pathToNode.find(node_->GetName());
std::string pathFromParent = pathToNode.substr(n);
Expand Down
12 changes: 12 additions & 0 deletions DetectorDescription/DDCMS/src/DDNamespace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,15 @@ std::vector<double> DDNamespace::vecDbl(const std::string& name) const {
} else
return std::vector<double>();
}

std::vector<float> DDNamespace::vecFloat(const std::string& name) const {
cms::DDVectorsMap* registry = m_context->description.load()->extension<cms::DDVectorsMap>();
auto it = registry->find(name);
if (it != registry->end()) {
std::vector<float> result;
for (auto in : it->second)
result.emplace_back((float)in);
return result;
} else
return std::vector<float>();
}
14 changes: 5 additions & 9 deletions DetectorDescription/DDCMS/src/Filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,19 @@ namespace cms {

bool compareEqual(string_view node, string_view name) { return (name == node); }

bool compareEqual(string_view node, regex pattern) { return regex_match(begin(node), end(node), pattern); }
bool compareEqual(string_view node, regex pattern) {
return regex_match(std::string(node.data(), node.size()), pattern);
}

bool accepted(vector<std::regex> const& keys, string_view node) {
return (find_if(begin(keys), end(keys), [&](const auto& n) -> bool { return compareEqual(node, n); }) !=
end(keys));
}

int contains(string_view input, string_view needle) {
auto const& it = search(begin(input), end(input), default_searcher(begin(needle), end(needle)));
if (it != end(input)) {
return (it - begin(input));
}
return -1;
bool isRegex(string_view input) {
return (input.find(".") != std::string_view::npos) || (input.find("*") != std::string_view::npos);
}

bool isRegex(string_view input) { return ((contains(input, "*") != -1) || (contains(input, ".") != -1)); }

string_view realTopName(string_view input) {
string_view v = input;
auto first = v.find_first_of("//");
Expand Down
2 changes: 1 addition & 1 deletion DetectorDescription/DDCMS/test/DDCompactView.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class testDDCompactView : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE_REGISTRATION(testDDCompactView);

void testDDCompactView::setUp() {
fileName_ = edm::FileInPath("DetectorDescription/DDCMS/data/cms-2015-muon-geometry.xml").fullPath();
fileName_ = edm::FileInPath("Geometry/CMSCommonData/data/dd4hep/cmsExtendedGeometry2021.xml").fullPath();
}

void testDDCompactView::checkCompactView() {
Expand Down
Loading