CMS 3D CMS Logo

Functions
DDCheck.cc File Reference
#include "DetectorDescription/Core/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 162 of file DDCheck.cc.

References DDCheckAll(), and mps_fire::result.

163 {
164  bool result = false;
165  os << "DDCore: start comprehensive checking" << std::endl;
166  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
167  DDExpandedView exv(cpv);
168  result |= DDCheckAll(cpv,os);
169 
170  // done
171  os << "DDCore: end of comprehensive checking" << std::endl;
172 
173  if (result) { // at least one error found
174  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
175  }
176 
177  return result;
178 }
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:83
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:121
Provides an exploded view of the detector (tree-view)
bool DDCheck ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 180 of file DDCheck.cc.

References DDCheckAll(), and mps_fire::result.

181 {
182  bool result = false;
183  os << "DDCore: start comprehensive checking" << std::endl;
184  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
185  DDExpandedView exv(cpv);
186  result |= DDCheckAll(cpv,os);
187 
188  // done
189  os << "DDCore: end of comprehensive checking" << std::endl;
190 
191  if (result) { // at least one error found
192  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
193  }
194 
195  return result;
196 }
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:121
Provides an exploded view of the detector (tree-view)
bool DDCheckAll ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 121 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().

122 {
123  bool result = false;
124  // const_cast because Graph does not provide const_iterators!
125  DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());
126 
127  // basic debuggger
128  std::map< std::pair<std::string,std::string>, int > lp_names;
129 
131  for(; it < g.size(); ++it) {
132  const DDLogicalPart & lp = g.nodeData(it);
133  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
134  }
135 
136  for( const auto& mit : lp_names ) {
137  if (mit.second >1) {
138  os << "interesting: " << mit.first.first << ":" << mit.first.second
139  << " counted " << mit.second << " times!" << std::endl;
140  os << " Names of LogicalParts seem not to be unique!" << std::endl << std::endl;
141  result = true;
142 
143  }
144  }
145  // iterate over all nodes in the graph (nodes are logicalparts,
146  // edges are posdata*
147  for(it=0; it < g.size(); ++it) {
148  const DDLogicalPart & lp = g.nodeData(it);
149  result |= DDCheckLP(lp,os);
150  result |= DDCheckPD(lp ,g.edges(it), g, os);
151  }
152 
153  // Check the connectivity of the graph..., takes quite some time & memory
154  result |= DDCheckConnect(cpv, os);
155  return result;
156 }
const N & name() const
Definition: DDBase.h:78
edge_range edges(index_type nodeIndex)
Definition: Graph.h:272
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:17
const std::string & ns() const
Returns the namespace.
Definition: DDName.cc:102
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
const N & nodeData(const edge_type &) const
Definition: Graph.h:312
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:92
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:72
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
auto size() const -> adj_list::size_type
Definition: Graph.h:196
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::Graph::edge_range nb, const DDCompactView::Graph &g, std::ostream &os)
Definition: DDCheck.cc:49
const std::string & name() const
Returns the name.
Definition: DDName.cc:88
bool DDCheckConnect ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 72 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().

73 {
74  bool result = false;
75  os << std::endl << "Checking connectivity of CompactView:" << std::endl;
76 
77  // Algorithm:
78  // Pass 1: walk the whole graph, mark every visited LogicalPart-node
79  // Pass 2: iterate over all nodes, check with marked nodes from Pass 1
80 
81  // Pass 1:
82  std::map<DDLogicalPart,bool> visited;
84  visited[wkr.current().first]=true;
85  while(wkr.next()) {
86  // std::cout << "DDCheck" << " " << wkr.current().first << std::endl;
87  visited[wkr.current().first]=true;
88  }
89  os << " CompactView has " << visited.size()
90  << " (multiple-)connected LogicalParts with root=" << cpv.root().ddname() << std::endl;
91 
92  // Pass 2:
93  DDCompactView::Graph & g = const_cast<DDCompactView::Graph&>(cpv.graph());
94 
95  int uc = 0;
97 
98  for(; it < g.size(); ++it) {
99  if (! visited[g.nodeData(it)] ) {
100  ++uc;
101  os << " " << g.nodeData(it).ddname();
102  }
103  }
104  os << std::endl;
105  os << " There were " << uc << " unconnected nodes found." << std::endl << std::endl;
106  if (uc) {
107  os << std::endl;
108  os << " ****************************************************************************" << std::endl;
109  os << " WARNING: The geometrical hierarchy may not be complete. " << std::endl
110  << " Expect unpredicted behaviour using DDCore/interface (i.e. SEGFAULT)"
111  << std::endl;
112  os << " ****************************************************************************" << std::endl;
113  os << std::endl;
114 
115  }
116  return result;
117 }
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
const N & nodeData(const edge_type &) const
Definition: Graph.h:312
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
auto size() const -> adj_list::size_type
Definition: Graph.h:196
const DDLogicalPart & root() const
returns the DDLogicalPart representing the root of the geometrical hierarchy
const N & ddname() const
Definition: DDBase.h:80
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().

18 {
19  bool result = false;
20  // is it defined or just declared?
21  if (!lp) {
22  os << "LogicalPart: " << lp << " is not defined!" << std::endl;
23  }
24  else {
25  // check solid
26  if (!lp.solid()) {
27  os << "LogicalPart: " << lp << "| no solid defined, solid="
28  << lp.solid() << std::endl;
29  }
30  else if(lp.solid().shape()==DDSolidShape::dd_not_init) {
31  os << "LogicalPart: " << lp << "| solid not init, solid="
32  << lp.solid() << std::endl;
33  }
34  // check material
35  if (!lp.material()) {
36  os << "LogicalPart: " << lp << "| no material defined, material="
37  << lp.material() << std::endl;
38  }
39  else { // check consituents recursively
40 
41  }
42  }
43  return result;
44 }
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
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 49 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().

50 {
51  bool result = false;
52  if (nb.first != nb.second) {
53  for (; nb.first != nb.second; ++(nb.first)) {
54  if (! nb.first->second ) {
55  edm::LogInfo ("DDCheck") << "PosData of LogicalPart " << lp.name() << " missing." << std::endl;
56  edm::LogInfo ("DDCheck") << " the LogicalPart is meant to be a daughter volume, but its position is missing!" << std::endl;
57  }
58  else { // check for the rotation matrix being present
59  const DDRotation & r = g.edgeData(nb.first->second)->ddrot();
60  if (! r.isDefined().second ) {
61  //if (! nb.first->second->rot_.rotation() ) {
62  const DDRotation & r = g.edgeData(nb.first->second)->ddrot();
63  os << "Rotationmatrix is not defined: " << r << std::endl;
64  }
65  }
66  }
67  }
68  return result;
69 }
def_type isDefined() const
Definition: DDBase.h:110
const N & name() const
Definition: DDBase.h:78
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:67
const E & edgeData(index_type i) const
Definition: Graph.h:178
const DDRotation & ddrot() const
Definition: DDPosData.h:34