CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDCheck.cc
Go to the documentation of this file.
2 
8 
9 // Message logger.
11 
12 
13 //#include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
14 
15 bool DDCheckLP(const DDLogicalPart & lp, std::ostream & os)
16 {
17  bool result = false;
18  // is it defined or just declared?
19  if (!lp) {
20  os << "LogicalPart: " << lp << " is not defined!" << std::endl;
21  }
22  else {
23  // check solid
24  if (!lp.solid()) {
25  os << "LogicalPart: " << lp << "| no solid defined, solid="
26  << lp.solid() << std::endl;
27  }
28  else if(lp.solid().shape()==dd_not_init) {
29  os << "LogicalPart: " << lp << "| solid not init, solid="
30  << lp.solid() << std::endl;
31  }
32  // check material
33  if (!lp.material()) {
34  os << "LogicalPart: " << lp << "| no material defined, material="
35  << lp.material() << std::endl;
36  }
37  else { // check consituents recursively
38 
39  }
40  }
41  return result;
42 }
43 
44 
45 // checks PosData* if it contains sensfull stuff ...
46 //:void DDCheckPD(const DDLogicalPart & lp, graph_type::neighbour_type & nb, std::ostream & os)
48 {
49  bool result = false;
50  if (nb.first != nb.second) {
51  for (; nb.first != nb.second; ++(nb.first)) {
52  if (! nb.first->second ) {
53  edm::LogInfo ("DDCheck") << "PosData of LogicalPart " << lp.name() << " missing." << std::endl;
54  edm::LogInfo ("DDCheck") << " the LogicalPart is meant to be a daughter volume, but its position is missing!" << std::endl;
55  }
56  else { // check for the rotation matrix being present
57  const DDRotation & r = g.edgeData(nb.first->second)->rot_;
58  if (! r.isDefined().second ) {
59  //if (! nb.first->second->rot_.rotation() ) {
60  const DDRotation & r = g.edgeData(nb.first->second)->rot_;
61  os << "Rotationmatrix is not defined: " << r << std::endl;
62  }
63  }
64  }
65  }
66  return result;
67 }
68 
69 
70 bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)
71 {
72  bool result = false;
73  os << std::endl << "Checking connectivity of CompactView:" << std::endl;
74 
75  // Algorithm:
76  // Pass 1: walk the whole graph, mark every visited LogicalPart-node
77  // Pass 2: iterate over all nodes, check with marked nodes from Pass 1
78 
79  // Pass 1:
80  std::map<DDLogicalPart,bool> visited;
81  // walker_type wkr = DDCompactView().walker();
82  walker_type wkr = cpv.walker();
83  visited[wkr.current().first]=true;
84  while(wkr.next()) {
85  // std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
86  visited[wkr.current().first]=true;
87  }
88  os << " CompactView has " << visited.size()
89  << " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;
90 
91  // Pass 2:
93 
94  int uc = 0;
96 
97  for(; it < g.size(); ++it) {
98  if (! visited[g.nodeData(it)] ) {
99  ++uc;
100  os << " " << g.nodeData(it).ddname();
101  }
102  }
103  os << std::endl;
104  os << " There were " << uc << " unconnected nodes found." << std::endl << std::endl;
105  if (uc) {
106  os << std::endl;
107  os << " ****************************************************************************" << std::endl;
108  os << " WARNING: The geometrical hierarchy may not be complete. " << std::endl
109  << " Expect unpredicted behaviour using DDCore/interface (i.e. SEGFAULT)"
110  << std::endl;
111  os << " ****************************************************************************" << std::endl;
112  os << std::endl;
113 
114  }
115  return result;
116 }
117 
118 // iterates over the whole compactview and chechs whether the posdata
119 // (edges in the acyclic graph ..) are complete
120 bool DDCheckAll(const DDCompactView & cpv, std::ostream & os)
121 {
122  bool result = false;
123  // const_cast because graph_type does not provide const_iterators!
125 
126  // basic debuggger
127  std::map< std::pair<std::string,std::string>, int > lp_names;
128 
130  for(; it < g.size(); ++it) {
131  const DDLogicalPart & lp = g.nodeData(it);
132  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
133  }
134  std::map< std::pair<std::string,std::string>, int >::iterator mit = lp_names.begin();
135 
136 
137  for (; mit != lp_names.end(); ++ mit) {
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  //os << "registered: " << mit->first.first << ":" << mit->first.second << std::endl;
146 
147  }
148  // iterate over all nodes in the graph (nodes are logicalparts,
149  // edges are posdata*
150  for(it=0; it < g.size(); ++it) {
151  const DDLogicalPart & lp = g.nodeData(it);
152  result |= DDCheckLP(lp,os);
153  result |= DDCheckPD(lp ,g.edges(it), g, os);
154  }
155 
156  // Check the connectivity of the graph..., takes quite some time & memory
157  result |= DDCheckConnect(cpv, os);
158  return result;
159 
160 }
161 
162 
163 // comprehensive check, very cpu intensive!
164 // - expands the compact-view
165 // - detects cyclic containment of parts (not yet)
166 // - checks for completeness of solid & material definition / logical-part
167 bool DDCheck(std::ostream&os)
168 {
169  bool result = false;
170  os << "DDCore: start comprehensive checking" << std::endl;
171  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
172  DDExpandedView exv(cpv);
173 
174  // result |= DDCheckMaterials(os);
175  //DDCheckLP(exv.logicalPart(),os);
176  result |= DDCheckAll(cpv,os);
177 
178  // done
179  os << "DDCore: end of comprehensive checking" << std::endl;
180 
181  if (result) { // at least one error found
182  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
183 // edm::LogError("DDCheck") << "To continue press 'y' ... " << std::endl;
184 // char c;
185 // cin >> c;
186 // if (c != 'y') {
187 // edm::LogError("DDCheck") << " terminating ..." << std::endl; exit(1);
188 // (Mike Case) should we throw instead? OR is an if (DDCheck) the best way?
189 // throw(DDException(std::string("DDD:DDCore:DDCheck: found inconsistency problems!"));
190  }
191 
192  return result;
193 }
194 
195 bool DDCheck(const DDCompactView& cpv, std::ostream&os)
196 {
197  bool result = false;
198  os << "DDCore: start comprehensive checking" << std::endl;
199  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
200  DDExpandedView exv(cpv);
201 
202  // result |= DDCheckMaterials(os);
203  //DDCheckLP(exv.logicalPart(),os);
204  result |= DDCheckAll(cpv,os);
205 
206  // done
207  os << "DDCore: end of comprehensive checking" << std::endl;
208 
209  if (result) { // at least one error found
210  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
211 // edm::LogError("DDCheck") << "To continue press 'y' ... " << std::endl;
212 // char c;
213 // cin >> c;
214 // if (c != 'y') {
215 // edm::LogError("DDCheck") << " terminating ..." << std::endl; exit(1);
216 // (Mike Case) should we throw instead? OR is an if (DDCheck) the best way?
217 // throw(DDException(std::string("DDD:DDCore:DDCheck: found inconsistency problems!"));
218  }
219 
220  return result;
221 }
adj_list::size_type size() const
Definition: adjgraph.h:202
def_type isDefined() const
Definition: DDBase.h:121
const N & name() const
Definition: DDBase.h:88
std::pair< edge_iterator, edge_iterator > edge_range
Definition: adjgraph.h:139
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
bool DDCheck(std::ostream &os)
Definition: DDCheck.cc:167
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:15
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:101
const N & nodeData(const edge_type &) const
Definition: adjgraph.h:318
const E & edgeData(index_type i) const
Definition: adjgraph.h:184
type of data representation of DDCompactView
Definition: DDCompactView.h:81
uint16_t size_type
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
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:278
tuple result
Definition: query.py:137
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:70
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:120
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
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
static DDI::Store< N, C >::iterator begin()
Definition: DDBase.h:76
Provides an exploded view of the detector (tree-view)
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
DDRotation rot_
Definition: DDPosData.h:49
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::graph_type::edge_range nb, const DDCompactView::graph_type &g, std::ostream &os)
Definition: DDCheck.cc:47
const N & ddname() const
Definition: DDBase.h:90