CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
DDCheck.cc File Reference
#include "DetectorDescription/Core/src/DDCheck.h"
#include "DetectorDescription/Core/interface/DDCompactView.h"
#include "DetectorDescription/Core/interface/DDExpandedView.h"
#include "DetectorDescription/Core/interface/DDLogicalPart.h"
#include "DetectorDescription/Core/interface/DDSolid.h"
#include "DetectorDescription/Core/interface/DDMaterial.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_type::edge_range nb, const DDCompactView::graph_type &g, std::ostream &os)
 

Function Documentation

bool DDCheck ( std::ostream &  os)

Definition at line 167 of file DDCheck.cc.

References DDCheckAll(), and query::result.

168 {
169  bool result = false;
170  os << "DDCore: start comprehensive checking" << std::endl;
171  DDCompactView cpv; // THE one and only (prototype restriction) CompactView
172  DDExpandedView exv(cpv);
173 
174  // result |= DDCheckMaterials(os);
175  //DDCheckLP(exv.logicalPart(),os);
176  result |= DDCheckAll(cpv,os);
177 
178  // done
179  os << "DDCore: end of comprehensive checking" << std::endl;
180 
181  if (result) { // at least one error found
182  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
183 // edm::LogError("DDCheck") << "To continue press 'y' ... " << std::endl;
184 // char c;
185 // cin >> c;
186 // if (c != 'y') {
187 // edm::LogError("DDCheck") << " terminating ..." << std::endl; exit(1);
188 // (Mike Case) should we throw instead? OR is an if (DDCheck) the best way?
189 // throw(DDException(std::string("DDD:DDCore:DDCheck: found inconsistency problems!"));
190  }
191 
192  return result;
193 }
type of data representation of DDCompactView
Definition: DDCompactView.h:81
tuple result
Definition: query.py:137
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:120
Provides an exploded view of the detector (tree-view)
bool DDCheck ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 195 of file DDCheck.cc.

References DDCheckAll(), and query::result.

196 {
197  bool result = false;
198  os << "DDCore: start comprehensive checking" << std::endl;
199  // DDCompactView cpv; // THE one and only (prototype restriction) CompactView
200  DDExpandedView exv(cpv);
201 
202  // result |= DDCheckMaterials(os);
203  //DDCheckLP(exv.logicalPart(),os);
204  result |= DDCheckAll(cpv,os);
205 
206  // done
207  os << "DDCore: end of comprehensive checking" << std::endl;
208 
209  if (result) { // at least one error found
210  edm::LogError("DDCheck") << std::endl << "DDD:DDCore:DDCheck: found inconsistency problems!" << std::endl;
211 // edm::LogError("DDCheck") << "To continue press 'y' ... " << std::endl;
212 // char c;
213 // cin >> c;
214 // if (c != 'y') {
215 // edm::LogError("DDCheck") << " terminating ..." << std::endl; exit(1);
216 // (Mike Case) should we throw instead? OR is an if (DDCheck) the best way?
217 // throw(DDException(std::string("DDD:DDCore:DDCheck: found inconsistency problems!"));
218  }
219 
220  return result;
221 }
tuple result
Definition: query.py:137
bool DDCheckAll(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:120
Provides an exploded view of the detector (tree-view)
bool DDCheckAll ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 120 of file DDCheck.cc.

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

Referenced by DDCheck().

121 {
122  bool result = false;
123  // const_cast because graph_type does not provide const_iterators!
125 
126  // basic debuggger
127  std::map< std::pair<std::string,std::string>, int > lp_names;
128 
130  for(; it < g.size(); ++it) {
131  const DDLogicalPart & lp = g.nodeData(it);
132  lp_names[std::make_pair(lp.name().ns(),lp.name().name())]++;
133  }
134  std::map< std::pair<std::string,std::string>, int >::iterator mit = lp_names.begin();
135 
136 
137  for (; mit != lp_names.end(); ++ mit) {
138  if (mit->second >1) {
139  os << "interesting: " << mit->first.first << ":" << mit->first.second
140  << " counted " << mit->second << " times!" << std::endl;
141  os << " Names of LogicalParts seem not to be unique!" << std::endl << std::endl;
142  result = true;
143 
144  }
145  //os << "registered: " << mit->first.first << ":" << mit->first.second << std::endl;
146 
147  }
148  // iterate over all nodes in the graph (nodes are logicalparts,
149  // edges are posdata*
150  for(it=0; it < g.size(); ++it) {
151  const DDLogicalPart & lp = g.nodeData(it);
152  result |= DDCheckLP(lp,os);
153  result |= DDCheckPD(lp ,g.edges(it), g, os);
154  }
155 
156  // Check the connectivity of the graph..., takes quite some time & memory
157  result |= DDCheckConnect(cpv, os);
158  return result;
159 
160 }
adj_list::size_type size() const
Definition: adjgraph.h:202
const N & name() const
Definition: DDBase.h:88
bool DDCheckLP(const DDLogicalPart &lp, std::ostream &os)
Definition: DDCheck.cc:15
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:318
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
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:278
tuple result
Definition: query.py:137
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:95
bool DDCheckConnect(const DDCompactView &cpv, std::ostream &os)
Definition: DDCheck.cc:70
static DDI::Store< N, C >::iterator begin()
Definition: DDBase.h:76
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
bool DDCheckPD(const DDLogicalPart &lp, DDCompactView::graph_type::edge_range nb, const DDCompactView::graph_type &g, std::ostream &os)
Definition: DDCheck.cc:47
bool DDCheckConnect ( const DDCompactView cpv,
std::ostream &  os 
)

Definition at line 70 of file DDCheck.cc.

References graphwalker< N, E >::current(), DDBase< N, C >::ddname(), g, DDCompactView::graph(), graphwalker< N, E >::next(), graph< N, E >::nodeData(), query::result, DDCompactView::root(), graph< N, E >::size(), and DDCompactView::walker().

Referenced by DDCheckAll().

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

Definition at line 15 of file DDCheck.cc.

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

Referenced by DDCheckAll().

16 {
17  bool result = false;
18  // is it defined or just declared?
19  if (!lp) {
20  os << "LogicalPart: " << lp << " is not defined!" << std::endl;
21  }
22  else {
23  // check solid
24  if (!lp.solid()) {
25  os << "LogicalPart: " << lp << "| no solid defined, solid="
26  << lp.solid() << std::endl;
27  }
28  else if(lp.solid().shape()==dd_not_init) {
29  os << "LogicalPart: " << lp << "| solid not init, solid="
30  << lp.solid() << std::endl;
31  }
32  // check material
33  if (!lp.material()) {
34  os << "LogicalPart: " << lp << "| no material defined, material="
35  << lp.material() << std::endl;
36  }
37  else { // check consituents recursively
38 
39  }
40  }
41  return result;
42 }
DDSolidShape shape() const
The type of the solid.
Definition: DDSolid.cc:147
const DDMaterial & material() const
Returns a reference object of the material this LogicalPart is made of.
tuple result
Definition: query.py:137
const DDSolid & solid() const
Returns a reference object of the solid being the shape of this LogicalPart.
bool DDCheckPD ( const DDLogicalPart lp,
DDCompactView::graph_type::edge_range  nb,
const DDCompactView::graph_type g,
std::ostream &  os 
)

Definition at line 47 of file DDCheck.cc.

References graph< N, E >::edgeData(), DDBase< N, C >::isDefined(), DDBase< N, C >::name(), csvReporter::r, query::result, and DDPosData::rot_.

Referenced by DDCheckAll().

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