From a475fee5392fd0b788d213ec11aa384bb3021016 Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Thu, 19 Sep 2013 19:06:45 +0000
Subject: [PATCH] Improve exceptions on expression handling

---
 DDCore/include/DD4hep/Objects.h        |  6 ++--
 DDCore/include/DD4hep/Shapes.h         |  6 ++--
 DDCore/include/DD4hep/Volumes.h        |  2 +-
 DDCore/include/XML/UnicodeValues.h     |  2 ++
 DDCore/include/XML/XMLElements.h       | 22 +++++++++++---
 DDCore/src/Detector.cpp                | 42 +++++++++++++-------------
 DDCore/src/Handle.cpp                  |  5 +++
 DDCore/src/IDDescriptor.cpp            | 10 +++---
 DDCore/src/LCDDImp.cpp                 | 23 ++++++--------
 DDCore/src/LCDDImp.h                   |  2 +-
 DDCore/src/MatrixHelpers.cpp           |  8 ++---
 DDCore/src/MatrixHelpers.h             |  2 +-
 DDCore/src/Objects.cpp                 | 12 ++++----
 DDCore/src/Printout.cpp                |  2 +-
 DDCore/src/Readout.cpp                 |  4 +--
 DDCore/src/Segementations.cpp          |  8 ++---
 DDCore/src/Shapes.cpp                  | 22 +++++++-------
 DDCore/src/VolumeManager.cpp           | 30 +++++++++---------
 DDCore/src/Volumes.cpp                 | 22 +++++++-------
 DDCore/src/XML/DocumentHandler.cpp     | 20 ++++++------
 DDCore/src/XML/XMLElements.cpp         | 17 +++++++++++
 DDCore/src/plugins/Compact2Objects.cpp |  5 ++-
 DDCore/src/plugins/StandardPlugins.cpp |  2 +-
 23 files changed, 156 insertions(+), 118 deletions(-)

diff --git a/DDCore/include/DD4hep/Objects.h b/DDCore/include/DD4hep/Objects.h
index c711533c1..30172b325 100644
--- a/DDCore/include/DD4hep/Objects.h
+++ b/DDCore/include/DD4hep/Objects.h
@@ -176,7 +176,7 @@ namespace DD4hep {
     template <class V> V RotateY(const V& v, double a) { return ROOT::Math::VectorUtil::RotateY(v,a); }
     template <class V> V RotateZ(const V& v, double a) { return ROOT::Math::VectorUtil::RotateZ(v,a); }
   
-    typedef ROOT::Math::RotationZYX   Rotation;
+    typedef ROOT::Math::RotationZYX   RotationZYX;
     typedef ROOT::Math::RotationZ     RotationZ;
     typedef ROOT::Math::RotationY     RotationY;
     typedef ROOT::Math::RotationX     RotationX;
@@ -316,9 +316,9 @@ namespace DD4hep {
       /// Align the PhysicalNode (translation only)
       int align(const Position& pos, bool check=false, double overlap=0.001);
       /// Align the PhysicalNode (rotation only)
-      int align(const Rotation& rot, bool check=false, double overlap=0.001);
+      int align(const RotationZYX& rot, bool check=false, double overlap=0.001);
       /// Align the PhysicalNode (translation + rotation)
-      int align(const Position& pos, const Rotation& rot, bool check=false, double overlap=0.001);
+      int align(const Position& pos, const RotationZYX& rot, bool check=false, double overlap=0.001);
     };
 
 
diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h
index dac315634..2f748e69a 100644
--- a/DDCore/include/DD4hep/Shapes.h
+++ b/DDCore/include/DD4hep/Shapes.h
@@ -507,7 +507,7 @@ namespace DD4hep {
       /// Constructor to be used when creating a new object. Rotation is identity-rotation!
       SubtractionSolid(const Solid& shape1, const Solid& shape2, const Position& pos);
       /// Constructor to be used when creating a new object
-      SubtractionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot);
+      SubtractionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot);
       /// Constructor to be used when creating a new object
       SubtractionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot);
    };
@@ -529,7 +529,7 @@ namespace DD4hep {
       /// Constructor to be used when creating a new object. Rotation is identity-rotation!
       UnionSolid(const Solid& shape1, const Solid& shape2, const Position& pos);
       /// Constructor to be used when creating a new object
-      UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot);
+      UnionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot);
       /// Constructor to be used when creating a new object
       UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot);
     };
@@ -551,7 +551,7 @@ namespace DD4hep {
       /// Constructor to be used when creating a new object. Rotation is identity-rotation!
       IntersectionSolid(const Solid& shape1, const Solid& shape2, const Position& pos);
       /// Constructor to be used when creating a new object
-      IntersectionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot);
+      IntersectionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot);
       /// Constructor to be used when creating a new object
       IntersectionSolid(const Solid& shape1, const Solid& shape2, const Rotation3D& rot);
     };
diff --git a/DDCore/include/DD4hep/Volumes.h b/DDCore/include/DD4hep/Volumes.h
index 30ef66546..613dafb39 100644
--- a/DDCore/include/DD4hep/Volumes.h
+++ b/DDCore/include/DD4hep/Volumes.h
@@ -154,7 +154,7 @@ namespace DD4hep {
       /// Place un-rotated daughter volume at the given position.
       PlacedVolume placeVolume(const Volume& vol, const Position& pos)  const;
       /// Place rotated daughter volume. The position is automatically the identity position
-      PlacedVolume placeVolume(const Volume& vol, const Rotation& rot)  const;
+      PlacedVolume placeVolume(const Volume& vol, const RotationZYX& rot)  const;
       /// Place rotated daughter volume. The position is automatically the identity position
       PlacedVolume placeVolume(const Volume& vol, const Rotation3D& rot)  const;
      
diff --git a/DDCore/include/XML/UnicodeValues.h b/DDCore/include/XML/UnicodeValues.h
index 56ad58519..becb3e0cc 100644
--- a/DDCore/include/XML/UnicodeValues.h
+++ b/DDCore/include/XML/UnicodeValues.h
@@ -203,6 +203,7 @@ namespace DD4hep   { namespace XML  {
   UNICODE(material);
   UNICODE(materialref);
   UNICODE(materials);
+  UNICODE(member);
   UNICODE(MeV);
   UNICODE(mm);
   UNICODE(module);
@@ -320,6 +321,7 @@ namespace DD4hep   { namespace XML  {
   UNICODE(sensitive_detector);
   UNICODE(sensitive_detectors);
   UNICODE(sensor);
+  UNICODE(sequence);
   UNICODE(setup);
   UNICODE(signed);
   UNICODE(solidref);
diff --git a/DDCore/include/XML/XMLElements.h b/DDCore/include/XML/XMLElements.h
index f5ab817f7..9514f4d30 100644
--- a/DDCore/include/XML/XMLElements.h
+++ b/DDCore/include/XML/XMLElements.h
@@ -473,15 +473,27 @@ namespace DD4hep {
       void operator--(int)  const;
       /// Access to current element
       Elt_t current() const { return m_node; }
+      /// Helper function to throw an exception
+      void throw_loop_exception(const std::exception& e) const;
       /// Loop processor using function object
       template <class T> void for_each(T oper) const  {
-        for(const Collection_t& c=*this; c; ++c)
-          oper(*this);
+	try  {
+	  for(const Collection_t& c=*this; c; ++c)
+	    oper(*this);
+	}
+	catch(const std::exception& e)  {
+	  throw_loop_exception(e);
+	}
       }
       /// Loop processor using function object
-      template <class T> void for_each(const XmlChar* tag, T oper) const  {
-        for(const Collection_t& c=*this; c; ++c)
-          Collection_t(c.m_node, tag).for_each(oper);
+      template <class T> void for_each(const XmlChar* tag_name, T oper) const  {
+	try {
+	  for(const Collection_t& c=*this; c; ++c)
+	    Collection_t(c.m_node, tag_name).for_each(oper);
+	}
+	catch(const std::exception& e)  {
+	  throw_loop_exception(e);
+	}
       }
     };
 
diff --git a/DDCore/src/Detector.cpp b/DDCore/src/Detector.cpp
index 111b15856..c4495c249 100644
--- a/DDCore/src/Detector.cpp
+++ b/DDCore/src/Detector.cpp
@@ -83,7 +83,7 @@ static TGeoHMatrix* create_trafo(const vector<TGeoNode*>& det_nodes)   {
   }
   vector<TGeoNode*> nodes;
   if ( !collect_detector_nodes(det_nodes,nodes) ) {
-    throw runtime_error("DetElement cannot connect "+string(det_nodes[0]->GetName())+
+    throw runtime_error("DD4hep: DetElement cannot connect "+string(det_nodes[0]->GetName())+
 			" to child "+string(det_nodes[1]->GetName()));
   }
   TGeoHMatrix* mat = new TGeoHMatrix(*gGeoIdentity);
@@ -191,7 +191,7 @@ DetElement::Object* DetElement::Object::clone(int new_id, int flag)  const  {
       child._data().parent = det;
     }
     else {
-      throw runtime_error("DetElement::copy: Element "+string(child.name())+" is already present [Double-Insert]");
+      throw runtime_error("DD4hep: DetElement::copy: Element "+string(child.name())+" is already present [Double-Insert]");
     }
   }
   return obj;
@@ -244,7 +244,7 @@ TGeoMatrix* DetElement::Object::referenceTransformation() {
       DetElement me(this->asRef());
       DetElement elt = _par(ref,me,nodes);
       if ( !elt.isValid() )   {
-	throw runtime_error("referenceTransformation: No path from "+string(self.name())+
+	throw runtime_error("DD4hep: referenceTransformation: No path from "+string(self.name())+
 			    " to reference element "+string(ref.name())+" present!");
       }
       TGeoMatrix* m = create_trafo(nodes);
@@ -293,7 +293,7 @@ void* DetElement::i_addExtension(void* ptr, const type_info& info, void* (*copy)
     //cout << "Extension[" << name() << "]:" << ptr << " " << info.name() << endl;
     return o.extensions[&info] = ptr;
   }
-  throw runtime_error("addExtension: The object "+string(name())+
+  throw runtime_error("DD4hep: addExtension: The object "+string(name())+
 		      " already has an extension of type:"+string(info.name())+".");
 }
 
@@ -304,7 +304,7 @@ void* DetElement::i_extension(const type_info& info)   const {
   if ( j != o.extensions.end() )   {
     return (*j).second;
   }
-  throw runtime_error("extension: The object "+string(name())+
+  throw runtime_error("DD4hep: extension: The object "+string(name())+
 		      " has no extension of type:"+string(info.name())+".");
 }
  
@@ -317,7 +317,7 @@ string DetElement::placementPath() const {
       vector<TGeoNode*> nodes, path;
       _top(*this,nodes);
       if ( !collect_detector_nodes(nodes,path) ) {
-	throw runtime_error("DetElement cannot determine placement path of "+string(name()));
+	throw runtime_error("DD4hep: DetElement cannot determine placement path of "+string(name()));
       }
       path.push_back(gGeoManager->GetTopNode());
       for(vector<TGeoNode*>::const_reverse_iterator i=path.rbegin(); i!=path.rend(); ++i)
@@ -340,7 +340,7 @@ DetElement& DetElement::setType(const string& typ)   {
     m_element->SetTitle(typ.c_str());
     return *this;
   }
-  throw runtime_error("DetElement::setType: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::setType: Self is not defined [Invalid Handle]");
 }
 
 string DetElement::path() const   {
@@ -402,7 +402,7 @@ DetElement DetElement::parent() const {
 
 void DetElement::check(bool condition, const string& msg) const  {
   if ( condition )  {
-    throw runtime_error(msg);
+    throw runtime_error("DD4hep: "+msg);
   }
 }
 
@@ -413,9 +413,9 @@ DetElement& DetElement::add(DetElement sdet)  {
       sdet.object<Object>().parent = *this;
       return *this;
     }
-    throw runtime_error("DetElement::add: Element "+string(sdet.name())+" is already present [Double-Insert]");
+    throw runtime_error("DD4hep: DetElement::add: Element "+string(sdet.name())+" is already present [Double-Insert]");
   }
-  throw runtime_error("DetElement::add: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::add: Self is not defined [Invalid Handle]");
 }
 
 DetElement DetElement::clone(const string& new_name)  const  {
@@ -423,7 +423,7 @@ DetElement DetElement::clone(const string& new_name)  const  {
     Object& o = object<Object>();
     return DetElement(o.clone(o.id,COPY_NONE), new_name, o.GetTitle());
   }
-  throw runtime_error("DetElement::clone: Self is not defined - clone failed! [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::clone: Self is not defined - clone failed! [Invalid Handle]");
 }
 
 DetElement DetElement::clone(const string& new_name, int new_id)  const  {
@@ -431,7 +431,7 @@ DetElement DetElement::clone(const string& new_name, int new_id)  const  {
     Object& o = object<Object>();
     return DetElement(o.clone(new_id, COPY_NONE), new_name, o.GetTitle());
   }
-  throw runtime_error("DetElement::clone: Self is not defined - clone failed! [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::clone: Self is not defined - clone failed! [Invalid Handle]");
 }
 
 /// Access to the physical volume of this detector element
@@ -454,9 +454,9 @@ DetElement& DetElement::setPlacement(const PlacedVolume& placement) {
       o.volume    = placement.volume();
       return *this;
     }
-    throw runtime_error("DetElement::setPlacement: Placement is not defined [Invalid Handle]");
+    throw runtime_error("DD4hep: DetElement::setPlacement: Placement is not defined [Invalid Handle]");
   }
-  throw runtime_error("DetElement::setPlacement: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::setPlacement: Self is not defined [Invalid Handle]");
 }
 
 /// Access to the logical volume of the placements (all daughters have the same!)
@@ -464,7 +464,7 @@ Volume DetElement::volume() const   {
   if ( isValid() )  {
     return object<Object>().volume;
   }
-  throw runtime_error("DetElement::volume: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::volume: Self is not defined [Invalid Handle]");
 }
 
 DetElement& DetElement::setVisAttributes(const LCDD& lcdd, const string& name, const Volume& volume)  {
@@ -472,7 +472,7 @@ DetElement& DetElement::setVisAttributes(const LCDD& lcdd, const string& name, c
     volume.setVisAttributes(lcdd,name);
     return *this;
   }
-  throw runtime_error("DetElement::setVisAttributes: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::setVisAttributes: Self is not defined [Invalid Handle]");
 }
 
 DetElement& DetElement::setRegion(const LCDD& lcdd, const string& name, const Volume& volume)  {
@@ -482,7 +482,7 @@ DetElement& DetElement::setRegion(const LCDD& lcdd, const string& name, const Vo
     }
     return *this;
   }
-  throw runtime_error("DetElement::setRegion: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::setRegion: Self is not defined [Invalid Handle]");
 }
 
 DetElement& DetElement::setLimitSet(const LCDD& lcdd, const string& name, const Volume& volume)  {
@@ -492,7 +492,7 @@ DetElement& DetElement::setLimitSet(const LCDD& lcdd, const string& name, const
     }
     return *this;
   }
-  throw runtime_error("DetElement::setLimitSet: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: DetElement::setLimitSet: Self is not defined [Invalid Handle]");
 }
 
 DetElement& DetElement::setAttributes(const LCDD& lcdd, const Volume& volume,
@@ -615,7 +615,7 @@ SensitiveDetector& SensitiveDetector::setType(const string& typ)   {
     m_element->SetTitle(typ.c_str());
     return *this;
   }
-  throw runtime_error("SensitiveDetector::setType: Self is not defined [Invalid Handle]");
+  throw runtime_error("DD4hep: SensitiveDetector::setType: Self is not defined [Invalid Handle]");
 }
 
 /// Access the type of the sensitive detector
@@ -721,7 +721,7 @@ void* SensitiveDetector::i_addExtension(void* ptr, const type_info& info, void (
     cout << "Extension["<<name()<<"]:" << ptr << " " << typeid(*(TNamed*)ptr).name() << endl;
     return o.extensions[&info] = ptr;
   }
-  throw runtime_error("addExtension: The object "+string(name())+
+  throw runtime_error("DD4hep: addExtension: The object "+string(name())+
 		      " already has an extension of type:"+string(info.name())+".");
 }
 
@@ -732,7 +732,7 @@ void* SensitiveDetector::i_extension(const type_info& info)   const {
   if ( j != o.extensions.end() )   {
     return (*j).second;
   }
-  throw runtime_error("extension: The object "+string(name())+
+  throw runtime_error("DD4hep: extension: The object "+string(name())+
 		      " has no extension of type:"+string(info.name())+".");
 }
  
diff --git a/DDCore/src/Handle.cpp b/DDCore/src/Handle.cpp
index 5b38a59ef..d2bea8fac 100644
--- a/DDCore/src/Handle.cpp
+++ b/DDCore/src/Handle.cpp
@@ -50,6 +50,7 @@ int DD4hep::Geometry::_toInt(const string& value)  {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << value << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation of "+value);
   }
   return (int)result;
 }
@@ -64,6 +65,7 @@ long DD4hep::Geometry::_toLong(const string& value)  {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << value << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation of "+value);
   }
   return (long)result;
 }
@@ -77,6 +79,7 @@ float DD4hep::Geometry::_toFloat(const string& value)   {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << value << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation of "+value);
   }
   return (float)result;
 }
@@ -86,6 +89,7 @@ double DD4hep::Geometry::_toDouble(const string& value)   {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << value << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation of "+value);
   }
   return result;
 }
@@ -119,6 +123,7 @@ void DD4hep::Geometry::_toDictionary(const string& name, const string& value)  {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << value << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation "+name+"="+value);
   }
   eval.setVariable(n.c_str(),result);
 }
diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp
index efc675d75..a7ae2d2e3 100644
--- a/DDCore/src/IDDescriptor.cpp
+++ b/DDCore/src/IDDescriptor.cpp
@@ -71,7 +71,7 @@ const IDDescriptor::FieldIDs& IDDescriptor::ids() const    {
   if ( isValid() )  {
     return data<Object>()->fieldIDs;
   }
-  throw runtime_error("Attempt to access an invalid IDDescriptor object.");
+  throw runtime_error("DD4hep: Attempt to access an invalid IDDescriptor object.");
 }
 
 /// Access the fieldmap container 
@@ -79,7 +79,7 @@ const IDDescriptor::FieldMap& IDDescriptor::fields() const  {
   if ( isValid() )  {
     return data<Object>()->fieldMap; 
   }
-  throw runtime_error("Attempt to access an invalid IDDescriptor object.");
+  throw runtime_error("DD4hep: Attempt to access an invalid IDDescriptor object.");
 }
 
 /// Get the field descriptor of one field by name
@@ -87,7 +87,7 @@ IDDescriptor::Field IDDescriptor::field(const string& field_name)  const  {
   const FieldMap& m = fields(); // This already checks the object validity
   for(FieldMap::const_iterator i=m.begin(); i!=m.end(); ++i)
     if ( (*i).first == field_name ) return (*i).second;
-  throw runtime_error(string(name())+": This ID descriptor has no field with the name:"+field_name);
+  throw runtime_error("DD4hep: "+string(name())+": This ID descriptor has no field with the name:"+field_name);
 }
 
 /// Get the field descriptor of one field by its identifier
@@ -101,7 +101,7 @@ size_t IDDescriptor::fieldID(const string& field_name)  const   {
   const FieldIDs& m = ids(); // This already checks the object validity
   for(FieldIDs::const_iterator i=m.begin(); i!=m.end(); ++i)
     if ( (*i).second == field_name ) return (*i).first;
-  throw runtime_error(string(name())+": This ID descriptor has no field with the name:"+field_name);
+  throw runtime_error("DD4hep: "+string(name())+": This ID descriptor has no field with the name:"+field_name);
 }
 
 /// Encoede a set of volume identifiers (corresponding to this description of course!) to a volumeID.
@@ -124,5 +124,5 @@ void IDDescriptor::decodeFields(VolumeID vid, VolIDFields& fields)   {
       fields.push_back(VolIDField(*i,(*i)->value(vid)));
     return;
   }
-  throw runtime_error("Attempt to access an invalid IDDescriptor object.");
+  throw runtime_error("DD4hep: Attempt to access an invalid IDDescriptor object.");
 }
diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp
index 49109a50b..40cae2fe8 100644
--- a/DDCore/src/LCDDImp.cpp
+++ b/DDCore/src/LCDDImp.cpp
@@ -311,23 +311,23 @@ void LCDDImp::fromXML(const string& xmlfile, LCDDBuildType build_type) {
     if ( 0 == result ) {
       PluginDebug dbg;
       PluginService::Create<long>(type,lcdd,&xml_root);
-      throw runtime_error("Failed to locate plugin to interprete files of type"
+      throw runtime_error("DD4hep: Failed to locate plugin to interprete files of type"
 			  " \""+tag+"\" - no factory:"+type+". "+dbg.missingFactory(type));
     }
     result = *(long*)result;
     if ( result != 1 ) {
-      throw runtime_error("Failed to parse the XML file "+xmlfile+" with the plugin "+type);
+      throw runtime_error("DD4hep: Failed to parse the XML file "+xmlfile+" with the plugin "+type);
     }
   }
   catch(const XML::XmlException& e)  {
-    throw runtime_error("XML-DOM Exception:\n\""+XML::_toString(e.msg)+
-			"\"\n  while parsing "+xmlfile);
+    throw runtime_error(XML::_toString(e.msg)+
+			"\nDD4hep: XML-DOM Exception while parsing "+xmlfile);
   } 
   catch(const exception& e)  {
-    throw runtime_error(string(e.what())+"\n           while parsing "+xmlfile);
+    throw runtime_error(string(e.what())+"\nDD4hep: while parsing "+xmlfile);
   }
   catch(...)  {
-    throw runtime_error("UNKNOWN exception while parsing "+xmlfile);
+    throw runtime_error("DD4hep: UNKNOWN exception while parsing "+xmlfile);
   }
 #endif
 }
@@ -347,23 +347,20 @@ void LCDDImp::apply(const char* factory_type, int argc, char** argv)   {
     if ( 0 == result ) {
       PluginDebug dbg;
       PluginService::Create<long>(fac,(LCDD*)this,argc,argv);
-      throw runtime_error("apply-plugin: Failed to locate plugin "+fac+". "+dbg.missingFactory(fac));
+      throw runtime_error("DD4hep: apply-plugin: Failed to locate plugin "+fac+". "+dbg.missingFactory(fac));
     }
     result = *(long*)result;
     if ( result != 1 ) {
-      throw runtime_error("apply-plugin: Failed to execute plugin "+fac);
+      throw runtime_error("DD4hep: apply-plugin: Failed to execute plugin "+fac);
     }
   }
   catch(const XML::XmlException& e)  {
-    cout << "XML-DOM Exception:" << XML::_toString(e.msg) << endl;
-    throw runtime_error("XML-DOM Exception:\""+XML::_toString(e.msg)+"\" with plugin:"+fac);
+    throw runtime_error(XML::_toString(e.msg)+"\nDD4hep: XML-DOM Exception with plugin:"+fac);
   } 
   catch(const exception& e)  {
-    cout << "Exception:" << e.what() << endl;
-    throw runtime_error("Exception:\""+string(e.what())+"\" with plugin:"+fac);
+    throw runtime_error(string(e.what())+"\nDD4hep: with plugin:"+fac);
   }
   catch(...)  {
-    cout << "UNKNOWN Exception" << endl;
     throw runtime_error("UNKNOWN exception from plugin:"+fac);
   }
 }
diff --git a/DDCore/src/LCDDImp.h b/DDCore/src/LCDDImp.h
index 638707b36..9739a683a 100644
--- a/DDCore/src/LCDDImp.h
+++ b/DDCore/src/LCDDImp.h
@@ -38,7 +38,7 @@ namespace DD4hep {
 
     public:
       struct InvalidObjectError : public std::runtime_error {
-        InvalidObjectError(const std::string& msg) : std::runtime_error(msg) {}
+        InvalidObjectError(const std::string& msg) : std::runtime_error("DD4hep: "+msg) {}
       };
       
       struct ObjectHandleMap : public HandleMap  {
diff --git a/DDCore/src/MatrixHelpers.cpp b/DDCore/src/MatrixHelpers.cpp
index 3064cf71b..d42aec7ed 100644
--- a/DDCore/src/MatrixHelpers.cpp
+++ b/DDCore/src/MatrixHelpers.cpp
@@ -21,7 +21,7 @@ TGeoTranslation* DD4hep::Geometry::_translation(const Position& pos) {
   return new TGeoTranslation("",pos.X()*MM_2_CM,pos.Y()*MM_2_CM,pos.Z()*MM_2_CM);
 }
 
-TGeoRotation* DD4hep::Geometry::_rotation(const Rotation& rot) {
+TGeoRotation* DD4hep::Geometry::_rotationZYX(const RotationZYX& rot) {
   return new TGeoRotation("",rot.Phi()*RAD_2_DEGREE,rot.Theta()*RAD_2_DEGREE,rot.Psi()*RAD_2_DEGREE);
 }
 
@@ -40,9 +40,9 @@ TGeoHMatrix* DD4hep::Geometry::_transform(const Transform3D& trans)   {
   t[1] *= MM_2_CM;
   t[2] *= MM_2_CM;
 #endif
-  double t[3];
-  Rotation rot;
-  Position pos;
+  double      t[3];
+  RotationZYX rot;
+  Position    pos;
   trans.GetDecomposition(rot,pos);
   TGeoHMatrix *tr = new TGeoHMatrix();
   tr->RotateZ(rot.Phi()*RAD_2_DEGREE);
diff --git a/DDCore/src/MatrixHelpers.h b/DDCore/src/MatrixHelpers.h
index 7f2506c18..d74b53dab 100644
--- a/DDCore/src/MatrixHelpers.h
+++ b/DDCore/src/MatrixHelpers.h
@@ -30,7 +30,7 @@ namespace DD4hep {
 
     TGeoIdentity*     identityTransform();
     TGeoTranslation* _translation(const Position& pos);
-    TGeoRotation*    _rotation(const Rotation& rot);
+    TGeoRotation*    _rotationZYX(const RotationZYX& rot);
     TGeoRotation*    _rotation3D(const Rotation3D& rot);
     TGeoHMatrix*     _transform(const Transform3D& trans);
 
diff --git a/DDCore/src/Objects.cpp b/DDCore/src/Objects.cpp
index e0f337224..adae1bfb2 100644
--- a/DDCore/src/Objects.cpp
+++ b/DDCore/src/Objects.cpp
@@ -173,9 +173,9 @@ double Material::radLength() const {
   if ( val.isValid() ) {
     TGeoMaterial* m = val->GetMaterial();
     if ( m ) return m->GetRadLen();
-    throw runtime_error("The medium "+string(val->GetName())+" has an invalid material reference!");
+    throw runtime_error("DD4hep: The medium "+string(val->GetName())+" has an invalid material reference!");
   }
-  throw runtime_error("Attempt to access radiation length from invalid material handle!");
+  throw runtime_error("DD4hep: Attempt to access radiation length from invalid material handle!");
 }
 
 /// Access the radiation length of the underlying material
@@ -321,16 +321,16 @@ AlignmentEntry::AlignmentEntry(const string& path)   {
 
 /// Align the PhysicalNode (translation only)
 int AlignmentEntry::align(const Position& pos, bool check, double overlap) {
-  return align(pos,Rotation(),check,overlap);
+  return align(pos,RotationZYX(),check,overlap);
 }
 
 /// Align the PhysicalNode (rotation only)
-int AlignmentEntry::align(const Rotation& rot, bool check, double overlap) {
+int AlignmentEntry::align(const RotationZYX& rot, bool check, double overlap) {
   return align(Position(),rot,check,overlap);
 }
 
 /// Align the PhysicalNode (translation + rotation)
-int AlignmentEntry::align(const Position& pos, const Rotation& rot, bool check, double overlap) {
+int AlignmentEntry::align(const Position& pos, const RotationZYX& rot, bool check, double overlap) {
 
   if ( isValid() ) {
     TGeoHMatrix* new_matrix = dynamic_cast<TGeoHMatrix*>(m_element->GetOriginalMatrix()->MakeClone());
@@ -341,7 +341,7 @@ int AlignmentEntry::align(const Position& pos, const Rotation& rot, bool check,
     m_element->Align(new_matrix,0,check,overlap);
     return 1;
   }
-  throw runtime_error("Callot align non existing physical node.");
+  throw runtime_error("DD4hep: Cannot align non existing physical node.");
 }
 
 
diff --git a/DDCore/src/Printout.cpp b/DDCore/src/Printout.cpp
index 61ea2e42e..506b33d27 100644
--- a/DDCore/src/Printout.cpp
+++ b/DDCore/src/Printout.cpp
@@ -218,7 +218,7 @@ namespace DD4hep {
 	     prefix.c_str(),val->GetName(),val->GetTitle());
   }
 
-  template <> void Printer<Rotation>::operator()(const Rotation& val)  const  {
+  template <> void Printer<RotationZYX>::operator()(const RotationZYX& val)  const  {
     printout(INFO,"Printer","%s ++ ZYXRotation: phi: %7.3 rad theta: %7.3 rad psi: %7.3 rad",
 	     prefix.c_str(),val.Phi(),val.Theta(),val.Psi());
   }
diff --git a/DDCore/src/Readout.cpp b/DDCore/src/Readout.cpp
index 29b0c5cf7..b0945f9ff 100644
--- a/DDCore/src/Readout.cpp
+++ b/DDCore/src/Readout.cpp
@@ -38,7 +38,7 @@ void Readout::setIDDescriptor(const Ref_t& new_descriptor)  const   {
       return;
     }
   }
-  throw runtime_error("Readout::setSegmentation: Cannot assign ID descriptor [Invalid Handle]");
+  throw runtime_error("DD4hep: Readout::setSegmentation: Cannot assign ID descriptor [Invalid Handle]");
 }
 
 /// Access IDDescription structure
@@ -59,7 +59,7 @@ void Readout::setSegmentation(const Segmentation& seg)   const  {
       return;
     }
   }
-  throw runtime_error("Readout::setSegmentation: Cannot assign segmentation [Invalid Handle]");
+  throw runtime_error("DD4hep: Readout::setSegmentation: Cannot assign segmentation [Invalid Handle]");
 }
 
 /// Access segmentation structure
diff --git a/DDCore/src/Segementations.cpp b/DDCore/src/Segementations.cpp
index bf7171b6d..fed771b03 100644
--- a/DDCore/src/Segementations.cpp
+++ b/DDCore/src/Segementations.cpp
@@ -67,13 +67,13 @@ void* Segmentation::i_extension(const type_info& info)   const {
       if ( &info == o.info ) {
 	return o.ptr;
       }
-      throw runtime_error("extension: The segmentation object "+string(type())+
+      throw runtime_error("DD4hep: extension: The segmentation object "+string(type())+
 			  " has the wrong type!");
     }
-    throw runtime_error("extension: The segmentation object "+string(type())+
+    throw runtime_error("DD4hep: extension: The segmentation object "+string(type())+
 			" has no extension defined.");
   }
-  throw runtime_error("extension: The segmentation object is not valid!");
+  throw runtime_error("DD4hep: extension: The segmentation object is not valid!");
 }
  
 /// Segmentation type
@@ -119,7 +119,7 @@ SegmentationParams::Parameters SegmentationParams::parameters() const  {
     params.push_back(make_pair("lunit",_toDouble("mm")));
   }
   else   {
-    throw runtime_error("The segmentation type "+typ+" is not supported by DD4hep.");
+    throw runtime_error("DD4hep: The segmentation type "+typ+" is not supported by DD4hep.");
   }
   return params;
 }
diff --git a/DDCore/src/Shapes.cpp b/DDCore/src/Shapes.cpp
index 1824e6ed8..8a291910d 100644
--- a/DDCore/src/Shapes.cpp
+++ b/DDCore/src/Shapes.cpp
@@ -94,7 +94,7 @@ Polycone::Polycone(double start, double delta, const vector<double>& rmin, const
 {
   vector<double> params;
   if ( rmin.size() < 2 )  {
-    throw runtime_error("PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
+    throw runtime_error("DD4hep: PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
   }
   params.push_back(RAD_2_DEGREE * start);
   params.push_back(RAD_2_DEGREE * delta);
@@ -112,7 +112,7 @@ Polycone::Polycone(const string& name, double start, double delta, const vector<
 {
   vector<double> params;
   if ( rmin.size() < 2 )  {
-    throw runtime_error("PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
+    throw runtime_error("DD4hep: PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
   }
   params.push_back(RAD_2_DEGREE * start);
   params.push_back(RAD_2_DEGREE * delta);
@@ -131,7 +131,7 @@ void Polycone::addZPlanes(const vector<double>& rmin, const vector<double>& rmax
   vector<double> params;
   size_t num = s->GetNz();
   if ( rmin.size() < 2 )  {
-    throw runtime_error("PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
+    throw runtime_error("DD4hep: PolyCone::addZPlanes> Not enough Z planes. minimum is 2!");
   }
   params.push_back(s->GetPhi1());
   params.push_back(s->GetDphi());
@@ -367,9 +367,9 @@ void PolyhedraRegular::_create(const string& name, int nsides, double rmin, doub
 			       double zpos, double zneg, double start, double delta)
 {
   if ( rmin<0e0 || rmin>rmax )
-    throw runtime_error("PolyhedraRegular: Illegal argument rmin:<"+_toString(rmin)+"> is invalid!");
+    throw runtime_error("DD4hep: PolyhedraRegular: Illegal argument rmin:<"+_toString(rmin)+"> is invalid!");
   else if ( rmax<0e0 )
-    throw runtime_error("PolyhedraRegular: Illegal argument rmax:<"+_toString(rmax)+"> is invalid!");
+    throw runtime_error("DD4hep: PolyhedraRegular: Illegal argument rmax:<"+_toString(rmax)+"> is invalid!");
   _assign(new TGeoPgon(),name,"polyhedra",false);
   double params[] = {
     RAD_2_DEGREE * start,
@@ -421,8 +421,8 @@ SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, con
 }
 
 /// Constructor to be used when creating a new object
-SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot)   {
-  TGeoSubtraction* sub  = new TGeoSubtraction(shape1,shape2,identityTransform(),_rotation(rot));
+SubtractionSolid::SubtractionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot)   {
+  TGeoSubtraction* sub  = new TGeoSubtraction(shape1,shape2,identityTransform(),_rotationZYX(rot));
   _assign(new TGeoCompositeShape("",sub),"","subtraction",true);
 }
 
@@ -451,8 +451,8 @@ UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Position&
 }
 
 /// Constructor to be used when creating a new object
-UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot)   {
-  TGeoUnion *uni = new TGeoUnion(shape1,shape2,identityTransform(),_rotation(rot));
+UnionSolid::UnionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot)   {
+  TGeoUnion *uni = new TGeoUnion(shape1,shape2,identityTransform(),_rotationZYX(rot));
   _assign(new TGeoCompositeShape("",uni),"","union",true);
 }
 
@@ -481,8 +481,8 @@ IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, c
 }
 
 /// Constructor to be used when creating a new object
-IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const Rotation& rot)  {
-  TGeoIntersection* inter = new TGeoIntersection(shape1,shape2,identityTransform(),_rotation(rot));
+IntersectionSolid::IntersectionSolid(const Solid& shape1, const Solid& shape2, const RotationZYX& rot)  {
+  TGeoIntersection* inter = new TGeoIntersection(shape1,shape2,identityTransform(),_rotationZYX(rot));
   _assign(new TGeoCompositeShape("",inter),"","intersection",true);
 }
 
diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp
index 27599c9a8..026006208 100644
--- a/DDCore/src/VolumeManager.cpp
+++ b/DDCore/src/VolumeManager.cpp
@@ -343,17 +343,17 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro)  {
       string det_name = detector.name();
       // First check all pre-conditions
       if ( !ro.isValid() )  {
-	throw runtime_error("VolumeManager::addSubdetector: Only subdetectors with a "
+	throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with a "
 			    "valid readout descriptor are allowed. [Invalid DetElement:"+det_name+"]");
       }
       PlacedVolume pv = detector.placement();
       if ( !pv.isValid() )   {
-	throw runtime_error("VolumeManager::addSubdetector: Only subdetectors with a "
+	throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with a "
 			    "valid placement are allowed. [Invalid DetElement:"+det_name+"]");
       }
       PlacedVolume::VolIDs::Base::const_iterator vit = pv.volIDs().find("system");
       if ( vit == pv.volIDs().end() )   {
-	throw runtime_error("VolumeManager::addSubdetector: Only subdetectors with "
+	throw runtime_error("DD4hep: VolumeManager::addSubdetector: Only subdetectors with "
 			    "valid placement VolIDs are allowed. [Invalid DetElement:"+det_name+"]");
       }
 
@@ -362,7 +362,8 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro)  {
       VolumeManager m = (*i).second;
       IDDescriptor::Field field = ro.idSpec().field(id.first);
       if ( !field )   {
-	throw runtime_error("VolumeManager::addSubdetector: IdDescriptor of "+string(detector.name())+" has no field "+id.first);
+	throw runtime_error("DD4hep: VolumeManager::addSubdetector: IdDescriptor of "+
+			    string(detector.name())+" has no field "+id.first);
       }
       Object& mo = m._data();
       m.setDetector(detector,ro);
@@ -375,7 +376,8 @@ VolumeManager VolumeManager::addSubdetector(DetElement detector, Readout ro)  {
     }
     return (*i).second;
   }
-  throw runtime_error("VolumeManager::addSubdetector: Failed to add subdetector section. [Invalid Manager Handle]");
+  throw runtime_error("DD4hep: VolumeManager::addSubdetector: "
+		      "Failed to add subdetector section. [Invalid Manager Handle]");
 }
 
 /// Access the volume manager by cell id
@@ -390,9 +392,9 @@ VolumeManager VolumeManager::subdetector(VolumeID id)  const   {
       if ( sys_id == mo.sysID )
 	return (*j).second;
     }
-    throw runtime_error("VolumeManager::subdetector(VolID): Attempt to access unknown subdetector section.");
+    throw runtime_error("DD4hep: VolumeManager::subdetector(VolID): Attempt to access unknown subdetector section.");
   }
-  throw runtime_error("VolumeManager::subdetector(VolID): Cannot assign ID descriptor [Invalid Manager Handle]");
+  throw runtime_error("DD4hep: VolumeManager::subdetector(VolID): Cannot assign ID descriptor [Invalid Manager Handle]");
 }
 
 /// Assign the top level detector element to this manager
@@ -404,9 +406,9 @@ void VolumeManager::setDetector(DetElement e, Readout ro)   {
       o.detector = e;
       return;
     }
-    throw runtime_error("VolumeManager::setDetector: Cannot assign invalid detector element [Invalid Handle]");
+    throw runtime_error("DD4hep: VolumeManager::setDetector: Cannot assign invalid detector element [Invalid Handle]");
   }
-  throw runtime_error("VolumeManager::setDetector: Cannot assign detector element [Invalid Manager Handle]");
+  throw runtime_error("DD4hep: VolumeManager::setDetector: Cannot assign detector element [Invalid Manager Handle]");
 }
 
 /// Access the top level detector element
@@ -414,7 +416,7 @@ DetElement VolumeManager::detector() const   {
   if ( isValid() )  {
     return _data().detector;
   }
-  throw runtime_error("VolumeManager::detector: Cannot access DetElement [Invalid Handle]");
+  throw runtime_error("DD4hep: VolumeManager::detector: Cannot access DetElement [Invalid Handle]");
 }
 
 /// Assign IDDescription to VolumeManager structure
@@ -425,7 +427,7 @@ void VolumeManager::setIDDescriptor(IDDescriptor new_descriptor)  const   {
       return;
     }
   }
-  throw runtime_error("VolumeManager::setIDDescriptor: Cannot assign ID descriptor [Invalid Manager Handle]");
+  throw runtime_error("DD4hep: VolumeManager::setIDDescriptor: Cannot assign ID descriptor [Invalid Manager Handle]");
 }
 
 /// Access IDDescription structure
@@ -515,7 +517,7 @@ bool VolumeManager::adoptPlacement(Context* context)   {
   err << "Failed to add new physical volume [Invalid Manager Handle]";
   goto Fail;
  Fail:
-  throw runtime_error(err.str());
+  throw runtime_error("DD4hep: "+err.str());
   return false;
 }
 
@@ -543,9 +545,9 @@ VolumeManager::Context* VolumeManager::lookupContext(VolumeID volume_id) const
     stringstream err;
     err << "VolumeManager::lookupContext: Failed to search Volume context [Unknown identifier]" 
 	<< (void*)volume_id;
-    throw runtime_error(err.str());
+    throw runtime_error("DD4hep: "+err.str());
   }
-  throw runtime_error("VolumeManager::lookupContext: Failed to search Volume context [Invalid Manager Handle]");
+  throw runtime_error("DD4hep: VolumeManager::lookupContext: Failed to search Volume context [Invalid Manager Handle]");
 }
 
 /// Lookup a physical (placed) volume identified by its 64 bit hit ID
diff --git a/DDCore/src/Volumes.cpp b/DDCore/src/Volumes.cpp
index f3e863ece..b04cfbba2 100644
--- a/DDCore/src/Volumes.cpp
+++ b/DDCore/src/Volumes.cpp
@@ -266,7 +266,7 @@ PlacedVolume::VolIDs::insert(const string& name, int value)   {
 static PlacedVolume::Object* _data(const PlacedVolume& v)  {
    PlacedVolume::Object* o = dynamic_cast<PlacedVolume::Object*>(v.ptr());
    if ( o ) return o;
-   throw runtime_error("Attempt to access invalid handle of type: PlacedVolume");
+   throw runtime_error("DD4hep: Attempt to access invalid handle of type: PlacedVolume");
 }
 
 /// Add identifier
@@ -324,7 +324,7 @@ Volume::Object* _data(const Volume& v, bool throw_exception = true) {
   Volume::Object* o = dynamic_cast<Volume::Object*>(v.ptr());
   if ( o ) return o;
   else if ( !throw_exception ) return 0;
-  throw runtime_error("Attempt to access invalid handle of type: PlacedVolume");
+  throw runtime_error("DD4hep: Attempt to access invalid handle of type: PlacedVolume");
 }
 
 /// Constructor to be used when creating a new geometry tree.
@@ -356,7 +356,7 @@ PlacedVolume Volume::placeVolume(const Volume& volume, const Transform3D& trans)
   if ( volume.isValid() )   {
     return _addNode(m_element,volume,_transform(trans));
   }
-  throw runtime_error("Volume: Attempt to assign an invalid physical volume.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign an invalid physical volume.");
 
 }
 
@@ -365,7 +365,7 @@ PlacedVolume Volume::placeVolume(const Volume& volume)  const   {
   if ( volume.isValid() )   {
     return _addNode(m_element,volume,identityTransform());
   }
-  throw runtime_error("Volume: Attempt to assign an invalid physical volume.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign an invalid physical volume.");
 }
 
 /// Place un-rotated daughter volume at the given position.
@@ -373,15 +373,15 @@ PlacedVolume Volume::placeVolume(const Volume& volume, const Position& pos)  con
   if ( volume.isValid() )   {
     return _addNode(m_element,volume,_translation(pos));
   }
-  throw runtime_error("Volume: Attempt to assign an invalid physical volume.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign an invalid physical volume.");
 }
 
 /// Place rotated daughter volume. The position is automatically the identity position
-PlacedVolume Volume::placeVolume(const Volume& volume, const Rotation& rot)  const  {
+PlacedVolume Volume::placeVolume(const Volume& volume, const RotationZYX& rot)  const  {
   if ( volume.isValid() )   {
-    return _addNode(m_element,volume,_rotation(rot));
+    return _addNode(m_element,volume,_rotationZYX(rot));
   }
-  throw runtime_error("Volume: Attempt to assign an invalid physical volume.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign an invalid physical volume.");
 }
 
 /// Place rotated daughter volume. The position is automatically the identity position
@@ -389,7 +389,7 @@ PlacedVolume Volume::placeVolume(const Volume& volume, const Rotation3D& rot)  c
   if ( volume.isValid() )   {
     return _addNode(m_element,volume,_rotation3D(rot));
   }
-  throw runtime_error("Volume: Attempt to assign an invalid physical volume.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign an invalid physical volume.");
 }
 
 /// Set the volume's material
@@ -400,9 +400,9 @@ const Volume& Volume::setMaterial(const Material& m)  const  {
       m_element->SetMedium(medium);
       return *this;
     }
-    throw runtime_error("Volume: Medium "+string(m.name())+" is not registered with geometry manager.");
+    throw runtime_error("DD4hep: Volume: Medium "+string(m.name())+" is not registered with geometry manager.");
   }
-  throw runtime_error("Volume: Attempt to assign invalid material.");
+  throw runtime_error("DD4hep: Volume: Attempt to assign invalid material.");
 }
 
 /// Access to the Volume material
diff --git a/DDCore/src/XML/DocumentHandler.cpp b/DDCore/src/XML/DocumentHandler.cpp
index aa666c520..afe4198bd 100644
--- a/DDCore/src/XML/DocumentHandler.cpp
+++ b/DDCore/src/XML/DocumentHandler.cpp
@@ -148,12 +148,12 @@ Document DocumentHandler::load(const string& fname)  const  {
   try {
     parser->parse(path.c_str());
   }
-  catch(std::exception& e) {
+  catch(exception& e) {
     cout << "parse(path):" << e.what() << endl;
     try {
       parser->parse(fname.c_str());
     }
-    catch(std::exception& ex) {
+    catch(exception& ex) {
       cout << "parse(URI):" << ex.what() << endl;      
     }
   }
@@ -174,7 +174,7 @@ Document DocumentHandler::parse(const char* bytes, size_t length)  const {
 }
 
 /// Write xml document to output file (stdout if file name empty)
-int DocumentHandler::output(Document doc, const std::string& fname) const {
+int DocumentHandler::output(Document doc, const string& fname) const {
   XMLFormatTarget   *tar = 0;
   DOMImplementation *imp = DOMImplementationRegistry::getDOMImplementation(Strng_t("LS"));
   DOMLSOutput       *out = imp->createLSOutput();
@@ -272,13 +272,13 @@ Document DocumentHandler::load(const string& fname)  const  {
 	cout << "Document:" << doc->Value() << endl;
 	cout << "Location: Line:" << doc->ErrorRow() 
 	     << " Column:" << doc->ErrorCol() << endl;
-	throw runtime_error(doc->ErrorDesc());
+	throw runtime_error(string("DD4hep: ")+doc->ErrorDesc());
       }
       else
-	throw runtime_error("Unknown error whaile parsing XML document with TiXml.");
+	throw runtime_error("DD4hep: Unknown error whaile parsing XML document with TiXml.");
     }
   }
-  catch(std::exception& e) {
+  catch(exception& e) {
     cout << "parse(path):" << e.what() << endl;
   }
   if ( result ) {
@@ -301,11 +301,11 @@ Document DocumentHandler::parse(const char* doc_string, size_t /* length */) con
       cout << "Document:" << doc->Value() << endl;
       cout << "Location: Line:" << doc->ErrorRow() 
 	   << " Column:" << doc->ErrorCol() << endl;
-      throw runtime_error(doc->ErrorDesc());
+      throw runtime_error(string("DD4hep: ")+doc->ErrorDesc());
     }
-    throw runtime_error("Unknown error whaile parsing XML document with TiXml.");
+    throw runtime_error("DD4hep: Unknown error whaile parsing XML document with TiXml.");
   }
-  catch(std::exception& e) {
+  catch(exception& e) {
     cout << "parse(xml-string):" << e.what() << endl;
   }
   delete doc;
@@ -313,7 +313,7 @@ Document DocumentHandler::parse(const char* doc_string, size_t /* length */) con
 }
 
 /// Write xml document to output file (stdout if file name empty)
-int DocumentHandler::output(Document doc, const std::string& fname) const {
+int DocumentHandler::output(Document doc, const string& fname) const {
   FILE* file = fname.empty() ? stdout : ::fopen(fname.c_str(),"w");
   if ( !file ) {
     cout << "Failed to open output file:" << fname << endl;
diff --git a/DDCore/src/XML/XMLElements.cpp b/DDCore/src/XML/XMLElements.cpp
index 2e0680e27..d0ede732f 100644
--- a/DDCore/src/XML/XMLElements.cpp
+++ b/DDCore/src/XML/XMLElements.cpp
@@ -169,6 +169,7 @@ int DD4hep::XML::_toInt(const XmlChar* value)  {
     if (eval.status() != XmlTools::Evaluator::OK) {
       cerr << s << ": ";
       eval.print_error();
+      throw runtime_error("DD4hep: Severe error during expression evaluation of "+s);
     }
     return (int)result;
   }
@@ -191,6 +192,7 @@ float DD4hep::XML::_toFloat(const XmlChar* value)   {
     if (eval.status() != XmlTools::Evaluator::OK) {
       cerr << s << ": ";
       eval.print_error();
+      throw runtime_error("DD4hep: Severe error during expression evaluation of "+s);
     }
     return (float)result;
   }
@@ -204,6 +206,7 @@ double DD4hep::XML::_toDouble(const XmlChar* value)   {
     if (eval.status() != XmlTools::Evaluator::OK) {
       cerr << s << ": ";
       eval.print_error();
+      throw runtime_error("DD4hep: Severe error during expression evaluation of "+s);
     }
     return result;
   }
@@ -220,6 +223,7 @@ void DD4hep::XML::_toDictionary(const XmlChar* name, const XmlChar* value)  {
   if (eval.status() != XmlTools::Evaluator::OK) {
     cerr << v << ": ";
     eval.print_error();
+    throw runtime_error("DD4hep: Severe error during expression evaluation of "+v);
   }
   eval.setVariable(n.c_str(),result);
 }
@@ -928,21 +932,34 @@ Collection_t::Collection_t(Handle_t element, const char* tag)
   m_node = m_children.reset();
 }
 
+/// Constructor over XmlElements in a node list
 Collection_t::Collection_t(NodeList node_list) 
   : m_children(node_list)
 {
   m_node = m_children.reset();
 }
 
+/// Reset the collection object to restart the iteration
 Collection_t& Collection_t::reset()  {
   m_node = m_children.reset();
   return *this;
 }
 
+/// Access the collection size. Avoid this call -- sloooow!
 size_t Collection_t::size()  const  {
   return Handle_t(m_children.m_node).numChildren(m_children.m_tag,false);
 }
 
+/// Helper function to throw an exception
+void Collection_t::throw_loop_exception(const std::exception& e)  const   {
+  if ( m_node )  {
+    throw runtime_error(std::string(e.what())+"\n"+
+			"DD4hep: Error interpreting XML nodes of type <"+tag()+"/>");
+  }
+  throw runtime_error(std::string(e.what())+"\n"+
+		      "DD4hep: Error interpreting collections XML nodes.");
+}
+
 void Collection_t::operator++()  const  {
   Elt_t e = this->parent();
   while(m_node)  {
diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index 9c8fd9f1c..dee18c47b 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -418,7 +418,7 @@ template <> void Converter<AlignmentEntry>::operator()(xml_h e)  const  {
   bool overlap = e.hasAttr(_U(overlap));
   AlignmentEntry alignment(path);
   Position pos;
-  Rotation rot;
+  RotationZYX rot;
   if ( (child=e.child(_U(position),false)) )  { // Position is not mandatory!
     pos.SetXYZ(child.x(),child.y(),child.z());
   }
@@ -637,6 +637,9 @@ template <> void Converter<SensitiveDetector>::operator()(xml_h element)  const
     }
     printout(DEBUG,"Compact","SensitiveDetector-update: %-18s %-24s Hits:%-24s Cutoff:%f7.3f",
 	     sd.name(),(" ["+sd.type()+"]").c_str(),sd.hitsCollection().c_str(),sd.energyCutoff());
+    xml_attr_t sequence = element.attr_nothrow(_U(sequence));
+    if ( sequence )   {
+    }
   }
   catch(const exception& e) {
     printout(ERROR,"Compact","++ FAILED    to convert sensitive detector: %s: %s",
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 2bb20cd3b..668680b05 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -69,7 +69,7 @@ static long load_volmgr(LCDD& lcdd,int,char**)    {
   }
   catch(const exception& e)  {
     throw runtime_error(string(e.what())+"\n"
-			"           while programming VolumeManager. Are your volIDs correct?");
+			"DD4hep: while programming VolumeManager. Are your volIDs correct?");
   }
   catch(...)  {
     throw runtime_error("UNKNOWN exception while programming VolumeManager. Are your volIDs correct?");
-- 
GitLab