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