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()==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_type::neighbour_type & nb, 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)->rot_;
60  if (! r.isDefined().second ) {
61  //if (! nb.first->second->rot_.rotation() ) {
62  const DDRotation & r = g.edgeData(nb.first->second)->rot_;
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;
83  // walker_type wkr = DDCompactView().walker();
84  walker_type wkr = cpv.walker();
85  visited[wkr.current().first]=true;
86  while(wkr.next()) {
87  // std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
88  visited[wkr.current().first]=true;
89  }
90  os << " CompactView has " << visited.size()
91  << " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;
92 
93  // Pass 2:
95 
96  int uc = 0;
98 
99  for(; it < g.size(); ++it) {
100  if (! visited[g.nodeData(it)] ) {
101  ++uc;
102  os << " " << g.nodeData(it).ddname();
103  }
104  }
105  os << std::endl;
106  os << " There were " << uc << " unconnected nodes found." << std::endl << std::endl;
107  if (uc) {
108  os << std::endl;
109  os << " ****************************************************************************" << std::endl;
110  os << " WARNING: The geometrical hierarchy may not be complete. " << std::endl
111  << " Expect unpredicted behaviour using DDCore/interface (i.e. SEGFAULT)"
112  << std::endl;
113  os << " ****************************************************************************" << std::endl;
114  os << std::endl;
115 
116  }
117  return result;
118 }
119 
120 // iterates over the whole compactview and chechs whether the posdata
121 // (edges in the acyclic graph ..) are complete
122 bool DDCheckAll(const DDCompactView & cpv, std::ostream & os)
123 {
124  bool result = false;
125  // const_cast because graph_type does not provide const_iterators!
127 
128  // basic debuggger
129  std::map< std::pair<std::string,std::string>, int > lp_names;
130 
132  for(; it < g.size(); ++it) {
133  const DDLogicalPart & lp = g.nodeData(it);
134  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
135  }
136 
137  for( const auto& mit : lp_names ) {
138  if (mit.second >1) {
139  os << "interesting: " << mit.first.first << ":" << mit.first.second
140  << " counted " << mit.second << " times!" << std::endl;
141  os << " Names of LogicalParts seem not to be unique!" << std::endl << std::endl;
142  result = true;
143 
144  }
145  }
146  // iterate over all nodes in the graph (nodes are logicalparts,
147  // edges are posdata*
148  for(it=0; it < g.size(); ++it) {
149  const DDLogicalPart & lp = g.nodeData(it);
150  result |= DDCheckLP(lp,os);
151  result |= DDCheckPD(lp ,g.edges(it), g, os);
152  }
153 
154  // Check the connectivity of the graph..., takes quite some time & memory
155  result |= DDCheckConnect(cpv, os);
156  return result;
157 }
158 
159 // comprehensive check, very cpu intensive!
160 // - expands the compact-view
161 // - detects cyclic containment of parts (not yet)
162 // - checks for completeness of solid & material definition / logical-part
163 bool DDCheck(std::ostream&os)
164 {
165  bool result = false;
166  os << "DDCore: start comprehensive checking" << std::endl;
167  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
168  DDExpandedView exv(cpv);
169  result |= DDCheckAll(cpv,os);
170 
171  // done
172  os << "DDCore: end of comprehensive checking" << std::endl;
173 
174  if (result) { // at least one error found
175  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
176  }
177 
178  return result;
179 }
180 
181 bool DDCheck(const DDCompactView& cpv, std::ostream&os)
182 {
183  bool result = false;
184  os << "DDCore: start comprehensive checking" << std::endl;
185  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
186  DDExpandedView exv(cpv);
187  result |= DDCheckAll(cpv,os);
188 
189  // done
190  os << "DDCore: end of comprehensive checking" << std::endl;
191 
192  if (result) { // at least one error found
193  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
194  }
195 
196  return result;
197 }
adj_list::size_type size() const
Definition: adjgraph.h:201
def_type isDefined() const
Definition: DDBase.h:110
const N & name() const
Definition: DDBase.h:78
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:138
bool DDCheck(std::ostream &os)
Definition: DDCheck.cc:163
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:17
const graph_type & graph() const
Provides read-only access to the data structure of the compact-view.
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:104
const N & nodeData(const edge_type &) const
Definition: adjgraph.h:317
const E & edgeData(index_type i) const
Definition: adjgraph.h:183
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
type of data representation of DDCompactView
Definition: DDCompactView.h:90
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:66
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:151
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:72
result_type next()
Definition: graphwalker.h:185
value_type current() const
Definition: graphwalker.h:109
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:122
walker_type walker() const
dont&#39;t use ! Proper implementation missing ...
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
Provides an exploded view of the detector (tree-view)
const std::string & name() const
Returns the name.
Definition: DDName.cc:90
DDRotation rot_
Definition: DDPosData.h:37
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::graph_type::edge_range nb, const DDCompactView::graph_type &g, std::ostream &os)
Definition: DDCheck.cc:49
const N & ddname() const
Definition: DDBase.h:80