CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
DDErrorDetection Class Reference

#include <DDErrorDetection.h>

Public Member Functions

 DDErrorDetection (const DDCompactView &cpv)
 
void errors ()
 
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv (const DDCompactView &cpv)
 
const std::vector< std::pair< std::string, std::string > > & ma ()
 
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp ()
 
void nix ()
 
bool noErrorsInTheReport (const DDCompactView &cpv)
 
void report (const DDCompactView &cpv, std::ostream &o)
 
void scan (const DDCompactView &cpv)
 
const std::map< DDSolid, std::set< DDSolid > > & so ()
 
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp ()
 
void warnings ()
 
 ~DDErrorDetection ()
 

Private Member Functions

 DDErrorDetection ()
 

Detailed Description

Definition at line 111 of file DDErrorDetection.h.

Constructor & Destructor Documentation

DDErrorDetection::DDErrorDetection ( const DDCompactView cpv)

Definition at line 36 of file DDErrorDetection.cc.

References DDI::Singleton< I >::instance().

37 {
38  DDMaterial::StoreT::instance().setReadOnly(false);
39  DDSolid::StoreT::instance().setReadOnly(false);
40  DDLogicalPart::StoreT::instance().setReadOnly(false);
41  DDSpecifics::StoreT::instance().setReadOnly(false);
42  DDRotation::StoreT::instance().setReadOnly(false);
43 
44  scan(cpv);
45 }
void scan(const DDCompactView &cpv)
static value_type & instance()
DDErrorDetection::~DDErrorDetection ( )

Definition at line 47 of file DDErrorDetection.cc.

References DDI::Singleton< I >::instance().

47  {
48  DDMaterial::StoreT::instance().setReadOnly(true);
49  DDSolid::StoreT::instance().setReadOnly(true);
50  DDLogicalPart::StoreT::instance().setReadOnly(true);
51  DDSpecifics::StoreT::instance().setReadOnly(true);
52  DDRotation::StoreT::instance().setReadOnly(true);
53 }
static value_type & instance()
DDErrorDetection::DDErrorDetection ( )
inlineprivate

Definition at line 137 of file DDErrorDetection.h.

137 { };

Member Function Documentation

void DDErrorDetection::errors ( )

Definition at line 75 of file DDErrorDetection.cc.

References gather_cfg::cout.

76 {
77  std::cout << "What does DDErrorDetection::errors() do? nothing." << std::endl;
78 }
const std::map< std::string, std::set< DDLogicalPart > > & DDErrorDetection::lp_cpv ( const DDCompactView cpv)

Definition at line 86 of file DDErrorDetection.cc.

References begin, DDBase< N, C >::ddname(), end, DDName::fullname(), g, DDCompactView::graph(), and DDI::Singleton< I >::instance().

87 {
88  static std::map<std::string, std::set<DDLogicalPart> > result_;
89  if (!result_.empty()) return result_;
90 
91  const auto & g = cpv.graph();
92 
93  std::map<std::string, std::set<DDLogicalPart> >::const_iterator it(lp_err::instance().begin()),
94  ed(lp_err::instance().end());
95  for (; it != ed; ++it) {
96  std::set<DDLogicalPart>::const_iterator sit(it->second.begin()), sed(it->second.end());
97  for( ; sit != sed; ++sit) {
98  const DDLogicalPart & lp = *sit;
99  auto er = g.edges(lp);
100  if (g.nodeIndex(lp).second) {
101  result_.insert(make_pair(lp.ddname().fullname(), std::set<DDLogicalPart>()));
102  }
103  for (; er.first != er.second; ++er.first) {
104  result_[lp.ddname().fullname()].insert(g.nodeData(er.first->first));
105  }
106  }
107  }
108  return result_;
109 }
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
static value_type & instance()
const std::string fullname() const
Definition: DDName.h:43
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
#define end
Definition: vmac.h:39
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
#define begin
Definition: vmac.h:32
const N & ddname() const
Definition: DDBase.h:76
const std::vector< pair< std::string, std::string > > & DDErrorDetection::ma ( )

Definition at line 177 of file DDErrorDetection.cc.

References DDCheckMaterials(), and connectstrParser::o.

178 {
179  static std::vector<pair<std::string, std::string> > result_;
180  ofstream o("/dev/null");
181 
182  if (!result_.empty()) return result_;
183 
184  DDCheckMaterials(o,&result_);
185  return result_;
186 
187 /*
188  */
189 }
bool DDCheckMaterials(std::ostream &, std::vector< std::pair< std::string, std::string > > *=0)
const std::map< DDMaterial, std::set< DDLogicalPart > > & DDErrorDetection::ma_lp ( )

Definition at line 151 of file DDErrorDetection.cc.

References mps_fire::i, funct::m, and alignCSCRings::s.

152 {
153  static std::map<DDMaterial, std::set<DDLogicalPart> > result_;
154  if (!result_.empty()) return result_;
155 
156  const std::vector<pair<std::string, std::string> > & err_mat = ma();
157  std::vector<pair<std::string, std::string> >::const_iterator it(err_mat.begin()), ed(err_mat.end());
158  for (; it != ed; ++it) {
159  std::set<DDLogicalPart> s;
160  DDMaterial m(it->second);
161  result_[m]=s;
162  }
163  DDLogicalPart::iterator<DDLogicalPart> lpit,lped; lped.end();
164  for (; lpit != lped; ++lpit) {
165  if (lpit->isDefined().second) {
166  std::map<DDMaterial, std::set<DDLogicalPart> >::iterator i = result_.find(lpit->material());
167  if ( i != result_.end() ) {
168  //std::cout << std::endl << "FOUND: " << lpit->name() << std::endl << std::endl;
169  i->second.insert(*lpit);
170  }
171  }
172  }
173  return result_;
174 }
const std::vector< std::pair< std::string, std::string > > & ma()
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
void DDErrorDetection::nix ( )
bool DDErrorDetection::noErrorsInTheReport ( const DDCompactView cpv)

Definition at line 282 of file DDErrorDetection.cc.

References DDI::Singleton< I >::instance().

283 {
284  return lp_err::instance().empty() &&
285  ma_err::instance().empty() &&
286  so_err::instance().empty() &&
287  ro_err::instance().empty() &&
288  sp_err::instance().empty() &&
289  lp_cpv(cpv).empty() &&
290  ma().empty() &&
291  so().empty() &&
292  ma_lp().empty() &&
293  so_lp().empty();
294 }
const std::map< DDSolid, std::set< DDSolid > > & so()
const std::vector< std::pair< std::string, std::string > > & ma()
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
static value_type & instance()
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
void DDErrorDetection::report ( const DDCompactView cpv,
std::ostream &  o 
)

Definition at line 237 of file DDErrorDetection.cc.

References gather_cfg::cout, and DDI::Singleton< I >::instance().

238 {
239 
240  o << std::endl << std::endl << "---> DDD ERROR REPORT <---" << std::endl << std::endl;
241  o << "MISSING DEFINITIONS:" << std::endl << std::endl;
242  o << "LogicalParts:" << std::endl
243  << lp_err::instance() << std::endl;
244  o << "Materials:" << std::endl
245  << ma_err::instance() << std::endl;
246  o << "Solids:" << std::endl
247  << so_err::instance() << std::endl;
248  o << "Rotations:" << std::endl
249  << ro_err::instance() << std::endl;
250  o << "Specifics:" << std::endl
251  << sp_err::instance() << std::endl;
252  o << std::endl << "IMPLICATIONS OF MISSING DEFINITIONS:" << std::endl << std::endl;
253 
254  o << "A) LogicalParts that have missing definitions but are used in the geometr. hierarchy (PosParts):" << std::endl
255  << " Format: namespace:name: [name of child]*" << std::endl;
256  o << lp_cpv(cpv) << std::endl;
257 
258  o << "B) Detailed report on Materials:" << std::endl;
259  const std::vector<pair<std::string,std::string>> & res = ma();
260  std::vector<pair<std::string,std::string>>::const_iterator it(res.begin()), ed(res.end());
261  for (; it != ed; ++it) {
262  std::cout << it->second << ": " << it->first << std::endl;
263  }
264  std::cout << std::endl;
265 
266 
267  o << "C) Solids affected by Solids that have missing definitions:" << std::endl;
268  o << so() << std::endl;
269 
270  o << "D) LogicalParts affected by Materials of B):" << std::endl;
271  o << ma_lp() << std::endl;
272 
273  o << "E) LogicalParts affected by Solids of C):" << std::endl;
274  o << so_lp() << std::endl;
275 
276  // Did this ever exist?
277  // o << "F) Parent-Child positionings affected by Rotations that have missing definitions:" << std::endl;
278  o << std::endl;
279  //nix();
280 }
const std::map< DDSolid, std::set< DDSolid > > & so()
const std::vector< std::pair< std::string, std::string > > & ma()
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
Definition: Electron.h:6
static value_type & instance()
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
void DDErrorDetection::scan ( const DDCompactView cpv)

Definition at line 56 of file DDErrorDetection.cc.

References gather_cfg::cout, dd_error_scan(), and DDI::Singleton< I >::instance().

57 {
58  std::cout << "DDErrorDetection::scan(): Scanning for DDD errors ..." << std::flush;
59 
60  DDLogicalPart lp_dummy;
61  DDMaterial ma_dummy;
62  DDRotation ro_dummy;
63  DDSpecifics sp_dummy;
64  DDSolid so_dummy;
65 
66  lp_err::instance() = dd_error_scan(lp_dummy);
67  ma_err::instance() = dd_error_scan(ma_dummy);
68  ro_err::instance() = dd_error_scan(ro_dummy);
69  sp_err::instance() = dd_error_scan(sp_dummy);
70  so_err::instance() = dd_error_scan(so_dummy);
71 
72  std::cout << " ... finished." << std::endl;
73 }
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:43
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:68
static value_type & instance()
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:41
const std::map< DDSolid, std::set< DDSolid > > & DDErrorDetection::so ( )

Definition at line 192 of file DDErrorDetection.cc.

References a, b, gather_cfg::cout, ddintersection, ddsubtraction, ddunion, DDBase< N, C >::isDefined(), mag(), DDSolid::shape(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and w.

193 {
194  static std::map<DDSolid, std::set<DDSolid> > result_;
195  if (!result_.empty()) return result_;
196 
197  // build the material dependency graph
198  using ma_graph_t = math::Graph<DDSolid,double>;
199  using ma_walker_t = math::GraphWalker<DDSolid,double>;
200 
201  ma_graph_t mag;
202  std::vector<DDSolid> errs;
203  DDSolid::iterator<DDSolid> it, ed; ed.end();
204  for (; it != ed; ++it) {
205  DDSolid ma = *it;
206  if (ma.isDefined().second) {
207  DDSolidShape sh = ma.shape();
209  DDBooleanSolid bs(ma);
210  DDSolid a(bs.solidA()),b(bs.solidB());
211  //DDRotation r(bs.rotation());
212  //DDTranslation t(bs.translation);
213  mag.addEdge(a, ma, 0);
214  mag.addEdge(b, ma, 0);
215  }
216  }
217  else {
218  errs.emplace_back(ma);
219  }
220  }
221 
222  std::vector<DDSolid>::const_iterator mit(errs.begin()),
223  med(errs.end());
224  for (; mit != med; ++mit) {
225 
226  ma_walker_t w(mag,*mit);
227  while (w.next()) {
228  result_[*mit].insert(w.current().first);
229  }
230  std::cout << std::endl;
231  }
232 
233  return result_;
234 }
def_type isDefined() const
Definition: DDBase.h:107
const double w
Definition: UKUtility.cc:23
const std::vector< std::pair< std::string, std::string > > & ma()
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
DDSolidShape
Definition: DDSolidShapes.h:6
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
const std::map< DDSolid, std::set< DDLogicalPart > > & DDErrorDetection::so_lp ( )

Definition at line 112 of file DDErrorDetection.cc.

References mps_fire::i, funct::m, and alignCSCRings::s.

113 {
114  static std::map<DDSolid, std::set<DDLogicalPart> > result_;
115  if (!result_.empty()) return result_;
116 
117  const std::map<DDSolid, std::set<DDSolid> > & err_mat = so();
118  std::map<DDSolid, std::set<DDSolid> >::const_iterator it(err_mat.begin()), ed(err_mat.end());
119  for (; it != ed; ++it) {
120  std::set<DDLogicalPart> s;
121  DDSolid m(it->first);
122  result_[m]=s;
123  std::set<DDSolid>::const_iterator sit(it->second.begin()), sed(it->second.end());
124  for(; sit != sed; ++sit) {
125  result_[*sit] = s;
126  }
127  //std::cout << "insert: " << m.name() << std::endl;
128  }
129  DDLogicalPart::iterator<DDLogicalPart> lpit,lped; lped.end();
130  for (; lpit != lped; ++lpit) {
131  if (lpit->isDefined().second) {
132  std::map<DDSolid, std::set<DDLogicalPart> >::iterator i = result_.find(lpit->solid());
133  //std::cout << "searching: " << lpit->name() << std::endl;
134  if ( i != result_.end() ) {
135  //std::cout << std::endl << "FOUND: " << lpit->name() << std::endl << std::endl;
136  i->second.insert(*lpit);
137  }
138  }
139  }
140  return result_;
141 }
const std::map< DDSolid, std::set< DDSolid > > & so()
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
void DDErrorDetection::warnings ( )

Definition at line 80 of file DDErrorDetection.cc.

References gather_cfg::cout.

81 {
82  std::cout << "What does DDErrorDetection::warnings() do? nothing." << std::endl;
83 }