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
DDErrorDetection::report
void report(const DDCompactView &cpv, std::ostream &o)
Definition: DDErrorDetection.cc:225
DDErrorDetection::warnings
void warnings()
Definition: DDErrorDetection.cc:74
DDTransform.h
DDName
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:15
DDI::Singleton
Definition: Singleton.h:6
DDErrorDetection::nix
void nix()
findQualityFiles.v
v
Definition: findQualityFiles.py:179
findNameSpaces
bool findNameSpaces(T dummy, ns_type &m)
Definition: DDErrorDetection.h:68
dd_error_scan
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
Definition: DDErrorDetection.h:96
DDErrorDetection::so_lp
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
Definition: DDErrorDetection.cc:102
DDErrorDetection::DDErrorDetection
DDErrorDetection()
Definition: DDErrorDetection.h:134
DDCompactView.h
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
ns_type
std::map< std::string, std::set< std::string > > ns_type
Definition: DDErrorDetection.h:33
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
DDCompactView
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
ns_nm_type
std::map< std::string, std::set< DDName > > ns_nm_type
Definition: DDErrorDetection.h:34
mps_fire.end
end
Definition: mps_fire.py:242
N
#define N
Definition: blowfish.cc:9
operator<<
std::ostream & operator<<(std::ostream &o, const std::set< T > &v)
Definition: DDErrorDetection.h:37
DDSolid.h
DDSpecifics
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:41
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DDSpecifics.h
DDErrorDetection::ma
const std::vector< std::pair< std::string, std::string > > & ma()
Definition: DDErrorDetection.cc:168
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDMaterial.h
DDErrorDetection::so
const std::map< DDSolid, std::set< DDSolid > > & so()
Definition: DDErrorDetection.cc:182
DDErrorDetection::~DDErrorDetection
~DDErrorDetection()
Definition: DDErrorDetection.cc:46
DDErrorDetection::scan
void scan(const DDCompactView &cpv)
Definition: DDErrorDetection.cc:54
svgfig.template
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
DDLogicalPart.h
DDErrorDetection
Definition: DDErrorDetection.h:109
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
Singleton.h
gen::C
C
Definition: PomwigHadronizer.cc:78
T
long double T
Definition: Basic3DVectorLD.h:48
DDErrorDetection::errors
void errors()
Definition: DDErrorDetection.cc:72
DDErrorDetection::ma_lp
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
Definition: DDErrorDetection.cc:142
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
mps_fire.result
result
Definition: mps_fire.py:311
genParticles_cff.map
map
Definition: genParticles_cff.py:11
dummy
Definition: DummySelector.h:38
DDErrorDetection::lp_cpv
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
Definition: DDErrorDetection.cc:77
DDErrorDetection::noErrorsInTheReport
bool noErrorsInTheReport(const DDCompactView &cpv)
Definition: DDErrorDetection.cc:262