CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
DDCheck.cc File Reference
#include "DetectorDescription/RegressionTest/src/DDCheck.h"
#include <map>
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDMaterial.h"
#include "DetectorDescription/Core/interface/DDName.h"
#include "DetectorDescription/Core/interface/DDPosData.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDSolidShapes.h"
#include "DetectorDescription/Core/interface/DDTransform.h"
#include "DataFormats/Math/interface/Graph.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Functions

bool DDCheck (std::ostream &os)
 
bool DDCheck (const DDCompactView &cpv, std::ostream &os)
 
bool DDCheckAll (const DDCompactView &cpv, std::ostream &os)
 
bool DDCheckConnect (const DDCompactView &cpv, std::ostream &os)
 
bool DDCheckLP (const DDLogicalPart &lp, std::ostream &os)
 
bool DDCheckPD (const DDLogicalPart &lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph &g, std::ostream &os)
 

Function Documentation

bool DDCheck ( std::ostream &  os)

Definition at line 149 of file DDCheck.cc.

References DDCheckAll(), and mps_fire::result.

149  {
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 }
Log< level::Error, false > LogError
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
tuple result
Definition: mps_fire.py:311
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:110
Provides an exploded view of the detector (tree-view)
bool DDCheck ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 166 of file DDCheck.cc.

References DDCheckAll(), and mps_fire::result.

166  {
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 }
Log< level::Error, false > LogError
tuple result
Definition: mps_fire.py:311
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:110
Provides an exploded view of the detector (tree-view)
bool DDCheckAll ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 110 of file DDCheck.cc.

References DDCheckConnect(), DDCheckLP(), DDCheckPD(), math::Graph< N, E >::edges(), g, DDCompactView::graph(), DDName::name(), DDBase< N, C >::name(), math::Graph< N, E >::nodeData(), DDName::ns(), mps_fire::result, and math::Graph< N, E >::size().

Referenced by DDCheck().

110  {
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 }
const N & name() const
Definition: DDBase.h:59
edge_range edges(index_type nodeIndex)
Definition: Graph.h:240
auto size() const -> adj_list::size_type
Definition: Graph.h:176
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:17
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:52
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:311
const N & nodeData(const edge_type &) const
Definition: Graph.h:272
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:64
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph &g, std::ostream &os)
Definition: DDCheck.cc:40
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
bool DDCheckConnect ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 64 of file DDCheck.cc.

References DDBase< N, C >::ddname(), g, DDCompactView::graph(), math::Graph< N, E >::nodeData(), mps_fire::result, DDCompactView::root(), math::Graph< N, E >::size(), and class-composition::visited.

Referenced by DDCheckAll().

64  {
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 }
auto size() const -> adj_list::size_type
Definition: Graph.h:176
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:311
const N & nodeData(const edge_type &) const
Definition: Graph.h:272
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
const N & ddname() const
Definition: DDBase.h:61
bool DDCheckLP ( const DDLogicalPart lp,
std::ostream &  os 
)

Definition at line 17 of file DDCheck.cc.

References dd_not_init, DDLogicalPart::material(), mps_fire::result, DDSolid::shape(), and DDLogicalPart::solid().

Referenced by DDCheckAll().

17  {
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 }
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
tuple result
Definition: mps_fire.py:311
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
bool DDCheckPD ( const DDLogicalPart lp,
DDCompactView::Graph::edge_range  nb,
const DDCompactView::Graph g,
std::ostream &  os 
)

Definition at line 40 of file DDCheck.cc.

References DDPosData::ddrot(), math::Graph< N, E >::edgeData(), DDBase< N, C >::isDefined(), DDBase< N, C >::name(), alignCSCRings::r, and mps_fire::result.

Referenced by DDCheckAll().

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!"
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 }
def_type isDefined() const
Definition: DDBase.h:90
const N & name() const
Definition: DDBase.h:59
tuple result
Definition: mps_fire.py:311
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
const E & edgeData(index_type i) const
Definition: Graph.h:158
const DDRotation & ddrot() const
Definition: DDPosData.h:32
Log< level::Info, false > LogInfo