CMS 3D CMS Logo

DDCheck.cc
Go to the documentation of this file.
2 
3 #include <map>
4 
16 
17 bool DDCheckLP( const DDLogicalPart & lp , std::ostream & os )
18 {
19  bool result = false;
20  // is it defined or just declared?
21  if (!lp) {
22  os << "LogicalPart: " << lp << " is not defined!" << std::endl;
23  }
24  else {
25  // check solid
26  if (!lp.solid()) {
27  os << "LogicalPart: " << lp << "| no solid defined, solid="
28  << lp.solid() << std::endl;
29  }
30  else if(lp.solid().shape()==DDSolidShape::dd_not_init) {
31  os << "LogicalPart: " << lp << "| solid not init, solid="
32  << lp.solid() << std::endl;
33  }
34  // check material
35  if (!lp.material()) {
36  os << "LogicalPart: " << lp << "| no material defined, material="
37  << lp.material() << std::endl;
38  }
39  else { // check consituents recursively
40 
41  }
42  }
43  return result;
44 }
45 
46 
47 // checks PosData* if it contains sensfull stuff ...
48 //:void DDCheckPD(const DDLogicalPart & lp, Graph::neighbour_type & nb, std::ostream & os)
49 bool DDCheckPD(const DDLogicalPart & lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph & g, std::ostream & os)
50 {
51  bool result = false;
52  if (nb.first != nb.second) {
53  for (; nb.first != nb.second; ++(nb.first)) {
54  if (! nb.first->second ) {
55  edm::LogInfo ("DDCheck") << "PosData of LogicalPart " << lp.name() << " missing." << std::endl;
56  edm::LogInfo ("DDCheck") << " the LogicalPart is meant to be a daughter volume, but its position is missing!" << std::endl;
57  }
58  else { // check for the rotation matrix being present
59  const DDRotation & r = g.edgeData(nb.first->second)->ddrot();
60  if (! r.isDefined().second ) {
61  //if (! nb.first->second->rot_.rotation() ) {
62  const DDRotation & r = g.edgeData(nb.first->second)->ddrot();
63  os << "Rotationmatrix is not defined: " << r << std::endl;
64  }
65  }
66  }
67  }
68  return result;
69 }
70 
71 
72 bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)
73 {
74  bool result = false;
75  os << std::endl << "Checking connectivity of CompactView:" << std::endl;
76 
77  // Algorithm:
78  // Pass 1: walk the whole graph, mark every visited LogicalPart-node
79  // Pass 2: iterate over all nodes, check with marked nodes from Pass 1
80 
81  // Pass 1:
82  std::map<DDLogicalPart,bool> visited;
84  visited[wkr.current().first]=true;
85  while(wkr.next()) {
86  // std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
87  visited[wkr.current().first]=true;
88  }
89  os << " CompactView has " << visited.size()
90  << " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;
91 
92  // Pass 2:
93  DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());
94 
95  int uc = 0;
97 
98  for(; it < g.size(); ++it) {
99  if (! visited[g.nodeData(it)] ) {
100  ++uc;
101  os << " " << g.nodeData(it).ddname();
102  }
103  }
104  os << std::endl;
105  os << " There were " << uc << " unconnected nodes found." << std::endl << std::endl;
106  if (uc) {
107  os << std::endl;
108  os << " ****************************************************************************" << std::endl;
109  os << " WARNING: The geometrical hierarchy may not be complete. " << std::endl
110  << " Expect unpredicted behaviour using DDCore/interface (i.e. SEGFAULT)"
111  << std::endl;
112  os << " ****************************************************************************" << std::endl;
113  os << std::endl;
114 
115  }
116  return result;
117 }
118 
119 // iterates over the whole compactview and chechs whether the posdata
120 // (edges in the acyclic graph ..) are complete
121 bool DDCheckAll(const DDCompactView & cpv, std::ostream & os)
122 {
123  bool result = false;
124  // const_cast because Graph does not provide const_iterators!
125  DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());
126 
127  // basic debuggger
128  std::map< std::pair<std::string,std::string>, int > lp_names;
129 
131  for(; it < g.size(); ++it) {
132  const DDLogicalPart & lp = g.nodeData(it);
133  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
134  }
135 
136  for( const auto& mit : lp_names ) {
137  if (mit.second >1) {
138  os << "interesting: " << mit.first.first << ":" << mit.first.second
139  << " counted " << mit.second << " times!" << std::endl;
140  os << " Names of LogicalParts seem not to be unique!" << std::endl << std::endl;
141  result = true;
142 
143  }
144  }
145  // iterate over all nodes in the graph (nodes are logicalparts,
146  // edges are posdata*
147  for(it=0; it < g.size(); ++it) {
148  const DDLogicalPart & lp = g.nodeData(it);
149  result |= DDCheckLP(lp,os);
150  result |= DDCheckPD(lp ,g.edges(it), g, os);
151  }
152 
153  // Check the connectivity of the graph..., takes quite some time & memory
154  result |= DDCheckConnect(cpv, os);
155  return result;
156 }
157 
158 // comprehensive check, very cpu intensive!
159 // - expands the compact-view
160 // - detects cyclic containment of parts (not yet)
161 // - checks for completeness of solid & material definition / logical-part
162 bool DDCheck(std::ostream&os)
163 {
164  bool result = false;
165  os << "DDCore: start comprehensive checking" << std::endl;
166  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
167  DDExpandedView exv(cpv);
168  result |= DDCheckAll(cpv,os);
169 
170  // done
171  os << "DDCore: end of comprehensive checking" << std::endl;
172 
173  if (result) { // at least one error found
174  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
175  }
176 
177  return result;
178 }
179 
180 bool DDCheck(const DDCompactView& cpv, std::ostream&os)
181 {
182  bool result = false;
183  os << "DDCore: start comprehensive checking" << std::endl;
184  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
185  DDExpandedView exv(cpv);
186  result |= DDCheckAll(cpv,os);
187 
188  // done
189  os << "DDCore: end of comprehensive checking" << std::endl;
190 
191  if (result) { // at least one error found
192  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
193  }
194 
195  return result;
196 }
def_type isDefined() const
Definition: DDBase.h:107
const N & name() const
Definition: DDBase.h:74
edge_range edges(index_type nodeIndex)
Definition: Graph.h:272
bool DDCheck(std::ostream &os)
Definition: DDCheck.cc:162
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:17
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:67
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
uint16_t size_type
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
std::pair< edge_iterator, edge_iterator > edge_range
Definition: Graph.h:135
const N & nodeData(const edge_type &) const
Definition: Graph.h:312
const E & edgeData(index_type i) const
Definition: Graph.h:178
const DDRotation & ddrot() const
Definition: DDPosData.h:34
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:72
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:121
auto size() const -> adj_list::size_type
Definition: Graph.h:196
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph &g, std::ostream &os)
Definition: DDCheck.cc:49
Provides an exploded view of the detector (tree-view)
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
const N & ddname() const
Definition: DDBase.h:76