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 109 of file DDErrorDetection.h.

Constructor & Destructor Documentation

◆ DDErrorDetection() [1/2]

DDErrorDetection::DDErrorDetection ( const DDCompactView cpv)

Definition at line 36 of file DDErrorDetection.cc.

36  {
37  DDMaterial::StoreT::instance().setReadOnly(false);
38  DDSolid::StoreT::instance().setReadOnly(false);
39  DDLogicalPart::StoreT::instance().setReadOnly(false);
40  DDSpecifics::StoreT::instance().setReadOnly(false);
41  DDRotation::StoreT::instance().setReadOnly(false);
42 
43  scan(cpv);
44 }

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

◆ ~DDErrorDetection()

DDErrorDetection::~DDErrorDetection ( )

Definition at line 46 of file DDErrorDetection.cc.

46  {
47  DDMaterial::StoreT::instance().setReadOnly(true);
48  DDSolid::StoreT::instance().setReadOnly(true);
49  DDLogicalPart::StoreT::instance().setReadOnly(true);
50  DDSpecifics::StoreT::instance().setReadOnly(true);
51  DDRotation::StoreT::instance().setReadOnly(true);
52 }

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

◆ DDErrorDetection() [2/2]

DDErrorDetection::DDErrorDetection ( )
inlineprivate

Definition at line 134 of file DDErrorDetection.h.

134 {};

Member Function Documentation

◆ errors()

void DDErrorDetection::errors ( )

Definition at line 72 of file DDErrorDetection.cc.

72 { std::cout << "What does DDErrorDetection::errors() do? nothing." << std::endl; }

References gather_cfg::cout.

◆ lp_cpv()

const std::map< std::string, std::set< DDLogicalPart > > & DDErrorDetection::lp_cpv ( const DDCompactView cpv)

Definition at line 77 of file DDErrorDetection.cc.

77  {
78  static std::map<std::string, std::set<DDLogicalPart>> result_;
79  if (!result_.empty())
80  return result_;
81 
82  const auto& g = cpv.graph();
83 
84  std::map<std::string, std::set<DDLogicalPart>>::const_iterator it(lp_err::instance().begin()),
85  ed(lp_err::instance().end());
86  for (; it != ed; ++it) {
87  std::set<DDLogicalPart>::const_iterator sit(it->second.begin()), sed(it->second.end());
88  for (; sit != sed; ++sit) {
89  const DDLogicalPart& lp = *sit;
90  auto er = g.edges(lp);
91  if (g.nodeIndex(lp).second) {
92  result_.insert(make_pair(lp.ddname().fullname(), std::set<DDLogicalPart>()));
93  }
94  for (; er.first != er.second; ++er.first) {
95  result_[lp.ddname().fullname()].insert(g.nodeData(er.first->first));
96  }
97  }
98  }
99  return result_;
100 }

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

◆ ma()

const std::vector< pair< std::string, std::string > > & DDErrorDetection::ma ( )

Definition at line 168 of file DDErrorDetection.cc.

168  {
169  static std::vector<pair<std::string, std::string>> result_;
170  ofstream o("/dev/null");
171 
172  if (!result_.empty())
173  return result_;
174 
175  DDCheckMaterials(o, &result_);
176  return result_;
177 
178  /*
179  */
180 }

References DDCheckMaterials(), and EcalTangentSkim_cfg::o.

◆ ma_lp()

const std::map< DDMaterial, std::set< DDLogicalPart > > & DDErrorDetection::ma_lp ( )

Definition at line 142 of file DDErrorDetection.cc.

142  {
143  static std::map<DDMaterial, std::set<DDLogicalPart>> result_;
144  if (!result_.empty())
145  return result_;
146 
147  const std::vector<pair<std::string, std::string>>& err_mat = ma();
148  std::vector<pair<std::string, std::string>>::const_iterator it(err_mat.begin()), ed(err_mat.end());
149  for (; it != ed; ++it) {
150  std::set<DDLogicalPart> s;
151  DDMaterial m(it->second);
152  result_[m] = s;
153  }
154  DDLogicalPart::iterator<DDLogicalPart> lpit, lped;
155  lped.end();
156  for (; lpit != lped; ++lpit) {
157  if (lpit->isDefined().second) {
158  std::map<DDMaterial, std::set<DDLogicalPart>>::iterator i = result_.find(lpit->material());
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 }

References mps_fire::i, visualization-live-secondInstance_cfg::m, and alignCSCRings::s.

◆ nix()

void DDErrorDetection::nix ( )

◆ noErrorsInTheReport()

bool DDErrorDetection::noErrorsInTheReport ( const DDCompactView cpv)

Definition at line 262 of file DDErrorDetection.cc.

262  {
263  return lp_err::instance().empty() && ma_err::instance().empty() && so_err::instance().empty() &&
264  ro_err::instance().empty() && sp_err::instance().empty() && lp_cpv(cpv).empty() && ma().empty() &&
265  so().empty() && ma_lp().empty() && so_lp().empty();
266 }

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

◆ report()

void DDErrorDetection::report ( const DDCompactView cpv,
std::ostream &  o 
)

Definition at line 225 of file DDErrorDetection.cc.

225  {
226  o << std::endl << std::endl << "---> DDD ERROR REPORT <---" << std::endl << std::endl;
227  o << "MISSING DEFINITIONS:" << std::endl << std::endl;
228  o << "LogicalParts:" << std::endl << lp_err::instance() << std::endl;
229  o << "Materials:" << std::endl << ma_err::instance() << std::endl;
230  o << "Solids:" << std::endl << so_err::instance() << std::endl;
231  o << "Rotations:" << std::endl << ro_err::instance() << std::endl;
232  o << "Specifics:" << std::endl << sp_err::instance() << std::endl;
233  o << std::endl << "IMPLICATIONS OF MISSING DEFINITIONS:" << std::endl << std::endl;
234 
235  o << "A) LogicalParts that have missing definitions but are used in the geometr. hierarchy (PosParts):" << std::endl
236  << " Format: namespace:name: [name of child]*" << std::endl;
237  o << lp_cpv(cpv) << std::endl;
238 
239  o << "B) Detailed report on Materials:" << std::endl;
240  const std::vector<pair<std::string, std::string>>& res = ma();
241  std::vector<pair<std::string, std::string>>::const_iterator it(res.begin()), ed(res.end());
242  for (; it != ed; ++it) {
243  std::cout << it->second << ": " << it->first << std::endl;
244  }
245  std::cout << std::endl;
246 
247  o << "C) Solids affected by Solids that have missing definitions:" << std::endl;
248  o << so() << std::endl;
249 
250  o << "D) LogicalParts affected by Materials of B):" << std::endl;
251  o << ma_lp() << std::endl;
252 
253  o << "E) LogicalParts affected by Solids of C):" << std::endl;
254  o << so_lp() << std::endl;
255 
256  // Did this ever exist?
257  // o << "F) Parent-Child positionings affected by Rotations that have missing definitions:" << std::endl;
258  o << std::endl;
259  //nix();
260 }

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

◆ scan()

void DDErrorDetection::scan ( const DDCompactView cpv)

Definition at line 54 of file DDErrorDetection.cc.

54  {
55  std::cout << "DDErrorDetection::scan(): Scanning for DDD errors ..." << std::flush;
56 
57  DDLogicalPart lp_dummy;
58  DDMaterial ma_dummy;
59  DDRotation ro_dummy;
60  DDSpecifics sp_dummy;
61  DDSolid so_dummy;
62 
63  lp_err::instance() = dd_error_scan(lp_dummy);
64  ma_err::instance() = dd_error_scan(ma_dummy);
65  ro_err::instance() = dd_error_scan(ro_dummy);
66  sp_err::instance() = dd_error_scan(sp_dummy);
67  so_err::instance() = dd_error_scan(so_dummy);
68 
69  std::cout << " ... finished." << std::endl;
70 }

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

◆ so()

const std::map< DDSolid, std::set< DDSolid > > & DDErrorDetection::so ( )

Definition at line 182 of file DDErrorDetection.cc.

182  {
183  static std::map<DDSolid, std::set<DDSolid>> result_;
184  if (!result_.empty())
185  return result_;
186 
187  // build the material dependency graph
188  using ma_graph_t = math::Graph<DDSolid, double>;
189  using ma_walker_t = math::GraphWalker<DDSolid, double>;
190 
191  ma_graph_t mag;
192  std::vector<DDSolid> errs;
193  DDSolid::iterator<DDSolid> it, ed;
194  ed.end();
195  for (; it != ed; ++it) {
196  DDSolid ma = *it;
197  if (ma.isDefined().second) {
198  DDSolidShape sh = ma.shape();
199  if ((sh == DDSolidShape::ddunion) || (sh == DDSolidShape::ddintersection) ||
200  (sh == DDSolidShape::ddsubtraction)) {
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  } else {
209  errs.emplace_back(ma);
210  }
211  }
212 
213  std::vector<DDSolid>::const_iterator mit(errs.begin()), med(errs.end());
214  for (; mit != med; ++mit) {
215  ma_walker_t w(mag, *mit);
216  while (w.next()) {
217  result_[*mit].insert(w.current().first);
218  }
219  std::cout << std::endl;
220  }
221 
222  return result_;
223 }

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

◆ so_lp()

const std::map< DDSolid, std::set< DDLogicalPart > > & DDErrorDetection::so_lp ( )

Definition at line 102 of file DDErrorDetection.cc.

102  {
103  static std::map<DDSolid, std::set<DDLogicalPart>> result_;
104  if (!result_.empty())
105  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;
120  lped.end();
121  for (; lpit != lped; ++lpit) {
122  if (lpit->isDefined().second) {
123  std::map<DDSolid, std::set<DDLogicalPart>>::iterator i = result_.find(lpit->solid());
124  //std::cout << "searching: " << lpit->name() << std::endl;
125  if (i != result_.end()) {
126  //std::cout << std::endl << "FOUND: " << lpit->name() << std::endl << std::endl;
127  i->second.insert(*lpit);
128  }
129  }
130  }
131  return result_;
132 }

References mps_fire::i, visualization-live-secondInstance_cfg::m, and alignCSCRings::s.

◆ warnings()

void DDErrorDetection::warnings ( )

Definition at line 74 of file DDErrorDetection.cc.

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

References gather_cfg::cout.

mps_fire.i
i
Definition: mps_fire.py:428
DDSolidShape
DDSolidShape
Definition: DDSolidShapes.h:6
math::GraphWalker
Definition: GraphWalker.h:12
gather_cfg.cout
cout
Definition: gather_cfg.py:144
dd_error_scan
const std::map< std::string, std::set< C > > & dd_error_scan(const C &)
Definition: DDErrorDetection.h:96
DDErrorDetection::so_lp
const std::map< DDSolid, std::set< DDLogicalPart > > & so_lp()
Definition: DDErrorDetection.cc:102
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
DDBooleanSolid
Definition: DDSolid.h:173
alignCSCRings.s
s
Definition: alignCSCRings.py:92
cms::cuda::bs
bs
Definition: HistoContainer.h:127
DDMaterial
DDMaterial is used to define and access material information.
Definition: DDMaterial.h:45
DDCompactView::graph
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.
Definition: DDCompactView.cc:59
w
const double w
Definition: UKUtility.cc:23
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mps_fire.end
end
Definition: mps_fire.py:242
DDSpecifics
Interface to attach user specific data to nodes in the expanded-view.
Definition: DDSpecifics.h:41
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
DDBase::ddname
const N & ddname() const
Definition: DDBase.h:61
DDI::Singleton::instance
static value_type & instance()
DDErrorDetection::ma
const std::vector< std::pair< std::string, std::string > > & ma()
Definition: DDErrorDetection.cc:168
DDLogicalPart
A DDLogicalPart aggregates information concerning material, solid and sensitveness ....
Definition: DDLogicalPart.h:93
DDErrorDetection::so
const std::map< DDSolid, std::set< DDSolid > > & so()
Definition: DDErrorDetection.cc:182
DDErrorDetection::scan
void scan(const DDCompactView &cpv)
Definition: DDErrorDetection.cc:54
res
Definition: Electron.h:6
instance
static PFTauRenderPlugin instance
Definition: PFTauRenderPlugin.cc:70
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
DDErrorDetection::ma_lp
const std::map< DDMaterial, std::set< DDLogicalPart > > & ma_lp()
Definition: DDErrorDetection.cc:142
DDSolid
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDRotation
Represents a uniquely identifyable rotation matrix.
Definition: DDTransform.h:57
math::Graph
Definition: Graph.h:13
DDName::fullname
const std::string fullname() const
Definition: DDName.h:40
DDSolidShape::ddsubtraction
DDSolidShape::ddintersection
DDErrorDetection::lp_cpv
const std::map< std::string, std::set< DDLogicalPart > > & lp_cpv(const DDCompactView &cpv)
Definition: DDErrorDetection.cc:77
DDCheckMaterials
bool DDCheckMaterials(std::ostream &, std::vector< std::pair< std::string, std::string > > *=nullptr)
DDSolidShape::ddunion
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