File indexing completed on 2024-04-06 12:05:25
0001 #include "DetectorDescription/Core/interface/DDFilter.h"
0002
0003 #include <cstddef>
0004 #include <iterator>
0005 #include <string>
0006 #include <utility>
0007
0008 #include "DetectorDescription/Core/interface/DDExpandedView.h"
0009 #include "DetectorDescription/Core/interface/DDLogicalPart.h"
0010 #include "DetectorDescription/Core/interface/DDsvalues.h"
0011 #include "DetectorDescription/Core/interface/DDComparator.h"
0012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0013
0014 DDFilter::DDFilter() {}
0015
0016 DDFilter::~DDFilter() {}
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 DDSpecificsFilter::DDSpecificsFilter() : DDFilter() {}
0034
0035 DDSpecificsFilter::~DDSpecificsFilter() {}
0036
0037 void DDSpecificsFilter::setCriteria(const DDValue& nameVal,
0038 DDCompOp op) {
0039 criteria_.emplace_back(SpecificCriterion(nameVal, op));
0040 }
0041
0042 bool DDSpecificsFilter::accept(const DDExpandedView& node) const { return accept_impl(node); }
0043
0044 bool DDSpecificsFilter::accept_impl(const DDExpandedView& node) const {
0045 bool result = true;
0046 const DDLogicalPart& logp = node.logicalPart();
0047
0048 for (auto it = begin(criteria_); it != end(criteria_); ++it) {
0049 bool locres = false;
0050 if (logp.hasDDValue(it->nameVal_)) {
0051 const auto& specs = logp.attachedSpecifics();
0052
0053 const auto& hist = node.geoHistory();
0054 bool decided = false;
0055 for (auto const& spec : specs) {
0056 if (DDCompareEqual(hist, *spec.first)()) {
0057 for (auto const& v : *(spec.second)) {
0058 if (it->nameVal_.id() == v.first) {
0059 switch (it->comp_) {
0060 case DDCompOp::equals: {
0061 locres = (it->nameVal_.strings() == v.second.strings());
0062 break;
0063 }
0064 case DDCompOp::not_equals: {
0065 locres = (it->nameVal_.strings() != v.second.strings());
0066 break;
0067 }
0068 default:
0069 return false;
0070 }
0071 decided = true;
0072 break;
0073 }
0074 }
0075 if (decided) {
0076 break;
0077 }
0078 }
0079 }
0080 }
0081 result &= locres;
0082
0083 if (!result) {
0084 break;
0085 }
0086 }
0087 return result;
0088 }
0089
0090 bool DDSpecificsHasNamedValueFilter::accept(const DDExpandedView& node) const {
0091 const DDLogicalPart& logp = node.logicalPart();
0092
0093 if (logp.hasDDValue(attribute_)) {
0094 const auto& specs = logp.attachedSpecifics();
0095
0096 const auto& hist = node.geoHistory();
0097 for (auto const& spec : specs) {
0098 for (auto const& v : *(spec.second)) {
0099 if (attribute_.id() == v.first) {
0100
0101
0102 if (DDCompareEqual(hist, *spec.first)()) {
0103 return true;
0104 } else {
0105
0106
0107
0108 break;
0109 }
0110 }
0111 }
0112 }
0113 }
0114 return false;
0115 }
0116
0117 bool DDSpecificsMatchesValueFilter::accept(const DDExpandedView& node) const {
0118 const DDLogicalPart& logp = node.logicalPart();
0119
0120 if (logp.hasDDValue(value_)) {
0121 const auto& specs = logp.attachedSpecifics();
0122
0123 const auto& hist = node.geoHistory();
0124 for (auto const& spec : specs) {
0125 for (auto const& v : *(spec.second)) {
0126 if (value_.id() == v.first) {
0127 if (DDCompareEqual(hist, *spec.first)()) {
0128 return (value_.strings() == v.second.strings());
0129 } else {
0130
0131
0132
0133 break;
0134 }
0135 }
0136 }
0137 }
0138 }
0139 return false;
0140 }