Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root interface changes #428

Merged
merged 2 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DDCore/include/DD4hep/MatrixHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace dd4hep {

/// Convert a TGeoMatrix object to a generic Transform3D \ingroup DD4HEP \ingroup DD4HEP_CORE
Transform3D _transform(const TGeoMatrix* matrix);
Transform3D _transform(const TGeoMatrix& matrix);

/// Decompose a generic Transform3D into a translation (Position) and a RotationZYX \ingroup DD4HEP \ingroup DD4HEP_CORE
void _decompose(const Transform3D& trafo, Position& pos, RotationZYX& rot);
Expand Down
13 changes: 13 additions & 0 deletions DDCore/src/MatrixHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,19 @@ Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix* matrix) {
0e0,0e0,0e0,t[1]*MM_2_CM,
0e0,0e0,0e0,t[2]*MM_2_CM);
}
// add another implementation that takes const reference
Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix& matrix) {
const Double_t* t = matrix.GetTranslation();
if ( matrix.IsRotation() ) {
const Double_t* r = matrix.GetRotationMatrix();
return Transform3D(r[0],r[1],r[2],t[0]*MM_2_CM,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of conversions here. It looks like the MM_2_CM and RAD_2_DEGREE assume that the input units are mm and rad. Should it be a user who defines which units to use and if they are not the DD4hep default, convert them?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user should always use DD4hep units, when addressing/talking to DD4hep. There some exceptions to this rule, e.g. when interfaces of underlying classes are exposed, there you should use or expect ROOT or Geant4 conventions.

r[3],r[4],r[5],t[1]*MM_2_CM,
r[6],r[7],r[8],t[2]*MM_2_CM);
}
return Transform3D(0e0,0e0,0e0,t[0]*MM_2_CM,
0e0,0e0,0e0,t[1]*MM_2_CM,
0e0,0e0,0e0,t[2]*MM_2_CM);
}

dd4hep::XYZAngles dd4hep::detail::matrix::_xyzAngles(const TGeoMatrix* m) {
return m->IsRotation() ? _xyzAngles(m->GetRotationMatrix()) : XYZAngles(0,0,0);
Expand Down
2 changes: 1 addition & 1 deletion DDCore/src/plugins/Compact2Objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ template <> void Converter<Parallelworld_Volume>::operator()(xml_h element) cons
}

/// Create the shape and the corresponding volume
Transform3D tr_volume(detail::matrix::_transform(&anchor.nominal().worldTransformation().Inverse()));
Transform3D tr_volume(detail::matrix::_transform(anchor.nominal().worldTransformation().Inverse()));
Solid sol(shape.createShape());
Volume vol(name, sol, mat);
Volume par = conn ? description.worldVolume() : description.parallelWorldVolume();
Expand Down
4 changes: 2 additions & 2 deletions DDCore/src/plugins/LCDDConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con
obj.setAttr(_U(unit), "cm");
}
if (lm->IsRotation()) {
TGeoMatrix& linv = lm->Inverse();
TGeoMatrix const & linv = lm->Inverse();
XYZRotation rot = getXYZangles(linv.GetRotationMatrix());
if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) {
first_solid.append(obj = xml_elt_t(geo.doc, _U(firstrotation)));
Expand All @@ -568,7 +568,7 @@ xml_h LCDDConverter::handleSolid(const string& name, const TGeoShape* shape) con
solid.setRef(_U(positionref), pos.name());
}
if (rm->IsRotation()) {
TGeoMatrix& rinv = rm->Inverse();
TGeoMatrix const & rinv = rm->Inverse();
XYZRotation rot = getXYZangles(rinv.GetRotationMatrix());
if ((rot.X() != 0.0) || (rot.Y() != 0.0) || (rot.Z() != 0.0)) {
xml_ref_t xml_rot = handleRotation(rnam+"_rot", &rinv);
Expand Down