test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDErrorDetection.cc
Go to the documentation of this file.
1 namespace std { } using namespace std;
2 
5 #include <iostream>
6 #include <fstream>
7 
8 //**** to get rid of compile errors about ambiguous delete of Stores
13 
14 //***** Explicit template instantiation of Singleton
15 #include "DetectorDescription/Base/interface/Singleton.icc"
16 
22 
23 //*****
24 
26 {
27  DDMaterial::StoreT::instance().setReadOnly(false);
28  DDSolid::StoreT::instance().setReadOnly(false);
29  DDLogicalPart::StoreT::instance().setReadOnly(false);
30  DDSpecifics::StoreT::instance().setReadOnly(false);
31  DDRotation::StoreT::instance().setReadOnly(false);
32 
33  scan(cpv);
34 }
35 
37  DDMaterial::StoreT::instance().setReadOnly(true);
38  DDSolid::StoreT::instance().setReadOnly(true);
39  DDLogicalPart::StoreT::instance().setReadOnly(true);
40  DDSpecifics::StoreT::instance().setReadOnly(true);
41  DDRotation::StoreT::instance().setReadOnly(true);
42 }
43 
44 
46 {
47  std::cout << "DDErrorDetection::scan(): Scanning for DDD errors ..." << std::flush;
48 
49  DDLogicalPart lp_dummy;
50  DDMaterial ma_dummy;
51  DDRotation ro_dummy;
52  DDSpecifics sp_dummy;
53  DDSolid so_dummy;
54 
55  lp_err::instance() = dd_error_scan(lp_dummy);
56  ma_err::instance() = dd_error_scan(ma_dummy);
57  ro_err::instance() = dd_error_scan(ro_dummy);
58  sp_err::instance() = dd_error_scan(sp_dummy);
59  so_err::instance() = dd_error_scan(so_dummy);
60 
61  std::cout << " ... finished." << std::endl;
62 }
63 
65 {
66  std::cout << "What does DDErrorDetection::errors() do? nothing." << std::endl;
67 }
68 
70 {
71  std::cout << "What does DDErrorDetection::warnings() do? nothing." << std::endl;
72 }
73 
74 // ddname as std::string, std::set<edges>
75 const std::map<std::string, std::set<DDLogicalPart> > & DDErrorDetection::lp_cpv( const DDCompactView & cpv)
76 {
77  static std::map<std::string, std::set<DDLogicalPart> > result_;
78  if (result_.size()) return result_;
79 
80  // DDCompactView cpv;
81  const DDCompactView::graph_type & g = cpv.graph();
82 
83  std::map<std::string, std::set<DDLogicalPart> >::const_iterator it(lp_err::instance().begin()),
84  ed(lp_err::instance().end());
85  for (; it != ed; ++it) {
86  std::set<DDLogicalPart>::const_iterator sit(it->second.begin()), sed(it->second.end());
87  for( ; sit != sed; ++sit) {
88  const DDLogicalPart & lp = *sit;
90  if (g.nodeIndex(lp).second) {
91  result_.insert(make_pair(lp.ddname().fullname(), std::set<DDLogicalPart>()));
92  }
93  for (; er.first != er.second; ++er.first) {
94  result_[lp.ddname().fullname()].insert(g.nodeData(er.first->first));
95  }
96  }
97  }
98  return result_;
99 }
100 
101 
102 const std::map<DDSolid, std::set<DDLogicalPart> > & DDErrorDetection::so_lp()
103 {
104  static std::map<DDSolid, std::set<DDLogicalPart> > result_;
105  if (result_.size()) return result_;
106 
107  const std::map<DDSolid, std::set<DDSolid> > & err_mat = so();
108  std::map<DDSolid, std::set<DDSolid> >::const_iterator it(err_mat.begin()), ed(err_mat.end());
109  for (; it != ed; ++it) {
110  std::set<DDLogicalPart> s;
111  DDSolid m(it->first);
112  result_[m]=s;
113  std::set<DDSolid>::const_iterator sit(it->second.begin()), sed(it->second.end());
114  for(; sit != sed; ++sit) {
115  result_[*sit] = s;
116  }
117  //std::cout << "insert: " << m.name() << std::endl;
118  }
119  DDLogicalPart::iterator<DDLogicalPart> lpit,lped; lped.end();
120  for (; lpit != lped; ++lpit) {
121  if (lpit->isDefined().second) {
122  std::map<DDSolid, std::set<DDLogicalPart> >::iterator i = result_.find(lpit->solid());
123  //std::cout << "searching: " << lpit->name() << std::endl;
124  if ( i != result_.end() ) {
125  //std::cout << std::endl << "FOUND: " << lpit->name() << std::endl << std::endl;
126  i->second.insert(*lpit);
127  }
128  }
129  }
130  return result_;
131 }
132 
133 /*
134 const std::map<DDSpecifics, std::set<pair<DDLogicalPart, std::string> > & DDErrorDetection::sp()
135 {
136  static std::map<DDSpecifics, std::set<pair<DDLogicalPart, std::string> result_;
137  if (result_.size()) return result_;
138 }
139 */
140 
141 const std::map<DDMaterial, std::set<DDLogicalPart> > & DDErrorDetection::ma_lp()
142 {
143  static std::map<DDMaterial, std::set<DDLogicalPart> > result_;
144  if (result_.size()) return result_;
145 
146  const std::vector<pair<std::string,DDName> > & err_mat = ma();
147  std::vector<pair<std::string,DDName> >::const_iterator it(err_mat.begin()), ed(err_mat.end());
148  for (; it != ed; ++it) {
149  std::set<DDLogicalPart> s;
150  DDMaterial m(it->second);
151  result_[m]=s;
152  //std::cout << "insert: " << m.name() << std::endl;
153  }
154  DDLogicalPart::iterator<DDLogicalPart> lpit,lped; lped.end();
155  for (; lpit != lped; ++lpit) {
156  if (lpit->isDefined().second) {
157  std::map<DDMaterial, std::set<DDLogicalPart> >::iterator i = result_.find(lpit->material());
158  //std::cout << "searching: " << lpit->name() << std::endl;
159  if ( i != result_.end() ) {
160  //std::cout << std::endl << "FOUND: " << lpit->name() << std::endl << std::endl;
161  i->second.insert(*lpit);
162  }
163  }
164  }
165  return result_;
166 }
167 
168 
169 const std::vector<pair<std::string,DDName> > & DDErrorDetection::ma()
170 {
171  static std::vector<pair<std::string,DDName> > result_;
172  ofstream o("/dev/null");
173 
174  if (result_.size()) return result_;
175 
176  DDCheckMaterials(o,&result_);
177  return result_;
178 
179 /*
180  */
181 }
182 
183 
184 const std::map<DDSolid,std::set<DDSolid> > & DDErrorDetection::so()
185 {
186  static std::map<DDSolid, std::set<DDSolid> > result_;
187  if (result_.size()) return result_;
188 
189  // build the material dependency graph
190  typedef graph<DDSolid,double> ma_graph_t;
191  typedef graphwalker<DDSolid,double> ma_walker_t;
192 
193  ma_graph_t mag;
194  std::vector<DDSolid> errs;
195  DDSolid::iterator<DDSolid> it, ed; ed.end();
196  for (; it != ed; ++it) {
197  DDSolid ma = *it;
198  if (ma.isDefined().second) {
199  DDSolidShape sh = ma.shape();
200  if ( (sh == ddunion) || (sh == ddintersection) || (sh == ddsubtraction) ) {
201  DDBooleanSolid bs(ma);
202  DDSolid a(bs.solidA()),b(bs.solidB());
203  //DDRotation r(bs.rotation());
204  //DDTranslation t(bs.translation);
205  mag.addEdge(a, ma, 0);
206  mag.addEdge(b, ma, 0);
207  }
208  }
209  else {
210  errs.push_back(ma);
211  }
212  }
213 
214  std::vector<DDSolid>::const_iterator mit(errs.begin()),
215  med(errs.end());
216  for (; mit != med; ++mit) {
217 
218  try {
219  // loop over erroreous materials
220  ma_walker_t w(mag,*mit);
221  while (w.next()) {
222  result_[*mit].insert(w.current().first);
223  }
224  std::cout << std::endl;
225  }
226  catch(DDSolid m) {
227  ;
228  //std::cout << "no such material: " << m << " for creating a walker." << std::endl;
229  }
230  }
231  return result_;
232 }
233 
234 
235 void DDErrorDetection::report(const DDCompactView& cpv, ostream & o)
236 {
237 
238  o << std::endl << std::endl << "---> DDD ERROR REPORT <---" << std::endl << std::endl;
239  o << "MISSING DEFINITIONS:" << std::endl << std::endl;
240  o << "LogicalParts:" << std::endl
241  << lp_err::instance() << std::endl;
242  o << "Materials:" << std::endl
243  << ma_err::instance() << std::endl;
244  o << "Solids:" << std::endl
245  << so_err::instance() << std::endl;
246  o << "Rotations:" << std::endl
247  << ro_err::instance() << std::endl;
248  o << "Specifics:" << std::endl
249  << sp_err::instance() << std::endl;
250  o << std::endl << "IMPLICATIONS OF MISSING DEFINITIONS:" << std::endl << std::endl;
251 
252  o << "A) LogicalParts that have missing definitions but are used in the geometr. hierarchy (PosParts):" << std::endl
253  << " Format: namespace:name: [name of child]*" << std::endl;
254  o << lp_cpv(cpv) << std::endl;
255 
256  o << "B) Detailed report on Materials:" << std::endl;
257  const std::vector<pair<std::string,DDName> > & res = ma();
258  std::vector<pair<std::string,DDName> >::const_iterator it(res.begin()), ed(res.end());
259  for (; it != ed; ++it) {
260  std::cout << it->second << ": " << it->first << std::endl;
261  }
262  std::cout << std::endl;
263 
264 
265  o << "C) Solids affected by Solids that have missing definitions:" << std::endl;
266  o << so() << std::endl;
267 
268  o << "D) LogicalParts affected by Materials of B):" << std::endl;
269  o << ma_lp() << std::endl;
270 
271  o << "E) LogicalParts affected by Solids of C):" << std::endl;
272  o << so_lp() << std::endl;
273 
274  // Did this ever exist?
275  // o << "F) Parent-Child positionings affected by Rotations that have missing definitions:" << std::endl;
276  o << std::endl;
277  //nix();
278 }
279 
281 {
282  return lp_err::instance().empty() &&
283  ma_err::instance().empty() &&
284  so_err::instance().empty() &&
285  ro_err::instance().empty() &&
286  sp_err::instance().empty() &&
287  lp_cpv(cpv).empty() &&
288  ma().empty() &&
289  so().empty() &&
290  ma_lp().empty() &&
291  so_lp().empty();
292 }
void scan(const DDCompactView &cpv)
int i
Definition: DBlmapReader.cc:9
def_type isDefined() const
Definition: DDBase.h:110
const std::map< DDSolid, std::set< DDSolid > > & so()
const double w
Definition: UKUtility.cc:23
std::pair< const_edge_iterator, const_edge_iterator > const_edge_range
Definition: adjgraph.h:140
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:41
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
DDSolidShape
Definition: DDSolidShapes.h:6
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:317
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
type of data representation of DDCompactView
Definition: DDCompactView.h:77
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
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
DDSolid solidB(void) const
Definition: DDSolid.cc:550
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:66
static value_type & instance()
edge_range edges(index_type nodeIndex)
Definition: adjgraph.h:277
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
bool noErrorsInTheReport(const DDCompactView &cpv)
const std::string fullname() const
Definition: DDName.h:51
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:88
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
#define end
Definition: vmac.h:37
const std::vector< std::pair< std::string, DDName > > & ma()
DDSolid solidA(void) const
Definition: DDSolid.cc:545
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
void report(const DDCompactView &cpv, std::ostream &o)
double b
Definition: hdecay.h:120
#define begin
Definition: vmac.h:30
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:145
bool DDCheckMaterials(std::ostream &, std::vector< std::pair< std::string, DDName > > *=0)
Checks all registered materials and sends a report /p os.
index_result nodeIndex(const N &) const
Definition: adjgraph.h:252
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:37
const N & ddname() const
Definition: DDBase.h:80