CMS 3D CMS Logo

Classes | Functions
DDCompareTools.h File Reference
#include <vector>
#include "DetectorDescription/Core/interface/DDRotationMatrix.h"
#include "DetectorDescription/Core/interface/DDTranslation.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/DDTransform.h"

Go to the source code of this file.

Classes

struct  DDCompOptions
 DDComparators need to know if names of DDRotation matter. More...
 

Functions

bool DDCompareBoolSol (const DDBooleanSolid &lhs, const DDBooleanSolid &rhs, const DDCompOptions &ddco)
 Needs to know because of Rotation Matrix of Boolean Relationship. More...
 
bool DDCompareCPV (const DDCompactView &lhs, const DDCompactView &rhs, const DDCompOptions &ddco)
 
bool DDCompareDBLVEC (const std::vector< double > &lhs, const std::vector< double > &rhs, double tol=0.0004)
 
bool DDCompareDDRot (const DDRotation &lhs, const DDRotation &rhs, const DDCompOptions &ddco)
 Allows to compare name or not. If not, compares only values of the rotation matrix. More...
 
bool DDCompareDDRotMat (const DDRotationMatrix &lhs, const DDRotationMatrix &rhs, double tol=0.0004)
 
bool DDCompareDDTrans (const DDTranslation &lhs, const DDTranslation &rhs, double tol=0.0004)
 
bool DDCompareEPV (DDExpandedView &lhs, DDExpandedView &rhs, const DDCompOptions &ddco)
 
bool DDCompareLP (const DDLogicalPart &lhs, const DDLogicalPart &rhs, const DDCompOptions &ddco)
 LogicalParts have solids which could be BooleanSolids. More...
 
bool DDCompareSolid (const DDSolid &lhs, const DDSolid &rhs, const DDCompOptions &ddco)
 Needs to know about rotmat because of BooleanSolid. More...
 

Function Documentation

◆ DDCompareBoolSol()

bool DDCompareBoolSol ( const DDBooleanSolid lhs,
const DDBooleanSolid rhs,
const DDCompOptions ddco 
)

Needs to know because of Rotation Matrix of Boolean Relationship.

Definition at line 221 of file DDCompareTools.cc.

References gather_cfg::cout, DDCompareDBLVEC(), DDCompareDDRot(), DDCompareDDTrans(), DDCompareSolid(), DDCompOptions::distTol_, DDName::fullname(), DDBase< N, C >::name(), DDSolid::parameters(), runTheMatrix::ret, DDBooleanSolid::rotation(), DDSolid::shape(), DDBooleanSolid::solidA(), DDBooleanSolid::solidB(), and DDBooleanSolid::translation().

Referenced by DDCompareSolid().

221  {
222  bool ret(true);
223  if (lhs.name().fullname() != rhs.name().fullname()) {
224  ret = false;
225  std::cout << "BooleanSolid names do not match ";
226  } else if (lhs.shape() != rhs.shape()) {
227  ret = false;
228  std::cout << "BooleanSolid shape types do not match ";
229  } else if (!DDCompareDBLVEC(lhs.parameters(), rhs.parameters(), ddco.distTol_)) {
230  ret = false;
231  std::cout << "BooleanSolid parameters do not match ";
232  } else if (!DDCompareSolid(lhs.solidA(), rhs.solidA(), ddco)) {
233  ret = false;
234  std::cout << "BooleanSolid SolidA solids do not match ";
235  } else if (!DDCompareSolid(lhs.solidB(), rhs.solidB(), ddco)) {
236  ret = false;
237  std::cout << "BooleanSolid SolidB solids do not match ";
238  } else if (!DDCompareDDTrans(lhs.translation(), rhs.translation(), ddco.distTol_)) {
239  ret = false;
240  std::cout << "BooleanSolid Translations do not match ";
241  } else if (!DDCompareDDRot(lhs.rotation(), rhs.rotation(), ddco)) {
242  ret = false;
243  std::cout << "BooleanSolid Rotations do not match ";
244  }
245  if (!ret) {
246  std::cout << "for boolean solids " << lhs.name().fullname() << " and " << rhs.name().fullname() << std::endl;
247  }
248  return ret;
249 }
DDSolid solidA(void) const
Definition: DDSolid.cc:470
DDRotation rotation(void) const
Definition: DDSolid.cc:466
bool DDCompareDBLVEC(const std::vector< double > &lhs, const std::vector< double > &rhs, double tol)
ret
prodAgent to be discontinued
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
bool DDCompareSolid(const DDSolid &lhs, const DDSolid &rhs, const DDCompOptions &ddco)
Needs to know about rotmat because of BooleanSolid.
DDTranslation translation(void) const
Definition: DDSolid.cc:468
DDSolid solidB(void) const
Definition: DDSolid.cc:472
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
bool DDCompareDDTrans(const DDTranslation &lhs, const DDTranslation &rhs, double tol)
const N & name() const
Definition: DDBase.h:59
const std::string fullname() const
Definition: DDName.h:43
bool DDCompareDDRot(const DDRotation &lhs, const DDRotation &rhs, const DDCompOptions &ddco)
Allows to compare name or not. If not, compares only values of the rotation matrix.

◆ DDCompareCPV()

bool DDCompareCPV ( const DDCompactView lhs,
const DDCompactView rhs,
const DDCompOptions ddco 
)

Definition at line 63 of file DDCompareTools.cc.

References gather_cfg::cout, DDCompareDDRot(), DDCompareDDTrans(), DDCompareLP(), DDName::fullname(), diffTwoXMLs::g1, diffTwoXMLs::g2, DDCompactView::graph(), mps_fire::i, DDBase< N, C >::name(), LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, and runTheMatrix::ret.

Referenced by CompareDDCompactViews::beginRun().

63  {
64  bool ret(true);
65 
66  const auto& g1 = lhs.graph();
67  const auto& g2 = rhs.graph();
68 
71 
72  adjl_iterator git1 = g1.begin();
73  adjl_iterator gend1 = g1.end();
74  adjl_iterator git2 = g2.begin();
75  adjl_iterator gend2 = g2.end();
76 
77  Graph::index_type i = 0;
78 
79  while (git1 != gend1 && git2 != gend2 && ret) {
80  const DDLogicalPart& ddLP1 = g1.nodeData(git1);
81  const DDLogicalPart& ddLP2 = g2.nodeData(git2);
82  std::cout << ++i << " P " << ddLP1.name() << " " << ddLP2.name() << std::endl;
83  if (!DDCompareLP(ddLP1, ddLP2, ddco)) {
84  ret = false;
85  break;
86  } else if (!git1->empty() && !git2->empty()) {
87  auto cit1 = git1->begin();
88  auto cend1 = git1->end();
89  auto cit2 = git2->begin();
90  auto cend2 = git2->end();
91 
92  while (cit1 != cend1 && cit2 != cend2) {
93  const DDLogicalPart& ddcurLP1 = g1.nodeData(cit1->first);
94  const DDLogicalPart& ddcurLP2 = g2.nodeData(cit2->first);
95  std::cout << ++i << " c1--> " << g1.edgeData(cit1->second)->copyno() << " " << ddcurLP1.name().fullname()
96  << std::endl;
97  std::cout << ++i << " c2--> " << g2.edgeData(cit2->second)->copyno() << " " << ddcurLP2.name().fullname()
98  << std::endl;
99  const DDPosData* p1(g1.edgeData(cit1->second));
100  const DDPosData* p2(g2.edgeData(cit2->second));
101 
102  if (p1->copyno() != p2->copyno() || !DDCompareLP(ddcurLP1, ddcurLP2, ddco)) {
103  std::cout << "Failed to match node (fullname:copy_no): 1: " << ddcurLP1.name().fullname() << ":"
104  << p1->copyno() << " 2: " << ddcurLP2.name().fullname() << ":" << p2->copyno() << std::endl;
105  ret = false;
106  break;
107  } else if (!DDCompareDDTrans(p1->trans(), p2->trans())) {
108  std::cout << "Failed to match translation " << std::endl;
109  ret = false;
110  break;
111  } else if (!DDCompareDDRot(p1->ddrot(), p2->ddrot(), ddco)) {
112  std::cout << "Failed to match rotation " << std::endl;
113  ret = false;
114  break;
115  }
116  ++cit1;
117  ++cit2;
118  }
119  } else if (git1->size() != git2->size()) {
120  ret = false;
121  std::cout << "DDCompactViews are different because number of children do not match" << std::endl;
122  std::cout << "graph1 size of edge_list: " << git1->size() << " and graph2 size of edge_list: " << git2->size()
123  << std::endl;
124  break;
125  }
126  ++git1;
127  ++git2;
128  }
129  return ret;
130 }
math::Graph< DDLogicalPart, DDPosData * > Graph
Definition: DDCompactView.h:83
Relative position of a child-volume inside a parent-volume.
Definition: DDPosData.h:13
std::vector< double >::size_type index_type
Definition: Graph.h:15
ret
prodAgent to be discontinued
bool DDCompareLP(const DDLogicalPart &lhs, const DDLogicalPart &rhs, const DDCompOptions &ddco)
LogicalParts have solids which could be BooleanSolids.
A DDLogicalPart aggregates information concerning material, solid and sensitveness ...
Definition: DDLogicalPart.h:93
Graph::const_adj_iterator adjl_iterator
bool DDCompareDDTrans(const DDTranslation &lhs, const DDTranslation &rhs, double tol)
const N & name() const
Definition: DDBase.h:59
const std::string fullname() const
Definition: DDName.h:43
bool DDCompareDDRot(const DDRotation &lhs, const DDRotation &rhs, const DDCompOptions &ddco)
Allows to compare name or not. If not, compares only values of the rotation matrix.
adj_list::const_iterator const_adj_iterator
Definition: Graph.h:105
const Graph & graph() const
Provides read-only access to the data structure of the compact-view.

◆ DDCompareDBLVEC()

bool DDCompareDBLVEC ( const std::vector< double > &  lhs,
const std::vector< double > &  rhs,
double  tol = 0.0004 
)

Definition at line 198 of file DDCompareTools.cc.

References gather_cfg::cout, alignBH_cfg::fixed, mps_fire::i, and runTheMatrix::ret.

Referenced by DDCompareBoolSol(), and DDCompareSolid().

198  {
199  bool ret(true);
200  std::ios_base::fmtflags originalFlags = std::cout.flags();
201  int originalPrecision = std::cout.precision();
202  if (lhs.size() != rhs.size()) {
203  ret = false;
204  std::cout << "Size of vectors do not match." << std::endl;
205  } else {
206  for (size_t i = 0; i < lhs.size(); ++i) {
207  if (std::fabs(lhs[i] - rhs[i]) > tol) {
208  ret = false;
209  std::cout << "Vector content at index " << i << " does not match ";
210  std::cout << std::setw(12) << std::fixed << std::setprecision(4) << lhs[i] << " != " << rhs[i] << std::endl;
211  break;
212  }
213  }
214  }
215  // Now set everything back to defaults
216  std::cout.flags(originalFlags);
217  std::cout.precision(originalPrecision);
218  return ret;
219 }
ret
prodAgent to be discontinued

◆ DDCompareDDRot()

bool DDCompareDDRot ( const DDRotation lhs,
const DDRotation rhs,
const DDCompOptions ddco 
)

Allows to compare name or not. If not, compares only values of the rotation matrix.

Definition at line 260 of file DDCompareTools.cc.

References DDCompOptions::compRotName_, gather_cfg::cout, DDCompareDDRotMat(), DDName::fullname(), DDBase< N, C >::name(), runTheMatrix::ret, and DDRotation::rotation().

Referenced by DDCompareBoolSol(), and DDCompareCPV().

260  {
261  bool ret(true);
262  if (ddco.compRotName_ && lhs.name().fullname() != rhs.name().fullname()) {
263  ret = false;
264  std::cout << "DDRotation names do not match " << lhs.name().fullname() << " and " << rhs.name().fullname()
265  << std::endl;
266  } else if (!DDCompareDDRotMat(lhs.rotation(), rhs.rotation())) {
267  ret = false;
268  std::cout << "DDRotationMatrix values do not match " << lhs.name().fullname() << " and " << rhs.name().fullname()
269  << std::endl;
270  }
271  return ret;
272 }
ret
prodAgent to be discontinued
bool DDCompareDDRotMat(const DDRotationMatrix &lhs, const DDRotationMatrix &rhs, double tol)
const N & name() const
Definition: DDBase.h:59
const std::string fullname() const
Definition: DDName.h:43
const DDRotationMatrix & rotation() const
Returns the read-only rotation-matrix.
Definition: DDTransform.h:81

◆ DDCompareDDRotMat()

bool DDCompareDDRotMat ( const DDRotationMatrix lhs,
const DDRotationMatrix rhs,
double  tol = 0.0004 
)

Definition at line 275 of file DDCompareTools.cc.

References gather_cfg::cout, alignBH_cfg::fixed, runTheMatrix::ret, x, detailsBasic3DVector::y, and detailsBasic3DVector::z.

Referenced by DDCompareDDRot().

275  {
276  bool ret(true);
277  // manual way to do it... postponed. Tested with Distance method from root::math
278  //DD3Vector x1, y1, z1;
279  //lhs.GetComponents(x1,y1,z1);
280  //DD3Vector x2, y2, z2;
281  //rhs.GetComponents(x2,y2,z2);
282  double dist = Distance(lhs, rhs);
283  if (std::fabs(dist) > tol) {
284  std::cout << "Rotation matrices do not match." << std::endl;
285  ret = false;
286  DD3Vector x, y, z;
287  std::cout << "FIRST" << std::endl;
288  lhs.GetComponents(x, y, z);
289  std::cout << std::setw(12) << std::fixed << std::setprecision(4) << x.X();
290  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.X();
291  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.X();
292  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Y();
293  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Y();
294  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Y();
295  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Z();
296  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Z();
297  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Z() << std::endl;
298  std::cout << "SECOND" << std::endl;
299  rhs.GetComponents(x, y, z);
300  std::cout << std::setw(12) << std::fixed << std::setprecision(4) << x.X();
301  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.X();
302  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.X();
303  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Y();
304  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Y();
305  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Y();
306  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << x.Z();
307  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << y.Z();
308  std::cout << "," << std::setw(12) << std::fixed << std::setprecision(4) << z.Z() << std::endl;
309  }
310 
311  return ret;
312 }
ret
prodAgent to be discontinued
float float float z
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > DD3Vector
float x

◆ DDCompareDDTrans()

bool DDCompareDDTrans ( const DDTranslation lhs,
const DDTranslation rhs,
double  tol = 0.0004 
)

Definition at line 252 of file DDCompareTools.cc.

References runTheMatrix::ret.

Referenced by DDCompareBoolSol(), and DDCompareCPV().

252  {
253  bool ret(true);
254  if (std::fabs(lhs.x() - rhs.x()) > tol || std::fabs(lhs.y() - rhs.y()) > tol || std::fabs(lhs.z() - rhs.z()) > tol) {
255  ret = false;
256  }
257  return ret;
258 }
ret
prodAgent to be discontinued

◆ DDCompareEPV()

bool DDCompareEPV ( DDExpandedView lhs,
DDExpandedView rhs,
const DDCompOptions ddco 
)

Definition at line 17 of file DDCompareTools.cc.

References DDExpandedView::copyno(), gather_cfg::cout, DDExpandedView::depth(), DDExpandedView::firstChild(), DDExpandedView::logicalPart(), DDName::name(), DDBase< N, C >::name(), DDExpandedView::next(), DDExpandedView::nextSibling(), DDExpandedView::parent(), and runTheMatrix::ret.

17  {
18  bool ret(true);
19 
20  std::cout << "*********FIRST BY firstChild, firstChild, nextSibling, nextSibling*********" << std::endl;
21  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
22  << ":" << rhs.copyno() << std::endl;
23  lhs.firstChild();
24  rhs.firstChild();
25  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
26  << ":" << rhs.copyno() << std::endl;
27  lhs.firstChild();
28  rhs.firstChild();
29  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
30  << ":" << rhs.copyno() << std::endl;
31  lhs.nextSibling();
32  rhs.nextSibling();
33  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
34  << ":" << rhs.copyno() << std::endl;
35  lhs.nextSibling();
36  rhs.nextSibling();
37  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
38  << ":" << rhs.copyno() << std::endl;
39  lhs.parent();
40  rhs.parent();
41  std::cout << "*********THEN BY next, next, next, next*********" << std::endl;
42  lhs.parent();
43  rhs.parent();
44  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
45  << ":" << rhs.copyno() << std::endl;
46  lhs.next();
47  rhs.next();
48  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
49  << ":" << rhs.copyno() << std::endl;
50  lhs.next();
51  rhs.next();
52  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
53  << ":" << rhs.copyno() << std::endl;
54  std::cout << lhs.depth() << " depth " << rhs.depth() << std::endl;
55  lhs.next();
56  rhs.next();
57  std::cout << lhs.depth() << " depth " << rhs.depth() << std::endl;
58  std::cout << lhs.logicalPart().name().name() << ":" << lhs.copyno() << " !=? " << rhs.logicalPart().name().name()
59  << ":" << rhs.copyno() << std::endl;
60  return ret;
61 }
bool next()
set current node to the next node in the expanded tree
bool parent()
set the current node to the parent node ...
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the expanded-view.
ret
prodAgent to be discontinued
const std::string & name() const
Returns the name.
Definition: DDName.cc:41
int depth() const
depth of the scope. 0 means unrestricted depth.
const N & name() const
Definition: DDBase.h:59
int copyno() const
Copy number associated with the current node.
bool firstChild()
set the current node to the first child ...
bool nextSibling()
set the current node to the next sibling ...

◆ DDCompareLP()

bool DDCompareLP ( const DDLogicalPart lhs,
const DDLogicalPart rhs,
const DDCompOptions ddco 
)

LogicalParts have solids which could be BooleanSolids.

This means they need to know if the DDRotation naems matter.

Definition at line 132 of file DDCompareTools.cc.

References gather_cfg::cout, DDCompareSolid(), DDName::fullname(), DDBase< N, C >::name(), runTheMatrix::ret, and DDLogicalPart::solid().

Referenced by DDCompareCPV().

132  {
133  bool ret(true);
134  // for a logical part to be equal, the solid must be equal and the name must be equal.
135  if (lhs.name().fullname() != rhs.name().fullname()) {
136  ret = false;
137  std::cout << "LogicalPart names do not match " << lhs.name().fullname() << " and " << rhs.name().fullname()
138  << std::endl;
139  } else if (!DDCompareSolid(lhs.solid(), rhs.solid(), ddco)) {
140  ret = false;
141  std::cout << "LogicalPart Solids do not match " << lhs.name().fullname() << " and " << rhs.name().fullname()
142  << std::endl;
143  }
144  return ret;
145 }
ret
prodAgent to be discontinued
bool DDCompareSolid(const DDSolid &lhs, const DDSolid &rhs, const DDCompOptions &ddco)
Needs to know about rotmat because of BooleanSolid.
const N & name() const
Definition: DDBase.h:59
const std::string fullname() const
Definition: DDName.h:43
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.

◆ DDCompareSolid()

bool DDCompareSolid ( const DDSolid lhs,
const DDSolid rhs,
const DDCompOptions ddco 
)

Needs to know about rotmat because of BooleanSolid.

Definition at line 147 of file DDCompareTools.cc.

References gather_cfg::cout, dd_not_init, ddbox, DDCompareBoolSol(), DDCompareDBLVEC(), ddcons, ddcuttubs, ddellipticaltube, ddextrudedpolygon, ddintersection, ddpolycone_rrz, ddpolycone_rz, ddpolyhedra_rrz, ddpolyhedra_rz, ddpseudotrap, ddshapeless, ddsphere, ddsubtraction, ddtorus, ddtrap, ddtrunctubs, ddtubs, ddunion, DDName::fullname(), DDBase< N, C >::name(), DDSolid::parameters(), runTheMatrix::ret, and DDSolid::shape().

Referenced by DDCompareBoolSol(), and DDCompareLP().

147  {
148  bool ret(true);
149  switch (lhs.shape()) {
151  case DDSolidShape::ddbox:
167  if (lhs.name().fullname() != rhs.name().fullname()) {
168  ret = false;
169  std::cout << "Solid names do not match for solid " << lhs.name().fullname() << " and " << rhs.name().fullname()
170  << std::endl;
171  } else if (lhs.shape() != rhs.shape()) {
172  ret = false;
173  std::cout << "Shape types do not match for solids " << lhs.name().fullname() << " and " << rhs.name().fullname()
174  << " even though their names match " << std::endl;
175  } else if (!DDCompareDBLVEC(lhs.parameters(), rhs.parameters())) {
176  ret = false;
177  std::cout << "Parameters do not match for solids " << lhs.name().fullname() << " and " << rhs.name().fullname()
178  << " even though their names and shape type match." << std::endl;
179  std::cout << "size: " << lhs.parameters().size() << " " << rhs.parameters().size() << std::endl;
180  }
181  break;
182  }
186  if (!DDCompareBoolSol(lhs, rhs, ddco)) {
187  ret = false;
188  }
189  break;
190  }
191  default:
192  break;
193  }
194  return ret;
195 }
bool DDCompareDBLVEC(const std::vector< double > &lhs, const std::vector< double > &rhs, double tol)
ret
prodAgent to be discontinued
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:125
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:123
const N & name() const
Definition: DDBase.h:59
const std::string fullname() const
Definition: DDName.h:43
bool DDCompareBoolSol(const DDBooleanSolid &lhs, const DDBooleanSolid &rhs, const DDCompOptions &ddco)
Needs to know because of Rotation Matrix of Boolean Relationship.