CMS 3D CMS Logo

DDDCmsMTDConstruction.cc
Go to the documentation of this file.
2 
3 #include <utility>
10 
11 class DDNameFilter : public DDFilter {
12 public:
13  void add(const std::string& add) { allowed_.emplace_back(add); }
14  void veto(const std::string& veto) { veto_.emplace_back(veto); }
15 
16  bool accept(const DDExpandedView& ev) const final {
17  for (const auto& test : veto_) {
18  if (ev.logicalPart().name().fullname().find(test) != std::string::npos)
19  return false;
20  }
21  for (const auto& test : allowed_) {
22  if (ev.logicalPart().name().fullname().find(test) != std::string::npos)
23  return true;
24  }
25  return false;
26  }
27 
28 private:
29  std::vector<std::string> allowed_;
30  std::vector<std::string> veto_;
31 };
32 
33 using namespace cms;
34 
35 std::unique_ptr<GeometricTimingDet> DDDCmsMTDConstruction::construct(const DDCompactView& cpv,
36  std::vector<int> detidShifts) {
37  std::string attribute{"CMSCutsRegion"};
39  filter.add("mtd:");
40  filter.add("btl:");
41  filter.add("etl:");
42  filter.veto("service");
43  filter.veto("support");
44  filter.veto("FSide");
45  filter.veto("BSide");
46  filter.veto("LSide");
47  filter.veto("RSide");
48  filter.veto("Between");
49  filter.veto("SupportPlate");
50  filter.veto("Shield");
51 
52  DDFilteredView fv(cpv, filter);
53 
54  CmsMTDStringToEnum theCmsMTDStringToEnum;
55  auto check_root = theCmsMTDStringToEnum.type(ExtractStringFromDDD::getString(attribute, &fv));
56  if (check_root != GeometricTimingDet::MTD) {
57  fv.firstChild();
58  auto check_child = theCmsMTDStringToEnum.type(ExtractStringFromDDD::getString(attribute, &fv));
59  if (check_child != GeometricTimingDet::MTD) {
60  throw cms::Exception("Configuration") << " The first child of the DDFilteredView is not what is expected \n"
61  << ExtractStringFromDDD::getString(attribute, &fv) << "\n";
62  }
63  fv.parent();
64  }
65 
66  auto mtd = std::make_unique<GeometricTimingDet>(&fv, GeometricTimingDet::MTD);
67  CmsMTDBuilder theCmsMTDBuilder;
68  theCmsMTDBuilder.build(fv, mtd.get(), attribute);
69 
70  return mtd;
71 }
GeometricTimingDet::GeometricTimingEnumType type(std::string const &) const
bool ev
bool accept(const DDExpandedView &ev) const final
std::vector< std::string > veto_
static std::unique_ptr< GeometricTimingDet > construct(const DDCompactView &cpv, std::vector< int > detidShifts)
void add(const std::string &add)
bool parent()
set the current node to the parent node ...
bool firstChild()
set the current node to the first child
void build(DDFilteredView &, GeometricTimingDet *, std::string) override
std::vector< std::string > allowed_
Namespace of DDCMS conversion namespace.
static std::string getString(std::string const &, DDFilteredView *)
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:15
void veto(const std::string &veto)