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 private:
28  std::vector<std::string> allowed_;
29  std::vector<std::string> veto_;
30 };
31 
32 using namespace cms;
33 
35 {}
36 
37 const GeometricTimingDet*
38 DDDCmsMTDConstruction::construct( const DDCompactView* cpv, std::vector<int> detidShifts)
39 {
40  attribute = std::string("CMSCutsRegion");
42  filter.add("mtd:");
43  filter.add("btl:");
44  filter.add("etl:");
45  filter.veto("service");
46  filter.veto("support");
47  filter.veto("FSide");
48  filter.veto("BSide");
49  filter.veto("LSide");
50  filter.veto("RSide");
51  filter.veto("Between");
52  filter.veto("SupportPlate");
53  filter.veto("Shield");
54 
55  DDFilteredView fv( *cpv, filter );
56  auto check_root = theCmsMTDStringToEnum.type( ExtractStringFromDDD::getString(attribute,&fv));
57  if( check_root != GeometricTimingDet::MTD )
58  {
59  fv.firstChild();
60  auto check_child = theCmsMTDStringToEnum.type( ExtractStringFromDDD::getString(attribute,&fv));
61  if( check_child != GeometricTimingDet::MTD )
62  {
63  throw cms::Exception( "Configuration" ) << " The first child of the DDFilteredView is not what is expected \n"
64  << ExtractStringFromDDD::getString( attribute, &fv ) << "\n";
65  }
66  fv.parent();
67  }
68 
70  CmsMTDBuilder theCmsMTDBuilder;
71  theCmsMTDBuilder.build( fv, mtd, attribute );
72 
73  return mtd;
74 }
75 
static std::string getString(std::string const &, DDFilteredView *)
bool parent()
set the current node to the parent node ...
const GeometricTimingDet * construct(const DDCompactView *cpv, std::vector< int > detidShifts)
bool ev
bool accept(const DDExpandedView &ev) const final
true, if the DDExpandedNode fulfills the filter criteria
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
std::vector< std::string > veto_
void add(const std::string &add)
void build(DDFilteredView &, GeometricTimingDet *, std::string) override
std::vector< std::string > allowed_
Namespace of DDCMS conversion namespace.
bool firstChild()
set the current node to the first child ...
A Filter accepts or rejects a DDExpandedNode based on a user-coded decision rule. ...
Definition: DDFilter.h:15
void veto(const std::string &veto)
Provides an exploded view of the detector (tree-view)