From 5bdf9b9bfe89b2ec324c9f9585ffd94547448ce3 Mon Sep 17 00:00:00 2001
From: Markus FRANK <Markus.Frank@cern.ch>
Date: Mon, 9 Nov 2020 09:30:27 +0100
Subject: [PATCH] Try to fix reflections for volumes and assemblies

---
 DDCore/include/DD4hep/MatrixHelpers.h         |  31 +-
 DDCore/include/DD4hep/Objects.h               |   6 +-
 DDCore/include/DD4hep/detail/ObjectsInterna.h |   2 +-
 DDCore/src/DetectorImp.cpp                    |   6 +-
 DDCore/src/MatrixHelpers.cpp                  |  59 +++-
 DDCore/src/Objects.cpp                        |  45 +--
 DDCore/src/ObjectsInterna.cpp                 |  13 +-
 DDCore/src/plugins/Compact2Objects.cpp        |  16 +-
 DDCore/src/plugins/StandardPlugins.cpp        |  24 +-
 DDCore/src/plugins/VisVolNameProcessor.cpp    |  37 ++-
 examples/ClientTests/CMakeLists.txt           |   9 +
 .../compact/ReflectionMatrices.xml            | 122 ++++++++
 .../src/NestedBoxReflection_geo.cpp           |   5 +-
 .../src/ReflectionMatrices_geo.cpp            | 142 +++++++++
 examples/DDCMS/data/caloBase.xml              |   3 +
 examples/DDCMS/data/cms_close_geom.xml        |   4 +
 examples/DDCMS/data/cms_ecal.xml              |  62 ++++
 examples/DDCMS/data/dd4hep-ecal.xml           | 185 +++++++++++
 examples/DDCMS/data/ecal-vis.xml              |  50 +++
 examples/DDCMS/data/ecalmaterial.xml          |   7 +
 examples/DDCMS/data/eealgo.xml                | 198 ++++++++++++
 examples/DDCMS/data/eecon.xml                 | 296 ++++++++++++++++++
 examples/DDCMS/data/eehier.xml                | 129 ++++++++
 examples/DDCMS/data/materials.xml             |  24 +-
 examples/DDCMS/data/rotations.xml             |  18 ++
 examples/DDCMS/include/DDCMS/DDCMS.h          |  26 +-
 examples/DDCMS/include/DDCMS/DDCMSTags.h      |   2 +
 examples/DDCMS/scripts/CMSEcalSim.py          | 107 +++++++
 examples/DDCMS/src/DDCMS.cpp                  |  21 +-
 .../src/plugins/DDDefinitions2Objects.cpp     | 188 ++++++-----
 .../DDCMS/src/plugins/DDEcalEndcapAlgo.cpp    |   2 +-
 31 files changed, 1650 insertions(+), 189 deletions(-)
 create mode 100644 examples/ClientTests/compact/ReflectionMatrices.xml
 create mode 100644 examples/ClientTests/src/ReflectionMatrices_geo.cpp
 create mode 100644 examples/DDCMS/data/cms_close_geom.xml
 create mode 100644 examples/DDCMS/data/cms_ecal.xml
 create mode 100644 examples/DDCMS/data/dd4hep-ecal.xml
 create mode 100644 examples/DDCMS/data/ecal-vis.xml
 create mode 100644 examples/DDCMS/data/ecalmaterial.xml
 create mode 100644 examples/DDCMS/data/eealgo.xml
 create mode 100644 examples/DDCMS/data/eecon.xml
 create mode 100644 examples/DDCMS/data/eehier.xml
 create mode 100644 examples/DDCMS/data/rotations.xml
 create mode 100644 examples/DDCMS/scripts/CMSEcalSim.py

diff --git a/DDCore/include/DD4hep/MatrixHelpers.h b/DDCore/include/DD4hep/MatrixHelpers.h
index 2f77fb04f..71282fb39 100644
--- a/DDCore/include/DD4hep/MatrixHelpers.h
+++ b/DDCore/include/DD4hep/MatrixHelpers.h
@@ -79,29 +79,44 @@ 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);
+      /// Convert a generic ROOT Matrix into a generic transformation Transform3D             \ingroup DD4HEP \ingroup DD4HEP_CORE
+      void             _transform(const TGeoMatrix* matrix, Transform3D& trafo);
+      /// Convert a generic ROOT Matrix into a generic transformation Transform3D             \ingroup DD4HEP \ingroup DD4HEP_CORE
+      void             _transform(const TGeoMatrix& matrix, Transform3D& trafo);
 
       /// Decompose a generic ROOT Matrix into a translation (Position) and a Rotation3D        \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const TGeoMatrix& trafo, Position& pos, Rotation3D& rot);
+      void _decompose(const TGeoMatrix& matrix, Position& pos, Rotation3D& rot);
       /// Decompose a generic ROOT Matrix into a translation (Position) and a RotationZYX       \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const TGeoMatrix& trafo, Position& pos, RotationZYX& rot);
+      void _decompose(const TGeoMatrix& matrix, Position& pos, RotationZYX& rot);
       /// Decompose a generic ROOT Matrix into a translation (Position) and XYZAngles           \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const TGeoMatrix& trafo, Position& pos, XYZAngles& rot);
+      void _decompose(const TGeoMatrix& matrix, Position& pos, XYZAngles& rot);
       /// Decompose a generic Transform3D into a translation (Position) and a Rotation3D        \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const Transform3D& trafo, Position& pos, Rotation3D& rot);
+      void _decompose(const Transform3D& matrix, Position& pos, Rotation3D& rot);
       /// 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);
+      void _decompose(const Transform3D& matrix, Position& pos, RotationZYX& rot);
       /// Decompose a generic Transform3D into a translation (Position) and XYZAngles \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const Transform3D& trafo, Position& pos, XYZAngles& rot);
+      void _decompose(const Transform3D& matrix, Position& pos, XYZAngles& rot);
       /// Decompose a generic Transform3D into a translation (Translation3D) and a RotationZYX  \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const Transform3D& trafo, Translation3D& pos, RotationZYX& rot);
+      void _decompose(const Transform3D& matrix, Translation3D& pos, RotationZYX& rot);
       /// Decompose a generic Transform3D into a translation (Translation3D) and XYZAngles      \ingroup DD4HEP \ingroup DD4HEP_CORE
-      void _decompose(const Transform3D& trafo, Translation3D& pos, XYZAngles& rot);
+      void _decompose(const Transform3D& matrix, Translation3D& pos, XYZAngles& rot);
+      /// Decompose a Rotation3D into a 3 orthogonal unit vectors.
+      void _decompose(const Rotation3D&  rot, Position& x, Position& y, Position& z);
 
       /// Convert a 3x3 rotation matrix to XYZAngles                                            \ingroup DD4HEP \ingroup DD4HEP_CORE
       XYZAngles _xyzAngles(const double* matrix);
       /// Convert a the rotation part of a TGeoMatrix to XYZAngles                              \ingroup DD4HEP \ingroup DD4HEP_CORE
       XYZAngles _xyzAngles(const TGeoMatrix* matrix);
 
+      /// Access determinant of rotation component (0 if no rotation present)
+      double determinant(const TGeoMatrix* matrix);
+      /// Access determinant of rotation component (0 if no rotation present)
+      double determinant(const TGeoMatrix& matrix);
+      /// Access determinant of the rotation component of a Transform3D
+      double determinant(const Transform3D& trafo);
+      /// Access determinant of a Rotation3D
+      double determinant(const Rotation3D& rot);
+
       enum MatrixEqualityCode  {
         MATRICES_EQUAL = 1,
         MATRICES_DIFFER_TRANSLATION = 2,
diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h
index 0f1e7a8cf..0c5ab281e 100644
--- a/DDCore/include/DD4hep/Objects.h
+++ b/DDCore/include/DD4hep/Objects.h
@@ -363,16 +363,16 @@ namespace dd4hep {
 
     /// Get alpha value
     float alpha() const;
-    /// Set alpha value
-    void setAlpha(float value);
 
     /// Get object color
     int color() const;
     /// Set object color
-    void setColor(float red, float green, float blue);
+    void setColor(float alpha, float red, float green, float blue);
 
     /// Get RGB values of the color (if valid)
     bool rgb(float& red, float& green, float& blue) const;
+    /// Get alpha and RGB values of the color (if valid)
+    bool argb(float& alpha, float& red, float& green, float& blue) const;
 
     /// String representation of this object
     std::string toString() const;
diff --git a/DDCore/include/DD4hep/detail/ObjectsInterna.h b/DDCore/include/DD4hep/detail/ObjectsInterna.h
index 5812f017b..143dbbbf0 100644
--- a/DDCore/include/DD4hep/detail/ObjectsInterna.h
+++ b/DDCore/include/DD4hep/detail/ObjectsInterna.h
@@ -88,7 +88,7 @@ namespace dd4hep {
   class VisAttrObject: public NamedObject {
   public:
     unsigned long magic;
-    TColor*       col    = 0;
+    TColor*       col    = nullptr;
     int           color  = 0;
     float         alpha  = 0;
     unsigned char drawingStyle  = VisAttr::SOLID;
diff --git a/DDCore/src/DetectorImp.cpp b/DDCore/src/DetectorImp.cpp
index 18ca12268..ca48509bd 100644
--- a/DDCore/src/DetectorImp.cpp
+++ b/DDCore/src/DetectorImp.cpp
@@ -196,8 +196,7 @@ DetectorImp::DetectorImp(const string& name)
   m_std_conditions.temperature = Temperature_NTP;
   
   VisAttr attr("invisible");
-  attr.setColor(0.5, 0.5, 0.5);
-  attr.setAlpha(1);
+  attr.setColor(1.0, 0.5, 0.5, 0.5);
   attr.setLineStyle(VisAttr::SOLID);
   attr.setDrawingStyle(VisAttr::SOLID);
   attr.setVisible(false);
@@ -720,10 +719,9 @@ void DetectorImp::init() {
     VisAttr worldVis = visAttributes("WorldVis");
     if ( !worldVis.isValid() )  {
       worldVis = VisAttr("WorldVis");
-      worldVis.setAlpha(1.0);
       worldVis.setVisible(false);
       worldVis.setShowDaughters(true);
-      worldVis.setColor(1.0, 1.0, 1.0);
+      worldVis.setColor(1., 1., 1., 1.);
       worldVis.setLineStyle(VisAttr::SOLID);
       worldVis.setDrawingStyle(VisAttr::WIREFRAME);
       //m_worldVol.setVisAttributes(worldVis);
diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp
index 0aff6a825..549a6ea90 100644
--- a/DDCore/src/MatrixHelpers.cpp
+++ b/DDCore/src/MatrixHelpers.cpp
@@ -164,16 +164,30 @@ dd4hep::Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix* matrix)
 dd4hep::Transform3D dd4hep::detail::matrix::_transform(const TGeoMatrix& matrix)    {
   const Double_t* t = matrix.GetTranslation();
   if ( matrix.IsRotation() )  {
-    const Double_t* rot = matrix.GetRotationMatrix();
-    return Transform3D(rot[0],rot[1],rot[2],t[0]*MM_2_CM,
-                       rot[3],rot[4],rot[5],t[1]*MM_2_CM,
-                       rot[6],rot[7],rot[8],t[2]*MM_2_CM);
+    const Double_t* r = matrix.GetRotationMatrix();
+    return Transform3D(r[0],r[1],r[2],t[0]*MM_2_CM,
+                       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);
 }
 
+/// Decompose a generic ROOT Matrix into a generic transformation Transform3D            \ingroup DD4HEP \ingroup DD4HEP_CORE
+void dd4hep::detail::matrix::_transform(const TGeoMatrix& matrix, Transform3D& tr)   {
+  tr = _transform(matrix);
+}
+
+/// Decompose a generic ROOT Matrix into a generic transformation Transform3D            \ingroup DD4HEP \ingroup DD4HEP_CORE
+void dd4hep::detail::matrix::_transform(const TGeoMatrix* matrix, Transform3D& tr)   {
+  if ( matrix )   {
+    _transform(*matrix, tr);
+    return;
+  }
+  tr = Transform3D();
+}
+
 dd4hep::XYZAngles dd4hep::detail::matrix::_xyzAngles(const TGeoMatrix* matrix) {
   return matrix->IsRotation() ? _xyzAngles(matrix->GetRotationMatrix()) : XYZAngles(0,0,0);
 }
@@ -202,6 +216,10 @@ void dd4hep::detail::matrix::_decompose(const Transform3D& trafo, Position& pos,
   trafo.GetDecomposition(rot, pos);  
 }
 
+void dd4hep::detail::matrix::_decompose(const Rotation3D& rot, Position& x, Position& y, Position& z)  {
+  rot.GetComponents(x,y,z);
+}
+
 void dd4hep::detail::matrix::_decompose(const Transform3D& trafo, Translation3D& pos, RotationZYX& rot)   {
   trafo.GetDecomposition(rot, pos);
 }
@@ -222,6 +240,39 @@ void dd4hep::detail::matrix::_decompose(const Transform3D& trafo, Position& pos,
   rot.SetXYZ(r.Psi(),r.Theta(),r.Phi());
 }
 
+/// Access determinant of rotation component (0 if no rotation present)
+double dd4hep::detail::matrix::determinant(const TGeoMatrix* matrix)   {
+  return (matrix) ? determinant(*matrix) : 0e0;
+}
+
+/// Access determinant of rotation component (0 if no rotation present)
+double dd4hep::detail::matrix::determinant(const TGeoMatrix& matrix)   {
+  const double* r = matrix.GetRotationMatrix();
+  if ( r )   {
+    double det =
+      r[0]*r[4]*r[8] + r[3]*r[7]*r[2] + r[6]*r[1]*r[5] -
+      r[2]*r[4]*r[6] - r[5]*r[7]*r[0] - r[8]*r[1]*r[3];
+    return det;
+  }
+  return 0.0;
+}
+
+/// Access determinant of the rotation component of a Transform3D
+double dd4hep::detail::matrix::determinant(const Transform3D& tr)   {
+  Position p;
+  Rotation3D r;
+  tr.GetDecomposition(r, p);
+  return determinant(r);
+}
+
+/// Access determinant of a Rotation3D
+double dd4hep::detail::matrix::determinant(const Rotation3D& rot)   {
+  Position x, y, z;
+  rot.GetComponents(x,y,z);
+  double det = (x.Cross(y)).Dot(z);
+  return det;
+}
+
 /// Check matrices for equality
 int dd4hep::detail::matrix::_matrixEqual(const TGeoMatrix& left, const TGeoMatrix& right)   {
   double epsilon = 1e-12;
diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp
index f6880561d..3f9ed6b6e 100644
--- a/DDCore/src/Objects.cpp
+++ b/DDCore/src/Objects.cpp
@@ -286,10 +286,10 @@ VisAttr::VisAttr(const string& nam) {
   Object* obj = new Object();
   assign(obj, nam, "vis");
   obj->color = 2;
+  obj->alpha = 0.9f;
   setLineStyle (SOLID);
   setDrawingStyle(SOLID);
   setShowDaughters(true);
-  setAlpha(0.9f);
 }
 
 /// Constructor to be used when creating a new entity
@@ -297,10 +297,10 @@ VisAttr::VisAttr(const char* nam) {
   Object* obj = new Object();
   assign(obj, nam, "vis");
   obj->color = 2;
+  obj->alpha = 0.9f;
   setLineStyle (SOLID);
   setDrawingStyle(SOLID);
   setShowDaughters(true);
-  setAlpha(0.9f);
 }
 
 /// Get Flag to show/hide daughter elements
@@ -345,16 +345,11 @@ void VisAttr::setDrawingStyle(int value) {
 
 /// Get alpha value
 float VisAttr::alpha() const {
-  //NamedObject* obj = first_value<NamedObject>(*this);
-  //obj->SetAlpha(value);
-  return object<Object>().alpha;
-}
-
-/// Set alpha value
-void VisAttr::setAlpha(float value) {
-  object<Object>().alpha = value;
-  //NamedObject* obj = first_value<NamedObject>(*this);
-  //obj->SetAlpha(value);
+  Object& o = object<Object>();
+  if ( o.col )  {
+    return o.alpha;
+  }
+  return 0.0f;
 }
 
 /// Get object color
@@ -363,18 +358,30 @@ int VisAttr::color() const {
 }
 
 /// Set object color
-void VisAttr::setColor(float red, float green, float blue) {
+void VisAttr::setColor(float alpha, float red, float green, float blue) {
   Object& o = object<Object>();
-  o.color = TColor::GetColor(red, green, blue);
-  o.col = gROOT->GetColor(o.color);
+  Int_t col = TColor::GetColor(red, green, blue);
+  o.alpha   = alpha;
+  o.color   = col;//TColor::GetColorTransparent(o.alpha=alpha, col);
+  o.col     = gROOT->GetColor(o.color);
 }
 
 /// Get RGB values of the color (if valid)
 bool VisAttr::rgb(float& red, float& green, float& blue) const {
   Object& o = object<Object>();
-  if (o.col) {
-    TColor* c = (TColor*) o.col;
-    c->GetRGB(red, green, blue);
+  if ( o.col )  {
+    o.col->GetRGB(red, green, blue);
+    return true;
+  }
+  return false;
+}
+
+/// Get alpha and RGB values of the color (if valid)
+bool VisAttr::argb(float& alpha, float& red, float& green, float& blue) const {
+  Object& o = object<Object>();
+  if ( o.col )  {
+    alpha = o.alpha;
+    o.col->GetRGB(red, green, blue);
     return true;
   }
   return false;
@@ -383,7 +390,7 @@ bool VisAttr::rgb(float& red, float& green, float& blue) const {
 /// String representation of this object
 string VisAttr::toString() const {
   const VisAttr::Object* obj = &object<Object>();
-  TColor* col = gROOT->GetColor(obj->color);
+  TColor* col = obj->col;
   char text[256];
   ::snprintf(text, sizeof(text), "%-20s RGB:%-8s [%d] %7.2f  Style:%d %d ShowDaughters:%3s Visible:%3s", ptr()->GetName(),
              col->AsHexString(), obj->color, col->GetAlpha(), int(obj->drawingStyle), int(obj->lineStyle),
diff --git a/DDCore/src/ObjectsInterna.cpp b/DDCore/src/ObjectsInterna.cpp
index 373c9a274..4b2766751 100644
--- a/DDCore/src/ObjectsInterna.cpp
+++ b/DDCore/src/ObjectsInterna.cpp
@@ -11,12 +11,13 @@
 //
 //==========================================================================
 
-#include "DD4hep/Objects.h"
-#include "DD4hep/InstanceCount.h"
-#include "DD4hep/detail/Handle.inl"
-#include "DD4hep/detail/ObjectsInterna.h"
-#include "DD4hep/detail/SegmentationsInterna.h"
+#include <DD4hep/Objects.h>
+#include <DD4hep/InstanceCount.h>
+#include <DD4hep/detail/Handle.inl>
+#include <DD4hep/detail/ObjectsInterna.h>
+#include <DD4hep/detail/SegmentationsInterna.h>
 
+#include <TROOT.h>
 using namespace std;
 using namespace dd4hep;
 using namespace dd4hep::detail;
@@ -26,6 +27,8 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(VisAttrObject);
 /// Standard constructor
 VisAttrObject::VisAttrObject() : magic(magic_word())   {
   InstanceCount::increment(this);
+  this->col = gROOT->GetColor(kWhite);
+  this->alpha = 0.0;
 }
 
 /// Default destructor
diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index cceffd1c2..9229a9570 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -814,16 +814,16 @@ template <> void Converter<PropertyTable>::operator()(xml_h e) const {
  */
 template <> void Converter<VisAttr>::operator()(xml_h e) const {
   VisAttr attr(e.attr<string>(_U(name)));
-  float red   = e.hasAttr(_U(r)) ? e.attr<float>(_U(r)) : 1.0f;
-  float green = e.hasAttr(_U(g)) ? e.attr<float>(_U(g)) : 1.0f;
-  float blue  = e.hasAttr(_U(b)) ? e.attr<float>(_U(b)) : 1.0f;
+  xml_dim_t dim(e);
+  float alpha = dim.alpha(1.0);
+  float red   = dim.r(1.0);
+  float green = dim.g(1.0);
+  float blue  = dim.b(1.0);
 
   printout(s_debug.visattr ? ALWAYS : DEBUG, "Compact",
-           "++ Converting VisAttr  structure: %-16s. R=%.3f G=%.3f B=%.3f",
-           attr.name(), red, green, blue);
-  attr.setColor(red, green, blue);
-  if (e.hasAttr(_U(alpha)))
-    attr.setAlpha(e.attr<float>(_U(alpha)));
+           "++ Converting VisAttr  structure: %-16s. Alpha=%.2f R=%.3f G=%.3f B=%.3f",
+           attr.name(), alpha, red, green, blue);
+  attr.setColor(alpha, red, green, blue);
   if (e.hasAttr(_U(visible)))
     attr.setVisible(e.attr<bool>(_U(visible)));
   if (e.hasAttr(_U(lineStyle))) {
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 0c5ce8619..630ae7f13 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -1021,6 +1021,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
             "     -sensitive         Only print information for sensitive volumes                \n"
             "     -topstats          Print statistics about top level node                       \n"       
             "\tArguments given: " << arguments(ac,av) << endl << flush;
+	  _exit(0);
         }
       }
       if ( m_printMaxLevel < 999999 )
@@ -1080,6 +1081,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
         pref += "/";
         pref += aligned->GetName();
       }
+      /// 
       if ( m_printPositions || m_printVolIDs )  {
         if ( m_printPointers )    {
           if ( ideal != aligned )
@@ -1113,32 +1115,40 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
           }
         }
         opt_info = log.str();
+	log.str("");
+      }
+      ///  
+      if ( m_printVis && pv.volume().visAttributes().isValid() )   {
+        log << " Vis:" << pv.volume().visAttributes().name();
+	opt_info += log.str();
+	log.str("");
       }
       TGeoVolume* volume = ideal ? ideal->GetVolume() : 0;
       if ( !m_printSensitivesOnly || (m_printSensitivesOnly && sensitive) )  {
         char sens = pv.volume().isSensitive() ? 'S' : ' ';
         if ( m_printPointers )    {
           if ( ideal == aligned )  {
-            ::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p] %%-%ds %%-16s (%%s) \t %c %%s",
+            ::snprintf(fmt,sizeof(fmt),"%03d %%s [Ideal:%p] %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s",
                        level+1,(void*)ideal,2*level+1,sens);
           }
           else  {
-            ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s",
+            ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s",
                        level+1,(void*)ideal,(void*)aligned,2*level+1,sens);
           }
         }
         else  {
           if ( ideal == aligned )  {
-            ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%-16s (%%s) \t %c %%s",
+            ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%-16s Vol:%%s shape:%%s \t %c %%s",
                        level+1,2*level+1,sens);
           }
           else  {
-            ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s (%%s) %c %%s",
+            ::snprintf(fmt,sizeof(fmt),"%03d %%s Ideal:%p Aligned:%p %%-%ds %%-16s Vol:%%s shape:%%s %c %%s",
                        level+1,(void*)ideal,(void*)aligned,2*level+1,sens);
           }
         }
         printout(INFO,"VolumeDump",fmt,pref.c_str(),"",
                  aligned->GetName(),
+		 volume->GetName(),
                  volume ? volume->GetShape()->IsA()->GetName() : "[Invalid Volume]",
                  opt_info.c_str());
         if ( sens == 'S' ) ++m_numSensitive;
@@ -1148,7 +1158,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
         Material mat = vol.material();
         TGeoMaterial* mptr = mat->GetMaterial();
         bool ok = mat.A() == mptr->GetA() && mat.Z() == mptr->GetZ();
-        ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Material: %%-16s A:%%f %%f   Z:%%f %%f",
+        ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Material: %%-16s A:%%6.2f %%6.2f  Z:%%6.2f %%6.2f",
                    level+1,2*level+1);
         ++m_numMaterial;
         if ( !ok ) ++m_numMaterialERR;
@@ -1169,9 +1179,6 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
         }
         log << fmt << " \t";
       }
-      if ( m_printVis && pv.volume().visAttributes().isValid() )   {
-        log << " Vis:" << pv.volume().visAttributes().name();
-      }
       if ( !log.str().empty() )  {
         ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%s",level+1,2*level+1);
         printout(INFO, "VolumeDump", fmt, "  ->", "", log.str().c_str());
@@ -1189,6 +1196,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) {
       }
       return 1;
     }
+    ///
     int operator()()   {
       PlacedVolume pv;
       DetElement   top = description.world();
diff --git a/DDCore/src/plugins/VisVolNameProcessor.cpp b/DDCore/src/plugins/VisVolNameProcessor.cpp
index 32750cad0..e1e9bff14 100644
--- a/DDCore/src/plugins/VisVolNameProcessor.cpp
+++ b/DDCore/src/plugins/VisVolNameProcessor.cpp
@@ -14,7 +14,9 @@
 #define DD4HEP_DDCORE_VISVOLNAMEPROCESSOR_H
 
 // Framework include files
-#include "DD4hep/VolumeProcessor.h"
+#include <DD4hep/VolumeProcessor.h>
+// C/C++ include files
+#include <vector>
 
 namespace dd4hep  {
   
@@ -27,10 +29,11 @@ namespace dd4hep  {
    */
   class VisVolNameProcessor : public PlacedVolumeProcessor  {
   public:
-    Detector&              description;
-    std::string            name;
-    size_t                 numApplied = 0;
-    bool                   show = false;
+    Detector&                description;
+    std::string              name;
+    size_t                   numApplied = 0;
+    bool                     show = false;
+    VisAttr                  visattr;
     /// Print properties
     void _show();
   public:
@@ -57,18 +60,19 @@ namespace dd4hep  {
 //
 //==========================================================================
 
-//#include "DD4hep/VisVolNameProcessor.h"
-#include "DD4hep/Printout.h"
-#include "DD4hep/DetectorTools.h"
-#include "DD4hep/DetectorHelper.h"
-#include "DD4hep/DetFactoryHelper.h"
+//#include <DD4hep/VisVolNameProcessor.h>
+#include <DD4hep/Printout.h>
+#include <DD4hep/DetectorTools.h>
+#include <DD4hep/DetectorHelper.h>
+#include <DD4hep/DetFactoryHelper.h>
 #include <sstream>
 
 using namespace std;
 using namespace dd4hep;
 
 /// Initializing constructor
-VisVolNameProcessor::VisVolNameProcessor(Detector& desc) : description(desc), name("VisVolNameProcessor")
+VisVolNameProcessor::VisVolNameProcessor(Detector& desc)
+  : description(desc), name("VisVolNameProcessor")
 {
 }
 
@@ -82,9 +86,8 @@ VisVolNameProcessor::~VisVolNameProcessor()   {
 /// Callback to output PlacedVolume information of an single Placement
 int VisVolNameProcessor::operator()(PlacedVolume pv, int /* level */)   {
   Volume   vol = pv.volume();
-  VisAttr  vis = description.visAttributes(vol.name());
-  if ( vol.visAttributes().ptr() != vis.ptr() )  {
-    vol.setVisAttributes(vis);
+  if ( vol.visAttributes().ptr() != visattr.ptr() && name == vol.name() )  {
+    vol.setVisAttributes(visattr);
     ++numApplied;
   }
   return 1;
@@ -96,8 +99,12 @@ static void* create_object(Detector& description, int argc, char** argv)   {
   for ( int i=0; i<argc; ++i )   {
     if ( argv[i] )    {
       if ( ::strncmp(argv[i],"-name",4) == 0 )   {
-        string     name = argv[++i];
+        string name = argv[++i];
         proc->name = name;
+	proc->visattr = description.visAttributes(name);
+	if ( !proc->visattr.ptr() )   {
+	  except(name,"+++ Unknown visual attribute: %s",name.c_str());
+	}
         continue;
       }
       else if ( ::strncmp(argv[i],"-show",4) == 0 )   {
diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt
index f5779e4fb..966021ac0 100644
--- a/examples/ClientTests/CMakeLists.txt
+++ b/examples/ClientTests/CMakeLists.txt
@@ -241,6 +241,15 @@ dd4hep_add_test_reg( ClientTests_Check_Temp_Pressure_Air_STP
   REGEX_PASS "Temp=273 \\[Kelvin\\] Pressure=1000 \\[hPa\\] state=Undefined"
   REGEX_FAIL "Exception;EXCEPTION;ERROR;Error;FATAL" )
 #
+#  Test reflection matrices
+dd4hep_add_test_reg( ClientTests_Check_reflection_matrices
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoDisplay
+  -input file:${ClientTestsEx_INSTALL}/compact/ReflectionMatrices.xml
+  -load -destroy -print WARNING
+  REGEX_PASS "Analysed 7 right handed and 10 left handed matrices"
+  REGEX_FAIL "Exception;EXCEPTION;ERROR;Error;FATAL" )
+#
 # only if root version > 6.19: MaterialTester
 #
 foreach (test Assemblies BoxTrafos CaloEndcapReflection IronCylinder LheD_tracker MagnetFields  
diff --git a/examples/ClientTests/compact/ReflectionMatrices.xml b/examples/ClientTests/compact/ReflectionMatrices.xml
new file mode 100644
index 000000000..f0bb6ce67
--- /dev/null
+++ b/examples/ClientTests/compact/ReflectionMatrices.xml
@@ -0,0 +1,122 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/>
+  </includes>
+
+  <define>
+    <constant name="world_size" value="6*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+  </define>
+
+  <display>
+    <vis name="Invisible" showDaughters="false" visible="false"/>
+    <vis name="InvisibleWithChildren" showDaughters="true" visible="false"/>
+    <vis name="VisibleGrey"   alpha="0.4" r="0.7" g="0.7" b="0.7" showDaughters="true" visible="true"/>
+  </display>
+
+  <detectors>
+    <detector id="1" name="Matrices" type="DD4hep_Test_ReflectionMatrices" vis="VisibleGrey">
+      <assembly/>
+      <dimensions x="50*cm"   y="70*cm"   z="90*cm" level="2">
+	<position x="0*cm" y="0*cm" z="0*cm"/>
+      </dimensions>
+      <reflect name="ReflectionX[LEFT-handed]">
+	<rotation phiY="90.*deg" thetaY="90.*deg"
+		  phiX="180.*deg" thetaX="90.*deg"
+		  phiZ="0.*deg" thetaZ="0.*deg"/>
+	<position x="200*cm" y="0*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="ReflectionY[LEFT-handed]">
+	<rotation phiY="270.*deg" thetaY="90.*deg"
+		  phiX=" 0.*deg" thetaX="90.*deg"
+		  phiZ="0.*deg" thetaZ="0.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="180R[LEFT-handed]">
+	<rotation thetaX="90*deg" phiX="0*deg"
+		  thetaY="90*deg" phiY="90*deg"
+		  thetaZ="180*deg" phiZ="0*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="180RYZ[LEFT-handed]">
+	<rotation thetaX="90*deg" phiX="180*deg"
+		  thetaY="90*deg" phiY="90*deg"
+		  thetaZ="0*deg" phiZ="0*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="R005R[LEFT-handed]">
+	<rotation thetaX="90*deg" phiX="175*deg"
+		  thetaY="90*deg" phiY="85*deg"
+		  thetaZ="0*deg" phiZ="0*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="R010R[LEFT-handed]">
+	<rotation thetaX="90*deg" phiX="170*deg"
+		  thetaY="90*deg" phiY="80*deg"
+		  thetaZ="0*deg" phiZ="0*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      <reflect name="R025R[LEFT-handed]">
+	<rotation thetaX="90*deg" phiX="155*deg"
+		  thetaY="90*deg" phiY="65*deg"
+		  thetaZ="0*deg" phiZ="0*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect_x  name="reflect_x[LEFT-handed]" x="-200*cm" y="0*cm"    z="0*cm"/>
+      <reflect_y  name="reflect_x[LEFT-handed]" x="0*cm"    y="-200*cm" z="0*cm"/>
+      <reflect_z  name="reflect_x[LEFT-handed]" x="0*cm"    y="0*cm"    z="200*cm"/>
+
+      <reflect name="EERotVFE">
+	<rotation phiX=" 0.*deg" thetaX=" 0.*deg" phiY="  0.*deg" thetaY="90.*deg" phiZ="90.*deg" thetaZ="90.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EERotZ90">
+	<rotation phiX="90.*deg" thetaX="90.*deg" phiY="180.*deg" thetaY="90.*deg" phiZ=" 0.*deg" thetaZ=" 0.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EEfCR420">
+	<rotation phiX="-57*deg" thetaX=" 90*deg" phiY=" 33*deg" thetaY="110*deg" phiZ="33*deg" thetaZ=" 20*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EEfCRot45">
+	<rotation phiX="  0.*deg" thetaX="180.*deg" phiY=" 45.*deg" thetaY="90.*deg" phiZ="-45.*deg" thetaZ="90.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EEfCRotX">
+	<rotation phiX="0.*deg" thetaX="90.*deg" phiY="0.*deg" thetaY="180.*deg" phiZ="90.*deg" thetaZ="90.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EEfCRotY">
+	<rotation phiX="0.*deg" thetaX="180.*deg" phiY="90.*deg" thetaY="90.*deg" phiZ="0.*deg" thetaZ="90.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+
+      <reflect name="EEfCR100">
+	<rotation phiX="0.*deg" thetaX="180.*deg" phiY="123.*deg" thetaY="90.*deg" phiZ="33.*deg" thetaZ="90.*deg"/>
+	<position x="0*cm" y="200*cm" z="0*cm"/>
+      </reflect>
+      
+    </detector>
+  </detectors>
+  
+  <fields>
+    <field name="GlobalSolenoid" type="solenoid" 
+	   inner_field="5.0*tesla"
+	   outer_field="-1.5*tesla" 
+	   zmax="2*m"
+	   outer_radius="3*m">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/examples/ClientTests/src/NestedBoxReflection_geo.cpp b/examples/ClientTests/src/NestedBoxReflection_geo.cpp
index 6964950a9..e38b6b755 100644
--- a/examples/ClientTests/src/NestedBoxReflection_geo.cpp
+++ b/examples/ClientTests/src/NestedBoxReflection_geo.cpp
@@ -107,8 +107,6 @@ namespace   {
       mat->ReflectZ(kTRUE, kTRUE);
       vol.placeVolume(tvol0, mat);
 
-#if 0
-#endif
       double dz2 = dz-tsol2.dZ();
       // OK
       mat = detail::matrix::_transform(Transform3D(Position(0, 0, dz2)));
@@ -127,8 +125,7 @@ namespace   {
       vol.placeVolume(tvol4, mat);
 
 
-      /** Now eflect the quadrants to the other endcap:  */
-      
+      /** Now eflect the quadrants to the other endcap:  */      
       // OK
       mat = detail::matrix::_transform(Transform3D(Position(0, 0,-dz2)));
       mat->ReflectY(kTRUE,kTRUE);
diff --git a/examples/ClientTests/src/ReflectionMatrices_geo.cpp b/examples/ClientTests/src/ReflectionMatrices_geo.cpp
new file mode 100644
index 000000000..5de9ad7d1
--- /dev/null
+++ b/examples/ClientTests/src/ReflectionMatrices_geo.cpp
@@ -0,0 +1,142 @@
+//==========================================================================
+//  AIDA Detector description implementation 
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework includes
+#include "DD4hep/Printout.h"
+#include "DD4hep/MatrixHelpers.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "XML/VolumeBuilder.h"
+#include "XML/Utilities.h"
+#include <iostream>
+#include <cmath>
+
+using namespace std;
+using namespace dd4hep;
+using namespace dd4hep::detail;
+
+namespace   {
+  Rotation3D makeRotReflect(double thetaX, double phiX, double thetaY, double phiY, double thetaZ, double phiZ) {
+    // define 3 unit std::vectors forming the new left-handed axes
+    Position x(cos(phiX) * sin(thetaX), sin(phiX) * sin(thetaX), cos(thetaX));
+    Position y(cos(phiY) * sin(thetaY), sin(phiY) * sin(thetaY), cos(thetaY));
+    Position z(cos(phiZ) * sin(thetaZ), sin(phiZ) * sin(thetaZ), cos(thetaZ));
+    printout(INFO,"ReflectionMatrices",
+           "+++ Adding rotation: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
+           thetaX,phiX,thetaY,phiY,thetaZ,phiZ);
+    Rotation3D rotation(x.x(), y.x(), z.x(), x.y(), y.y(), z.y(), x.z(), y.z(), z.z());
+    return rotation;
+  }
+  Transform3D transform_3d(xml_h element)   {
+    xml_dim_t xrot(element.child(_U(rotation)));
+    xml_dim_t xpos(element.child(_U(position)));
+    double thetaX = xrot.attr<double>(Unicode("thetaX"));
+    double phiX   = xrot.attr<double>(Unicode("phiX"));
+    double thetaY = xrot.attr<double>(Unicode("thetaY"));
+    double phiY   = xrot.attr<double>(Unicode("phiY"));
+    double thetaZ = xrot.attr<double>(Unicode("thetaZ"));
+    double phiZ   = xrot.attr<double>(Unicode("phiZ"));
+    printout(INFO, "ReflectionMatrices",
+	     "+++ Adding reflection rotation \"%s\": "
+	     "(theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
+	     element.attr<string>(_U(name)).c_str(), thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
+    Rotation3D rot = makeRotReflect(thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
+    Position   pos = Position(xpos.x(),xpos.y(),xpos.z());
+    return Transform3D(rot, pos);
+  }
+
+  struct ReflectionMatrices : public xml::tools::VolumeBuilder  {
+    int num_left = 0, num_right = 0;
+    
+    using VolumeBuilder::VolumeBuilder;
+    ///
+    void dump(const string& nam, const Transform3D& tr)   {
+      stringstream str;
+      Position x, y, z, p;
+      Rotation3D r;
+      tr.GetDecomposition(r, p);
+      r.GetComponents(x,y,z);
+      double det1 = (x.Cross(y)).Dot(z);
+      double det2 = detail::matrix::determinant(r);
+      double det3 = detail::matrix::determinant(tr);
+      str << "+++ Using rotation: " << nam << "   "
+	  << (const char*)((det1 >= 0) ? "RIGHT" : "LEFT") << "-handed  "
+	  << " Determinant: " << det1 << " " << det2 << " " << det3 << endl
+	  << "Pos: " << p << " Rotation:" << x << " " << y << " " << z
+	  << r;
+      PrintLevel lvl = det1 != det2 || det1 != det3 ? ERROR : INFO;
+      if ( det1 < 0e0 ) ++num_left;
+      if ( det1 > 0e0 ) ++num_right;
+      if ( det1 < 0e0 && nam.find("LEFT-handed") == string::npos )   {
+	lvl = ERROR;
+      }
+      printout(lvl, "ReflectionMatrices",str.str().c_str());
+    }
+    /// 
+    void dump(xml_elt_t elt, char reflection)   {
+      Position    pos;
+      RotationZYX rot;
+      xml_dim_t   e(elt);
+      xml_dim_t   xpos = e.child(_U(position), false);
+      xml_dim_t   xrot = e.child(_U(rotation), false);
+      if ( !xpos.ptr() ) xpos = e;
+      if ( xpos.ptr()  ) pos = Position(xpos.x(0),xpos.y(0),xpos.z(0));
+      if ( xrot.ptr()  ) rot = RotationZYX(xrot.x(0),xrot.y(0),xrot.z(0));
+
+      TGeoHMatrix mat;
+      detail::matrix::_transform(mat, pos, rot);
+      switch(reflection)  {
+      case 'X':
+	mat.ReflectX(kTRUE, kTRUE);
+	break;
+      case 'Y':
+	mat.ReflectY(kTRUE, kTRUE);
+	break;
+      case 'Z':
+      default:
+	mat.ReflectZ(kTRUE, kTRUE);
+	break;
+      }
+      dump(e.nameStr(), detail::matrix::_transform(mat));
+    }
+    DetElement create()    {
+      xml_dim_t x_box(x_det.dimensions()); 
+      double    bx = x_box.x();
+      double    by = x_box.y();
+      double    bz = x_box.z();
+
+      for(xml_coll_t c(x_det,_U(reflect_x)); c; ++c)
+	dump(c, 'X');
+      for(xml_coll_t c(x_det,_U(reflect_y)); c; ++c)
+	dump(c, 'Y');
+      for(xml_coll_t c(x_det,_U(reflect_z)); c; ++c)
+	dump(c, 'Z');
+      for(xml_coll_t c(x_det,_U(reflect)); c; ++c)
+	dump(xml_dim_t(c).nameStr(), transform_3d(c));
+
+      auto pv = placeDetector(Volume("envelope",Box(bx, by, bz),description.air()), x_det);
+      pv.addPhysVolID("system",x_det.id());
+      return detector;
+    }
+  };
+  ///
+  Ref_t create_test(Detector& description, xml_dim_t x_det, SensitiveDetector sens)  {
+    ReflectionMatrices builder(description, x_det, sens);
+    DetElement det = builder.create();
+    printout(ALWAYS,"ReflectionMatrices",
+	     "+++ Analysed %d right handed and %d left handed matrices.",
+	     builder.num_right, builder.num_left);
+    return det;
+  }
+}
+
+DECLARE_DETELEMENT(DD4hep_Test_ReflectionMatrices,create_test)
diff --git a/examples/DDCMS/data/caloBase.xml b/examples/DDCMS/data/caloBase.xml
index 18da683e9..d19a5b8ae 100644
--- a/examples/DDCMS/data/caloBase.xml
+++ b/examples/DDCMS/data/caloBase.xml
@@ -1,4 +1,7 @@
 <DDDefinition>
+  <RotationSection label="caloBase.xml">
+    <Rotation name="000D" thetaX="90*deg" phiX="0*deg" thetaY="90*deg" phiY="90*deg" thetaZ="0*deg" phiZ="0*deg"/>
+  </RotationSection> 
   <SolidSection label="caloBase.xml">
     <Polycone name="CALO" startPhi="0*deg" deltaPhi="360*deg">
       <ZSection z=" -554.10000*cm" rMin="  8.93000*cm" rMax="295.00000*cm"/>
diff --git a/examples/DDCMS/data/cms_close_geom.xml b/examples/DDCMS/data/cms_close_geom.xml
new file mode 100644
index 000000000..dced56372
--- /dev/null
+++ b/examples/DDCMS/data/cms_close_geom.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<DDDefinition>
+  <close_geometry/>
+</DDDefinition>
diff --git a/examples/DDCMS/data/cms_ecal.xml b/examples/DDCMS/data/cms_ecal.xml
new file mode 100644
index 000000000..e67ab19c8
--- /dev/null
+++ b/examples/DDCMS/data/cms_ecal.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<DDDefinition>
+  <debug>
+<!-- 
+    <debug_placements/>
+    <debug_rotations/>
+    <debug_includes/>
+    <debug_materials/>
+
+    <debug_shapes/>
+    <debug_volumes/>
+    <debug_namespaces/>
+    <debug_visattr/>
+    <debug_constants/>
+    <debug_algorithms/>
+-->
+  </debug>
+
+  <open_geometry/>
+<!-- 
+  <close_geometry/>
+-->
+
+  <ConstantsSection label="" eval="true">
+    <Constant name="world_x" value="5*m"/>
+    <Constant name="world_y" value="5*m"/>
+    <Constant name="world_z" value="5*m"/>
+    <Constant name="fm"      value="1e-12*m"/>
+    <Constant name="Air"     value="materials:Air"     type="string"/>
+    <Constant name="Vacuum"  value="materials:Vacuum"  type="string"/>
+  </ConstantsSection>
+  <ConstantsSection label="servicescylinderb.xml" eval="true">
+	<Constant name="zero" value="0.0*fm"/>
+  </ConstantsSection>
+  <ConstantsSection label="servicescylinderf.xml" eval="true">
+	<Constant name="zero" value="0.0*fm"/>
+  </ConstantsSection>
+
+  <IncludeSection>
+    <Include ref="materials.xml"/>
+    <Include ref="rotations.xml"/>
+    <Include ref="trackermaterial.xml"/>
+    <Include ref="ecalmaterial.xml"/>
+    <Include ref="caloBase.xml"/>
+    <Include ref="eecon.xml"/>
+    <Include ref="eehier.xml"/>
+    <Include ref="eregalgo.xml"/>
+    <Include ref="eealgo.xml"/>
+  </IncludeSection>
+
+  <PosPartSection label="">
+    <PosPart copyNumber="1">
+	<rParent name="world_volume"/>
+	<rChild name="eregalgo:ECAL"/>
+   </PosPart>
+    <PosPart copyNumber="2">
+	<rParent name="world_volume"/>
+	<rChild name="eregalgo:EREG"/>
+   </PosPart>
+  </PosPartSection>
+
+</DDDefinition>
diff --git a/examples/DDCMS/data/dd4hep-ecal.xml b/examples/DDCMS/data/dd4hep-ecal.xml
new file mode 100644
index 000000000..adc96d597
--- /dev/null
+++ b/examples/DDCMS/data/dd4hep-ecal.xml
@@ -0,0 +1,185 @@
+<plugins>
+<!--
+
+   # Configuration file top load the CMS geometry
+
+   This XML script extends the raw geometry defintiion from CMS (see cms_tracker.xml for details).
+   * We load the primary geometry entities and instantiate them.
+     Note: TEC, and PixbarFWD do not work and cannot be converted;
+   * Here the DetElement structure and the readout structures are defined to run Geant4
+     Note: TEC, and PixbarFWD do not work and cannot be used for Geant4. To be investigated.
+   * Here we also define the visualization attributes to get nicer pictures.
+
+                         M.Frank CERN EP/LBC  October 2017
+
+-->
+
+  <display>
+
+    <vis name="solid-light-grey"                                 alpha="0.5"   r="0.5"  g="0.5"  b="0.5" showDaughters="true"  visible="false"/>
+    <vis name="solid-verylight-grey"                             alpha="0.6"   r="0.5"  g="0.5"  b="0.5" showDaughters="true"  visible="true"/>
+    <vis name="solid-red"                                        alpha="1.0"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-red"                              alpha="0.6"   r="1.0"  g="0.8"  b="0.8" showDaughters="true"  visible="true"/>
+    <vis name="solid-green"                                      alpha="1.0"   r="0.0"  g="0.9"  b="0.2" showDaughters="true"  visible="true"/>
+    <vis name="solid-light-green"                                alpha="0.4"   r="0.0"  g="0.4"  b="0.0" showDaughters="true"  visible="false"/>
+    <vis name="solid-verylight-green"                            alpha="0.6"   r="0.8"  g="1.0"  b="0.8" showDaughters="true"  visible="true"/>
+    <vis name="solid-blue"                                       alpha="1.0"   r="0.0"  g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-light-blue"                                 alpha="1.0"   r="0.0"  g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-blue"                             alpha="0.6"   r="0.8"  g="0.8"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-yellow"                           alpha="0.3"   r="1.0"  g="1.0"  b="0.2" showDaughters="true"  visible="true"/>
+    <vis name="CMS_Invisible"                                    alpha="0.5"   r="0.9"  g="0.9"  b="0.9" showDaughters="true"  visible="false"/>
+
+    <vis name="vis-active-material"                              alpha="1.0"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="vis-invisible-daughters"                          alpha="1.0"   r="0.1"  g="0.1"  b="0.8" showDaughters="true"  visible="false"/>
+
+    <vis name="eregalgo:ECAL"                                    alpha="1.0"   r="0.1"  g="0.1"  b="0.1" showDaughters="true"  visible="false"/>
+    <vis name="eregalgo:EREG"                                    alpha="0.3"   r="1.0"  g="0.1"  b="1.0" showDaughters="true"  visible="false"/>
+    <vis name="eehier:ENCA"                                      alpha="1.0"   r="0.1"  g="0.1"  b="0.1" showDaughters="true"  visible="false"/>
+    <vis name="eehier:EEDee"                                     alpha="1.0"   r="0.1"  g="1.0"  b="0.1" showDaughters="true"  visible="false"/>
+    <vis name="eehier:EEFrontQuad"                               alpha="0.3"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="false"/>
+    <vis name="eehier:EEBackQuad"                                alpha="0.3"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="false"/>
+    <vis name="eehier:EEFrontDee"                                alpha="0.5"   r="0.0"  g="1.0"  b="0.1" showDaughters="true"  visible="false"/>
+    <vis name="eehier:EEBackDee"                                 alpha="0.5"   r="0.0"  g="1.0"  b="0.1" showDaughters="true"  visible="false"/>
+    <vis name="eregalgo:EESCEnv1"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="eregalgo:EESCEnv2"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="eregalgo:EESCEnv3"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="eregalgo:EESCEnv4"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="eregalgo:EESCEnv5"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="eregalgo:EESCEnv6"                                alpha="0.5"   r="0.0"  g="0.0"  b="0.9" showDaughters="false" visible="true"/>
+    <vis name="EESCAlv4"                                         alpha="0.5"   r="0.8"  g="0.1"  b="0.1" showDaughters="true"  visible="true"/>
+    <vis name="EFRY"                                             alpha="0.7"   r="0.0"  g="0.9"  b="0.2" showDaughters="true"  visible="true"/>
+  </display>
+
+  <plugin name="DD4hep_XMLLoader">
+    <arg value="file:${DD4hepExamplesINSTALL}/examples/DDCMS/data/cms_ecal.xml"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:ECAL"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:ENCA"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:EEDee"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:EEFrontDee"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:EEBackDee"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:EEFrontQuad"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eehier:EEBackQuad"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv1"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv2"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv3"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv4"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv5"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EESCEnv6"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="eregalgo:EREG"/>
+    <arg value="-show"/>
+  </plugin>
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="EFRY"/>
+    <arg value="-show"/>
+  </plugin>
+  <!--
+  <plugin name="DD4hep_VolumeDump">
+    <arg value="-materials"/>
+    <arg value="-vis"/>
+  </plugin>
+  -->
+  <plugin name="DD4hep_XMLLoader">
+    <arg value="file:${DD4hepExamplesINSTALL}/examples/DDCMS/data/cms_close_geom.xml"/>
+  </plugin>
+</plugins>
diff --git a/examples/DDCMS/data/ecal-vis.xml b/examples/DDCMS/data/ecal-vis.xml
new file mode 100644
index 000000000..78456ec6b
--- /dev/null
+++ b/examples/DDCMS/data/ecal-vis.xml
@@ -0,0 +1,50 @@
+<plugins>
+<!--
+
+   # Configuration file top load the CMS geometry
+
+   This XML script extends the raw geometry defintiion from CMS (see cms_tracker.xml for details).
+   * We load the primary geometry entities and instantiate them.
+     Note: TEC, and PixbarFWD do not work and cannot be converted;
+   * Here the DetElement structure and the readout structures are defined to run Geant4
+     Note: TEC, and PixbarFWD do not work and cannot be used for Geant4. To be investigated.
+   * Here we also define the visualization attributes to get nicer pictures.
+
+                         M.Frank CERN EP/LBC  October 2017
+
+-->
+
+  <display>
+
+    <vis name="solid-light-grey"                                 alpha="0.5"   r="0.5"  g="0.5"  b="0.5" showDaughters="true"  visible="false"/>
+    <vis name="solid-verylight-grey"                             alpha="0.6"   r="0.5"  g="0.5"  b="0.5" showDaughters="true"  visible="true"/>
+    <vis name="solid-red"                                        alpha="1.0"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-red"                              alpha="0.6"   r="1.0"  g="0.8"  b="0.8" showDaughters="true"  visible="true"/>
+    <vis name="solid-green"                                      alpha="1.0"   r="0.0"  g="0.9"  b="0.2" showDaughters="true"  visible="true"/>
+    <vis name="solid-light-green"                                alpha="0.4"   r="0.0"  g="0.4"  b="0.0" showDaughters="true"  visible="false"/>
+    <vis name="solid-verylight-green"                            alpha="0.6"   r="0.8"  g="1.0"  b="0.8" showDaughters="true"  visible="true"/>
+    <vis name="solid-blue"                                       alpha="1.0"   r="0.0"  g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-light-blue"                                 alpha="1.0"   r="0.0"  g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-blue"                             alpha="0.6"   r="0.8"  g="0.8"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="solid-verylight-yellow"                           alpha="0.3"   r="1.0"  g="1.0"  b="0.2" showDaughters="true"  visible="true"/>
+    <vis name="CMS_Invisible"                                    alpha="0.5"   r="0.9"  g="0.9"  b="0.9" showDaughters="true"  visible="false"/>
+
+    <vis name="vis-active-material"                              alpha="1.0"   r="1.0"  g="0.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="vis-invisible-daughters"                          alpha="1.0"   r="0.1"  g="0.1"  b="0.8" showDaughters="true"  visible="false"/>
+
+    <vis name="EFRY"                                             alpha="0.7"   r="0.0"  g="0.9"  b="0.2" showDaughters="true"  visible="true"/>
+  </display>
+
+  <plugin name="DD4hep_XMLLoader">
+    <arg value="file:${DD4hepExamplesINSTALL}/examples/DDCMS/data/cms_ecal.xml"/>
+  </plugin>
+
+  <plugin name="DD4hep_PlacedVolumeProcessor">
+    <arg value="-recursive"/>
+    <arg value="-processor"/>
+    <arg value="DD4hep_VisVolNameProcessor"/>
+    <arg value="-name"/>
+    <arg value="EFRY"/>
+    <arg value="-show"/>
+  </plugin>
+</plugins>
diff --git a/examples/DDCMS/data/ecalmaterial.xml b/examples/DDCMS/data/ecalmaterial.xml
new file mode 100644
index 000000000..ae4164f65
--- /dev/null
+++ b/examples/DDCMS/data/ecalmaterial.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
+ <MaterialSection label="trackermaterial.xml">
+
+
+ </MaterialSection>
+</DDDefinition>
diff --git a/examples/DDCMS/data/eealgo.xml b/examples/DDCMS/data/eealgo.xml
new file mode 100644
index 000000000..23f0f6961
--- /dev/null
+++ b/examples/DDCMS/data/eealgo.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0"?>
+<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
+  <Algorithm name="ecal:DDEcalEndcapAlgo">
+    <rParent name="eregalgo:EREG"/>
+    <String name="EEMat" value="materials:Air"/>
+    <Numeric name="EEzOff" value="[eecon:EEzOff]"/>
+    <String name="EECutBoxName" value="EECutBox"/>
+    <String name="EEEnvName" value="EESCEnv"/>
+    <String name="EEAlvName" value="EESCAlv"/>
+    <String name="EEIntName" value="EESCInt"/>
+    <String name="EECryName" value="EFRY"/>
+    <!-- Added by BWK -->
+    <!-- More endcap materials -->
+    <String name="EECrysMat" value="materials:E_PbWO4"/>
+    <String name="EEBPMat" value="materials:E_Aluminium"/>
+    <String name="EEWallMat" value="materials:EE_Aveolar"/>
+    <!--  Endcap Quadrant -->
+    <String name="EEQuaName" value="eehier:EEFrontQuad"/>
+    <String name="EEQuaMat" value="materials:Air"/>
+    <!-- Endcap crystal: nominal size -->
+    <Numeric name="EECrysLength" value="220.00*mm"/>
+    <Numeric name="EECrysRear" value="30.000*mm - 0.05*mm"/>
+    <Numeric name="EECrysFront" value="28.618*mm - 0.05*mm"/>
+    <!-- Taper = 0.36deg -->
+    <!-- Endcap supercrystal: size of tapered envelope -->
+    <Numeric name="EESCELength" value="[eecon:SCEnvLength]"/>
+    <Numeric name="EESCERear" value="156.87*mm"/>
+    <Numeric name="EESCEFront" value="145.98*mm"/>
+    <!-- Taper = 1.80deg -->
+    <!-- Endcap supercrystal: size of C-fibre alveolar -->
+    <Numeric name="EESCALength" value="276.20*mm"/>
+    <Numeric name="EESCARear" value="154.66*mm - 0.01*mm"/>
+    <Numeric name="EESCAFront" value="145.98*mm - 0.01*mm"/>
+    <!-- Taper = 1.80deg -->
+    <Numeric name="EESCAWall" value="0.200*mm"/>
+    <!-- SC wall thickness -->
+    <Numeric name="EEiLength" value="2*mm"/>
+    <Numeric name="EEiXYOff" value="-2.2*mm"/>
+    <!-- Endcap supercrystal: size of rear housing -->
+    <Numeric name="EESCHLength" value="60.20*mm"/>
+    <Numeric name="EESCHSide" value="154.20*mm"/>
+    <!-- Supercrystal profiles: number of crystals in each column -->
+    <!--                        (-ve => counting from the top)    -->
+    <Numeric name="EEnSCTypes" value="6"/>
+    <!-- Number of SC types -->
+    <Vector name="EESCProf" type="numeric" nEntries="30">
+      5,5,5,5,5, 2,2,2,2,2, 5,5,0,0,0,
+      -4,-4,-4,-4,-4, 0,0,-1,-2,-3, 0,5,5,5,5
+    </Vector>
+    <!-- Endcap quadrant profile: lowest and highest SC in each column -->
+    <Numeric name="EEnColumns" value="10"/>
+    <!-- Number of endcap columns -->
+    <Vector name="EEShape" type="numeric" nEntries="20">
+      3,10,  2,10, 1,10, 1,9, 1,9, 1,9, 1,8, 1,7, 1,6, 1,3
+    </Vector>
+    <Numeric name="EEnSCCutaway" value="9"/>
+    <!-- Number of cutaway SCs -->
+    <Vector name="EESCCutaway" type="numeric" nEntries="27"><!-- Map of cutaway SCs -->
+      1,3,4, 2,2,5, 3,1,6, 3,10,2, 6,9,2, 7,8,2, 8,7,3, 9,6,3, 10,3,3
+    </Vector>
+    <!-- Endcap supercrystal: size of interface plate -->
+    <Numeric name="EESCILength" value="10.20*mm"/>
+    <!-- Factors used in shaving the SCs for partials -->
+    <Numeric name="EEPFHalf" value="0.3"/>
+    <Numeric name="EEPFFifth" value="1.55"/>
+    <Numeric name="EEPF45" value="0.65"/>
+    <!-- Which SCs are in place? -->
+    <Vector name="EESCLims" type="numeric" nEntries="4">
+      [eehier:EESCLimsXlo],  [eehier:EESCLimsXhi],  [eehier:EESCLimsYlo],  [eehier:EESCLimsYhi] 
+    </Vector>
+    <!-- Endcap supercrystal corner positions -->
+    <Numeric name="EEnSCquad" value="78"/>
+    <Numeric name="EEzFront" value="[eecon:EEzFront]"/>
+    <!-- EESCCtrs gives positions of centres of front and rear SC faces in CMS coordinates -->
+    <!-- Column headings for EESCCtrs vector                                       
+         Z positions are assuming front of EE env screen (EEzFront) is at 3172mm from IP-->
+    <!-- This correction to 3172 is made in the C++ code
+         -->
+    <!-- IX  IY   Xfront         Xrear        Yfront       Yrear        Zfront       Zrear -->
+    <Vector name="EESCCtrs" type="numeric" nEntries="624">
+      1,  3,  73.99*mm,     79.436*mm,  367.857*mm,  395.056*mm, 3183.583*mm, 3529.157*mm,
+      1,  4,  73.99*mm,     79.436*mm,  515.672*mm,  553.7125*mm,3185.869*mm, 3530.4185*mm,
+      1,  5,  73.99*mm,     79.436*mm,  664.0725*mm, 712.916*mm, 3188.148*mm, 3531.3325*mm,
+      1,  6,  73.99*mm,     79.436*mm,  813.2075*mm, 872.807*mm, 3190.418*mm, 3531.899*mm,
+      1,  7,  73.99*mm,     79.436*mm,  963.232*mm, 1033.5285*mm,3192.677*mm, 3532.1175*mm,
+      1,  8,  73.99*mm,     79.436*mm, 1114.304*mm, 1195.228*mm, 3194.9225*mm,3531.9865*mm,
+      1,  9,  73.99*mm,     79.436*mm, 1266.587*mm, 1358.058*mm, 3197.152*mm, 3531.5085*mm,
+      1, 10,  73.99*mm,     79.436*mm, 1420.249*mm, 1522.178*mm, 3199.3635*mm,3530.682*mm,
+      2,  2, 221.1655*mm,  238.0385*mm, 220.479*mm,  236.8095*mm,3183.701*mm, 3529.59025*mm,
+      2,  3, 221.24125*mm, 238.092*mm,  367.857*mm,  395.056*mm, 3185.99*mm,  3531.196*mm,
+      2,  4, 221.31675*mm, 238.133*mm,  515.672*mm,  553.7125*mm,3188.2745*mm, 3532.4565*mm,
+      2,  5, 221.392*mm,   238.163*mm,  664.0725*mm, 712.916*mm, 3190.5525*mm, 3533.37*mm,
+      2,  6, 221.467*mm,   238.1825*mm, 813.2075*mm, 872.807*mm, 3192.8215*mm, 3533.93625*mm,
+      2,  7, 221.5415*mm,  238.1895*mm, 963.232*mm, 1033.5285*mm,3195.079*mm, 3534.1545*mm,
+      2,  8, 221.6155*mm,  238.185*mm, 1114.304*mm, 1195.228*mm, 3197.323*mm, 3534.024*mm,
+      2,  9, 221.689*mm,   238.1695*mm,1266.587*mm, 1358.058*mm, 3199.5515*mm, 3533.54575*mm,
+      2, 10, 221.76225*mm, 238.142*mm, 1420.249*mm, 1522.178*mm, 3201.762*mm, 3532.72*mm,
+      3,  1, 368.51*mm,    396.814*mm,   73.39*mm,    78.836*mm, 3183.816*mm, 3529.3015*mm,
+      3,  2, 368.6615*mm,  396.943*mm,  220.479*mm,  236.8095*mm,3186.10375*mm, 3531.248*mm,
+      3,  3, 368.8125*mm,  397.049*mm,  367.857*mm,  395.056*mm, 3188.389*mm, 3532.851*mm,
+      3,  4, 368.9635*mm,  397.132*mm,  515.672*mm,  553.7125*mm,3190.67*mm, 3534.109*mm,
+      3,  5, 369.11375*mm, 397.1925*mm, 664.0725*mm, 712.916*mm, 3192.94425*mm, 3535.02125*mm,
+      3,  6, 369.2635*mm,  397.22975*mm,813.2075*mm, 872.807*mm, 3195.2095*mm, 3535.587*mm,
+      3,  7, 369.4125*mm,  397.24425*mm,963.232*mm, 1033.5285*mm,3197.46325*mm, 3535.80425*mm,
+      3,  8, 369.5605*mm,  397.2355*mm,1114.304*mm, 1195.228*mm, 3199.7035*mm, 3535.6745*mm,
+      3,  9, 369.708*mm,   397.204*mm, 1266.587*mm, 1358.058*mm, 3201.9285*mm, 3535.19675*mm,
+      3, 10, 369.85375*mm, 397.1495*mm,1420.249*mm, 1522.178*mm, 3204.1355*mm, 3534.372*mm,
+      4,  1, 516.413*mm,   556.1055*mm,  73.39*mm,    78.836*mm, 3186.2175*mm, 3530.58*mm,
+      4,  2, 516.6395*mm,  556.2985*mm, 220.479*mm,  236.8095*mm,3188.499*mm, 3532.52125*mm,
+      4,  3, 516.866*mm,   556.4575*mm, 367.857*mm,  395.056*mm, 3190.778*mm, 3534.12*mm,
+      4,  4, 517.09225*mm, 556.582*mm,  515.672*mm,  553.7125*mm,3193.053*mm, 3535.375*mm,
+      4,  5, 517.3175*mm,  556.6725*mm, 664.0725*mm, 712.916*mm, 3195.321*mm, 3536.2845*mm,
+      4,  6, 517.542*mm,   556.7285*mm, 813.2075*mm, 872.807*mm, 3197.58*mm, 3536.8485*mm,
+      4,  7, 517.76525*mm, 556.75025*mm,963.232*mm, 1033.5285*mm,3199.8275*mm, 3537.0655*mm,
+      4,  8, 517.98725*mm, 556.737*mm, 1114.304*mm, 1195.228*mm, 3202.062*mm, 3536.93625*mm,
+      4,  9, 518.20775*mm, 556.69*mm,  1266.587*mm, 1358.058*mm, 3204.2805*mm, 3536.46*mm,
+      5,  1, 664.9525*mm,  715.8825*mm,  73.39*mm,    78.836*mm, 3188.5885*mm, 3531.4695*mm,
+      5,  2, 665.2535*mm,  716.138*mm,  220.479*mm,  236.8095*mm,3190.86125*mm, 3533.403*mm,
+      5,  3, 665.5545*mm,  716.3495*mm, 367.857*mm,  395.056*mm, 3193.13175*mm, 3534.99575*mm,
+      5,  4, 665.855*mm,   716.515*mm,  515.672*mm,  553.7125*mm,3195.39775*mm, 3536.246*mm,
+      5,  5, 666.154*mm,   716.635*mm,  664.0725*mm, 712.916*mm, 3197.65725*mm, 3537.152*mm,
+      5,  6, 666.4525*mm,  716.7095*mm, 813.2075*mm, 872.807*mm, 3199.9075*mm, 3537.71375*mm,
+      5,  7, 666.749*mm,   716.738*mm,  963.232*mm, 1033.5285*mm,3202.14675*mm, 3537.93025*mm,
+      5,  8, 667.044*mm,   716.721*mm, 1114.304*mm, 1195.228*mm, 3204.37275*mm, 3537.80075*mm,
+      5,  9, 667.337*mm,   716.658*mm, 1266.587*mm, 1358.058*mm, 3206.583*mm, 3537.3265*mm,
+      6,  1, 814.2945*mm,  876.4065*mm,  73.39*mm,    78.836*mm, 3190.9485*mm, 3531.9815*mm,
+      6,  2, 814.66975*mm, 876.72575*mm,220.479*mm,  236.8095*mm,3193.21025*mm, 3533.9055*mm,
+      6,  3, 815.04475*mm, 876.98875*mm,367.857*mm,  395.056*mm, 3195.46975*mm, 3535.4905*mm,
+      6,  4, 815.419*mm,   877.1955*mm, 515.672*mm,  553.7125*mm,3197.725*mm, 3536.7345*mm,
+      6,  5, 815.792*mm,   877.34475*mm,664.0725*mm, 712.916*mm, 3199.97325*mm, 3537.6365*mm,
+      6,  6, 816.1635*mm,  877.4375*mm, 813.2075*mm, 872.807*mm, 3202.21275*mm, 3538.19525*mm,
+      6,  7, 816.5335*mm,  877.473*mm,  963.232*mm, 1033.5285*mm,3204.441*mm, 3538.4105*mm,
+      6,  8, 816.901*mm,   877.452*mm, 1114.304*mm, 1195.228*mm, 3206.656*mm, 3538.28225*mm,
+      6,  9, 817.266*mm,   877.3735*mm,1266.587*mm, 1358.058*mm, 3208.8555*mm, 3537.81025*mm,
+      7,  1, 964.607*mm,  1037.835*mm,   73.39*mm,    78.836*mm, 3193.2965*mm, 3532.116*mm,
+      7,  2, 965.056*mm,  1038.2165*mm, 220.479*mm,  236.8095*mm,3195.54475*mm, 3534.029*mm,
+      7,  3, 965.5045*mm, 1038.5315*mm, 367.857*mm,  395.056*mm, 3197.79075*mm, 3535.6045*mm,
+      7,  4, 965.95225*mm,1038.7785*mm, 515.672*mm,  553.7125*mm,3200.03225*mm, 3536.84125*mm,
+      7,  5, 966.39875*mm,1038.9575*mm, 664.0725*mm, 712.916*mm, 3202.26725*mm, 3537.7375*mm,
+      7,  6, 966.84325*mm,1039.0685*mm, 813.2075*mm, 872.807*mm, 3204.4935*mm, 3538.293*mm,
+      7,  7, 967.28575*mm,1039.111*mm,  963.232*mm, 1033.5285*mm,3206.7085*mm, 3538.507*mm,
+      7,  8, 967.7255*mm, 1039.0855*mm,1114.304*mm, 1195.228*mm, 3208.9105*mm, 3538.379*mm,
+      8,  1,1116.0475*mm, 1200.2185*mm,  73.39*mm,    78.836*mm, 3195.609*mm, 3531.877*mm,
+      8,  2,1116.56925*mm,1200.663*mm,  220.479*mm,  236.8095*mm,3197.8415*mm, 3533.7765*mm,
+      8,  3,1117.09025*mm,1201.02825*mm,367.857*mm,  395.056*mm, 3200.07175*mm, 3535.341*mm,
+      8,  4,1117.6105*mm, 1201.315*mm,  515.672*mm,  553.7125*mm,3202.29775*mm, 3536.569*mm,
+      8,  5,1118.129*mm,  1201.5235*mm, 664.0725*mm, 712.916*mm, 3204.517*mm, 3537.459*mm,
+      8,  6,1118.6455*mm, 1201.6525*mm, 813.2075*mm, 872.807*mm, 3206.7275*mm, 3538.0105*mm,
+      8,  7,1119.15975*mm,1201.702*mm,  963.232*mm, 1033.5285*mm,3208.927*mm, 3538.223*mm,
+      9,  1,1268.7805*mm, 1363.726*mm,   73.39*mm,    78.836*mm, 3197.8865*mm, 3531.273*mm,
+      9,  2,1269.37375*mm,1364.23075*mm,220.479*mm,  236.8095*mm,3200.101*mm, 3533.157*mm,
+      9,  3,1269.9665*mm, 1364.6465*mm, 367.857*mm,  395.056*mm, 3202.3135*mm, 3534.70925*mm,
+      9,  4,1270.558*mm,  1364.973*mm,  515.672*mm,  553.7125*mm,3204.5215*mm, 3535.927*mm,
+      9,  5,1271.14775*mm,1365.2095*mm, 664.0725*mm, 712.916*mm, 3206.723*mm, 3536.81025*mm,
+      9,  6,1271.73525*mm,1365.356*mm,  813.2075*mm, 872.807*mm, 3208.916*mm, 3537.3575*mm,
+      10, 1,1422.9755*mm, 1528.5285*mm,  73.39*mm,    78.836*mm, 3200.1305*mm, 3530.312*mm,
+      10, 2,1423.6395*mm, 1529.093*mm,  220.479*mm,  236.8095*mm,3202.325*mm, 3532.179*mm,
+      10, 3,1424.3025*mm, 1529.558*mm,  367.857*mm,  395.056*mm, 3204.51725*mm, 3533.717*mm
+    </Vector>
+    <!-- Crystal positions inside endcap supercrystal -->
+    <Numeric name="EEnCRSC" value="25"/>
+    <!-- EECRCtrs gives positions of centres of front and rear CR faces in SC coordinates  -->
+    <!-- Note: for historical reasons, "front" and "rear" in this table are reversed with  -->
+    <!--       respect to the EESCStrs definition - the CRs are rotated correctly in the   -->
+    <!--       C++ code which creates the endcap geometry.                                 -->
+    <!-- Column headings for EECRCtrs vector                                                          -->
+    <!-- IX  IY   Xfront           Xrear            Yfront        Yrear          Zfront         Zrear -->
+    <Vector name="EECRCtrs" type="numeric" nEntries="200">
+      1, 1, -59.27878125*mm, -59.96993625*mm, -59.96718*mm, -59.276025*mm, 110.333615*mm,-109.666385*mm,
+      1, 2, -59.27878125*mm, -59.96993625*mm, -30.84865*mm, -28.77521*mm,  110.24371*mm,-109.74761*mm,
+      1, 3, -59.27878125*mm, -59.96993625*mm,  -1.727815*mm,  1.727815*mm, 110.15381*mm,-109.820135*mm,
+      1, 4, -59.27878125*mm, -59.96993625*mm,  27.39645*mm,  32.234145*mm, 110.063915*mm,-109.883985*mm,
+      1, 5, -59.27878125*mm, -59.96993625*mm,  56.525305*mm, 62.744865*mm, 109.974035*mm,-109.93912*mm,
+      2, 1, -28.77730625*mm, -30.85140125*mm, -59.96718*mm, -59.276025*mm, 110.24367*mm,-109.747645*mm,
+      2, 2, -28.77679375*mm, -30.85083625*mm, -30.84865*mm,  -28.77521*mm, 110.153765*mm,-109.82887*mm,
+      2, 3, -28.77633625*mm, -30.85027125*mm,  -1.727815*mm,  1.727815*mm, 110.0638675*mm,-109.9013925*mm,
+      2, 4, -28.77593875*mm, -30.84970375*mm,  27.39645*mm,  32.234145*mm, 109.973975*mm,-109.965235*mm,
+      2, 5, -28.77558875*mm, -30.84913625*mm,  56.525305*mm, 62.744865*mm, 109.884095*mm,-110.0203725*mm,
+      3, 1,   1.72637375*mm,  -1.73056625*mm, -59.96718*mm, -59.276025*mm, 110.153725*mm,-109.8202*mm,
+      3, 2,   1.72739875*mm,  -1.72943625*mm, -30.84865*mm, -28.77521*mm,  110.0638275*mm,-109.901415*mm,
+      3, 3,   1.72830875*mm,  -1.72830875*mm,  -1.727815*mm,  1.727815*mm, 109.973935*mm,-109.973935*mm,
+      3, 4,   1.72911125*mm,  -1.72717375*mm,  27.39645*mm,  32.234145*mm, 109.884045*mm,-110.0377825*mm,
+      3, 5,   1.72980375*mm,  -1.72604625*mm,  56.525305*mm, 62.744865*mm, 109.79417*mm,-110.0929125*mm,
+      4, 1,  32.23335875*mm,  27.39369875*mm, -59.96718*mm, -59.276025*mm, 110.06379*mm,-109.884055*mm,
+      4 ,2,  32.23489125*mm,  27.39539625*mm, -30.84865*mm, -28.77521*mm,  109.9739*mm,-109.965265*mm,
+      4, 3,  32.23625875*mm,  27.39709125*mm,  -1.727815*mm,  1.727815*mm, 109.884015*mm,-110.037785*mm,
+      4, 4,  32.23746375*mm,  27.39878625*mm,  27.39645*mm,  32.234145*mm, 109.7941375*mm,-110.1016175*mm,
+      4, 5,  32.23850375*mm,  27.40048125*mm,  56.525305*mm, 62.744865*mm, 109.70427*mm,-110.15675*mm,
+      5, 1,  62.74475375*mm,  56.52256875*mm, -59.96718*mm, -59.276025*mm, 109.97386*mm,-109.93922*mm,
+      5, 2,  62.74679875*mm,  56.52483125*mm, -30.84865*mm, -28.77521*mm,  109.883985*mm,-110.02042*mm,
+      5, 3,  62.74861875*mm,  56.52709125*mm,  -1.727815*mm,  1.727815*mm, 109.7941125*mm,-110.0929225*mm,
+      5, 4,  62.75022625*mm,  56.52935125*mm,  27.39645*mm,  32.234145*mm, 109.7042475*mm,-110.1567525*mm,
+      5, 5,  62.75161125*mm,  56.53161125*mm,  56.525305*mm, 62.744865*mm, 109.6143925*mm,-110.2118725*mm
+    </Vector>
+    <!-- Z offset for crystals inside alveolus -->
+    <Numeric name="EECryZOff" value="21.0*mm"/>
+  </Algorithm>
+</DDDefinition>
diff --git a/examples/DDCMS/data/eecon.xml b/examples/DDCMS/data/eecon.xml
new file mode 100644
index 000000000..9330d178b
--- /dev/null
+++ b/examples/DDCMS/data/eecon.xml
@@ -0,0 +1,296 @@
+<?xml version="1.0"?>
+<DDDefinition>
+  <ConstantsSection label="eecon.xml" eval="true">
+    <Constant name="SCEnvLength" value="346.60*mm"/>
+    <Constant name="EESpaWidth" value="154*mm"/>
+    <Constant name="EESpaDepth" value=" 68.5*mm"/>
+    <Constant name="EESpAirWidth" value="102*mm"/>
+    <Constant name="EESpAirDepth" value=" 40*mm"/>
+    <Constant name="EESpHVDepth" value=" 16.0*mm"/>
+    <Constant name="EESpCaDepth" value="  8.0*mm"/>
+    <Constant name="EESpaXYOff" value="  1.8*mm"/>
+    <Constant name="EESpAirZOff" value="  3.0*mm"/>
+    <Constant name="EEIRECR"  value="115*mm"/>
+    <Constant name="EEIRECAL" value="200*mm"/>
+    <Constant name="EEIREREG" value="250*mm"/>
+    <Constant name="EEInnerAngle" value="5.9*deg"/>
+    <Constant name="EETanInnerAngle" value="tan([EEInnerAngle])"/>
+    <Constant name="EECosInnerAngle" value="cos([EEInnerAngle])"/>
+    <Constant name="EEOuterAngle" value="20.0*deg"/>
+    <Constant name="EETanOuterAngle" value="tan([EEOuterAngle])"/>
+    <Constant name="EECosOuterAngle" value="cos([EEOuterAngle])"/>
+    <Constant name="EEzMagF" value="-16*mm"/>
+    <!-- ESFrontZ controls the absolute position with no B field
+	 of all the ES and EE. All z's drive off this value      -->
+    <Constant name="ESFrontZ" value=" 2972.3*mm + 4.7*mm"/>
+    <Constant name="ESFrontToEEFrontinZ" value=" 199.7*mm + 0.3*mm"/>
+    <Constant name="ESFrontToESRingFrontinZ" value=" 101.7*mm"/>
+    <Constant name="EEFrontToNeckinZ" value=" 739.5*mm - 5.0*mm"/>
+    <Constant name="EEFrontToBackinZ" value=" 819.0*mm"/>
+    <Constant name="EEzFront" value="[ESFrontZ] + [ESFrontToEEFrontinZ]"/>
+    <Constant name="EEFarZ" value="[EEzFront] + [EEFrontToBackinZ]"/>
+    <Constant name="EEFarZC" value="[EEFarZ]  + [EEzMagF]"/>
+    <Constant name="EBRMin" value="1238.0*mm"/>
+    <Constant name="EBRMax" value="1775.0*mm"/>
+    <Constant name="EEBackPlateThick" value="  60*mm"/>
+    <Constant name="EEBackPlateOR" value="1715*mm"/>
+    <Constant name="EEBackPlateIR" value="353.8*mm"/>
+    <!-- Backplate pipe info -->
+    <Constant name="EEBPPIR" value="  4*mm"/>
+    <Constant name="EEBPPOR" value="  5*mm"/>
+    <Constant name="EEBPPLA" value="1250*mm"/>
+    <Constant name="EEBPPLB" value=" 490*mm"/>
+    <Constant name="EEBPPLC" value=" 160*mm"/>
+    <Constant name="EEdz" value=" 209.00*mm"/>
+    <Constant name="EErMin1" value=" 305.00*mm"/>
+    <Constant name="EErMin2" value=" 350.00*mm"/>
+    <Constant name="EErMax1" value="1561.90*mm"/>
+    <Constant name="EErMax2" value="1715.0*mm"/>
+    <Constant name="EEzOff" value="[EEzFront] + [EEdz]"/>
+    <Constant name="EEzBack" value="[EEzOff]   + [EEdz]"/>
+    <Constant name="EEzBackBack" value="[EEzBack]  + [EEBackPlateThick]"/>
+    <Constant name="EErNeck" value="1690.00*mm"/>
+    <Constant name="EEzNeck" value="[EEzFront] + [EEFrontToNeckinZ]"/>
+    <Constant name="EEzNeckC" value="[EEzNeck] + [EEzMagF]"/>
+    <!-- Preshower support cone -->
+    <Constant name="ESConeZ6" value=" 450.0*mm"/>
+    <Constant name="ESConeZ5" value=" 410.0*mm"/>
+    <Constant name="ESConeZ4" value=" 410.0*mm"/>
+    <!--
+	<Constant name="ESConeZ4"   value=" 370.0*mm"/>
+    -->
+    <Constant name="ESConeZ3" value="-434.0*mm"/>
+    <Constant name="ESConeZ2" value="-434.0*mm"/>
+    <Constant name="ESConeZ1" value="-450.0*mm"/>
+    <Constant name="ESConeI6" value=" 375.0*mm"/>
+    <Constant name="ESConeI5" value=" 371.0*mm"/>
+    <Constant name="ESConeI4" value=" 371.0*mm"/>
+    <!--
+	<Constant name="ESConeI4"   value="[ESConeI3] +
+	[EETanInnerAngle]*( [ESConeZ4] - [ESConeZ3] )"/>
+    -->
+    <Constant name="ESConeI3" value=" 284.0*mm"/>
+    <Constant name="ESConeI2" value=" 260.0*mm"/>
+    <Constant name="ESConeI1" value=" 260.0*mm"/>
+    <!--
+	<Constant name="ESConeO6"   value=" 450.0*mm"/>
+	
+	make cone not as big because it does not fit into inner moderator
+    -->
+    <Constant name="ESConeO6" value="[EEIModI5]"/>
+    <Constant name="ESConeO5" value="[ESConeO6]"/>
+    <Constant name="ESConeO4" value=" 374.0*mm"/>
+    <!--
+	<Constant name="ESConeO4"   value="[ESConeO3] +
+	[EETanInnerAngle]*( [ESConeZ4] - [ESConeZ3] )"/>
+    -->
+    <Constant name="ESConeO3" value=" 287.0*mm"/>
+    <Constant name="ESConeO2" value=" 306.0*mm"/>
+    <Constant name="ESConeO1" value=" 306.0*mm"/>
+    <Constant name="ESPlus" value=" 0.1*mm"/>
+    <Constant name="ESConeO6Plus" value="[ESConeO6] + [ESPlus]"/>
+    <Constant name="ESConeO5Plus" value="[ESConeO5] + [ESPlus]"/>
+    <Constant name="ESConeO4Plus" value="[ESConeO4] + [ESPlus]"/>
+    <Constant name="ESRingZFront" value="[ESFrontZ] + [ESFrontToESRingFrontinZ]"/>
+    <Constant name="ESRingZThick" value="  14*mm"/>
+    <Constant name="ESRingIR" value=" 288*mm"/>
+    <Constant name="ESRingOR" value=" 311*mm"/>
+    <Constant name="EEBConeZ" value="[EEFarZ] - [EEIModZA] + [EEIModZ5]"/>
+    <Constant name="EEBConeIR" value="[EEIModI5]"/>
+    <!-- Global size specifications -->
+    <Constant name="ENCAEnvZES" value="[ESRingZFront] + [ESRingZThick] + [ESConeZ2] - [ESConeZ1]"/>
+    <Constant name="ENCAEnvRNeck" value="[ESConeO3] + [EETanInnerAngle]*( [EEzNeck] - [ENCAEnvZES] ) + 5*mm"/>
+    <Constant name="ENCAEnvRBCone" value="[ESConeO3] + [EETanInnerAngle]*( [EEBConeZ] - [ENCAEnvZES] ) + 5*mm"/>
+    <Constant name="ENCAEnvRFront" value="[ESConeO3] + [EETanInnerAngle]*( [EEzFront] - [ENCAEnvZES] ) +5*mm"/>
+    <Constant name="ENCAEnvRBack" value="[ESConeO3] + [EETanInnerAngle]*( [EEzBack] - [ENCAEnvZES] ) + 5*mm"/>
+    <Constant name="ENCAEnvRFar" value="[ESConeO3] + [EETanInnerAngle]*( [EEFarZ] - [ENCAEnvZES] ) + 5*mm"/>
+    <Constant name="ECALEnvRFar" value="[ENCAEnvRFar] - 5.0*mm"/>
+    <Constant name="ECALEnvRNeck" value="[ESConeO3] + [EETanInnerAngle]*( [EEzNeck] - [ENCAEnvZES] ) - 5.0*mm"/>
+    <Constant name="EREGEnvRBack" value="[ENCAEnvRBack] - 5.0*mm"/>
+    <!-- Inner Moderator -->
+    <Constant name="EEIModDZ" value="151.5*mm"/>
+    <Constant name="EEIModNeckDZ" value="   20*mm"/>
+    <Constant name="EEIModBeltDZ" value="   20*mm"/>
+    <Constant name="EEIModZ1" value="-[EEIModDZ]"/>
+    <Constant name="EEIModZ2" value="[EEIModZ1] + 2*[EEFModDZ]"/>
+    <Constant name="EEIModZ3" value="[EEIModZ2]"/>
+    <Constant name="EEIModZ4" value=" 101.5*mm"/>
+    <Constant name="EEIModZ5" value="[EEIModZ4]"/>
+    <Constant name="EEIModZ6" value="[EEIModZ8] - [EEIModBeltDZ]"/>
+    <Constant name="EEIModZ7" value="[EEIModZ6]"/>
+    <Constant name="EEIModZ8" value="[EEIModZA] - [EEIModNeckDZ]"/>
+    <Constant name="EEIModZ9" value="[EEIModZ8]"/>
+    <Constant name="EEIModZA" value="[EEIModDZ]"/>
+    <Constant name="EEIModI1" value=" 365.0*mm"/>
+    <Constant name="EEIModI2" value="[EEIModI1] + [EETanInnerAngle]*( [EEIModZ2] - [EEIModZ1] )"/>
+    <Constant name="EEIModI3" value="[EEIModI2]"/>
+    <Constant name="EEIModI4" value="[EEIModI1] + [EETanInnerAngle]*( [EEIModZ4] - [EEIModZ1] )"/>
+    <Constant name="EEIModI5" value=" 436.15*mm"/>
+    <Constant name="EEIModI6" value="[EEIModI5]"/>
+    <Constant name="EEIModI7" value="[EEIModI5]"/>
+    <Constant name="EEIModI8" value="[EEIModI5]"/>
+    <Constant name="EEIModI9" value="[EEIModI5]"/>
+    <Constant name="EEIModIA" value="[EEIModI5]"/>
+    <Constant name="EEIModO1" value=" 420.0*mm"/>
+    <Constant name="EEIModO2" value="[EEIModO1]"/>
+    <Constant name="EEIModO3" value="[EEIModI3] + 70*mm*[EECosInnerAngle]"/>
+    <Constant name="EEIModO4" value="[EEIModO3] + [EETanInnerAngle]*( [EEIModZ4] - [EEIModZ3] )"/>
+    <Constant name="EEIModO5" value="[EEIModO4]"/>
+    <Constant name="EEIModO6" value="[EEIModO3] + [EETanInnerAngle]*( [EEIModZ6] - [EEIModZ3] )"/>
+    <Constant name="EEIModO7" value=" 495.0*mm"/>
+    <Constant name="EEIModO8" value="[EEIModO7]"/>
+    <Constant name="EEIModO9" value=" 460.0*mm"/>
+    <Constant name="EEIModOA" value="[EEIModO9]"/>
+    <Constant name="EEzMidIMod" value="[EEFarZ] - [EEIModDZ]"/>
+    <Constant name="EEzBackIMod" value="[EEzMidIMod] + [EEIModDZ]"/>
+    <Constant name="EEzFrontIMod" value="[EEzMidIMod] - [EEIModDZ]"/>
+    <!-- Rear Moderator -->
+    <Constant name="EERModOR" value="1655*mm"/>
+    <Constant name="EERModIR" value="[EEIModO9] + 2*mm"/>
+    <Constant name="EERMCPTh" value="   2*mm"/>
+    <Constant name="EERModTh" value="[EEIModNeckDZ] - [EERMCPTh]"/>
+    <!-- Front Moderator -->
+    <Constant name="EEFModIR" value="[EEIModO1]"/>
+    <Constant name="EEFModDZ" value=" 40*mm"/>
+    <Constant name="EEFModOR1" value="1300*mm"/>
+    <Constant name="EEFModOR2" value="1000*mm"/>
+    <Constant name="EEzFMod" value="[EEzFrontIMod] + [EEFModDZ]"/>
+    <Constant name="EEzBackFMod" value="[EEzFMod] + [EEFModDZ]"/>
+    <!-- Cables -->
+    <Constant name="EECableFdz" value=" 7*mm"/>
+    <Constant name="EECableRdz" value=" 3*mm"/>
+    <!-- Support Ring -->
+    <Constant name="EESRingZ1" value="[EEzBackBack] +  2*[EEBPPOR]"/>
+    <Constant name="EESRingZ2" value="[EESRingZ1] + 18.0*mm"/>
+    <Constant name="EESRingZ3" value="[EESRingZ2]"/>
+    <Constant name="EESRingZ4" value="[EEzNeck] - 40.0*mm - 5.0*mm"/>
+    <Constant name="EESRingZ5" value="[EESRingZ4]"/>
+    <Constant name="EESRingZ6" value="[EEzNeck]"/>
+    <Constant name="EESRingZ7" value="[EESRingZ6]"/>
+    <Constant name="EESRingZ8" value="[EEFarZ]"/>
+    <Constant name="EESRingIR" value="[EERModOR]"/>
+    <Constant name="EESRingOR1" value="[EEBackPlateOR]"/>
+    <Constant name="EESRingOR2" value="[EESRingOR1]"/>
+    <Constant name="EESRingOR3" value="[EESRingIR] + 10*mm"/>
+    <Constant name="EESRingOR4" value="[EESRingOR3]"/>
+    <Constant name="EESRingOR5" value="[EBRMax]"/>
+    <Constant name="EESRingOR6" value="[EESRingOR5]"/>
+    <Constant name="EESRingOR7" value="[EErNeck]"/>
+    <Constant name="EESRingOR8" value="[EESRingOR7]"/>
+    <!-- Front Environmental Screen -->
+    <Constant name="EEfEnvScrTh" value=" 2.0*mm"/>
+    <Constant name="EEiEnvScrTh" value=" 3.0*mm"/>
+    <Constant name="EEsEnvScrTh" value="25.0*mm"/>
+    <Constant name="EEsEnvScrInnTh" value=" 5.0*mm"/>
+    <Constant name="EEsEnvScrOutTh" value=" 2.0*mm"/>
+    <Constant name="EEiEnvScrRT" value="15.0*mm"/>
+    <Constant name="EEfEnvScrZ1" value="-[EEdz]                      "/>
+    <Constant name="EEfEnvScrZ2" value="[EEfEnvScrZ1] + [EEfEnvScrTh]"/>
+    <Constant name="EEfEnvScrZ3" value="[EEfEnvScrZ2]                "/>
+    <Constant name="EEfEnvScrZ4" value="[EEdz]                       "/>
+    <Constant name="EEfEnvScrOR1" value="[EErMax1]"/>
+    <Constant name="EEfEnvScrOR2" value="[EEfEnvScrOR1] + ( [EEfEnvScrZ2] - [EEfEnvScrZ1] )*[EETanOuterAngle]"/>
+    <Constant name="EEfEnvScrOR3" value="[EEfEnvScrOR2]"/>
+    <Constant name="EEfEnvScrOR4" value="[EErMax2]"/>
+    <Constant name="EEfEnvScrIR1" value="316*mm"/>
+    <Constant name="EEfEnvScrIR2" value="[EEfEnvScrIR1]"/>
+    <Constant name="EEfEnvScrIR3" value="[EEfEnvScrOR2] - [EEsEnvScrTh]/[EECosOuterAngle]"/>
+    <Constant name="EEfEnvScrIR4" value="[EEfEnvScrOR4] - [EEsEnvScrTh]/[EECosOuterAngle]"/>
+    <!-- Interior of Conical Environmental Screen -->
+    <Constant name="EEgEnvScrZ1" value="[EEfEnvScrZ1] + [EEiEnvScrRT]"/>
+    <Constant name="EEgEnvScrZ2" value="[EEfEnvScrZ4] - [EEiEnvScrRT]"/>
+    <Constant name="EEgEnvScrIR1" value="[EEfEnvScrIR4]-([EEfEnvScrZ4]-[EEgEnvScrZ1])*[EETanOuterAngle] + [EEsEnvScrInnTh]/[EECosOuterAngle]"/>
+    <Constant name="EEgEnvScrIR2" value="[EEfEnvScrIR4]-([EEfEnvScrZ4]-[EEgEnvScrZ2])*[EETanOuterAngle] + [EEsEnvScrInnTh]/[EECosOuterAngle]"/>
+    <Constant name="EEgEnvScrOR1" value="[EEfEnvScrOR4]-([EEfEnvScrZ4]-[EEgEnvScrZ1])*[EETanOuterAngle] - [EEsEnvScrOutTh]/[EECosOuterAngle]"/>
+    <Constant name="EEgEnvScrOR2" value="[EEfEnvScrOR4]-([EEfEnvScrZ4]-[EEgEnvScrZ2])*[EETanOuterAngle] - [EEsEnvScrOutTh]/[EECosOuterAngle]"/>
+    <!-- Inner Environmental Screen -->
+    <Constant name="EEiEnvScrZ1" value="[EEfEnvScrZ2]"/>
+    <Constant name="EEiEnvScrZ2" value="[EEiEnvScrZ1] + [EEiEnvScrRT]"/>
+    <Constant name="EEiEnvScrZ3" value="[EEiEnvScrZ1] + 112*mm"/>
+    <Constant name="EEiEnvScrZ4" value="[EEfEnvScrZ4] - [EEiEnvScrRT]"/>
+    <Constant name="EEiEnvScrZ5" value="[EEfEnvScrZ4]"/>
+    <Constant name="EEiEnvScrIR1" value="[EEfEnvScrIR2]"/>
+    <Constant name="EEiEnvScrIR2" value="[EEiEnvScrIR1]"/>
+    <Constant name="EEiEnvScrIR3" value="[EEiEnvScrIR2]"/>
+    <Constant name="EEiEnvScrIR4" value="[EEiEnvScrIR3] + ( [EEiEnvScrZ4] - [EEiEnvScrZ3] )*[EETanInnerAngle]"/>
+    <Constant name="EEiEnvScrIR5" value="[EEiEnvScrIR4] + ( [EEiEnvScrZ5] - [EEiEnvScrZ4] )*[EETanInnerAngle]"/>
+    <Constant name="EEiEnvScrOR1" value="[EEiEnvScrIR1] + [EEiEnvScrRT]"/>
+    <Constant name="EEiEnvScrOR2" value="[EEiEnvScrIR2] + [EEiEnvScrTh]"/>
+    <Constant name="EEiEnvScrOR3" value="[EEiEnvScrOR2]                "/>
+    <Constant name="EEiEnvScrOR4" value="[EEiEnvScrIR4] + [EEiEnvScrTh]"/>
+    <Constant name="EEiEnvScrOR5" value="[EEiEnvScrIR4] + [EEiEnvScrRT]"/>
+    <Constant name="EEDeeFrontIR" value="[EEiEnvScrIR5] - 0.3*mm - ( [EEiEnvScrZ5] - [EEiEnvScrZ1] - [EEfEnvScrTh] )*[EETanInnerAngle]"/>
+    <Constant name="EEFrontMidOR" value="[EEfEnvScrOR1] + ( [EEfEnvScrOR4] - [EEfEnvScrOR1] )*( [EEiEnvScrZ3] - [EEfEnvScrZ1] )/( [EEfEnvScrZ4] - [EEfEnvScrZ1] )"/>
+    <Constant name="EEFrontMidZ" value="[EEzFront] + ( [EEiEnvScrZ3] - [EEfEnvScrZ1] ) "/>
+    <!-- Slats for Support of Front Environmental Screen -->
+    <Constant name="EEhSlatThick" value=" 2.0*mm"/>
+    <Constant name="EEhSlatWidth" value="30.0*mm"/>
+    <Constant name="EESlatLength" value="[EEfEnvScrIR3] - [EEiEnvScrOR1] - 10*mm"/>
+    <Constant name="EEvSlatThick" value=" 3.0*mm"/>
+    <Constant name="EEvSlatWidth" value="40.0*mm"/>
+    <!-- Cooling Pipes for Front Environmental Screen -->
+    <Constant name="EEfCoolIR" value="5.0*mm"/>
+    <Constant name="EEfCoolOR" value="6.0*mm"/>
+    <Constant name="EEfCoolZOff" value="-[EEdz] + [EEfEnvScrTh] + [EEfCoolOR]"/>
+    <!-- Cooling blocks and associated piping -->
+    <Constant name="EECBHt" value=" 152*mm"/>
+    <Constant name="EECBWid" value=" 124*mm"/>
+    <Constant name="EECBLen" value=" 535*mm"/>
+    <Constant name="EECQIR" value="[EEIModO6]"/>
+    <Constant name="EECQOR" value="[EERModOR]"/>
+    <Constant name="EECBY1" value=" 25*mm + [EECBWid]/2"/>
+    <Constant name="EECBY2" value=" 30*mm + [EECBY1] + [EECBWid]"/>
+    <Constant name="EECBY3" value=" 30*mm + [EECBY2] + [EECBWid]"/>
+    <Constant name="EECBY4" value=" 30*mm + [EECBY3] + [EECBWid]"/>
+    <Constant name="EECBY5" value=" 30*mm + [EECBY4] + [EECBWid]"/>
+    <Constant name="EECBY6" value=" 18*mm + [EECBY5] + [EECBWid]/2 + [EECBLen]/2"/>
+    <Constant name="EECBY7" value="[EECBY1]"/>
+    <Constant name="EECBY8" value="[EECBY2]"/>
+    <Constant name="EECBY9" value="[EECBY3]"/>
+    <Constant name="EECBY10" value="[EECBY4]"/>
+    <Constant name="EECBY11" value="[EECBY5]"/>
+    <Constant name="EECBY12" value=" 35*mm + [EECBY11] + [EECBWid]"/>
+    <Constant name="EECBY13" value=" 35*mm + [EECBY12] + [EECBWid]"/>
+    <Constant name="EECBY14" value=" 35*mm + [EECBY13] + [EECBWid]"/>
+    <Constant name="EECBY15" value=" 35*mm + [EECBY14] + [EECBWid]"/>
+    <Constant name="EECBY16" value="-20*mm + [EECQIR] + [EECBLen]/2"/>
+    <Constant name="EECBY17" value=" 35*mm + [EECBY16] + [EECBLen]"/>
+    <Constant name="EECBY18" value=" 25*mm + [EECBY16]"/>
+    <Constant name="EECBY19" value=" 35*mm + [EECBY18] + [EECBLen]"/>
+    <Constant name="EECBX1" value="  37*mm + [EECQIR] + [EECBLen]*3/2"/>
+    <Constant name="EECBX2" value=" -35*mm + [EECBX1]"/>
+    <Constant name="EECBX3" value=" -18*mm + [EECBX2]"/>
+    <Constant name="EECBX4" value=" -75*mm + [EECBX3]"/>
+    <Constant name="EECBX5" value=" -20*mm + [EECBX4]"/>
+    <Constant name="EECBX6" value=" -17*mm + [EECBX5] - [EECBLen]/2 + [EECBWid]/2"/>
+    <Constant name="EECBX7" value=" -15*mm + [EECBX1] - [EECBLen]"/>
+    <Constant name="EECBX8" value=" -30*mm + [EECBX7]"/>
+    <Constant name="EECBX9" value=" -38*mm + [EECBX8]"/>
+    <Constant name="EECBX10" value="-138*mm + [EECQIR] + [EECBLen]/2"/>
+    <Constant name="EECBX11" value="[EECBX10]"/>
+    <Constant name="EECBX12" value="[EECBX10]"/>
+    <Constant name="EECBX13" value="[EECBX10]"/>
+    <Constant name="EECBX14" value="[EECBX10]"/>
+    <Constant name="EECBX15" value="[EECBX10]"/>
+    <Constant name="EECBX16" value="37*mm + [EECBWid]*3/2"/>
+    <Constant name="EECBX17" value="[EECBX16]"/>
+    <Constant name="EECBX18" value="5*mm + [EECBWid]/2"/>
+    <Constant name="EECBX19" value="[EECBX18]"/>
+    <Constant name="EECBXPIR" value="4*mm"/>
+    <Constant name="EECBXPOR" value="5*mm"/>
+    <Constant name="EECBzPip" value="[eecon:EECBHt]/2-13*mm"/>
+    <Constant name="EEzCoolQ" value="[EEzBackBack] + 121*mm + [EECBHt]/2. "/>
+  </ConstantsSection>
+  <RotationSection label="eecon.xml">
+    <Rotation name="EERotVFE" phiX=" 0.*deg" thetaX=" 0.*deg" phiY="  0.*deg" thetaY="90.*deg" phiZ="90.*deg" thetaZ="90.*deg"/>
+    <Rotation name="EERotZ90" phiX="90.*deg" thetaX="90.*deg" phiY="180.*deg" thetaY="90.*deg" phiZ=" 0.*deg" thetaZ=" 0.*deg"/>
+    <Rotation name="EEfCR420" phiX="-57*deg" thetaX=" 90*deg" phiY=" 33*deg" thetaY="110*deg" phiZ="33*deg" thetaZ=" 20*deg"/>
+    <Rotation name="EEfCRot45" phiX="  0.*deg" thetaX="180.*deg" phiY=" 45.*deg" thetaY="90.*deg" phiZ="-45.*deg" thetaZ="90.*deg"/>
+    <Rotation name="EEfCRotX" phiX="0.*deg" thetaX="90.*deg" phiY="0.*deg" thetaY="180.*deg" phiZ="90.*deg" thetaZ="90.*deg"/>
+    <Rotation name="EEfCRotY" phiX="0.*deg" thetaX="180.*deg" phiY="90.*deg" thetaY="90.*deg" phiZ="0.*deg" thetaZ="90.*deg"/>
+    <Rotation name="EEfCR100" phiX="0.*deg" thetaX="180.*deg" phiY="123.*deg" thetaY="90.*deg" phiZ="33.*deg" thetaZ="90.*deg"/>
+    <ReflectionRotation name="ReflectionY" phiY="270.*deg" thetaY="90.*deg" phiX=" 0.*deg" thetaX="90.*deg" phiZ="0.*deg" thetaZ="0.*deg"/>
+    <Rotation name="EEOScrR5A" phiX="0.*deg" thetaX=" 90.*deg" phiY=" 90.*deg" thetaY="110.*deg" phiZ="90.*deg" thetaZ=" 20.*deg"/>
+    <Rotation name="EEOScrR5B" phiX="0.*deg" thetaX="110.*deg" phiY=" 90.*deg" thetaY=" 90.*deg" phiZ=" 0.*deg" thetaZ=" 20.*deg"/>
+  </RotationSection>
+</DDDefinition>
diff --git a/examples/DDCMS/data/eehier.xml b/examples/DDCMS/data/eehier.xml
new file mode 100644
index 000000000..4ec4ba084
--- /dev/null
+++ b/examples/DDCMS/data/eehier.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0"?>
+<DDDefinition>
+  <ConstantsSection label="eehier.xml" eval="true">
+    <Constant name="EESCLimsXlo" value="1"/>
+    <Constant name="EESCLimsXhi" value="10"/>
+    <Constant name="EESCLimsYlo" value="1"/>
+    <Constant name="EESCLimsYhi" value="10"/>
+  </ConstantsSection>
+  <SolidSection label="eehier.xml">
+    <!-- Endcap, dee, quadrant, backplate volumes -->
+    <Polycone name="ENCA" startPhi="0*deg" deltaPhi="360*deg">
+      <ZSection z="[eecon:EEzFront]" rMin="[eecon:EEfEnvScrIR1]" rMax="[eecon:EErMax1]"/>
+      <ZSection z="[eecon:EEFrontMidZ]" rMin="[eecon:EEiEnvScrIR3]" rMax="[eecon:EEFrontMidOR]"/>
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EErMax2]"/>
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:ENCAEnvRBCone]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEFarZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+    </Polycone>
+    <Polycone name="EEDee" startPhi="-90*deg" deltaPhi="180*deg">
+      <ZSection z="[eecon:EEzFront]" rMin="[eecon:EEfEnvScrIR1]" rMax="[eecon:EErMax1]"/>
+      <ZSection z="[eecon:EEFrontMidZ]" rMin="[eecon:EEiEnvScrIR3]" rMax="[eecon:EEFrontMidOR]"/>
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EErMax2]"/>
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:ENCAEnvRBCone]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEFarZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+    </Polycone>
+    <Polycone name="EEBackDee" startPhi="-90*deg" deltaPhi="180*deg">
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:ENCAEnvRBCone]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEFarZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+    </Polycone>
+    <Polycone name="EEBackQuad" startPhi="0*deg" deltaPhi="90*deg">
+      <ZSection z="[eecon:EEzBack]" rMin="[eecon:ENCAEnvRBack]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EBRMax]"/>
+      <ZSection z="[eecon:EEzNeck]" rMin="[eecon:ENCAEnvRNeck]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:ENCAEnvRBCone]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEBConeZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+      <ZSection z="[eecon:EEFarZ]" rMin="[eecon:EEBConeIR]" rMax="[eecon:EErNeck]"/>
+    </Polycone>
+    <Polycone name="EEFrontDee" startPhi="-90*deg" deltaPhi="180*deg">
+      <ZSection z="[eecon:EEfEnvScrZ1]" rMin="[eecon:EEfEnvScrIR1]" rMax="[eecon:EErMax1]"/>
+      <ZSection z="[eecon:EEiEnvScrZ3]" rMin="[eecon:EEiEnvScrIR3]" rMax="[eecon:EEFrontMidOR]"/>
+      <ZSection z="[eecon:EEiEnvScrZ5]" rMin="[eecon:EEiEnvScrIR5]" rMax="[eecon:EErMax2]"/>
+    </Polycone>
+    <Polycone name="EEFrontQuad" startPhi="0*deg" deltaPhi="90*deg">
+      <ZSection z="[eecon:EEfEnvScrZ1]" rMin="[eecon:EEfEnvScrIR1]" rMax="[eecon:EErMax1]"/>
+      <ZSection z="[eecon:EEiEnvScrZ3]" rMin="[eecon:EEiEnvScrIR3]" rMax="[eecon:EEFrontMidOR]"/>
+      <ZSection z="[eecon:EEiEnvScrZ5]" rMin="[eecon:EEiEnvScrIR5]" rMax="[eecon:EEfEnvScrOR4]"/>
+    </Polycone>
+  </SolidSection>
+  <LogicalPartSection label="eehier.xml">
+    <LogicalPart name="ENCA" category="unspecified">
+      <rSolid name="ENCA"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+    <LogicalPart name="EEDee" category="unspecified">
+      <rSolid name="EEDee"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+    <LogicalPart name="EEFrontDee" category="unspecified">
+      <rSolid name="EEFrontDee"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+    <LogicalPart name="EEBackDee" category="unspecified">
+      <rSolid name="EEBackDee"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+    <LogicalPart name="EEFrontQuad" category="unspecified">
+      <rSolid name="EEFrontQuad"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+    <LogicalPart name="EEBackQuad" category="unspecified">
+      <rSolid name="EEBackQuad"/>
+      <rMaterial name="materials:E_Air"/>
+    </LogicalPart>
+  </LogicalPartSection>
+  <PosPartSection label="eehier.xml">
+    <!-- Full endcap, dees, front and back quadrants -->
+    <PosPart copyNumber="1">
+      <rParent name="eregalgo:EREG"/>
+      <rChild name="eehier:ENCA"/>
+    </PosPart>
+    <PosPart copyNumber="1">
+      <rParent name="eehier:ENCA"/>
+      <rChild name="eehier:EEDee"/>
+    </PosPart>
+    <PosPart copyNumber="2">
+      <rParent name="eehier:ENCA"/>
+      <rChild name="eehier:EEDee"/>
+      <rRotation name="rotations:R180"/>
+    </PosPart>
+    <PosPart copyNumber="1">
+      <rParent name="eehier:EEDee"/>
+      <rChild name="eehier:EEFrontDee"/>
+      <Translation x="0*mm" y="0*mm" z="[eecon:EEzFront] + [eecon:EEdz]"/>
+    </PosPart>
+    <PosPart copyNumber="1">
+      <rParent name="eehier:EEDee"/>
+      <rChild name="eehier:EEBackDee"/>
+    </PosPart>
+    <PosPart copyNumber="1">
+      <rParent name="eehier:EEFrontDee"/>
+      <rChild name="eehier:EEFrontQuad"/>
+    </PosPart>
+    <PosPart copyNumber="2">
+      <rParent name="eehier:EEFrontDee"/>
+      <rChild name="eehier:EEFrontQuad"/>
+      <rReflectionRotation name="eecon:ReflectionY"/>
+    </PosPart>
+    <PosPart copyNumber="1">
+      <rParent name="eehier:EEBackDee"/>
+      <rChild name="eehier:EEBackQuad"/>
+    </PosPart>
+    <PosPart copyNumber="2">
+      <rParent name="eehier:EEBackDee"/>
+      <rChild name="eehier:EEBackQuad"/>
+      <rReflectionRotation name="eecon:ReflectionY"/>
+    </PosPart>
+  </PosPartSection>
+</DDDefinition>
diff --git a/examples/DDCMS/data/materials.xml b/examples/DDCMS/data/materials.xml
index e0e4e2f27..52b5653c3 100644
--- a/examples/DDCMS/data/materials.xml
+++ b/examples/DDCMS/data/materials.xml
@@ -107,6 +107,14 @@
   <ElementaryMaterial name="Uranium"      density="18.95*g/cm3 " symbol=" " atomicWeight="238.03*g/mole"   atomicNumber="92"/>
 
 
+  <CompositeMaterial name="Water" density="1*g/cm3" symbol=" " method="mixture by weight">
+   <MaterialFraction fraction="0.11190083">
+    <rMaterial name="materials:Hydrogen"/>
+   </MaterialFraction>
+   <MaterialFraction fraction="0.88809917">
+    <rMaterial name="materials:Oxygen"/>
+   </MaterialFraction>
+  </CompositeMaterial>
   <CompositeMaterial name="FPix_Thermflow" density="0.7625*g/cm3" symbol=" " method="mixture by weight">
    <MaterialFraction fraction="0.3787448">
     <rMaterial name="materials:Silicon"/>
@@ -1239,15 +1247,15 @@
   <!--Phase1 BPIX micro-twisted pairs boundle material as defined by L. Caminada-->
   <CompositeMaterial name="micro_twisted_power_cable" density="3.639*g/cm3" symbol=" " method="mixture by weight">
     <MaterialFraction fraction="0.36933">
-      <rMaterial name="trackermaterial:T_Copper"/>
+      <rMaterial name="materials:Copper"/>
     </MaterialFraction>
     <MaterialFraction fraction="0.63067">
-      <rMaterial name="trackermaterial:T_Aluminium"/>
+      <rMaterial name="materials:Aluminium"/>
     </MaterialFraction>
   </CompositeMaterial>
   <CompositeMaterial name="micro_twisted_boundle_1" density="2.93382*g/cm3" symbol=" " method="mixture by weight"> <!--for L1-->
    <MaterialFraction fraction="0.04631">
-    <rMaterial name="trackermaterial:T_Copper"/>
+    <rMaterial name="materials:Copper"/>
    </MaterialFraction>
    <MaterialFraction fraction="0.95369">
     <rMaterial name="materials:micro_twisted_power_cable"/>
@@ -1255,7 +1263,7 @@
   </CompositeMaterial>
   <CompositeMaterial name="micro_twisted_boundle_2" density="2.91735*g/cm3" symbol=" " method="mixture by weight"> <!--for L2,3,4-->
    <MaterialFraction fraction="0.04964">
-    <rMaterial name="trackermaterial:T_Copper"/>
+    <rMaterial name="materials:Copper"/>
    </MaterialFraction>
    <MaterialFraction fraction="0.95036">
     <rMaterial name="materials:micro_twisted_power_cable"/>
@@ -4254,14 +4262,6 @@
     <rMaterial name="materials:Tungsten"/>
    </MaterialFraction>
   </CompositeMaterial>
-  <CompositeMaterial name="Water" density="1*g/cm3" symbol=" " method="mixture by weight">
-   <MaterialFraction fraction="0.11190083">
-    <rMaterial name="materials:Hydrogen"/>
-   </MaterialFraction>
-   <MaterialFraction fraction="0.88809917">
-    <rMaterial name="materials:Oxygen"/>
-   </MaterialFraction>
-  </CompositeMaterial>
   <CompositeMaterial name="Wood" density="500*mg/cm3" symbol=" " method="mixture by weight">
    <MaterialFraction fraction="0.11684213">
     <rMaterial name="materials:Hydrogen"/>
diff --git a/examples/DDCMS/data/rotations.xml b/examples/DDCMS/data/rotations.xml
new file mode 100644
index 000000000..4aecc870b
--- /dev/null
+++ b/examples/DDCMS/data/rotations.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<DDDefinition xmlns="http://www.cern.ch/cms/DDL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cern.ch/cms/DDL ../../../DetectorDescription/Schema/DDLSchema.xsd">
+        <RotationSection label="rotations.xml">
+                <Rotation name="000D" thetaX="90*deg" phiX="0*deg" thetaY="90*deg" phiY="90*deg" thetaZ="0*deg" phiZ="0*deg"/>
+                <Rotation name="180D" thetaX="90*deg" phiX="180*deg" thetaY="90*deg" phiY="90*deg" thetaZ="180*deg" phiZ="0*deg"/>
+                <Rotation name="180X" thetaX="90*deg" phiX="0*deg" thetaY="90*deg" phiY="-90*deg" thetaZ="180*deg" phiZ="0*deg"/>
+                <Rotation name="90XD" thetaX="90*deg" phiX="90*deg" thetaY="0*deg" phiY="0*deg" thetaZ="90*deg" phiZ="0*deg"/>
+                <Rotation name="R180" thetaX="90*deg" phiX="180*deg" thetaY="90*deg" phiY="-90*deg" thetaZ="0*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="180R" thetaX="90*deg" phiX="0*deg" thetaY="90*deg" phiY="90*deg" thetaZ="180*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="180RYZ" thetaX="90*deg" phiX="180*deg" thetaY="90*deg" phiY="90*deg" thetaZ="0*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="R005R" thetaX="90*deg" phiX="175*deg" thetaY="90*deg" phiY="85*deg" thetaZ="0*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="R010R" thetaX="90*deg" phiX="170*deg" thetaY="90*deg" phiY="80*deg" thetaZ="0*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="R025R" thetaX="90*deg" phiX="155*deg" thetaY="90*deg" phiY="65*deg" thetaZ="0*deg" phiZ="0*deg"/>
+		<ReflectionRotation name="ReflectionY" phiY="270.*deg" thetaY="90.*deg" phiX=" 0.*deg" thetaX="90.*deg" phiZ="0.*deg" thetaZ="0.*deg"/>
+
+        </RotationSection>
+
+</DDDefinition>
diff --git a/examples/DDCMS/include/DDCMS/DDCMS.h b/examples/DDCMS/include/DDCMS/DDCMS.h
index 79bd5c23e..725b0f846 100644
--- a/examples/DDCMS/include/DDCMS/DDCMS.h
+++ b/examples/DDCMS/include/DDCMS/DDCMS.h
@@ -128,19 +128,19 @@ namespace dd4hep {
       std::set<std::string>              disabledAlgs;
       std::vector<std::string>           namespaces;
       bool geo_inited = false;
-
-      // Debug flags
-      bool debug_includes     = false;
-      bool debug_constants    = false;
-      bool debug_materials    = false;
-      bool debug_rotations    = false;
-      bool debug_shapes       = false;
-      bool debug_volumes      = false;
-      bool debug_placements   = false;
-      bool debug_namespaces   = false;
-      bool debug_visattr      = false;
-      bool debug_algorithms   = false;
-
+      struct _debug  {
+	// Debug flags
+	bool includes     = false;
+	bool constants    = false;
+	bool materials    = false;
+	bool rotations    = false;
+	bool shapes       = false;
+	bool volumes      = false;
+	bool placements   = false;
+	bool namespaces   = false;
+	bool visattr      = false;
+	bool algorithms   = false;
+      } debug;
     public:
       ParsingContext(Detector* det) : description(det) { namespaces.push_back(""); }
       ~ParsingContext() = default;
diff --git a/examples/DDCMS/include/DDCMS/DDCMSTags.h b/examples/DDCMS/include/DDCMS/DDCMSTags.h
index 1342ec401..b3ce55e2b 100644
--- a/examples/DDCMS/include/DDCMS/DDCMSTags.h
+++ b/examples/DDCMS/include/DDCMS/DDCMSTags.h
@@ -47,6 +47,8 @@ namespace dd4hep {
     UNICODE(MaterialFraction);
 
     UNICODE(RotationSection);
+    UNICODE(ReflectionRotation);
+    UNICODE(rReflectionRotation);
     UNICODE(Rotation);
     UNICODE(rRotation);
     UNICODE(thetaX);
diff --git a/examples/DDCMS/scripts/CMSEcalSim.py b/examples/DDCMS/scripts/CMSEcalSim.py
new file mode 100644
index 000000000..e83eca786
--- /dev/null
+++ b/examples/DDCMS/scripts/CMSEcalSim.py
@@ -0,0 +1,107 @@
+from __future__ import absolute_import, unicode_literals
+import os
+import sys
+import time
+import DDG4
+from DDG4 import OutputLevel as Output
+from g4units import GeV, MeV
+import logging
+from ddsix.moves import range
+
+logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.INFO)
+logger = logging.getLogger(__name__)
+
+#
+#
+"""
+
+   dd4hep example setup using the python configuration
+
+   \author  M.Frank
+   \version 1.0
+
+"""
+
+
+def run():
+  kernel = DDG4.Kernel()
+  install_dir = os.environ['DD4hepExamplesINSTALL']
+  kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG)
+  kernel.setOutputLevel(str('Gun'), Output.INFO)
+  kernel.detectorDescription().fromXML(str("file:" + install_dir + "/examples/DDCMS/data/dd4hep-ecal.xml"))
+  kernel.NumEvents = 5
+  geant4 = DDG4.Geant4(kernel, tracker='Geant4TrackerCombineAction')
+  geant4.printDetectors()
+
+  batch = False
+  test = False
+  vis = False
+  ui = None
+  for i in range(len(sys.argv)):
+    arg = sys.argv[i].lower()
+    if arg == 'batch':
+      batch = True
+    elif arg[:4] == '-vis':
+      vis = True
+    elif arg == 'test':
+      test = True
+    elif arg == 'numevents':
+      kernel.NumEvents = int(sys.argv[i + 1])
+  if batch or test:
+    geant4.setupCshUI(ui=None, vis=None)
+    kernel.UI = 'UI'
+  else:
+    ui = geant4.setupCshUI(vis=vis)
+
+  # Configure field
+  geant4.setupTrackingField(prt=True)
+  # Configure I/O
+  geant4.setupROOTOutput('RootOutput', 'CMSEcal_' + time.strftime('%Y-%m-%d_%H-%M'), mc_truth=True)
+  # Setup particle gun
+  generators = []
+  generators.append(geant4.setupGun("GunPi-", particle='pi-', energy=300 * GeV,
+                                    multiplicity=1, Standalone=False, register=False, Mask=1))
+  if not test:
+    generators.append(geant4.setupGun("GunE+", particle='e+', energy=100 * GeV,
+                                      multiplicity=1, Standalone=False, register=False, Mask=8))
+  geant4.buildInputStage(generators)
+  # Now setup all tracking detectors
+  for i in geant4.description.detectors():
+    o = DDG4.DetElement(i.second.ptr())
+    sd = geant4.description.sensitiveDetector(o.name())
+    if sd.isValid():
+      type = geant4.sensitive_types[sd.type()]
+      logger.info('CMSTracker: Configure subdetector %-24s of type %s' % (o.name(), type,))
+      geant4.setupDetector(o.name(), type)
+
+  # And handle the simulation particles.
+  part = DDG4.GeneratorAction(kernel, "Geant4ParticleHandler/ParticleHandler")
+  kernel.generatorAction().adopt(part)
+  part.SaveProcesses = ['conv', 'Decay']
+  part.MinimalKineticEnergy = 1 * MeV
+  part.OutputLevel = 5  # generator_output_level
+  part.enableUI()
+
+  # Now build the physics list:
+  phys = kernel.physicsList()
+  phys.extends = 'QGSP_BERT'
+  phys.enableUI()
+  #
+  #
+  if ui and vis:
+    cmds = []
+    cmds.append('/control/verbose 2')
+    cmds.append('/run/initialize')
+    cmds.append('/vis/open OGL')
+    cmds.append('/vis/verbose errors')
+    cmds.append('/vis/drawVolume')
+    cmds.append('/vis/viewer/set/viewpointThetaPhi 55. 45.')
+    cmds.append('/vis/scene/add/axes 0 0 0 3 m')
+    ui.Commands = cmds
+#  
+  # and run
+  geant4.execute()
+
+
+if __name__ == "__main__":
+  run()
diff --git a/examples/DDCMS/src/DDCMS.cpp b/examples/DDCMS/src/DDCMS.cpp
index cf46e03f3..dbed15840 100644
--- a/examples/DDCMS/src/DDCMS.cpp
+++ b/examples/DDCMS/src/DDCMS.cpp
@@ -62,7 +62,7 @@ Namespace::Namespace(ParsingContext* ctx, xml_h element) : context(ctx)  {
     if ( !context->namespaces.empty() )  {
       name = context->namespaces.back();
     }
-    printout(context->debug_namespaces ? ALWAYS : DEBUG,
+    printout(context->debug.namespaces ? ALWAYS : DEBUG,
              "DDCMS","+++ Current namespace is now: %s",name.c_str());
     return;
   }
@@ -77,7 +77,7 @@ Namespace::Namespace(ParsingContext* ctx, xml_h element) : context(ctx)  {
   if ( !name.empty() ) name += NAMESPACE_SEP;
   context->namespaces.push_back(name);
   pop = true;
-  printout(context->debug_namespaces ? ALWAYS : DEBUG,
+  printout(context->debug.namespaces ? ALWAYS : DEBUG,
            "DDCMS","+++ Current namespace is now: %s",name.c_str());
   return;
 }
@@ -98,7 +98,7 @@ Namespace::Namespace(ParsingContext& ctx, xml_h element, bool ) : context(&ctx)
   if ( !name.empty() ) name += NAMESPACE_SEP;
   context->namespaces.push_back(name);
   pop = true;
-  printout(context->debug_namespaces ? ALWAYS : DEBUG,
+  printout(context->debug.namespaces ? ALWAYS : DEBUG,
            "DDCMS","+++ Current namespace is now: %s",name.c_str());
   return;
 }
@@ -117,7 +117,7 @@ Namespace::Namespace(ParsingContext& ctx) : context(&ctx)  {
 Namespace::~Namespace()   {
   if ( pop )  {
     context->namespaces.pop_back();
-    printout(context->debug_namespaces ? ALWAYS : DEBUG,
+    printout(context->debug.namespaces ? ALWAYS : DEBUG,
              "DDCMS","+++ Current namespace is now: %s",context->ns().c_str());
   }
 }
@@ -169,7 +169,7 @@ void Namespace::addConstant(const string& nam, const string& val, const string&
 void Namespace::addConstantNS(const string& nam, const string& val, const string& typ)  const {
   const string& v = val;
   const string& n = nam;
-  printout(context->debug_constants ? ALWAYS : DEBUG,
+  printout(context->debug.constants ? ALWAYS : DEBUG,
            "DDCMS","+++ Add constant object: %-40s = %s [type:%s]",
            n.c_str(), v.c_str(), typ.c_str());
   _toDictionary(n, v, typ);
@@ -185,6 +185,11 @@ Material Namespace::material(const string& nam)  const   {
 /// Add rotation matrix to current namespace
 void Namespace::addRotation(const string& nam,const Rotation3D& rot)  const  {
   string n = prepend(nam);
+  Position x, y, z;
+  rot.GetComponents(x,y,z);
+  double det = (x.Cross(y)).Dot(z);
+  printout(DEBUG, "DDCMS","+++ Add rotation:  %s  %s-handed",
+           nam.c_str(), (det>=0) ? "RIGHT" : "LEFT");
   context->rotations[n] = rot;
 }
 
@@ -218,7 +223,7 @@ Volume Namespace::addVolumeNS(Volume vol)  const  {
   Material mat = vol.material();
   vol->SetName(nam.c_str());
   context->volumes[nam] = vol;
-  printout(context->debug_volumes ? ALWAYS : DEBUG, "DDCMS",
+  printout(context->debug.volumes ? ALWAYS : DEBUG, "DDCMS",
            "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s",
            vol.name(), sol.name(), sol.type(), mat.name());
   return vol;
@@ -231,7 +236,7 @@ Volume Namespace::addVolume(Volume vol)  const  {
   Material mat = vol.material();
   vol->SetName(nam.c_str());
   context->volumes[nam] = vol;
-  printout(context->debug_volumes ? ALWAYS : DEBUG, "DDCMS",
+  printout(context->debug.volumes ? ALWAYS : DEBUG, "DDCMS",
            "+++ Add volume:%-38s Solid:%-26s[%-16s] Material:%s",
            vol.name(), sol.name(), sol.type(), mat.name());
   return vol;
@@ -258,7 +263,7 @@ Volume Namespace::volume(const string& nam, bool exc)  const   {
 
 /// Add solid to current namespace as fully indicated by the name
 Solid Namespace::addSolidNS(const string& nam,Solid sol)  const   {
-  printout(context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+++ Add shape of type %s : %s",sol->IsA()->GetName(), nam.c_str());
   context->shapes[nam] = sol.setName(nam);
   return sol;
diff --git a/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp b/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp
index 4c3c4ce83..933697cd2 100644
--- a/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp
+++ b/examples/DDCMS/src/plugins/DDDefinitions2Objects.cpp
@@ -222,6 +222,7 @@ template <> void Converter<materialsection>::operator()(xml_h element) const   {
 template <> void Converter<rotationsection>::operator()(xml_h element) const   {
   Namespace _ns(_param<ParsingContext>(), element);
   xml_coll_t(element, _CMU(Rotation)).for_each(Converter<rotation>(description,_ns.context,optional));
+  xml_coll_t(element, _CMU(ReflectionRotation)).for_each(Converter<rotation>(description,_ns.context,optional));
 }
 
 template <> void Converter<pospartsection>::operator()(xml_h element) const   {
@@ -335,7 +336,7 @@ template <> void Converter<constant>::operator()(xml_h element) const  {
     idx = val.find('[',idx);
   }
   //MSF NS while ( (idx=val.find(':')) != string::npos ) val[idx]=NAMESPACE_SEP;
-  printout(_ns.context->debug_constants ? ALWAYS : DEBUG,
+  printout(_ns.context->debug.constants ? ALWAYS : DEBUG,
            "Constant","Unresolved: %s -> %s",real.c_str(),val.c_str());
   res->allConst[real] = val;
   res->originalConst[real] = val;
@@ -350,22 +351,22 @@ template <> void Converter<constant>::operator()(xml_h element) const  {
  *       showDaughters="false"
  *       visible="true"/>
  */
-template <> void Converter<vis>::operator()(xml_h e) const {
+template <> void Converter<vis>::operator()(xml_h e) const   {
   Namespace _ns(_param<ParsingContext>());
   VisAttr attr(e.attr<string>(_U(name)));
-  float red   = e.hasAttr(_U(r)) ? e.attr<float>(_U(r)) : 1.0f;
-  float green = e.hasAttr(_U(g)) ? e.attr<float>(_U(g)) : 1.0f;
-  float blue  = e.hasAttr(_U(b)) ? e.attr<float>(_U(b)) : 1.0f;
+  xml_dim_t dim(e);
+  float alpha = dim.alpha(1.0);
+  float red   = dim.r(1.0);
+  float green = dim.g(1.0);
+  float blue  = dim.b(1.0);
 
-  printout(_ns.context->debug_visattr ? ALWAYS : DEBUG, "Compact",
+  printout(_ns.context->debug.visattr ? ALWAYS : DEBUG, "Compact",
            "++ Converting VisAttr  structure: %-16s. R=%.3f G=%.3f B=%.3f",
            attr.name(), red, green, blue);
-  attr.setColor(red, green, blue);
-  if (e.hasAttr(_U(alpha)))
-    attr.setAlpha(e.attr<float>(_U(alpha)));
-  if (e.hasAttr(_U(visible)))
+  attr.setColor(alpha, red, green, blue);
+  if ( e.hasAttr(_U(visible)) )
     attr.setVisible(e.attr<bool>(_U(visible)));
-  if (e.hasAttr(_U(lineStyle))) {
+  if ( e.hasAttr(_U(lineStyle)) ) {
     string ls = e.attr<string>(_U(lineStyle));
     if (ls == "unbroken")
       attr.setLineStyle(VisAttr::SOLID);
@@ -402,7 +403,7 @@ template <> void Converter<elementaryelement>::operator()(xml_h element) const
   TGeoElement*      elt1 = tab->FindElement(xmat.nameStr().c_str());
   TGeoElement*      elt2 = tab->FindElement(nam.c_str());
   static bool first = true;
-  if ( first && _ns.context->debug_materials )   {
+  if ( first && _ns.context->debug.materials )   {
     first = false;
     printout(ALWAYS, "DDCMS"," +++ Units: gram:   %7.3f ",dd4hep::g);
     printout(ALWAYS, "DDCMS"," +++ Units: cm3:    %7.3f ",dd4hep::cm3);
@@ -415,7 +416,7 @@ template <> void Converter<elementaryelement>::operator()(xml_h element) const
     double atomicNumber = xmat.attr<double>(_CMU(atomicNumber));
     double atomicWeight = xmat.attr<double>(_CMU(atomicWeight))/(dd4hep::g/dd4hep::mole);
     int n = int(atomicNumber);
-    printout(_ns.context->debug_materials ? ALWAYS : DEBUG, "DDCMS",
+    printout(_ns.context->debug.materials ? ALWAYS : DEBUG, "DDCMS",
              "+++ Converting element  %-32s  atomic number: %3d  weight: %8.3f   [g/mol]",
              ('"'+nam+'"').c_str(), n, atomicWeight);
     elt1 = new TGeoElement(nam.c_str(),"CMS element", n, atomicWeight);
@@ -439,7 +440,7 @@ template <> void Converter<elementarymaterial>::operator()(xml_h element) const
     TGeoMixture*      mix = new TGeoMixture(nam.c_str(), 1, density);
     TGeoElement*      elt = tab->FindElement(nam.c_str());
 
-    printout(_ns.context->debug_materials ? ALWAYS : DEBUG, "DDCMS",
+    printout(_ns.context->debug.materials ? ALWAYS : DEBUG, "DDCMS",
              "+++ Converting material %-48s  Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]",
              ('"'+nam+'"').c_str(), density, mix->GetDensity());
 
@@ -511,7 +512,7 @@ template <> void Converter<compositematerial>::operator()(xml_h element) const
 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,12,0)
     mix->ComputeDerivedQuantities();
 #endif
-    printout(_ns.context->debug_materials ? ALWAYS : DEBUG, "DDCMS",
+    printout(_ns.context->debug.materials ? ALWAYS : DEBUG, "DDCMS",
              "++  Converting material %-48s  Density: %8.3f [g/cm3] ROOT: %8.3f [g/cm3]",
              ('"'+nam+'"').c_str(), density, mix->GetDensity());
     
@@ -530,20 +531,33 @@ template <> void Converter<compositematerial>::operator()(xml_h element) const
 /// Converter for <Rotation/> tags
 template <> void Converter<rotation>::operator()(xml_h element) const  {
   ParsingContext* ctx = _param<ParsingContext>();
-  Namespace _ns(ctx);
-  xml_dim_t xrot(element);
-  string    nam    = xrot.nameStr();
-  double    thetaX = xrot.hasAttr(_CMU(thetaX)) ? _ns.attr<double>(xrot,_CMU(thetaX)) : 0e0;
-  double    phiX   = xrot.hasAttr(_CMU(phiX))   ? _ns.attr<double>(xrot,_CMU(phiX))   : 0e0;
-  double    thetaY = xrot.hasAttr(_CMU(thetaY)) ? _ns.attr<double>(xrot,_CMU(thetaY)) : 0e0;
-  double    phiY   = xrot.hasAttr(_CMU(phiY))   ? _ns.attr<double>(xrot,_CMU(phiY))   : 0e0;
-  double    thetaZ = xrot.hasAttr(_CMU(thetaZ)) ? _ns.attr<double>(xrot,_CMU(thetaZ)) : 0e0;
-  double    phiZ   = xrot.hasAttr(_CMU(phiZ))   ? _ns.attr<double>(xrot,_CMU(phiZ))   : 0e0;
+  Namespace  _ns(ctx);
+  xml_dim_t  xrot(element);
+  string     nam    = xrot.nameStr();
+  PrintLevel lvl = ctx->debug.rotations ? ALWAYS : DEBUG;
+  double     thetaX = xrot.hasAttr(_CMU(thetaX)) ? _ns.attr<double>(xrot,_CMU(thetaX)) : 0e0;
+  double     phiX   = xrot.hasAttr(_CMU(phiX))   ? _ns.attr<double>(xrot,_CMU(phiX))   : 0e0;
+  double     thetaY = xrot.hasAttr(_CMU(thetaY)) ? _ns.attr<double>(xrot,_CMU(thetaY)) : 0e0;
+  double     phiY   = xrot.hasAttr(_CMU(phiY))   ? _ns.attr<double>(xrot,_CMU(phiY))   : 0e0;
+  double     thetaZ = xrot.hasAttr(_CMU(thetaZ)) ? _ns.attr<double>(xrot,_CMU(thetaZ)) : 0e0;
+  double     phiZ   = xrot.hasAttr(_CMU(phiZ))   ? _ns.attr<double>(xrot,_CMU(phiZ))   : 0e0;
   Rotation3D rot = make_rotation3D(thetaX, phiX, thetaY, phiY, thetaZ, phiZ);
-  printout(ctx->debug_rotations ? ALWAYS : DEBUG,
-           "DDCMS","+++ Adding rotation: %-32s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
-           _ns.prepend(nam).c_str(),thetaX,phiX,thetaY,phiY,thetaZ,phiZ);
+
   _ns.addRotation(nam, rot);
+  if ( isActivePrintLevel(lvl) )   {
+    double det;
+    Position x, y, z;
+    stringstream str;
+    rot.GetComponents(x,y,z);
+    det = (x.Cross(y)).Dot(z);
+    str << "+++ rotation: " << nam
+	<< " " << ((det>=0) ? "RIGHT" : "LEFT") << "-handed "
+	<< scientific << setprecision(2) << setw(9) << x << y << z << rot;
+    printout(lvl, "DDCMS",
+	     "+++ Adding rotation: %-18s: (theta/phi)[rad] X: %6.3f %6.3f Y: %6.3f %6.3f Z: %6.3f %6.3f",
+	     _ns.prepend(nam).c_str(),thetaX,phiX,thetaY,phiY,thetaZ,phiZ);
+    printout(lvl, "DDCMS", str.str().c_str());
+  }
 }
 
 /// Converter for <Logicalpart/> tags
@@ -562,7 +576,8 @@ template <> void Converter<transform3d>::operator()(xml_h element) const {
   xml_dim_t   e(element);
   xml_dim_t   translation = e.child(_CMU(Translation),false);
   xml_dim_t   rotation    = e.child(_CMU(Rotation),false);
-  xml_dim_t   refRotation = e.child(_CMU(rRotation),false);
+  xml_dim_t   rRotation   = e.child(_CMU(rRotation),false);
+  xml_dim_t   rReflectionRotation = e.child(_CMU(rReflectionRotation),false);
   Position    pos;
   Rotation3D  rot;
 
@@ -578,33 +593,54 @@ template <> void Converter<transform3d>::operator()(xml_h element) const {
     double z = _ns.attr<double>(rotation,_U(z));
     rot = RotationZYX(z,y,x);
   }
-  else if ( refRotation.ptr() )   {
-    rot = _ns.rotation(refRotation.nameStr());
+  else if ( rRotation.ptr() )   {
+    rot = _ns.rotation(rRotation.nameStr());
+  }
+  else if ( rReflectionRotation.ptr() )   {
+    rot = _ns.rotation(rReflectionRotation.nameStr());
   }
   *tr = Transform3D(rot,pos);
 }
 
 /// Converter for <PosPart/> tags
 template <> void Converter<pospart>::operator()(xml_h element) const {
-  Namespace _ns(_param<ParsingContext>());
-  xml_dim_t   e(element);
-  int         copy        = e.attr<int>(_CMU(copyNumber));
-  string      parent_nam  = _ns.attr<string>(e.child(_CMU(rParent)),_U(name));
-  string      child_nam   = _ns.attr<string>(e.child(_CMU(rChild)),_U(name));
-  Volume      parent      = _ns.volume(parent_nam);
-  Volume      child       = _ns.volume(child_nam, false);
-  
-  printout(_ns.context->debug_placements ? ALWAYS : DEBUG, "DDCMS",
-           "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
+  Namespace  _ns(_param<ParsingContext>());
+  xml_dim_t  e(element);
+  int        copy        = e.attr<int>(_CMU(copyNumber));
+  string     parent_nam  = _ns.attr<string>(e.child(_CMU(rParent)),_U(name));
+  string     child_nam   = _ns.attr<string>(e.child(_CMU(rChild)),_U(name));
+  Volume     parent      = _ns.volume(parent_nam);
+  Volume     child       = _ns.volume(child_nam, false);
+  PrintLevel lvl         = _ns.context->debug.placements ? ALWAYS : DEBUG;
+  bool       dbg         = isActivePrintLevel(lvl);
+
+  if ( dbg )   {
+    printout(lvl, "DDCMS", "+++ %s Parent: %-24s [%s] Child: %-32s [%s] copy:%d",
            e.tag().c_str(),
            parent_nam.c_str(), parent.isValid() ? "VALID" : "INVALID",
            child_nam.c_str(),  child.isValid()  ? "VALID" : "INVALID",
            copy);
+  }
   PlacedVolume pv;
   if ( child.isValid() )   {
     Transform3D trafo;
     Converter<transform3d>(description,param,&trafo)(element);
-    pv = parent.placeVolume(child,copy,trafo);
+    pv = parent.placeVolume(child, copy, trafo);
+    if ( dbg )   {
+      stringstream str;
+      Rotation3D   r;
+      Position     p, x, y, z;
+      xml_dim_t    rRotation = e.child(_CMU(rRotation),false);
+      xml_dim_t    rReflectionRotation = e.child(_CMU(rReflectionRotation),false);
+      trafo.GetDecomposition(r, p);
+      r.GetComponents(x,y,z);
+      double det = (x.Cross(y)).Dot(z);
+      str << "+++ Rotation: " << (const char*)((det >=0) ? "RIGHT" : "LEFT") << "-handed  ";
+      if ( rRotation.ptr() ) str << rRotation.nameStr();
+      if ( rReflectionRotation.ptr() ) str << rReflectionRotation.nameStr();
+      str << "  Pos: " << p << "  Rotation:" << r;
+      printout(lvl, "DDCMS", str.str().c_str());
+    }
   }
   if ( !pv.isValid() )   {
     printout(ERROR,"DDCMS","+++ Placement FAILED! Parent:%s Child:%s Valid:%s",
@@ -619,7 +655,7 @@ static void convert_boolean(ParsingContext* ctx, xml_h element)   {
   string      nam = e.nameStr();
   Solid       solids[2];
   Solid       boolean;
-  int cnt=0;
+  int         cnt = 0;
 
   if ( e.hasChild(_CMU(rSolid)) )  {   // Old version
     for(xml_coll_t c(element, _CMU(rSolid)); cnt<2 && c; ++c, ++cnt)
@@ -632,7 +668,7 @@ static void convert_boolean(ParsingContext* ctx, xml_h element)   {
   if ( cnt != 2 )   {
     except("DDCMS","+++ Failed to create boolean solid %s. Found only %d parts.",nam.c_str(), cnt);
   }
-  printout(_ns.context->debug_placements ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.placements ? ALWAYS : DEBUG, "DDCMS",
            "+++ BooleanSolid: %s Left: %-32s Right: %-32s",
            nam.c_str(), solids[0]->GetName(), solids[1]->GetName());
 
@@ -680,7 +716,7 @@ template <> void Converter<polycone>::operator()(xml_h element) const {
     rmax.push_back(_ns.attr<double>(zplane,_CMU(rMax)));
     z.push_back(_ns.attr<double>(zplane,_U(z)));
   }
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Polycone: startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]  %4ld z-planes",
            startPhi, deltaPhi, z.size());
   _ns.addSolid(nam, Polycone(startPhi,deltaPhi,rmin,rmax,z));
@@ -703,7 +739,7 @@ template <> void Converter<extrudedpolygon>::operator()(xml_h element) const  {
     pt_x.push_back(_ns.attr<double>(pt,_U(x)));
     pt_y.push_back(_ns.attr<double>(pt,_U(y)));
   }
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   ExtrudedPolygon: %4ld points %4ld zxy sections",
            pt_x.size(), sec_z.size());
   _ns.addSolid(nam,ExtrudedPolygon(pt_x,pt_y,sec_z,sec_x,sec_y,sec_scale));
@@ -729,7 +765,7 @@ template <> void Converter<polyhedra>::operator()(xml_h element) const {
     rmax.push_back(_ns.attr<double>(zplane,_CMU(rMax)));
     z.push_back(_ns.attr<double>(zplane,_U(z)));
   }
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Polyhedra:startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]  %4d sides %4ld z-planes",
            startPhi, deltaPhi, numSide, z.size());
   _ns.addSolid(nam, Polyhedra(numSide,startPhi,deltaPhi,z,rmin,rmax));
@@ -746,7 +782,7 @@ template <> void Converter<sphere>::operator()(xml_h element) const {
   double deltaPhi = _ns.attr<double>(e,_CMU(deltaPhi));
   double startTheta = _ns.attr<double>(e,_CMU(startTheta));
   double deltaTheta = _ns.attr<double>(e,_CMU(deltaTheta));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Sphere:   r_inner=%8.3f [cm] r_outer=%8.3f [cm]"
            " startPhi=%8.3f [rad] deltaPhi=%8.3f startTheta=%8.3f delteTheta=%8.3f [rad]",
            rinner, router, startPhi, deltaPhi, startTheta, deltaTheta);
@@ -781,7 +817,7 @@ template <> void Converter<torus>::operator()(xml_h element) const   {
   double router   = _ns.attr<double>(e,_CMU(outerRadius));
   double startPhi = _ns.attr<double>(e,_CMU(startPhi));
   double deltaPhi = _ns.attr<double>(e,_CMU(deltaPhi));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Torus:    r=%8.3f [cm] r_inner=%8.3f [cm] r_outer=%8.3f [cm]"
            " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]",
            r, rinner, router, startPhi, deltaPhi);
@@ -800,7 +836,7 @@ template <> void Converter<pseudotrap>::operator()(xml_h element) const {
   double dz       = _ns.attr<double>(e,_U(dz));
   double r        = _ns.attr<double>(e,_U(radius));
   bool   atMinusZ = _ns.attr<bool>  (e,_CMU(atMinusZ));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Pseudotrap:  dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2=%.3f dy2=%.3f radius:%.3f atMinusZ:%s",
            dz, dx1, dy1, dx2, dy2, r, yes_no(atMinusZ));
   _ns.addSolid(nam, PseudoTrap(dx1, dx2, dy1, dy2, dz, r, atMinusZ));
@@ -822,7 +858,7 @@ template <> void Converter<trapezoid>::operator()(xml_h element) const {
   double h2       = _ns.attr<double>(e,_CMU(h2));
   double phi      = _ns.attr<double>(e,_U(phi),0.0);
   double theta    = _ns.attr<double>(e,_U(theta),0.0);
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Trapezoid:  dz=%8.3f [cm] alp1:%.3f bl1=%.3f tl1=%.3f alp2=%.3f bl2=%.3f tl2=%.3f h2=%.3f phi=%.3f theta=%.3f",
            dz, alp1, bl1, tl1, h1, alp2, bl2, tl2, h2, phi, theta);
   _ns.addSolid(nam, Trap(dz, theta, phi, h1, bl1, tl1, alp1, h2, bl2, tl2, alp2));
@@ -838,7 +874,7 @@ template <> void Converter<trd1>::operator()(xml_h element) const {
   double dx2      = _ns.attr<double>(e,_CMU(dx2),0.0);
   double dy2      = _ns.attr<double>(e,_CMU(dy2),0.0);
   double dz       = _ns.attr<double>(e,_CMU(dz));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Trd1:       dz=%8.3f [cm] dx1:%.3f dy1:%.3f dx2:%.3f dy2:%.3f",
            dz, dx1, dy1, dx2, dy2);
   _ns.addSolid(nam, Trapezoid(dx1, dx2, dy1, dy2, dz));
@@ -854,7 +890,7 @@ template <> void Converter<tubs>::operator()(xml_h element) const {
   double rmax     = _ns.attr<double>(e,_CMU(rMax));
   double startPhi = _ns.attr<double>(e,_CMU(startPhi),0.0);
   double deltaPhi = _ns.attr<double>(e,_CMU(deltaPhi),2*M_PI);
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Tubs:     dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
            " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]", dz, rmin, rmax, startPhi, deltaPhi);
   _ns.addSolid(nam, Tube(rmin,rmax,dz,startPhi,deltaPhi));
@@ -876,7 +912,7 @@ template <> void Converter<cuttubs>::operator()(xml_h element) const {
   double tx       = _ns.attr<double>(e,_CMU(tx));
   double ty       = _ns.attr<double>(e,_CMU(ty));
   double tz       = _ns.attr<double>(e,_CMU(tz));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   CutTube:  dz=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
            " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad]...",
            dz, rmin, rmax, startPhi, deltaPhi);
@@ -896,7 +932,7 @@ template <> void Converter<trunctubs>::operator()(xml_h element) const {
   double cutAtStart = _ns.attr<double>(e,_CMU(cutAtStart));
   double cutAtDelta = _ns.attr<double>(e,_CMU(cutAtDelta));
   bool   cutInside  = _ns.attr<bool>(e,_CMU(cutInside));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   TruncTube:zHalf=%8.3f [cm] rmin=%8.3f [cm] rmax=%8.3f [cm]"
            " startPhi=%8.3f [rad] deltaPhi=%8.3f [rad] atStart=%8.3f [cm] atDelta=%8.3f [cm] inside:%s",
            zhalf, rmin, rmax, startPhi, deltaPhi, cutAtStart, cutAtDelta, yes_no(cutInside));
@@ -911,7 +947,7 @@ template <> void Converter<ellipticaltube>::operator()(xml_h element) const   {
   double dx  = _ns.attr<double>(e,_CMU(xSemiAxis));
   double dy  = _ns.attr<double>(e,_CMU(ySemiAxis));
   double dz  = _ns.attr<double>(e,_CMU(zHeight));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   EllipticalTube xSemiAxis=%8.3f [cm] ySemiAxis=%8.3f [cm] zHeight=%8.3f [cm]",dx,dy,dz);
   _ns.addSolid(nam, EllipticalTube(dx,dy,dz));
 }
@@ -929,7 +965,7 @@ template <> void Converter<cone>::operator()(xml_h element) const {
   double startPhi = _ns.attr<double>(e,_CMU(startPhi));
   double deltaPhi = _ns.attr<double>(e,_CMU(deltaPhi));
   double phi2     = startPhi + deltaPhi;
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Cone:     dz=%8.3f [cm]"
            " rmin1=%8.3f [cm] rmax1=%8.3f [cm]"
            " rmin2=%8.3f [cm] rmax2=%8.3f [cm]"
@@ -943,7 +979,7 @@ template <> void Converter<shapeless>::operator()(xml_h element) const {
   Namespace _ns(_param<ParsingContext>());
   xml_dim_t e(element);
   string nam = e.nameStr();
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Shapeless: THIS ONE CAN ONLY BE USED AT THE VOLUME LEVEL -> Assembly%s", nam.c_str());
   _ns.addSolid(nam, Box(1,1,1));
 }
@@ -956,7 +992,7 @@ template <> void Converter<box>::operator()(xml_h element) const {
   double dx  = _ns.attr<double>(e,_CMU(dx));
   double dy  = _ns.attr<double>(e,_CMU(dy));
   double dz  = _ns.attr<double>(e,_CMU(dz));
-  printout(_ns.context->debug_shapes ? ALWAYS : DEBUG, "DDCMS",
+  printout(_ns.context->debug.shapes ? ALWAYS : DEBUG, "DDCMS",
            "+   Box:      dx=%8.3f [cm] dy=%8.3f [cm] dz=%8.3f [cm]", dx, dy, dz);
   _ns.addSolid(nam, Box(dx,dy,dz));
 }
@@ -982,7 +1018,7 @@ template <> void Converter<include_load>::operator()(xml_h element) const   {
   else
     doc = xml::DocumentHandler().load(element, element.attr_value(_U(ref)));
   fname = xml::DocumentHandler::system_path(doc.root());
-  printout(_param<ParsingContext>()->debug_includes ? ALWAYS : DEBUG,
+  printout(_param<ParsingContext>()->debug.includes ? ALWAYS : DEBUG,
            "DDCMS","+++ Processing the CMS detector description %s",fname.Data());
   _option<resolve>()->includes.push_back(doc);
 }
@@ -991,7 +1027,7 @@ template <> void Converter<include_load>::operator()(xml_h element) const   {
 template <> void Converter<include_unload>::operator()(xml_h element) const   {
   string fname = xml::DocumentHandler::system_path(element);
   xml::DocumentHolder(xml_elt_t(element).document()).assign(0);
-  printout(_param<ParsingContext>()->debug_includes ? ALWAYS : DEBUG,
+  printout(_param<ParsingContext>()->debug.includes ? ALWAYS : DEBUG,
            "DDCMS","+++ Finished processing %s",fname.c_str());
 }
 
@@ -1017,12 +1053,12 @@ template <> void Converter<algorithm>::operator()(xml_h element) const  {
 
     // SensitiveDetector and Segmentation currently are undefined. Let's keep it like this
     // until we found something better.....
-    printout(_ns.context->debug_algorithms ? ALWAYS : DEBUG,
+    printout(_ns.context->debug.algorithms ? ALWAYS : DEBUG,
              "DDCMS","+++ Start executing algorithm %s....",type.c_str());
     LogDebug context(e.nameStr(),true);
     long ret = PluginService::Create<long>(type, &description, _ns.context, &element, &sd);
     if ( ret == 1 )    {
-      printout(_ns.context->debug_algorithms ? ALWAYS : DEBUG,
+      printout(_ns.context->debug.algorithms ? ALWAYS : DEBUG,
                "DDCMS", "+++ Executed algorithm: %08lX = %s", ret, name.c_str());
       return;      
     }
@@ -1061,17 +1097,17 @@ template <> void Converter<algorithm>::operator()(xml_h element) const  {
 
 template <> void Converter<debug>::operator()(xml_h dbg) const {
   Namespace _ns(_param<ParsingContext>());
-  if ( dbg.hasChild(_CMU(debug_visattr))    ) _ns.context->debug_visattr    = true;
-  if ( dbg.hasChild(_CMU(debug_constants))  ) _ns.context->debug_constants  = true;
-  if ( dbg.hasChild(_CMU(debug_materials))  ) _ns.context->debug_materials  = true;
-  if ( dbg.hasChild(_CMU(debug_rotations))  ) _ns.context->debug_rotations  = true;
-  if ( dbg.hasChild(_CMU(debug_shapes))     ) _ns.context->debug_shapes     = true;
-  if ( dbg.hasChild(_CMU(debug_volumes))    ) _ns.context->debug_volumes    = true;
-  if ( dbg.hasChild(_CMU(debug_placements)) ) _ns.context->debug_placements = true;
-  if ( dbg.hasChild(_CMU(debug_namespaces)) ) _ns.context->debug_namespaces = true;
-  if ( dbg.hasChild(_CMU(debug_includes))   ) _ns.context->debug_includes   = true;
-  if ( dbg.hasChild(_CMU(debug_algorithms)) ) _ns.context->debug_algorithms = true;
-  LogDebug::setDebugAlgorithms(_ns.context->debug_algorithms);
+  if ( dbg.hasChild(_CMU(debug_visattr))    ) _ns.context->debug.visattr    = true;
+  if ( dbg.hasChild(_CMU(debug_constants))  ) _ns.context->debug.constants  = true;
+  if ( dbg.hasChild(_CMU(debug_materials))  ) _ns.context->debug.materials  = true;
+  if ( dbg.hasChild(_CMU(debug_rotations))  ) _ns.context->debug.rotations  = true;
+  if ( dbg.hasChild(_CMU(debug_shapes))     ) _ns.context->debug.shapes     = true;
+  if ( dbg.hasChild(_CMU(debug_volumes))    ) _ns.context->debug.volumes    = true;
+  if ( dbg.hasChild(_CMU(debug_placements)) ) _ns.context->debug.placements = true;
+  if ( dbg.hasChild(_CMU(debug_namespaces)) ) _ns.context->debug.namespaces = true;
+  if ( dbg.hasChild(_CMU(debug_includes))   ) _ns.context->debug.includes   = true;
+  if ( dbg.hasChild(_CMU(debug_algorithms)) ) _ns.context->debug.algorithms = true;
+  LogDebug::setDebugAlgorithms(_ns.context->debug.algorithms);
 }
 
 template <> void Converter<resolve>::operator()(xml_h /* element */) const {
@@ -1080,7 +1116,7 @@ template <> void Converter<resolve>::operator()(xml_h /* element */) const {
   Namespace       _ns(ctx);
   int count = 0;
 
-  printout(ctx->debug_constants ? ALWAYS : DEBUG,
+  printout(ctx->debug.constants ? ALWAYS : DEBUG,
            "DDCMS","+++ RESOLVING %ld unknown constants.....",res->unresolvedConst.size());
   while ( !res->unresolvedConst.empty() )   {
     for(auto i=res->unresolvedConst.begin(); i!=res->unresolvedConst.end(); ++i )   {
@@ -1104,7 +1140,7 @@ template <> void Converter<resolve>::operator()(xml_h /* element */) const {
           while ( (idx=v.find("+-")) != string::npos )
             v.replace(idx,2,"-");
         }
-        printout(ctx->debug_constants ? ALWAYS : DEBUG,
+        printout(ctx->debug.constants ? ALWAYS : DEBUG,
                  "DDCMS","+++ [%06ld] ----------  %-40s = %s",
                  res->unresolvedConst.size()-1,n.c_str(),res->originalConst[n].c_str());
         _ns.addConstantNS(n, v, "number");
@@ -1126,7 +1162,7 @@ template <> void Converter<resolve>::operator()(xml_h /* element */) const {
 
 template <> void Converter<print_xml_doc>::operator()(xml_h element) const {
   string fname = xml::DocumentHandler::system_path(element);
-  printout(_param<ParsingContext>()->debug_includes ? ALWAYS : DEBUG,
+  printout(_param<ParsingContext>()->debug.includes ? ALWAYS : DEBUG,
            "DDCMS","+++ Processing data from: %s",fname.c_str());
 }
 
diff --git a/examples/DDCMS/src/plugins/DDEcalEndcapAlgo.cpp b/examples/DDCMS/src/plugins/DDEcalEndcapAlgo.cpp
index ead7e5675..d1abcecec 100644
--- a/examples/DDCMS/src/plugins/DDEcalEndcapAlgo.cpp
+++ b/examples/DDCMS/src/plugins/DDEcalEndcapAlgo.cpp
@@ -325,7 +325,7 @@ void DDEcalEndcapTrap::print() {
   //  Print SC coordinates for debugging
   //
   for (int ic = 1; ic <= 8; ic++) {
-    /* DDTranslation cc = */ cornerPos(ic);
+    /* DDTranslation cc = */  cornerPos(ic);
   }
 }
 
-- 
GitLab