CMS 3D CMS Logo

DDErrorDetection.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_DD_ERROR_DETECTION_H
2 #define DETECTOR_DESCRIPTION_DD_ERROR_DETECTION_H
3 
5 #include <map>
6 #include <ostream>
7 #include <set>
8 #include <string>
9 #include <utility>
10 #include <vector>
11 
18 
19 class DDCompactView;
20 class DDLogicalPart;
21 class DDMaterial;
22 class DDName;
23 class DDRotation;
24 class DDSolid;
25 class DDSpecifics;
26 
32 
33 using ns_type = std::map<std::string, std::set<std::string>>;
34 using ns_nm_type = std::map<std::string, std::set<DDName>>;
35 
36 template <class T>
37 std::ostream& operator<<(std::ostream& o, const std::set<T>& v) {
38  typename std::set<T>::const_iterator it(v.begin()), ed(v.end());
39  for (; it != ed; ++it) {
40  o << it->ddname() << ' ';
41  }
42  return o;
43 }
44 
45 template <class T>
46 std::ostream& operator<<(std::ostream& o, const std::map<std::string, std::set<T>>& m) {
47  typedef typename std::map<std::string, std::set<T>>::const_iterator c_it;
48  c_it it(m.begin()), ed(m.end());
49  for (; it != ed; ++it) {
50  o << it->first << ": " << it->second;
51  o << std::endl;
52  }
53  return o;
54 }
55 
56 template <class T, class N>
57 std::ostream& operator<<(std::ostream& o, const std::map<N, std::set<T>>& m) {
58  typedef typename std::map<N, std::set<T>>::const_iterator c_it;
59  c_it it(m.begin()), ed(m.end());
60  for (; it != ed; ++it) {
61  o << it->first.ddname() << ": " << it->second;
62  o << std::endl;
63  }
64  return o;
65 }
66 
67 template <typename T>
69  bool result = true;
70  typename T::template iterator<T> it, ed;
71  ed.end();
72  for (; it != ed; ++it) {
73  result = it->isDefined().second;
74  if (!result)
75  DDI::Singleton<std::map<std::string, std::set<T>>>::instance()[it->name().ns()].insert(*it);
76  m[it->name().ns()].insert(it->name().name());
77  }
78  return result;
79 }
80 
81 template <typename T>
83  bool result = true;
84  typename T::template iterator<T> it, ed;
85  ed.end();
86  for (; it != ed; ++it) {
87  result = it->isDefined().second;
88  if (!result)
89  DDI::Singleton<std::map<std::string, std::set<T>>>::instance()[it->name().ns()].insert(*it);
90  m[it->name().ns()].insert(it->name().name());
91  }
92  return result;
93 }
94 
95 template <class C>
96 const std::map<std::string, std::set<C>>& dd_error_scan(const C&) {
97  typedef std::map<std::string, std::set<C>> error_type;
98  static error_type result_;
99  typename C::template iterator<C> it;
100  typename C::template iterator<C> ed(C::end());
101  for (; it != ed; ++it) {
102  if (!it->isDefined().second) {
103  result_[it->name().ns()].insert(*it);
104  }
105  }
106  return result_;
107 }
108 
110 public:
111  DDErrorDetection(const DDCompactView& cpv);
113 
114  void scan(const DDCompactView& cpv);
115 
116  void errors();
117 
118  void warnings();
119 
120  const std::map<std::string, std::set<DDLogicalPart>>& lp_cpv(const DDCompactView& cpv);
121  const std::map<DDMaterial, std::set<DDLogicalPart>>& ma_lp();
122  const std::map<DDSolid, std::set<DDLogicalPart>>& so_lp();
123  const std::map<DDSolid, std::set<DDSolid>>& so();
124 
125  void nix();
126 
127  const std::vector<std::pair<std::string, std::string>>& ma();
128 
129  void report(const DDCompactView& cpv, std::ostream& o);
130 
131  bool noErrorsInTheReport(const DDCompactView& cpv);
132 
133 private:
135 };
136 
137 #endif
void scan(const DDCompactView &cpv)
const std::map< DDSolid, std::set< DDSolid > > & so()
static PFTauRenderPlugin instance
const std::vector< std::pair< std::string, std::string > > & ma()
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
std::map< std::string, std::set< DDName >> ns_nm_type
std::map< std::string, std::set< std::string >> ns_type
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
bool noErrorsInTheReport(const DDCompactView &cpv)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
#define end
Definition: vmac.h:39
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
void report(const DDCompactView &cpv, std::ostream &o)
bool findNameSpaces(T dummy, ns_type &m)
long double T
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:41