CMS 3D CMS Logo

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 (const DDCompactView &cpv, std::ostream &os)
 
bool DDCheck (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

◆ DDCheck() [1/2]

bool DDCheck ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 166 of file DDCheck.cc.

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 }

References DDCheckAll(), and mps_fire::result.

◆ DDCheck() [2/2]

bool DDCheck ( std::ostream &  os)

Definition at line 149 of file DDCheck.cc.

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 }

References DDCheckAll(), and mps_fire::result.

◆ DDCheckAll()

bool DDCheckAll ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 110 of file DDCheck.cc.

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 }

References DDCheckConnect(), DDCheckLP(), DDCheckPD(), g, DDCompactView::graph(), DDName::name(), DDBase< N, C >::name(), DDName::ns(), and mps_fire::result.

Referenced by DDCheck().

◆ DDCheckConnect()

bool DDCheckConnect ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 64 of file DDCheck.cc.

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 }

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

Referenced by DDCheckAll().

◆ DDCheckLP()

bool DDCheckLP ( const DDLogicalPart lp,
std::ostream &  os 
)

Definition at line 17 of file DDCheck.cc.

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 }

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

Referenced by DDCheckAll().

◆ DDCheckPD()

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.

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 }

References g, DDBase< N, C >::name(), alignCSCRings::r, and mps_fire::result.

Referenced by DDCheckAll().

DDCheckPD
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph &g, std::ostream &os)
Definition: DDCheck.cc:40
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
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
DDSolid::shape
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:119
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
class-composition.visited
visited
Definition: class-composition.py:74
DDExpandedView
Provides an exploded view of the detector (tree-view)
Definition: DDExpandedView.h:41
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
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
DDSolidShape::dd_not_init
alignCSCRings.r
r
Definition: alignCSCRings.py:93
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
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
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