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.
6 
7 // Message logger.
9 
10 bool DDCheckLP(const DDLogicalPart & lp, std::ostream & os)
11 {
12  bool result = false;
13  // is it defined or just declared?
14  if (!lp) {
15  os << "LogicalPart: " << lp << " is not defined!" << std::endl;
16  }
17  else {
18  // check solid
19  if (!lp.solid()) {
20  os << "LogicalPart: " << lp << "| no solid defined, solid="
21  << lp.solid() << std::endl;
22  }
23  else if(lp.solid().shape()==dd_not_init) {
24  os << "LogicalPart: " << lp << "| solid not init, solid="
25  << lp.solid() << std::endl;
26  }
27  // check material
28  if (!lp.material()) {
29  os << "LogicalPart: " << lp << "| no material defined, material="
30  << lp.material() << std::endl;
31  }
32  else { // check consituents recursively
33 
34  }
35  }
36  return result;
37 }
38 
39 
40 // checks PosData* if it contains sensfull stuff ...
41 //:void DDCheckPD(const DDLogicalPart & lp, graph_type::neighbour_type & nb, std::ostream & os)
43 {
44  bool result = false;
45  if (nb.first != nb.second) {
46  for (; nb.first != nb.second; ++(nb.first)) {
47  if (! nb.first->second ) {
48  edm::LogInfo ("DDCheck") << "PosData of LogicalPart " << lp.name() << " missing." << std::endl;
49  edm::LogInfo ("DDCheck") << " the LogicalPart is meant to be a daughter volume, but its position is missing!" << std::endl;
50  }
51  else { // check for the rotation matrix being present
52  const DDRotation & r = g.edgeData(nb.first->second)->rot_;
53  if (! r.isDefined().second ) {
54  //if (! nb.first->second->rot_.rotation() ) {
55  const DDRotation & r = g.edgeData(nb.first->second)->rot_;
56  os << "Rotationmatrix is not defined: " << r << std::endl;
57  }
58  }
59  }
60  }
61  return result;
62 }
63 
64 
65 bool DDCheckConnect(const DDCompactView & cpv, std::ostream & os)
66 {
67  bool result = false;
68  os << std::endl << "Checking connectivity of CompactView:" << std::endl;
69 
70  // Algorithm:
71  // Pass 1: walk the whole graph, mark every visited LogicalPart-node
72  // Pass 2: iterate over all nodes, check with marked nodes from Pass 1
73 
74  // Pass 1:
75  std::map<DDLogicalPart,bool> visited;
76  // walker_type wkr = DDCompactView().walker();
77  walker_type wkr = cpv.walker();
78  visited[wkr.current().first]=true;
79  while(wkr.next()) {
80  // std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
81  visited[wkr.current().first]=true;
82  }
83  os << " CompactView has " << visited.size()
84  << " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;
85 
86  // Pass 2:
88 
89  int uc = 0;
91 
92  for(; it < g.size(); ++it) {
93  if (! visited[g.nodeData(it)] ) {
94  ++uc;
95  os << " " << g.nodeData(it).ddname();
96  }
97  }
98  os << std::endl;
99  os << " There were " << uc << " unconnected nodes found." << std::endl << std::endl;
100  if (uc) {
101  os << std::endl;
102  os << " ****************************************************************************" << std::endl;
103  os << " WARNING: The geometrical hierarchy may not be complete. " << std::endl
104  << " Expect unpredicted behaviour using DDCore/interface (i.e. SEGFAULT)"
105  << std::endl;
106  os << " ****************************************************************************" << std::endl;
107  os << std::endl;
108 
109  }
110  return result;
111 }
112 
113 // iterates over the whole compactview and chechs whether the posdata
114 // (edges in the acyclic graph ..) are complete
115 bool DDCheckAll(const DDCompactView & cpv, std::ostream & os)
116 {
117  bool result = false;
118  // const_cast because graph_type does not provide const_iterators!
120 
121  // basic debuggger
122  std::map< std::pair<std::string,std::string>, int > lp_names;
123 
125  for(; it < g.size(); ++it) {
126  const DDLogicalPart & lp = g.nodeData(it);
127  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
128  }
129 
130  for( const auto& mit : lp_names ) {
131  if (mit.second >1) {
132  os << "interesting: " << mit.first.first << ":" << mit.first.second
133  << " counted " << mit.second << " times!" << std::endl;
134  os << " Names of LogicalParts seem not to be unique!" << std::endl << std::endl;
135  result = true;
136 
137  }
138  }
139  // iterate over all nodes in the graph (nodes are logicalparts,
140  // edges are posdata*
141  for(it=0; it < g.size(); ++it) {
142  const DDLogicalPart & lp = g.nodeData(it);
143  result |= DDCheckLP(lp,os);
144  result |= DDCheckPD(lp ,g.edges(it), g, os);
145  }
146 
147  // Check the connectivity of the graph..., takes quite some time & memory
148  result |= DDCheckConnect(cpv, os);
149  return result;
150 }
151 
152 // comprehensive check, very cpu intensive!
153 // - expands the compact-view
154 // - detects cyclic containment of parts (not yet)
155 // - checks for completeness of solid & material definition / logical-part
156 bool DDCheck(std::ostream&os)
157 {
158  bool result = false;
159  os << "DDCore: start comprehensive checking" << std::endl;
160  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
161  DDExpandedView exv(cpv);
162  result |= DDCheckAll(cpv,os);
163 
164  // done
165  os << "DDCore: end of comprehensive checking" << std::endl;
166 
167  if (result) { // at least one error found
168  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
169  }
170 
171  return result;
172 }
173 
174 bool DDCheck(const DDCompactView& cpv, std::ostream&os)
175 {
176  bool result = false;
177  os << "DDCore: start comprehensive checking" << std::endl;
178  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
179  DDExpandedView exv(cpv);
180  result |= DDCheckAll(cpv,os);
181 
182  // done
183  os << "DDCore: end of comprehensive checking" << std::endl;
184 
185  if (result) { // at least one error found
186  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
187  }
188 
189  return result;
190 }
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:156
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:10
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: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:77
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
tuple result
Definition: mps_fire.py:95
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:88
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:65
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:115
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:87
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:42
const N & ddname() const
Definition: DDBase.h:80