From ae7db9cc834512ccab3d19a93b9200f218663c98 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Tue, 11 Jul 2017 16:28:39 +0200
Subject: [PATCH] Remove DDSegmentation library. Implement ROOT persistency --
 first try.

---
 DDCore/CMakeLists.txt                         |   8 +-
 DDCore/include/DD4hep/BasicGrammar.h          |   4 +
 DDCore/include/DD4hep/DD4hepRootPersistency.h |  88 ++--
 DDCore/include/DD4hep/DetectorData.h          |  12 +-
 DDCore/include/DD4hep/Dictionary.h            |   2 +
 DDCore/include/DD4hep/IDDescriptor.h          |   4 +-
 DDCore/include/DD4hep/OpaqueData.h            |  11 +-
 DDCore/include/DD4hep/Segmentations.h         |   2 +
 .../include/DD4hep/detail/AlignmentsInterna.h |   2 +-
 .../include/DD4hep/detail/BasicGrammar_inl.h  |  16 +
 DDCore/include/DD4hep/detail/ObjectsInterna.h |  19 +-
 .../DD4hep/detail/SegmentationsInterna.h      |   2 +-
 .../DD4hep/detail/VolumeManagerInterna.h      |   2 +-
 .../include/DDSegmentation/BitField64.h       |  11 +
 .../include/DDSegmentation/CartesianGrid.h    |   0
 .../include/DDSegmentation/CartesianGridXY.h  |   0
 .../include/DDSegmentation/CartesianGridXYZ.h |   0
 .../include/DDSegmentation/CartesianGridXZ.h  |   0
 .../include/DDSegmentation/CartesianGridYZ.h  |   0
 .../DDSegmentation/CylindricalSegmentation.h  |   0
 .../include/DDSegmentation/GridPhiEta.h       |   0
 .../include/DDSegmentation/GridRPhiEta.h      |   0
 .../DDSegmentation/MegatileLayerGridXY.h      |   0
 .../DDSegmentation/MultiSegmentation.h        |   0
 .../include/DDSegmentation/NoSegmentation.h   |   0
 .../include/DDSegmentation/PolarGrid.h        |   0
 .../include/DDSegmentation/PolarGridRPhi.h    |   0
 .../include/DDSegmentation/PolarGridRPhi2.h   |   0
 .../DDSegmentation/ProjectiveCylinder.h       |   0
 .../include/DDSegmentation/Segmentation.h     |   4 +-
 .../DDSegmentation/SegmentationFactory.h      |   0
 .../DDSegmentation/SegmentationParameter.h    |   0
 .../include/DDSegmentation/SegmentationUtil.h |   0
 .../include/DDSegmentation/TiledLayerGridXY.h |   0
 .../DDSegmentation/TiledLayerSegmentation.h   |   0
 .../include/DDSegmentation/WaferGridXY.h      |   0
 DDCore/src/DD4hepRootPersistency.cpp          | 472 ++++++++++++++++--
 DDCore/src/DetectorData.cpp                   |   4 +-
 DDCore/src/IDDescriptor.cpp                   |  26 +-
 DDCore/src/ObjectsInterna.cpp                 |   4 +-
 DDCore/src/OpaqueData.cpp                     |  48 +-
 DDCore/src/Segmentations.cpp                  |   5 +
 DDCore/src/plugins/Compact2Objects.cpp        |   5 +-
 DDCore/src/plugins/StandardPlugins.cpp        |  60 +++
 DDCore/src/plugins/VolumeMgrTest.cpp          |  80 +--
 .../src/segmentations}/BitField64.cpp         |   0
 .../src/segmentations}/CartesianGrid.cpp      |   0
 .../src/segmentations}/CartesianGridXY.cpp    |   0
 .../src/segmentations}/CartesianGridXYZ.cpp   |   0
 .../src/segmentations}/CartesianGridXZ.cpp    |   0
 .../src/segmentations}/CartesianGridYZ.cpp    |   0
 .../CylindricalSegmentation.cpp               |   0
 .../src/segmentations}/GridPhiEta.cpp         |   0
 .../src/segmentations}/GridRPhiEta.cpp        |   0
 .../segmentations}/MegatileLayerGridXY.cpp    |   0
 .../src/segmentations}/MultiSegmentation.cpp  |   0
 .../src/segmentations}/NoSegmentation.cpp     |   0
 .../src/segmentations}/PolarGrid.cpp          |   0
 .../src/segmentations}/PolarGridRPhi.cpp      |   0
 .../src/segmentations}/PolarGridRPhi2.cpp     |   0
 .../src/segmentations}/ProjectiveCylinder.cpp |   0
 .../src/segmentations}/Segmentation.cpp       |  20 +-
 .../segmentations}/SegmentationFactory.cpp    |   0
 .../src/segmentations}/TiledLayerGridXY.cpp   |   0
 .../segmentations}/TiledLayerSegmentation.cpp |   0
 .../src/segmentations}/WaferGridXY.cpp        |   0
 DDParsersStandAlone/CMakeLists.txt            |   6 +-
 DDSegmentation/CMakeLists.txt                 |   7 -
 DDSegmentation/src/bla.cpp                    |   0
 UtilityApps/CMakeLists.txt                    |   2 +-
 examples/CLICSiD/CMakeLists.txt               |  27 +-
 71 files changed, 737 insertions(+), 216 deletions(-)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/BitField64.h (96%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CartesianGrid.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CartesianGridXY.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CartesianGridXYZ.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CartesianGridXZ.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CartesianGridYZ.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/CylindricalSegmentation.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/GridPhiEta.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/GridRPhiEta.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/MegatileLayerGridXY.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/MultiSegmentation.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/NoSegmentation.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/PolarGrid.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/PolarGridRPhi.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/PolarGridRPhi2.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/ProjectiveCylinder.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/Segmentation.h (97%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/SegmentationFactory.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/SegmentationParameter.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/SegmentationUtil.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/TiledLayerGridXY.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/TiledLayerSegmentation.h (100%)
 rename {DDSegmentation => DDCore}/include/DDSegmentation/WaferGridXY.h (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/BitField64.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CartesianGrid.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CartesianGridXY.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CartesianGridXYZ.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CartesianGridXZ.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CartesianGridYZ.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/CylindricalSegmentation.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/GridPhiEta.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/GridRPhiEta.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/MegatileLayerGridXY.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/MultiSegmentation.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/NoSegmentation.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/PolarGrid.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/PolarGridRPhi.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/PolarGridRPhi2.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/ProjectiveCylinder.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/Segmentation.cpp (94%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/SegmentationFactory.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/TiledLayerGridXY.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/TiledLayerSegmentation.cpp (100%)
 rename {DDSegmentation/src => DDCore/src/segmentations}/WaferGridXY.cpp (100%)
 create mode 100644 DDSegmentation/src/bla.cpp

diff --git a/DDCore/CMakeLists.txt b/DDCore/CMakeLists.txt
index 7ec3378de..affdb5bf9 100644
--- a/DDCore/CMakeLists.txt
+++ b/DDCore/CMakeLists.txt
@@ -11,10 +11,10 @@
 #=================================================================================
 dd4hep_package(    DDCore
   USES             [ROOT REQUIRED COMPONENTS Geom GenVector]
-                   DDSegmentation DDParsers
+                   DDParsers
   OPTIONAL         XERCESC
   INCLUDE_DIRS     include
-  INSTALL_INCLUDES include/DD4hep include/XML include/JSON)
+  INSTALL_INCLUDES include/DDSegmentation include/DD4hep include/XML include/JSON)
 
 #---Generate ROOT dictionary------------------------------------------------------
 dd4hep_add_dictionary( G__DD4hep
@@ -22,8 +22,6 @@ dd4hep_add_dictionary( G__DD4hep
   include/DD4hep/*.h
   include/DD4hep/detail/*.h
   include/XML/*.h 
-  ${DDSegmentation_INCLUDE_DIRS}/DDSegmentation/BitField64.h
-  ${DDSegmentation_INCLUDE_DIRS}/DDSegmentation/Segmentation.h
   EXCLUDE include/DD4hep/DetFactoryHelper.h
   include/DD4hep/Factories.h
   include/DD4hep/Plugins.h
@@ -36,7 +34,7 @@ dd4hep_add_dictionary( G__DD4hep
 
 #---Generate DDCore Library-------------------------------------------------------
 dd4hep_add_package_library ( DDCore
-  SOURCES        src/*.cpp src/XML/*.cpp
+  SOURCES        src/*.cpp src/segmentations/*.cpp src/XML/*.cpp
   OPTIONAL       [BOOST SOURCES src/JSON/*.cpp]
   GENERATED      G__DD4hep.cxx 
   INCLUDE_DIRS   ${GaudiPluginService_INCLUDE_DIRS}
diff --git a/DDCore/include/DD4hep/BasicGrammar.h b/DDCore/include/DD4hep/BasicGrammar.h
index 635cbddbf..a10099a95 100644
--- a/DDCore/include/DD4hep/BasicGrammar.h
+++ b/DDCore/include/DD4hep/BasicGrammar.h
@@ -57,6 +57,10 @@ namespace dd4hep {
     virtual std::string str(const void* ptr) const = 0;
     /// Set value from serialized string. On successful data conversion TRUE is returned.
     virtual bool fromString(void* ptr, const std::string& value) const = 0;
+    /// Opaque object destructor
+    virtual void destruct(void* pointer) const = 0;
+    /// Opaque object copy construction. Memory must be allocated externally
+    virtual void copy(void* to, const void* from)  const = 0;
   };
 }      // End namespace dd4hep
 
diff --git a/DDCore/include/DD4hep/DD4hepRootPersistency.h b/DDCore/include/DD4hep/DD4hepRootPersistency.h
index db77918a6..f41839f98 100644
--- a/DDCore/include/DD4hep/DD4hepRootPersistency.h
+++ b/DDCore/include/DD4hep/DD4hepRootPersistency.h
@@ -17,11 +17,16 @@
 #include "DD4hep/DetectorData.h"
 
 /// Helper class to support ROOT persistency of Detector objects
-class DD4hepRootPersistency : public TNamed, public dd4hep::DetectorData  {
+class DD4hepRootPersistency : public TNamed  {
 public:
   typedef std::map<std::string, dd4hep::Handle<dd4hep::NamedObject> >  HandleMap;
   typedef std::map<std::string, std::string>          PropertyValues;
   typedef std::map<std::string, PropertyValues>       Properties;
+
+  /// Helper since plain segmentations cannot be saved
+  std::map<dd4hep::Readout,std::pair<dd4hep::IDDescriptor,dd4hep::DDSegmentation::Segmentation*> > m_segments;
+  /// The main data block
+  dd4hep::DetectorData*     m_data = 0;
   
   /// Default constructor
   DD4hepRootPersistency() : TNamed() {}
@@ -32,87 +37,87 @@ public:
   static int load(dd4hep::Detector& description, const char* fname, const char* instance = "Geometry");
   /// Access the geometry manager of this instance
   TGeoManager& manager() const {
-    return *m_manager;
+    return *m_data->m_manager;
   }
   /// Access to properties
   Properties& properties() const {
-    return *(Properties*)&m_properties;
+    return *(Properties*)&m_data->m_properties;
   }
   /// Return handle to material describing air
   dd4hep::Material air() const {
-    return m_materialAir;
+    return m_data->m_materialAir;
   }
   /// Return handle to material describing vacuum
   dd4hep::Material vacuum() const {
-    return m_materialVacuum;
+    return m_data->m_materialVacuum;
   }
   /// Return handle to "invisible" visualization attributes
   dd4hep::VisAttr invisible() const {
-    return m_invisibleVis;
+    return m_data->m_invisibleVis;
   }
   /// Return reference to the top-most (world) detector element
   dd4hep::DetElement world() const {
-    return m_world;
+    return m_data->m_world;
   }
   /// Return reference to detector element with all tracker devices.
   dd4hep::DetElement trackers() const {
-    return m_trackers;
+    return m_data->m_trackers;
   }
   /// Return handle to the world volume containing everything
   dd4hep::Volume worldVolume() const {
-    return m_worldVol;
+    return m_data->m_worldVol;
   }
   /// Return handle to the world volume containing the volume with the tracking devices
   dd4hep::Volume trackingVolume() const {
-    return m_trackingVol;
+    return m_data->m_trackingVol;
   }
   /// Return handle to the VolumeManager
   dd4hep::VolumeManager volumeManager() const {
-    return m_volManager;
+    return m_data->m_volManager;
   }
   /// Return handle to the combined electromagentic field description.
   dd4hep::OverlayedField field() const {
-    return m_field;
+    return m_data->m_field;
   }
   /// Accessor to the header entry
   dd4hep::Header header() const {
-    return m_header;
+    return m_data->m_header;
   }
   /// Accessor to the map of constants
   const HandleMap& constants() const {
-    return m_define;
+    return m_data->m_define;
   }
   /// Accessor to the map of visualisation attributes
   const HandleMap& visAttributes() const {
-    return m_display;
+    return m_data->m_display;
   }
   /// Accessor to the map of limit settings
   const HandleMap& limitsets() const {
-    return m_limits;
+    return m_data->m_limits;
   }
   /// Accessor to the map of region settings
   const HandleMap& regions() const {
-    return m_regions;
+    return m_data->m_regions;
   }
   /// Accessor to the map of readout structures
   const HandleMap& readouts() const {
-    return m_readouts;
+    return m_data->m_readouts;
   }
   /// Accessor to the map of sub-detectors
   const HandleMap& detectors() const {
-    return m_detectors;
+    return m_data->m_detectors;
   }
   /// Retrieve a sensitive detector by it's name from the detector description
   const HandleMap& sensitiveDetectors() const {
-    return m_sensitive;
+    return m_data->m_sensitive;
   }
   /// Accessor to the map of field entries, which together form the global field
   const HandleMap& fields() const {
-    return m_fields;
+    return m_data->m_fields;
   }
   /// Accessor to the map of ID specifications
   const HandleMap& idSpecifications() const {
-    return m_idDict;
+    return m_data->m_idDict;
   }
 
   /// ROOT implementation macro
@@ -121,24 +126,35 @@ public:
 
 class DD4hepRootCheck  {
 public:
-  const DD4hepRootPersistency* object = 0;
+  dd4hep::Detector* object=0;
   DD4hepRootCheck() = default;
   DD4hepRootCheck(const DD4hepRootCheck& copy) = default;
-  DD4hepRootCheck(const DD4hepRootPersistency* o) : object(o) {}
+  DD4hepRootCheck(dd4hep::Detector* o) : object(o) {}
   ~DD4hepRootCheck() = default;
   DD4hepRootCheck& operator=(const DD4hepRootCheck& copy) = default;
-  const DD4hepRootCheck& checkDetectors()  const;
-  const DD4hepRootCheck& checkMaterials()  const;
-  const DD4hepRootCheck& checkReadouts()   const;
-  const DD4hepRootCheck& checkFields()   const;
-  const DD4hepRootCheck& checkRegions()   const;
-  const DD4hepRootCheck& checkIdSpecs()   const;
-  const DD4hepRootCheck& checkSensitives()   const;
-  const DD4hepRootCheck& checkLimitSets()   const;
-  const DD4hepRootCheck& checkVolManager()   const;
-  const DD4hepRootCheck& checkDefines()   const;
-  const DD4hepRootCheck& checkProperties()   const;
-  const DD4hepRootCheck& checkAll()   const;
+  /// Call to check a Material object
+  size_t checkMaterials()  const;
+  /// Check the collection of define statements
+  size_t checkConstants()   const;
+  /// Check detector description properties (string defines)
+  size_t checkProperties()   const;
+  /// Call to theck the DD4hep fields
+  size_t checkFields()   const;
+  /// Call to check a Region object
+  size_t checkRegions()   const;
+  /// Call to check a Readout object
+  size_t checkReadouts()   const;
+  /// Call to check an ID specification
+  size_t checkIdSpecs()   const;
+  /// Call to check a sensitive detector
+  size_t checkSensitives()   const;
+  /// Call to check a limit-set object
+  size_t checkLimitSets()   const;
+  /// Call to check the volume manager hierarchy
+  size_t checkVolManager()   const;
+  /// Call to check a top level Detector element (subdetector)
+  size_t checkDetectors()  const;
+  size_t checkAll()   const;
 };
 
 
diff --git a/DDCore/include/DD4hep/DetectorData.h b/DDCore/include/DD4hep/DetectorData.h
index 4caddffaa..5b547e50a 100644
--- a/DDCore/include/DD4hep/DetectorData.h
+++ b/DDCore/include/DD4hep/DetectorData.h
@@ -87,21 +87,22 @@ namespace dd4hep {
     };
 
   protected:
+  public:
     /** All elments of the big detector description common block ;-0  */
     /// Reference to the geometry manager object from ROOT
     TGeoManager*             m_manager;
-    /// Map of readout descriptors indexed by subdetector name
-    ObjectHandleMap          m_readouts;
     /// Map of readout IDDescriptors indexed by hit collection name
     ObjectHandleMap          m_idDict;
     /// Map of limit sets
     ObjectHandleMap          m_limits;
     /// Map of regions settings for the simulation
     ObjectHandleMap          m_regions;
-    /// The map of top level sub-detector objects indexed by name
-    ObjectHandleMap          m_detectors;
+    /// Map of readout descriptors indexed by subdetector name
+    ObjectHandleMap          m_readouts;
     /// The map of top level sub-detector sensitive detector objects indexed by the detector name
     ObjectHandleMap          m_sensitive;
+    /// The map of top level sub-detector objects indexed by name
+    ObjectHandleMap          m_detectors;
     /// The map of display attributes in use
     ObjectHandleMap          m_display;
     /// The map of electro magnet field components for the global overlay field
@@ -133,6 +134,7 @@ namespace dd4hep {
     bool                     m_inhibitConstants;
 
   protected:
+  public:
     /// Default constructor
     DetectorData();
     /// Default destructor
@@ -147,7 +149,7 @@ namespace dd4hep {
     /// Clear data content: DOES NOT RELEASEW ALLOCATED RESOURCES!
     void clearData();
     /// Adopt all data from source structure.
-    void adoptData(DetectorData& source);
+    void adoptData(DetectorData& source, bool CLR=true);
   };
 
 }         /* End namespace dd4hep         */
diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/include/DD4hep/Dictionary.h
index 9df5c5b83..e08fe7e6a 100644
--- a/DDCore/include/DD4hep/Dictionary.h
+++ b/DDCore/include/DD4hep/Dictionary.h
@@ -116,6 +116,8 @@ template class dd4hep::Handle<TNamed>;
 #pragma link C++ class dd4hep::Detector::Properties+;
 #pragma link C++ class DD4hepRootPersistency+;
 #pragma link C++ class DD4hepRootCheck+;
+#pragma link C++ class pair<dd4hep::IDDescriptor,dd4hep::DDSegmentation::Segmentation*>+;
+#pragma link C++ class map<dd4hep::Readout,pair<dd4hep::IDDescriptor,dd4hep::DDSegmentation::Segmentation*> >+;
 
 // These below are the Namedobject instances to be generated ....
 //#pragma link C++ class dd4hep::Detector::HandleMap+;
diff --git a/DDCore/include/DD4hep/IDDescriptor.h b/DDCore/include/DD4hep/IDDescriptor.h
index 79425cc9d..c031454ac 100644
--- a/DDCore/include/DD4hep/IDDescriptor.h
+++ b/DDCore/include/DD4hep/IDDescriptor.h
@@ -45,8 +45,8 @@ namespace dd4hep {
     /// Constructor to be used when reading the already parsed object
     template <typename Q> IDDescriptor(const Handle<Q>& e) : Handle<Object>(e) { }
     /// Initializing constructor
-    IDDescriptor(const std::string& description);
-    // the string description of all fields
+    IDDescriptor(const std::string& name, const std::string& description);
+    /// The string description of all fields from the BitField
     std::string fieldDescription() const;
     /// The total number of encoding bits for this descriptor
     unsigned maxBit() const;
diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h
index 14a4c3ca0..1f8b89121 100644
--- a/DDCore/include/DD4hep/OpaqueData.h
+++ b/DDCore/include/DD4hep/OpaqueData.h
@@ -51,7 +51,7 @@ namespace dd4hep {
 
   protected:
     /// Pointer to object data
-    void* pointer = 0;
+    void* pointer = 0;   //! No ROOT persistency
 
   public:
     /// Create data block from string representation
@@ -89,13 +89,16 @@ namespace dd4hep {
       STACK_DATA = 1<<2,
       BOUND_DATA = 1<<3
     };
+
+
+    
     /// Data buffer: plain data are allocated directly on this buffer
     /** Internal data buffer is sufficient to store any vector  */
     unsigned char data[sizeof(std::vector<void*>)];
-    /// Destructor function -- only set if the object is valid
-    void (*destruct)(void*);
+    /// Destructor function  -- only set if the object is valid
+    //void (*destruct)(void*);
     /// Constructor function -- only set if the object is valid
-    void (*copy)(void*,const void*);
+    //void (*copy)(void*,const void*);
 
   public:
     /// Data buffer type: Must be a bitmap!
diff --git a/DDCore/include/DD4hep/Segmentations.h b/DDCore/include/DD4hep/Segmentations.h
index a03661557..6e80edf04 100644
--- a/DDCore/include/DD4hep/Segmentations.h
+++ b/DDCore/include/DD4hep/Segmentations.h
@@ -57,6 +57,8 @@ namespace dd4hep {
     /// Access flag for hit positioning
     bool useForHitPosition() const;
     /// Accessor: Segmentation type
+    const char* name() const;
+    /// Accessor: Segmentation type
     std::string type() const;
     /// Access to the parameters
     DDSegmentation::Parameters parameters() const;
diff --git a/DDCore/include/DD4hep/detail/AlignmentsInterna.h b/DDCore/include/DD4hep/detail/AlignmentsInterna.h
index 3ece0e0a1..5eee59e93 100644
--- a/DDCore/include/DD4hep/detail/AlignmentsInterna.h
+++ b/DDCore/include/DD4hep/detail/AlignmentsInterna.h
@@ -64,7 +64,7 @@ namespace dd4hep {
       /// Copy constructor
       AlignmentObject(const AlignmentObject& copy) = delete;
       /// Standard constructor with user provided payload pointer to bind alignment data
-      AlignmentObject(const std::string& nam,const std::string& tit,void* payload,size_t len);
+      AlignmentObject(const std::string& nam, const std::string& tit, void* payload, size_t len);
       /// Standard Destructor
       virtual ~AlignmentObject();
       /// Assignment operator
diff --git a/DDCore/include/DD4hep/detail/BasicGrammar_inl.h b/DDCore/include/DD4hep/detail/BasicGrammar_inl.h
index 5f6438a67..4046b8eda 100644
--- a/DDCore/include/DD4hep/detail/BasicGrammar_inl.h
+++ b/DDCore/include/DD4hep/detail/BasicGrammar_inl.h
@@ -78,6 +78,10 @@ namespace dd4hep {
     virtual bool fromString(void* ptr, const std::string& value) const  override;
     /// Evaluate string value if possible before calling boost::spirit
     virtual int evaluate(void* ptr, const std::string& value) const;
+    /// Opaque object destructor
+    virtual void destruct(void* pointer) const;
+    /// Opaque object copy construction. Memory must be allocated externally
+    virtual void copy(void* to, const void* from)  const;
   };
 
   /// Standarsd constructor
@@ -135,6 +139,18 @@ namespace dd4hep {
     return string_rep.str();
   }
 
+  /// Opaque object destructor
+  template <typename TYPE> void Grammar<TYPE>::destruct(void* pointer) const   {
+    TYPE* obj = (TYPE*)pointer;
+    obj->~TYPE();
+  }
+
+  /// Opaque object destructor
+  template <typename TYPE> void Grammar<TYPE>::copy(void* to, const void* from) const   {
+    const TYPE* from_obj = (const TYPE*)from;
+    new (to) TYPE(*from_obj);
+  }
+
   /// Helper function to parse data type
   static inline std::string pre_parse_obj(const std::string& in)   {
     std::string res = "";
diff --git a/DDCore/include/DD4hep/detail/ObjectsInterna.h b/DDCore/include/DD4hep/detail/ObjectsInterna.h
index 1e6573017..fd6e600e8 100644
--- a/DDCore/include/DD4hep/detail/ObjectsInterna.h
+++ b/DDCore/include/DD4hep/detail/ObjectsInterna.h
@@ -169,7 +169,7 @@ namespace dd4hep {
   class ReadoutObject: public NamedObject {
   public:
     /// Handle to the readout segmentation
-    Segmentation segmentation;  //! No ROOT persistency
+    Segmentation segmentation;  //! not ROOT-persistent
     /// Handle to the volume
     Volume readoutWorld;
     /// Handle to the field descriptor
@@ -190,12 +190,17 @@ namespace dd4hep {
    *  \date    2012/07/31
    *  \ingroup DD4HEP_CORE
    */
-  class IDDescriptorObject: public NamedObject, public BitField64 {
+  class IDDescriptorObject: public NamedObject {
   public:
     typedef std::vector<std::pair<std::string, BitFieldValue*> > FieldMap;
     typedef std::vector<std::pair<size_t, std::string> >         FieldIDs;
-    FieldMap fieldMap; //! not ROOT-persistent
-    FieldIDs fieldIDs; //! not ROOT-persistent
+    /// Map of id-fields in the descriptor
+    FieldMap fieldMap;  //! not ROOT-persistent
+    /// String map of id descriptors
+    FieldIDs fieldIDs;  //! not ROOT-persistent
+    /// Decoder object
+    BitField64 decoder; //! not ROOT-persistent
+    
     /// The description string to build the bit-field descriptors.
     std::string description;
     /// Default constructor
@@ -204,11 +209,13 @@ namespace dd4hep {
     IDDescriptorObject(const std::string& initString);
     /// Default destructor
     virtual ~IDDescriptorObject();
+#if 0
 #ifndef __CINT__
     /// Access to the field container of the BitField64
-    const std::vector<BitFieldValue*> fields() const {
-      return _fields;
+    const std::vector<BitFieldValue*>& fields() const {
+      return decoder.fields();
     }
+#endif
 #endif
   };
 }      /* End namespace dd4hep              */
diff --git a/DDCore/include/DD4hep/detail/SegmentationsInterna.h b/DDCore/include/DD4hep/detail/SegmentationsInterna.h
index 59d684d02..83b9fccf0 100644
--- a/DDCore/include/DD4hep/detail/SegmentationsInterna.h
+++ b/DDCore/include/DD4hep/detail/SegmentationsInterna.h
@@ -87,7 +87,7 @@ namespace dd4hep {
     /// Reference to hosting top level sensitve detector structure
     Handle<SensitiveDetectorObject> sensitive;
     /// Reference to base segmentation
-    DDSegmentation::Segmentation* segmentation;      
+    DDSegmentation::Segmentation* segmentation = 0;
   };
 
   /// Concrete wrapper class for segmentation implementation based on DDSegmentation objects
diff --git a/DDCore/include/DD4hep/detail/VolumeManagerInterna.h b/DDCore/include/DD4hep/detail/VolumeManagerInterna.h
index 749608111..77b997fa3 100644
--- a/DDCore/include/DD4hep/detail/VolumeManagerInterna.h
+++ b/DDCore/include/DD4hep/detail/VolumeManagerInterna.h
@@ -58,7 +58,7 @@ namespace dd4hep {
       /// The reference to the TOP level VolumeManager
       VolumeManagerObject* top    = 0;
       /// The system field descriptor
-      const BitFieldValue* system = 0;
+      const BitFieldValue* system = 0;   //! Not ROOT persistent
       /// System identifier
       VolumeID sysID              = 0;
       /// Sub-detector mask
diff --git a/DDSegmentation/include/DDSegmentation/BitField64.h b/DDCore/include/DDSegmentation/BitField64.h
similarity index 96%
rename from DDSegmentation/include/DDSegmentation/BitField64.h
rename to DDCore/include/DDSegmentation/BitField64.h
index 6b8708bcb..f4978771c 100644
--- a/DDSegmentation/include/DDSegmentation/BitField64.h
+++ b/DDCore/include/DDSegmentation/BitField64.h
@@ -145,6 +145,10 @@ namespace DDSegmentation {
      */
     std::string valueString() const ;
 
+    const std::vector<BitFieldValue*>& fields()  const  {
+      return _fields;
+    }
+    
   protected:
 
     /** Add an additional field to the list 
@@ -156,9 +160,11 @@ namespace DDSegmentation {
      */
     void init( const std::string& initString) ;
 
+  public:
     /** No default c'tor */
     BitField64() : _value(0) , _joined(0) { }
 
+  protected:
 
     // -------------- data members:--------------
 
@@ -274,6 +280,11 @@ namespace DDSegmentation {
     /** The field's mask */
     ulong64 mask() const { return _mask ; }
 
+    /** Minimal value  */
+    int  minValue()  const  { return _minVal;  }
+
+    /** Maximal value  */
+    int  maxValue()  const  { return _maxVal;  }
 
   protected:
   
diff --git a/DDSegmentation/include/DDSegmentation/CartesianGrid.h b/DDCore/include/DDSegmentation/CartesianGrid.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CartesianGrid.h
rename to DDCore/include/DDSegmentation/CartesianGrid.h
diff --git a/DDSegmentation/include/DDSegmentation/CartesianGridXY.h b/DDCore/include/DDSegmentation/CartesianGridXY.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CartesianGridXY.h
rename to DDCore/include/DDSegmentation/CartesianGridXY.h
diff --git a/DDSegmentation/include/DDSegmentation/CartesianGridXYZ.h b/DDCore/include/DDSegmentation/CartesianGridXYZ.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CartesianGridXYZ.h
rename to DDCore/include/DDSegmentation/CartesianGridXYZ.h
diff --git a/DDSegmentation/include/DDSegmentation/CartesianGridXZ.h b/DDCore/include/DDSegmentation/CartesianGridXZ.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CartesianGridXZ.h
rename to DDCore/include/DDSegmentation/CartesianGridXZ.h
diff --git a/DDSegmentation/include/DDSegmentation/CartesianGridYZ.h b/DDCore/include/DDSegmentation/CartesianGridYZ.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CartesianGridYZ.h
rename to DDCore/include/DDSegmentation/CartesianGridYZ.h
diff --git a/DDSegmentation/include/DDSegmentation/CylindricalSegmentation.h b/DDCore/include/DDSegmentation/CylindricalSegmentation.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/CylindricalSegmentation.h
rename to DDCore/include/DDSegmentation/CylindricalSegmentation.h
diff --git a/DDSegmentation/include/DDSegmentation/GridPhiEta.h b/DDCore/include/DDSegmentation/GridPhiEta.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/GridPhiEta.h
rename to DDCore/include/DDSegmentation/GridPhiEta.h
diff --git a/DDSegmentation/include/DDSegmentation/GridRPhiEta.h b/DDCore/include/DDSegmentation/GridRPhiEta.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/GridRPhiEta.h
rename to DDCore/include/DDSegmentation/GridRPhiEta.h
diff --git a/DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h b/DDCore/include/DDSegmentation/MegatileLayerGridXY.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/MegatileLayerGridXY.h
rename to DDCore/include/DDSegmentation/MegatileLayerGridXY.h
diff --git a/DDSegmentation/include/DDSegmentation/MultiSegmentation.h b/DDCore/include/DDSegmentation/MultiSegmentation.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/MultiSegmentation.h
rename to DDCore/include/DDSegmentation/MultiSegmentation.h
diff --git a/DDSegmentation/include/DDSegmentation/NoSegmentation.h b/DDCore/include/DDSegmentation/NoSegmentation.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/NoSegmentation.h
rename to DDCore/include/DDSegmentation/NoSegmentation.h
diff --git a/DDSegmentation/include/DDSegmentation/PolarGrid.h b/DDCore/include/DDSegmentation/PolarGrid.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/PolarGrid.h
rename to DDCore/include/DDSegmentation/PolarGrid.h
diff --git a/DDSegmentation/include/DDSegmentation/PolarGridRPhi.h b/DDCore/include/DDSegmentation/PolarGridRPhi.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/PolarGridRPhi.h
rename to DDCore/include/DDSegmentation/PolarGridRPhi.h
diff --git a/DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h b/DDCore/include/DDSegmentation/PolarGridRPhi2.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/PolarGridRPhi2.h
rename to DDCore/include/DDSegmentation/PolarGridRPhi2.h
diff --git a/DDSegmentation/include/DDSegmentation/ProjectiveCylinder.h b/DDCore/include/DDSegmentation/ProjectiveCylinder.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/ProjectiveCylinder.h
rename to DDCore/include/DDSegmentation/ProjectiveCylinder.h
diff --git a/DDSegmentation/include/DDSegmentation/Segmentation.h b/DDCore/include/DDSegmentation/Segmentation.h
similarity index 97%
rename from DDSegmentation/include/DDSegmentation/Segmentation.h
rename to DDCore/include/DDSegmentation/Segmentation.h
index b3d0c7277..fdbbbd40c 100644
--- a/DDSegmentation/include/DDSegmentation/Segmentation.h
+++ b/DDCore/include/DDSegmentation/Segmentation.h
@@ -154,9 +154,9 @@ protected:
 	/// The description of the segmentation
 	std::string _description;
 	/// The parameters for this segmentation
-	std::map<std::string, Parameter> _parameters;
+	std::map<std::string, Parameter> _parameters;   //! No ROOT persistency
 	/// The indices used for the encoding
-	std::map<std::string, StringParameter> _indexIdentifiers;
+	std::map<std::string, StringParameter> _indexIdentifiers;   //! No ROOT persistency
 	/// The cell ID encoder and decoder
 	mutable BitField64* _decoder = 0;    //! Not ROOT persistent
 	/// Keeps track of the decoder ownership
diff --git a/DDSegmentation/include/DDSegmentation/SegmentationFactory.h b/DDCore/include/DDSegmentation/SegmentationFactory.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/SegmentationFactory.h
rename to DDCore/include/DDSegmentation/SegmentationFactory.h
diff --git a/DDSegmentation/include/DDSegmentation/SegmentationParameter.h b/DDCore/include/DDSegmentation/SegmentationParameter.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/SegmentationParameter.h
rename to DDCore/include/DDSegmentation/SegmentationParameter.h
diff --git a/DDSegmentation/include/DDSegmentation/SegmentationUtil.h b/DDCore/include/DDSegmentation/SegmentationUtil.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/SegmentationUtil.h
rename to DDCore/include/DDSegmentation/SegmentationUtil.h
diff --git a/DDSegmentation/include/DDSegmentation/TiledLayerGridXY.h b/DDCore/include/DDSegmentation/TiledLayerGridXY.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/TiledLayerGridXY.h
rename to DDCore/include/DDSegmentation/TiledLayerGridXY.h
diff --git a/DDSegmentation/include/DDSegmentation/TiledLayerSegmentation.h b/DDCore/include/DDSegmentation/TiledLayerSegmentation.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/TiledLayerSegmentation.h
rename to DDCore/include/DDSegmentation/TiledLayerSegmentation.h
diff --git a/DDSegmentation/include/DDSegmentation/WaferGridXY.h b/DDCore/include/DDSegmentation/WaferGridXY.h
similarity index 100%
rename from DDSegmentation/include/DDSegmentation/WaferGridXY.h
rename to DDCore/include/DDSegmentation/WaferGridXY.h
diff --git a/DDCore/src/DD4hepRootPersistency.cpp b/DDCore/src/DD4hepRootPersistency.cpp
index f8e5b096b..9d34fae43 100644
--- a/DDCore/src/DD4hepRootPersistency.cpp
+++ b/DDCore/src/DD4hepRootPersistency.cpp
@@ -14,27 +14,77 @@
 // Framework include files
 #include "DD4hep/Printout.h"
 #include "DD4hep/DD4hepRootPersistency.h"
+#include "DD4hep/detail/ObjectsInterna.h"
+#include "DD4hep/detail/SegmentationsInterna.h"
 
 // ROOT include files
+#include "TClassStreamer.h"
+#include "TDataMember.h"
+#include "TClass.h"
 #include "TFile.h"
+#include "TROOT.h"
 
 ClassImp(DD4hepRootPersistency)
 
 using namespace dd4hep;
+using namespace std;
+
+namespace  {
+  void stream_opaque_datablock(TBuffer& b, void* obj)    {
+    if ( b.IsReading() )  {
+      printout(INFO,"OpaqueData","Streaming IN  opaque data object...");
+    }
+    else  {
+      printout(INFO,"OpaqueData","Streaming OUT opaque data object...");
+    }
+  }
+}
 
 int DD4hepRootPersistency::save(Detector& description, const char* fname, const char* instance)   {
   TFile* f = TFile::Open(fname,"RECREATE");
   if ( f && !f->IsZombie()) {
     DD4hepRootPersistency* persist = new DD4hepRootPersistency();
-    persist->adoptData(dynamic_cast<DetectorData&>(description));
+    persist->m_data = new dd4hep::DetectorData();
+    persist->m_data->adoptData(dynamic_cast<DetectorData&>(description),false);
+    for( const auto& s : persist->m_data->m_sensitive )  {
+      dd4hep::SensitiveDetector sd = s.second;
+      dd4hep::Readout ro = sd.readout();
+      if ( ro.isValid() && ro.segmentation().isValid() )  {
+        persist->m_segments[ro].first  = ro.idSpec();
+        persist->m_segments[ro].second = ro.segmentation().segmentation();
+      }
+    }
+
+    TClass* opaqueCl = gROOT->GetClass("dd4hep::OpaqueDataBlock");
+    if ( 0 == opaqueCl )  {
+      printout(ERROR,"DD4hepRootPersistency","+++ Missing TClass for 'dd4hep::OpaqueDataBlock'.");
+      return 0;
+    }
+    if ( 0 == opaqueCl->GetStreamer() )  {
+      opaqueCl->AdoptStreamer(new TClassStreamer(stream_opaque_datablock));
+      printout(ALWAYS,"DD4hepRootPersistency","+++ Set Streamer to %s",opaqueCl->GetName());
+    }
+    TDataMember* m = 0;
+    TClass* volCl = TGeoVolume::Class();
+    printout(ALWAYS,"DD4hepRootPersistency","+++ Patching %s.fUserExtension to persistent",volCl->GetName());    
+    m = volCl->GetDataMember("fUserExtension");
+    m->SetTitle(m->GetTitle()+2);
+    m->SetBit(BIT(2));
+    TClass* nodCl = TGeoNode::Class();
+    printout(ALWAYS,"DD4hepRootPersistency","+++ Patching %s.fUserExtension to persistent",nodCl->GetName());    
+    m = nodCl->GetDataMember("fUserExtension");
+    m->SetTitle(m->GetTitle()+2);
+    m->SetBit(BIT(2));
+    
+    /// Now we write the object
     int nBytes = persist->Write(instance);
     f->Close();
     printout(ALWAYS,"DD4hepRootPersistency",
-                     "+++ Wrote %d Bytes of geometry data '%s' to '%s'.",
-                     nBytes, instance, fname);
+             "+++ Wrote %d Bytes of geometry data '%s' to '%s'.",
+             nBytes, instance, fname);
     if ( nBytes > 0 )  {
       printout(ALWAYS,"DD4hepRootPersistency",
-                       "+++ Successfully saved geometry data to file.");
+               "+++ Successfully saved geometry data to file.");
     }
     delete f;
     delete persist;
@@ -45,19 +95,78 @@ int DD4hepRootPersistency::save(Detector& description, const char* fname, const
 }
 
 int DD4hepRootPersistency::load(Detector& description, const char* fname, const char* instance)  {
+
+  TClass* opaqueCl = gROOT->GetClass("dd4hep::OpaqueDataBlock");
+  if ( 0 == opaqueCl )  {
+    printout(ERROR,"DD4hepRootPersistency","+++ Missing TClass for 'dd4hep::OpaqueDataBlock'.");
+    return 0;
+  }
+  if ( 0 == opaqueCl->GetStreamer() )  {
+    opaqueCl->AdoptStreamer(new TClassStreamer(stream_opaque_datablock));
+    printout(ALWAYS,"DD4hepRootPersistency","+++ Set Streamer to %s",opaqueCl->GetName());
+  }
+  TDataMember* m = 0;
+  TClass* volCl = TGeoVolume::Class();
+  printout(ALWAYS,"DD4hepRootPersistency","+++ Patching %s.fUserExtension to persistent",volCl->GetName());    
+  m = volCl->GetDataMember("fUserExtension");
+  m->SetTitle(m->GetTitle()+2);
+  m->SetBit(BIT(2));
+  TClass* nodCl = TGeoNode::Class();
+  printout(ALWAYS,"DD4hepRootPersistency","+++ Patching %s.fUserExtension to persistent",nodCl->GetName());    
+  m = nodCl->GetDataMember("fUserExtension");
+  m->SetTitle(m->GetTitle()+2);
+  m->SetBit(BIT(2));
+
+
   TFile* f = TFile::Open(fname);
   if ( f && !f->IsZombie()) {
     DD4hepRootPersistency* persist = (DD4hepRootPersistency*)f->Get(instance);
     if ( persist )   {
       DetectorData& data = dynamic_cast<DetectorData&>(description);
-      data.adoptData(*persist);
-      persist->clearData();
+      DetectorData* target = persist->m_data;
+      for( const auto& s : target->m_idDict )  {
+        IDDescriptor id = s.second;
+        id.rebuild(id->description);
+      }
+      printout(ALWAYS,"DD4hepRootPersistency",
+               "+++ Fixed %ld IDDescriptor objects.",target->m_idDict.size());
+      for( const auto& s : persist->m_segments )  {
+        Readout ro = s.first;
+        IDDescriptor id = s.second.first;
+        DDSegmentation::Segmentation* seg = s.second.second;
+        ro.setSegmentation(Segmentation(seg->type(),seg->name(),id.decoder()));
+        delete seg;
+      }
+      printout(ALWAYS,"DD4hepRootPersistency",
+               "+++ Fixed %ld segmentation objects.",persist->m_segments.size());
+      persist->m_segments.clear();
+
+      const auto& sdets = persist->volumeManager()->subdetectors;
+      for( const auto& vm : sdets )  {
+        DetElement det = vm.first;
+        VolumeManager::Object* obj = vm.second.ptr();
+        obj->system = obj->id.field("system");
+        if ( 0 != obj->system )   {
+          printout(ALWAYS,"DD4hepRootPersistency",
+                   "+++ Fixed VolumeManager.system for '%s'.",
+                   det.path().c_str());
+          continue;
+        }
+        printout(ALWAYS,"DD4hepRootPersistency",
+                 "+++ FAILED to fix VolumeManager.system for '%s: %s'.",
+                 det.path().c_str(), "[No IDDescriptor field 'system']");
+      }
+      
+      data.adoptData(*target);
+      target->clearData();
       delete persist;
+      printout(ALWAYS,"DD4hepRootPersistency",
+               "+++ Successfully loaded detector description from file:%s",fname);
       return 1;
     }
     printout(ERROR,"DD4hepRootPersistency",
-                     "+++ Cannot Cannot load instance '%s' from file '%s'.",
-                     instance, fname);
+             "+++ Cannot Cannot load instance '%s' from file '%s'.",
+             instance, fname);
     f->ls();
     delete f;
     return 0;
@@ -67,69 +176,334 @@ int DD4hepRootPersistency::load(Detector& description, const char* fname, const
 }
 
 namespace {
-  int printDetElement(DetElement d)  {
-    const DetElement::Children& children = d.children();
-    int count = 1;
-    printout(INFO,"checkDetector","+++ %-40s Level:%3d Key:%08X VolID:%016llX",
-             d.name(), d.level(), d.key(), d.volumeID());
-    for( const auto& c : children )
-      count += printDetElement(c.second);
-    return count;
-  }
-  void checkDetector(DetElement d)   {
-    printout(INFO,"checkDetector","+++ Checking Sub-Detector: %-40s Key:%08X VolID:%016llX",
-             d.name(), d.key(), d.volumeID());
-    int count = printDetElement(d);
-  }
+
+  class PersistencyChecks  {
+
+  public:
+    
+    size_t errors = 0;
+
+    /// Default constructor
+    PersistencyChecks() = default;
+
+    size_t checkConstant(const std::pair<string,Constant>& obj)  {
+      if ( obj.first.empty() || obj.second->name.empty() )  {
+        printout(ERROR,"chkConstant","+++ Invalid constant: key error %s <> %s [%s]",
+                 obj.first.c_str(), obj.second->GetName(), obj.second->GetTitle());
+        ++errors;
+        return 0;
+      }
+      if ( obj.first != obj.second->GetName() )  {
+        printout(ERROR,"chkConstant","+++ Invalid constant: key error %s <> %s [%s]",
+                 obj.first.c_str(), obj.second->GetName(), obj.second->GetTitle());
+        ++errors;
+        return 0;
+      }
+      return 1;
+    }
+    
+    size_t checkProperty(const std::pair<string,map<string,string> >& obj)  {
+      if ( obj.first.empty() || obj.second.empty() )  {
+        printout(ERROR,"chkProperty","+++ Emptty property set: %s",obj.first.c_str());
+        ++errors;
+        return 0;
+      }
+      return 1;
+    }
+    
+    size_t printDetElement(DetElement d)  {
+      const DetElement::Children& children = d.children();
+      size_t count = 1;
+      printout(INFO,"chkDetector","+++ %-40s Level:%3d Key:%08X VolID:%016llX",
+               d.name(), d.level(), d.key(), d.volumeID());
+      Alignment ideal = d.nominal();
+      if ( ideal.isValid() )  {
+        const Delta& delta = ideal.delta();
+        printout(INFO,"chkDetector","+++     Ideal: %s  Delta:%s--%s--%s",
+                 yes_no(ideal.isValid()),
+                 delta.hasTranslation() ? "Translation" : "         ",
+                 delta.hasRotation()    ? "Rotation"    : "        ",
+                 delta.hasPivot()       ? "Pivot"       : "    "
+                 );
+        //ideal.worldTransformation().Print();
+      }
+      else  {
+        printout(INFO,"chkDetector","+++     Ideal: %s",yes_no(ideal.isValid()));
+      }
+      for( const auto& c : children )
+        count += printDetElement(c.second);
+      return count;
+    }
+
+    size_t checkDetector(DetElement d)   {
+      printout(INFO,"chkDetector","+++ Checking Sub-Detector: %-40s Key:%08X VolID:%016llX",
+               d.name(), d.key(), d.volumeID());
+      return printDetElement(d);
+    }
+
+
+    size_t checkSensitive(SensitiveDetector d)   {
+      printout(INFO,"chkDetector","+++ Checking SensitiveDetector: %-30s %-16s CombineHits:%s ecut:%g Collection:%s",
+               d.name(), ("["+d.type()+"]").c_str(),
+               yes_no(d.combineHits()), d.energyCutoff(), d.hitsCollection().c_str());
+      Readout ro = d.readout();
+      if ( !ro.isValid() )  {
+        printout(ERROR,"chkDetector",
+                 "+++ FAILED   SensitiveDetector:%s No Readout Stricture attached.",
+                 ro.name());
+        ++errors;
+        return 0;
+      }
+      if ( ro.isValid() )  {
+        if ( !checkReadout(ro) )  {
+          return 0;
+        }
+      }
+      return 1;
+    }
+
+    size_t checkReadout(Readout ro)  {
+      size_t ret = 1;
+      printout(INFO,"chkReadOut","+++ Checking Readout: %s Collection No:%ld IDspec:%s",
+               ro.name(), ro.numCollections(), yes_no(ro.idSpec().isValid()));
+      IDDescriptor id = ro.idSpec();
+      if ( id.isValid() )  {
+        if ( !checkIDDescriptor(id) ) ret = 0;
+      }
+      else  {
+        printout(ERROR,"chkReadOut",
+                 "+++ FAILED   Segmentation: %s Found readout without ID descriptor!",
+                 ro.name());
+        ++errors;
+        ret = 0;
+      }
+      Segmentation sg = ro.segmentation();
+      if ( sg.isValid() )  {
+        DDSegmentation::Segmentation* seg = sg.segmentation();
+        if ( !checkSegmentation(sg) )  {
+          ret = 0;
+        }
+        if ( id.isValid() && seg && id.decoder() != sg.decoder() )  {
+          printout(ERROR,"chkReadOut","+++ FAILED   Decoder ERROR:%p != %p",
+                   (void*)seg->decoder(), (void*)id.decoder());
+          ++errors;
+          ret = 0;
+        }        
+      }
+      return ret;
+    }
+
+    size_t checkSegmentation(Segmentation sg)  {
+      DDSegmentation::Segmentation* seg = sg.segmentation();
+      if ( seg )  {
+        size_t ret = 1;
+        printout(INFO,"chkSegment","+++ Checking Segmentation: %-24s [%s] DDSegmentation:%p  Decoder:%p",
+                 sg.name(), seg->type().c_str(),(void*)seg, seg->decoder());
+        const auto& pars = seg->parameters();
+        for ( const auto& p : pars )   {
+          printout(INFO,"chkSegment","+++             Param:%-24s  -> %-16s  [%s] opt:%s",
+                   p->name().c_str(), p->value().c_str(), p->type().c_str(),
+                   yes_no(p->isOptional()));
+            
+        }
+        if ( pars.empty() )   {
+          printout(ERROR,"chkSegment",
+                   "+++ FAILED   Segmentation: %s Found readout with invalid [EMPTY] ID descriptor!",
+                   sg.name());
+          ++errors;
+          ret = 0;
+        }
+        if ( !seg->decoder() )   {
+          printout(ERROR,"chkSegment","+++ FAILED   Segmentation: %s  NO Decoder!!!",
+                   sg.name());
+          ++errors;
+          ret = 0;
+        }
+        return ret;
+      }
+      printout(ERROR,"chkSegment","+++ FAILED   Segmentation: %s  NO DDSegmentation",
+               sg.name());
+      ++errors;
+      return 0;
+    }
+
+    size_t checkIDDescriptor(IDDescriptor id)   {
+      const IDDescriptor::FieldMap& fields = id.fields();
+      printout(INFO,"chkIDDescript","+++ Checking IDDesc:  %s decoder:%p",
+               id->GetName(), (void*)id.decoder());
+      printout(INFO,"chkIDDescript","+++             Specs:%s",id.fieldDescription().c_str());
+      for( const auto& f : fields )
+        printout(INFO,"chkIDDescript","+++             Field:%-24s  -> %016llX  %3d %3d [%d,%d]",
+                 f.first.c_str(), f.second->mask(), f.second->offset(), f.second->width(),
+                 f.second->minValue(), f.second->maxValue());
+      if ( fields.empty() )   {
+        printout(ERROR,"chkIDDescript",
+                 "+++ FAILED   IDDescriptor: %s Found invalid [EMPTY] ID descriptor!",
+                 id.name());
+        ++errors;
+        return 0;
+      }
+      return 1;
+    }
+
+    size_t checkLimitset(LimitSet ls)   {
+      printout(INFO,"chkLimitSet","+++ Checking Limits:  %s Num.Limiits:%ld",
+               ls.name(), ls.limits().size());
+      return 1;
+    }
+
+    size_t checkRegion(Region ls)   {
+      printout(INFO,"chkRegion","+++ Checking Limits:  %s Num.Limiits:%ld",
+               ls.name(), ls.limits().size());
+      return 1;
+    }
+
+    size_t checkField(CartesianField fld)   {
+      printout(INFO,"chkField","+++ Checking Field:  %s",
+               fld.name());
+      return 1;
+    }
+  };
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkDetectors()  const   {
-  const auto& dets = object->detectors();
-  for( const auto& d : dets )
-    checkDetector(d.second);
-  return *this;
+/// Check the collection of define statements
+size_t DD4hepRootCheck::checkConstants()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->constants() )
+    count += checks.checkConstant(obj);
+  printout(ALWAYS,"chkProperty","+++ Checked %ld Constant objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkMaterials()  const   {
-  return *this;
+/// Check detector description properties (string constants)
+size_t DD4hepRootCheck::checkProperties()   const   { 
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->properties() )
+    count += checks.checkProperty(obj);
+  printout(ALWAYS,"chkProperty","+++ Checked %ld Property objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkReadouts()   const   {
-  return *this;
+/// Call to check a Material object
+size_t DD4hepRootCheck::checkMaterials()  const   {
+  size_t count = 0;
+  printout(ALWAYS,"chkMaterials","+++ Check not implemented. Hence OK.");
+  return count;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkFields()   const   {
-  return *this;
+/// Call to check a Readout object
+size_t DD4hepRootCheck::checkReadouts()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->readouts() )
+    count += checks.checkReadout(obj.second);
+  printout(ALWAYS,"chkReadouts","+++ Checked %ld Readout objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkRegions()   const   {
-  return *this;
+/// Call to theck the DD4hep fields
+size_t DD4hepRootCheck::checkFields()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->fields() )
+    count += checks.checkField(obj.second);
+  printout(ALWAYS,"chkFields","+++ Checked %ld Field objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkIdSpecs()   const   {
-  return *this;
+/// Call to check a Region object
+size_t DD4hepRootCheck::checkRegions()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->regions() )
+    count += checks.checkRegion(obj.second);
+  printout(ALWAYS,"chkRegions","+++ Checked %ld Region objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkSensitives()   const   {
-  return *this;
+/// Call to check an ID specification
+size_t DD4hepRootCheck::checkIdSpecs()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->idSpecifications() )
+    count += checks.checkIDDescriptor(obj.second);
+  printout(ALWAYS,"chkReadouts","+++ Checked %ld Readout objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkLimitSets()   const   {
-  return *this;
+/// Call to check a top level Detector element (subdetector)
+size_t DD4hepRootCheck::checkDetectors()  const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->detectors() )
+    count += checks.checkDetector(obj.second);
+  printout(ALWAYS,"chkDetectors","+++ Checked %ld DetElement objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkVolManager()   const   {
-  return *this;
+/// Call to check a sensitive detector
+size_t DD4hepRootCheck::checkSensitives()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+  for( const auto& obj : object->sensitiveDetectors() )
+    count += checks.checkSensitive(obj.second);
+  printout(ALWAYS,"chkSensitives","+++ Checked %ld SensitiveDetector objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkDefines()   const   {
-  return *this;
+/// Call to check a limit-set object
+size_t DD4hepRootCheck::checkLimitSets()   const   {
+  PersistencyChecks checks;
+  size_t count = 0;
+  for( const auto& obj : object->limitsets() )
+    count += checks.checkLimitset(obj.second);
+  printout(ALWAYS,"chkSensitives","+++ Checked %ld SensitiveDetector objects. Num.Errors: %ld",
+           count, checks.errors); 
+  return checks.errors;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkProperties()   const   {
-  return *this;
+/// Call to check the volume manager hierarchy
+size_t DD4hepRootCheck::checkVolManager()   const   {
+  const void* args[] = {"SiTrackerBarrel",0};
+  size_t count = object->apply("DD4hepVolumeMgrTest",1,(char**)args);
+  printout(ALWAYS,"chkVolumeMgr","+++ Checked %ld Volume objects.",count); 
+  return count;
 }
 
-const DD4hepRootCheck& DD4hepRootCheck::checkAll()   const   {
-  return *this;
+size_t DD4hepRootCheck::checkAll()   const   {
+  size_t count = 0;
+  PersistencyChecks checks;
+
+  count += checkMaterials();
+  for( const auto& obj : object->properties() )
+    count += checks.checkProperty(obj);
+  for( const auto& obj : object->constants() )
+    count += checks.checkConstant(obj);
+  for( const auto& obj : object->limitsets() )
+    count += checks.checkLimitset(obj.second);
+  for( const auto& obj : object->fields() )
+    count += checks.checkField(obj.second);
+  for( const auto& obj : object->regions() )
+    count += checks.checkRegion(obj.second);
+  for( const auto& obj : object->idSpecifications() )
+    count += checks.checkIDDescriptor(obj.second);
+  for( const auto& obj : object->detectors() )
+    count += checks.checkDetector(obj.second);
+  for( const auto& obj : object->sensitiveDetectors() )
+    count += checks.checkSensitive(obj.second);
+
+  count += checkVolManager();
+  printout(ALWAYS,"chkAll","+++ Checked %ld objects. Num.Errors:%ld",
+           count, checks.errors);
+  return count;
 }
diff --git a/DDCore/src/DetectorData.cpp b/DDCore/src/DetectorData.cpp
index 9a2534876..6f2559c9f 100644
--- a/DDCore/src/DetectorData.cpp
+++ b/DDCore/src/DetectorData.cpp
@@ -104,7 +104,7 @@ void DetectorData::clearData()   {
 }
 
 /// Adopt all data from source structure
-void DetectorData::adoptData(DetectorData& source)   {
+void DetectorData::adoptData(DetectorData& source, bool clr)   {
   m_inhibitConstants = source.m_inhibitConstants;
   m_extensions.move(source.m_extensions);
   m_manager        = source.m_manager;
@@ -131,5 +131,5 @@ void DetectorData::adoptData(DetectorData& source)   {
   m_properties     = source.m_properties;
   //m_extensions     = source.m_extensions;
   m_volManager     = source.m_volManager;
-  source.clearData();
+  if ( clr ) source.clearData();
 }
diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp
index 9cf0aa540..b2a6fbf4c 100644
--- a/DDCore/src/IDDescriptor.cpp
+++ b/DDCore/src/IDDescriptor.cpp
@@ -26,7 +26,7 @@ using namespace dd4hep::detail;
 
 namespace {
   void _construct(IDDescriptor::Object* o, const string& dsc) {
-    BitField64& bf = *o;
+    BitField64& bf = o->decoder;
     o->fieldIDs.clear();
     o->fieldMap.clear();
     o->description = dsc;
@@ -39,17 +39,19 @@ namespace {
 }
 
 /// Initializing constructor
-IDDescriptor::IDDescriptor(const string& description) {
+IDDescriptor::IDDescriptor(const string& nam, const string& description) {
   Object* obj = new Object(description);
-  assign(obj, description, "iddescriptor");
+  assign(obj, nam, "iddescriptor");
   _construct(obj, description);
 }
 
 /// Re-build object in place
 void IDDescriptor::rebuild(const string& description)   {
   Object* p = ptr();
-  p->~Object();
-  new(p) Object(description);
+  string  dsc = description;
+  p->decoder.~BitField64();
+  new(&p->decoder) BitField64(dsc);
+  _construct(p, dsc);
 }
 
 /// Acces string representation
@@ -61,13 +63,13 @@ string IDDescriptor::toString() const {
 }
 
 std::string IDDescriptor::fieldDescription() const {
-  BitField64* bf = data<Object>();
-  return bf->fieldDescription();
+  BitField64& bf = data<Object>()->decoder;
+  return bf.fieldDescription();
 }
 
 /// The total number of encoding bits for this descriptor
 unsigned IDDescriptor::maxBit() const {
-  return data<Object>()->highestBit();
+  return data<Object>()->decoder.highestBit();
 }
 
 /// Access the field-id container
@@ -133,7 +135,7 @@ VolumeID IDDescriptor::encode(const std::vector<std::pair<std::string, int> >& i
 void IDDescriptor::decodeFields(VolumeID vid,
                                 vector<pair<const BitFieldValue*, VolumeID> >& flds)  const
 {
-  const vector<BitFieldValue*>& v = access()->fields();
+  const vector<BitFieldValue*>& v = access()->decoder.fields();
   flds.clear();
   for (auto f : v )
     flds.push_back(make_pair(f, f->value(vid)));
@@ -141,7 +143,7 @@ void IDDescriptor::decodeFields(VolumeID vid,
 
 /// Decode volume IDs and return string reprensentation for debugging purposes
 string IDDescriptor::str(VolumeID vid)   const {
-  const vector<BitFieldValue*>& v = access()->fields();
+  const vector<BitFieldValue*>& v = access()->decoder.fields();
   stringstream str;
   for (auto f : v )
     str << f->name() << ":" << setw(4) << setfill('0') << hex << right << f->value(vid)
@@ -151,7 +153,7 @@ string IDDescriptor::str(VolumeID vid)   const {
 
 /// Decode volume IDs and return string reprensentation for debugging purposes
 string IDDescriptor::str(VolumeID vid, VolumeID mask)   const {
-  const vector<BitFieldValue*>& v = access()->fields();
+  const vector<BitFieldValue*>& v = access()->decoder.fields();
   stringstream str;
   for (auto f : v )  {
     if ( 0 == (mask&f->mask()) ) continue;
@@ -163,5 +165,5 @@ string IDDescriptor::str(VolumeID vid, VolumeID mask)   const {
 
 /// Access the BitField64 object
 BitField64* IDDescriptor::decoder() {
-  return data<Object>();
+  return &(data<Object>()->decoder);
 }
diff --git a/DDCore/src/ObjectsInterna.cpp b/DDCore/src/ObjectsInterna.cpp
index e116552c4..6f82b1c00 100644
--- a/DDCore/src/ObjectsInterna.cpp
+++ b/DDCore/src/ObjectsInterna.cpp
@@ -115,13 +115,13 @@ DD4HEP_INSTANTIATE_HANDLE_NAMED(IDDescriptorObject);
 
 /// Standard constructor
 IDDescriptorObject::IDDescriptorObject()
-  : NamedObject(), BitField64()   {
+  : NamedObject(), decoder()   {
   InstanceCount::increment(this);
 }
 
 /// Standard constructor
 IDDescriptorObject::IDDescriptorObject(const std::string& desc)
-  : NamedObject(), BitField64(desc)   {
+  : NamedObject(), decoder(desc)   {
   InstanceCount::increment(this);
 }
 
diff --git a/DDCore/src/OpaqueData.cpp b/DDCore/src/OpaqueData.cpp
index bef75a5a1..5057469da 100644
--- a/DDCore/src/OpaqueData.cpp
+++ b/DDCore/src/OpaqueData.cpp
@@ -57,26 +57,27 @@ const string& OpaqueData::dataType() const   {
 }
 
 /// Standard initializing constructor
-OpaqueDataBlock::OpaqueDataBlock() : OpaqueData(), destruct(0), copy(0), type(0)   {
+OpaqueDataBlock::OpaqueDataBlock() : OpaqueData(), /*destruct(0), copy(0),*/ type(0)   {
   InstanceCount::increment(this);
 }
 
 /// Copy constructor
 OpaqueDataBlock::OpaqueDataBlock(const OpaqueDataBlock& c) 
-  : OpaqueData(c), destruct(c.destruct), copy(c.copy), type(c.type)   {
+  : OpaqueData(c), /*destruct(c.destruct), copy(c.copy), */type(c.type)   {
   grammar = 0;
   pointer = 0;
-  this->bind(c.grammar,c.copy,c.destruct);
-  this->copy(pointer,c.pointer);
+  this->bind(c.grammar,0,0/*c.copy,c.destruct*/);
+  this->grammar->copy(pointer,c.pointer);
   InstanceCount::increment(this);
 }
 
 /// Standard Destructor
 OpaqueDataBlock::~OpaqueDataBlock()   {
-  if ( destruct )  {
-    (*destruct)(pointer);
+  //if ( destruct )  {
+  //(*destruct)(pointer);
+  grammar->destruct(pointer);
     if ( (type&ALLOC_DATA) == ALLOC_DATA ) ::operator delete(pointer);
-  }
+    //}
   pointer = 0;
   grammar = 0;
   InstanceCount::decrement(this);
@@ -87,13 +88,13 @@ bool OpaqueDataBlock::move(OpaqueDataBlock& from)   {
   pointer = from.pointer;
   grammar = from.grammar;
   ::memcpy(data,from.data,sizeof(data));
-  destruct = from.destruct;
-  copy = from.copy;
+  //destruct = from.destruct;
+  //copy = from.copy;
   type = from.type;
   ::memset(from.data,0,sizeof(data));
   from.type = PLAIN_DATA;
-  from.destruct = 0;
-  from.copy = 0;
+  //from.destruct = 0;
+  //from.copy = 0;
   from.pointer = 0;
   from.grammar = 0;
   return true;
@@ -103,21 +104,22 @@ bool OpaqueDataBlock::move(OpaqueDataBlock& from)   {
 OpaqueDataBlock& OpaqueDataBlock::operator=(const OpaqueDataBlock& c)   {
   if ( this != &c )  {
     if ( this->grammar == c.grammar )   {
-      if ( destruct )  {
-        (*destruct)(pointer);
+      //if ( destruct )  {
+      //(*destruct)(pointer);
+  grammar->destruct(pointer);
         if ( (type&ALLOC_DATA) == ALLOC_DATA ) ::operator delete(pointer);
       }
       pointer = 0;
       grammar = 0;
-    }
+      //}
     if ( this->grammar == 0 )  {
       this->OpaqueData::operator=(c);
-      this->destruct = c.destruct;
-      this->copy = c.copy;
+      //this->destruct = c.destruct;
+      //this->copy = c.copy;
       this->type = c.type;
       this->grammar = 0;
-      this->bind(c.grammar,c.copy,c.destruct);
-      this->copy(pointer,c.pointer);
+      this->bind(c.grammar,0,0/*c.copy,c.destruct*/);
+      this->grammar->copy(pointer,c.pointer);
       return *this;
     }
     except("OpaqueData","You may not bind opaque data multiple times!");
@@ -130,8 +132,8 @@ bool OpaqueDataBlock::bind(const BasicGrammar* g, void (*ctor)(void*,const void*
   if ( !grammar )  {
     size_t len = g->sizeOf();
     grammar  = g;
-    destruct = dtor;
-    copy     = ctor;
+    //destruct = dtor;
+    //copy     = ctor;
     (len > sizeof(data))
       ? (pointer=::operator new(len),type=ALLOC_DATA)
       : (pointer=data,type=PLAIN_DATA);
@@ -151,8 +153,8 @@ bool OpaqueDataBlock::bind(void* ptr, size_t size, const BasicGrammar* g, void (
   if ( !grammar )  {
     size_t len = g->sizeOf();
     grammar  = g;
-    destruct = dtor;
-    copy     = ctor;
+    //destruct = dtor;
+    //copy     = ctor;
     if ( len <= size )
       pointer=ptr, type=STACK_DATA;
     else if ( len <= sizeof(data) )
@@ -178,5 +180,5 @@ void OpaqueDataBlock::assign(const void* ptr, const type_info& typ)  {
   else if ( grammar->type() != typ )  {
     except("OpaqueData","Bad data binding binding");
   }
-  (*copy)(pointer,ptr);
+  grammar->copy(pointer,ptr);
 }
diff --git a/DDCore/src/Segmentations.cpp b/DDCore/src/Segmentations.cpp
index 7b5a807a7..a44be3509 100644
--- a/DDCore/src/Segmentations.cpp
+++ b/DDCore/src/Segmentations.cpp
@@ -43,6 +43,11 @@ Segmentation::Segmentation(const string& typ, const string& nam, BitField64* dec
   except("Segmentation","FAILED to create segmentation: %s. [Missing factory]",typ.c_str());
 }
 
+/// Accessor: Segmentation type
+const char* Segmentation::name() const {
+  return data<Object>()->name().c_str();
+}
+
 /// Accessor: Segmentation type
 std::string Segmentation::type() const {
   return data<Object>()->type();
diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index 6a0fb02a2..4be2a4521 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -627,7 +627,7 @@ template <> void Converter<Segmentation>::operator()(xml_h seg) const {
   string name = seg.hasAttr(_U(name)) ? seg.attr<string>(_U(name)) : string();
   std::pair<Segmentation,IDDescriptor>* opt = _option<pair<Segmentation,IDDescriptor> >();
 
-  BitField64* bitfield = opt->second.ptr();
+  BitField64* bitfield = &opt->second->decoder;
   Segmentation segment(type, name, bitfield);
   if ( segment.isValid() ) {
     const DDSegmentation::Parameters& pars = segment.parameters();
@@ -717,8 +717,7 @@ template <> void Converter<Readout>::operator()(xml_h e) const {
   
   if (id) {
     //  <id>system:6,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id>
-    opt.second = IDDescriptor(id.text());
-    opt.second->SetName(ro.name());
+    opt.second = IDDescriptor(name,id.text());
     description.addIDSpecification(opt.second);
   }
   if (seg) {   // Segmentation is not mandatory!
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 9046a3885..4501bb1fe 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -94,6 +94,10 @@ DECLARE_APPLY(DD4hepGeometryDisplay,display)
 static long run_interpreter(Detector& /* description */, int argc, char** argv) {
   pair<int, char**> a(argc,argv);
   TRint app("dd4hep", &a.first, a.second);
+  for(int i=0; i<argc; ++i)   {
+    printout(INFO,"DD4hepRint","Excecute[%d]: %s",i,argv[i]);
+    gInterpreter->ProcessLine(argv[i]);
+  }
   app.Run();
   return 1;
 }
@@ -532,6 +536,62 @@ static long load_geometryFromroot(Detector& description, int argc, char** argv)
 }
 DECLARE_APPLY(DD4hepRootLoader,load_geometryFromroot)
 
+/// Basic entry point to check sensitive detector strictures
+/**
+ *  Factory: DD4hepCheckSensitives
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long check_sensitives(Detector& description, int /* argc */, char** /* argv */) {
+  DD4hepRootCheck check(&description);
+  return check.checkSensitives();
+}
+DECLARE_APPLY(DD4hepCheckSensitives,check_sensitives)
+
+/// Basic entry point to check sensitive detector strictures
+/**
+ *  Factory: DD4hepCheckDetectors
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long check_detectors(Detector& description, int /* argc */, char** /* argv */) {
+  DD4hepRootCheck check(&description);
+  return check.checkDetectors();
+}
+DECLARE_APPLY(DD4hepCheckDetectors,check_detectors)
+
+/// Basic entry point to check sensitive detector strictures
+/**
+ *  Factory: DD4hepCheckReadouts
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long check_readouts(Detector& description, int /* argc */, char** /* argv */) {
+  DD4hepRootCheck check(&description);
+  return check.checkReadouts();
+}
+DECLARE_APPLY(DD4hepCheckReadouts,check_readouts)
+
+/// Basic entry point to check IDDescriptors of the detector object
+/**
+ *  Factory: DD4hepCheckIdspecs
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long check_idspecs(Detector& description, int /* argc */, char** /* argv */) {
+  DD4hepRootCheck check(&description);
+  return check.checkIdSpecs();
+}
+DECLARE_APPLY(DD4hepCheckIdspecs,check_idspecs)
+
 /// Basic entry point to print out the volume hierarchy
 /**
  *  Factory: DD4hepVolumeDump
diff --git a/DDCore/src/plugins/VolumeMgrTest.cpp b/DDCore/src/plugins/VolumeMgrTest.cpp
index 11d856566..8e01c1e65 100644
--- a/DDCore/src/plugins/VolumeMgrTest.cpp
+++ b/DDCore/src/plugins/VolumeMgrTest.cpp
@@ -53,17 +53,18 @@ namespace  {
     IDDescriptor  m_iddesc;
     VolumeManager m_mgr;
     DetElement    m_det;
-
+    size_t        m_errors = 0;
+    size_t        m_elements = 0;
     /// Initializing constructor
     VolIDTest(Detector& description, DetElement sdet, size_t depth);
     /// Default destructor
-    virtual ~VolIDTest() {}
+    virtual ~VolIDTest();
     /// Check volume integrity
-    void checkVolume(DetElement e, PlacedVolume pv, const VolIDs& child_ids, const Chain& chain)  const;
+    void checkVolume(DetElement e, PlacedVolume pv, const VolIDs& child_ids, const Chain& chain);
     /// Walk through tree of detector elements
     //void walk(DetElement de, VolIDs ids, const Chain& chain, size_t depth, size_t mx_depth)  const;
     /// Walk through tree of volume placements
-    void walkVolume(DetElement e, PlacedVolume pv, VolIDs ids, const Chain& chain, size_t depth, size_t mx_depth)  const;
+    void walkVolume(DetElement e, PlacedVolume pv, VolIDs ids, const Chain& chain, size_t depth, size_t mx_depth);
 
     /// Action routine to execute the test
     static long run(Detector& description,int argc,char** argv);
@@ -97,14 +98,26 @@ VolIDTest::VolIDTest(Detector& description, DetElement sdet, size_t depth) : m_m
   walkVolume(sdet, pv, ids, chain, 1, depth);
 }
 
+/// Default destructor
+VolIDTest::~VolIDTest()   {
+  if ( m_errors == 0 )
+    printout(ALWAYS,"VolIDTest","+++ PASSED: Checked %ld objects. Num.Errors:%ld",
+             m_elements, m_errors);
+  else
+    printout(ALWAYS,"VolIDTest","+++ FAILED: Checked %ld objects. Num.Errors:%ld",
+             m_elements, m_errors);
+}
+
 /// Check volume integrity
-void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs& child_ids, const Chain& chain)  const {
+void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs& child_ids, const Chain& chain)   {
   stringstream err, log;
   VolumeID     det_vol_id = detector.volumeID();
   VolumeID     vid = det_vol_id;
   DetElement   top_sdet, det_elem;
   VolumeManagerContext* mgr_ctxt = 0;
   
+  ++m_elements;
+
   try {
     vid       = m_iddesc.encode(child_ids);
     top_sdet  = m_mgr.lookupDetector(vid);
@@ -118,12 +131,14 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
             << " got "        << det_place.name() << " (" << (void*)det_place.ptr() << ")"
             << " instead of " << pv.name()        << " (" << (void*)pv.ptr()        << ") "
             << " vid:" << volumeID(vid);
+        ++m_errors;
       }
       else if ( top_sdet.ptr() != detector.ptr() )   {
         err << "VolumeMgrTest: Wrong associated sub-detector element vid="  << volumeID(vid)
             << " got "        << top_sdet.path() << " (" << (void*)top_sdet.ptr() << ") "
             << " instead of " << detector.path() << " (" << (void*)detector.ptr() << ")"
             << " vid:" << volumeID(vid);
+        ++m_errors;
       }
       else if ( !detail::tools::isParentElement(detector,det_elem) )   {
       // This is sort of a bit wischi-waschi.... 
@@ -131,23 +146,28 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
             << " got "        << det_elem.path() << " (" << (void*)det_elem.ptr() << ") "
             << " instead of " << detector.path() << " (" << (void*)detector.ptr() << ")"
             << " vid:" << volumeID(vid);
+        ++m_errors;
       }
       else if ( top_sdet.ptr() != m_det.ptr() )   {
         err << "VolumeMgrTest: Wrong associated detector "
             << " vid:" << volumeID(vid);
+        ++m_errors;
       }
     }
   }
   catch(const exception& ex) {
     err << "Lookup " << pv.name() << " id:" << volumeID(vid)
         << " path:" << detector.path() << " error:" << ex.what();
+    ++m_errors;
   }
+
   if ( pv.volume().isSensitive() || (0 != det_vol_id) )  {
     string id_desc;
     log << "Volume:"  << setw(50) << left << pv.name();
     if ( pv.volume().isSensitive() )  {
       IDDescriptor dsc = SensitiveDetector(pv.volume().sensitiveDetector()).readout().idSpec();
       log << " IDDesc:" << (char*)(dsc.ptr() == m_iddesc.ptr() ? "OK " : "BAD");
+      if ( dsc.ptr() != m_iddesc.ptr() ) ++m_errors;
     }
     else  {
       log << setw(11) << " ";
@@ -178,17 +198,21 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
         }
         for (size_t i = chain.size(); i > 0; --i)  {
           const TGeoMatrix* mat = chain[i-1]->GetMatrix();
-          ::printf("Placement [%d]  VolID:%s\t\t",int(i),chain[i-1].volIDs().str().c_str());
-          mat->Print();
+          if ( printLevel() <= INFO )  {
+            ::printf("Placement [%d]  VolID:%s\t\t",int(i),chain[i-1].volIDs().str().c_str());
+            mat->Print();
+          }
         }
-        ::printf("Computed Trafo (from placements):\t\t");
-        trafo.Print();
         det_elem  = m_mgr.lookupDetElement(vid);
-        ::printf("DetElement Trafo: %s [%s]\t\t",
-                 det_elem.path().c_str(),volumeID(det_elem.volumeID()).c_str());
-        det_elem.nominal().worldTransformation().Print();
-        ::printf("VolumeMgr  Trafo: %s [%s]\t\t",det_elem.path().c_str(),volumeID(vid).c_str());
-        m_mgr.worldTransformation(m_mapping,vid).Print();
+        if ( printLevel() <= INFO )  {
+          ::printf("Computed Trafo (from placements):\t\t");
+          trafo.Print();
+          ::printf("DetElement Trafo: %s [%s]\t\t",
+                   det_elem.path().c_str(),volumeID(det_elem.volumeID()).c_str());
+          det_elem.nominal().worldTransformation().Print();
+          ::printf("VolumeMgr  Trafo: %s [%s]\t\t",det_elem.path().c_str(),volumeID(vid).c_str());
+          m_mgr.worldTransformation(m_mapping,vid).Print();
+        }
         if ( 0 == mgr_ctxt )  {
           printout(ERROR,m_det.name(),"VOLUME_MANAGER FAILED: Could not find entry for vid:%s.",
                    volumeID(vid).c_str());
@@ -200,9 +224,10 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
           int res2 = detail::matrix::_matrixEqual(trafo, m_mgr.worldTransformation(m_mapping,vid));
           if ( res1 != detail::matrix::MATRICES_EQUAL || res2 != detail::matrix::MATRICES_EQUAL )  {
             printout(ERROR,m_det.name(),"DETELEMENT_PLACEMENT FAILED: World transformation DIFFER.");
+            ++m_errors;
           }
           else  {
-            printout(ERROR,m_det.name(),"DETELEMENT_PLACEMENT: PASSED. All matrices equal: %s",
+            printout(INFO,m_det.name(),"DETELEMENT_PLACEMENT: PASSED. All matrices equal: %s",
                      volumeID(vid).c_str());
           }
         }
@@ -213,9 +238,10 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
           int res2 = detail::matrix::_matrixEqual(trafo, m_mgr.worldTransformation(m_mapping,vid));
           if ( res2 != detail::matrix::MATRICES_EQUAL )  {
             printout(ERROR,m_det.name(),"VOLUME_PLACEMENT FAILED: World transformation DIFFER.");
+            ++m_errors;
           }
           else  {
-            printout(ERROR,m_det.name(),"VOLUME_PLACEMENT: PASSED. All matrices equal: %s",
+            printout(INFO,m_det.name(),"VOLUME_PLACEMENT: PASSED. All matrices equal: %s",
                      volumeID(vid).c_str());
           }
         }
@@ -224,6 +250,7 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
     catch(const exception& ex) {
       err << "Matrix " << pv.name() << " id:" << volumeID(vid)
           << " path:" << detector.path() << " error:" << ex.what();
+      ++m_errors;
     }
     
   }
@@ -231,7 +258,7 @@ void VolIDTest::checkVolume(DetElement detector, PlacedVolume pv, const VolIDs&
 
 /// Walk through tree of detector elements
 void VolIDTest::walkVolume(DetElement detector, PlacedVolume pv, VolIDs ids, const Chain& chain,
-                           size_t depth, size_t mx_depth)  const
+                           size_t depth, size_t mx_depth)  
 {
   if ( depth <= mx_depth )  {
     const TGeoNode* current  = pv.ptr();
@@ -255,26 +282,7 @@ void VolIDTest::walkVolume(DetElement detector, PlacedVolume pv, VolIDs ids, con
     }
   }
 }
-#if 0
-/// Walk through tree of volume placements
-void VolIDTest::walk(DetElement detector, VolIDs ids, const Chain& chain, size_t depth, size_t mx_depth)  const   {
-  if ( depth <= mx_depth )  {
-    DetElement::Children::const_iterator i;
-    PlacedVolume pv = detector.placement();
-    VolIDs       child_ids(ids);
-    Chain        child_chain(chain);
-    VolumeID     det_vol_id   = detector.volumeID();
-    //bool         is_sensitive = pv.volume().isSensitive() || (0 != det_vol_id);
 
-    child_chain.push_back(pv);
-    child_ids.insert(child_ids.end(), pv.volIDs().begin(), pv.volIDs().end());
-    //if ( is_sensitive )  {
-    checkVolume(detector, pv, child_ids, child_chain);
-    //}
-    walkVolume(detector, pv, child_ids, child_chain, depth+1, mx_depth);
-  }
-}
-#endif
 /// Action routine to execute the test
 long VolIDTest::run(Detector& description,int argc,char** argv)    {
   printout(ALWAYS,"DD4hepVolumeMgrTest","++ Processing plugin...");
diff --git a/DDSegmentation/src/BitField64.cpp b/DDCore/src/segmentations/BitField64.cpp
similarity index 100%
rename from DDSegmentation/src/BitField64.cpp
rename to DDCore/src/segmentations/BitField64.cpp
diff --git a/DDSegmentation/src/CartesianGrid.cpp b/DDCore/src/segmentations/CartesianGrid.cpp
similarity index 100%
rename from DDSegmentation/src/CartesianGrid.cpp
rename to DDCore/src/segmentations/CartesianGrid.cpp
diff --git a/DDSegmentation/src/CartesianGridXY.cpp b/DDCore/src/segmentations/CartesianGridXY.cpp
similarity index 100%
rename from DDSegmentation/src/CartesianGridXY.cpp
rename to DDCore/src/segmentations/CartesianGridXY.cpp
diff --git a/DDSegmentation/src/CartesianGridXYZ.cpp b/DDCore/src/segmentations/CartesianGridXYZ.cpp
similarity index 100%
rename from DDSegmentation/src/CartesianGridXYZ.cpp
rename to DDCore/src/segmentations/CartesianGridXYZ.cpp
diff --git a/DDSegmentation/src/CartesianGridXZ.cpp b/DDCore/src/segmentations/CartesianGridXZ.cpp
similarity index 100%
rename from DDSegmentation/src/CartesianGridXZ.cpp
rename to DDCore/src/segmentations/CartesianGridXZ.cpp
diff --git a/DDSegmentation/src/CartesianGridYZ.cpp b/DDCore/src/segmentations/CartesianGridYZ.cpp
similarity index 100%
rename from DDSegmentation/src/CartesianGridYZ.cpp
rename to DDCore/src/segmentations/CartesianGridYZ.cpp
diff --git a/DDSegmentation/src/CylindricalSegmentation.cpp b/DDCore/src/segmentations/CylindricalSegmentation.cpp
similarity index 100%
rename from DDSegmentation/src/CylindricalSegmentation.cpp
rename to DDCore/src/segmentations/CylindricalSegmentation.cpp
diff --git a/DDSegmentation/src/GridPhiEta.cpp b/DDCore/src/segmentations/GridPhiEta.cpp
similarity index 100%
rename from DDSegmentation/src/GridPhiEta.cpp
rename to DDCore/src/segmentations/GridPhiEta.cpp
diff --git a/DDSegmentation/src/GridRPhiEta.cpp b/DDCore/src/segmentations/GridRPhiEta.cpp
similarity index 100%
rename from DDSegmentation/src/GridRPhiEta.cpp
rename to DDCore/src/segmentations/GridRPhiEta.cpp
diff --git a/DDSegmentation/src/MegatileLayerGridXY.cpp b/DDCore/src/segmentations/MegatileLayerGridXY.cpp
similarity index 100%
rename from DDSegmentation/src/MegatileLayerGridXY.cpp
rename to DDCore/src/segmentations/MegatileLayerGridXY.cpp
diff --git a/DDSegmentation/src/MultiSegmentation.cpp b/DDCore/src/segmentations/MultiSegmentation.cpp
similarity index 100%
rename from DDSegmentation/src/MultiSegmentation.cpp
rename to DDCore/src/segmentations/MultiSegmentation.cpp
diff --git a/DDSegmentation/src/NoSegmentation.cpp b/DDCore/src/segmentations/NoSegmentation.cpp
similarity index 100%
rename from DDSegmentation/src/NoSegmentation.cpp
rename to DDCore/src/segmentations/NoSegmentation.cpp
diff --git a/DDSegmentation/src/PolarGrid.cpp b/DDCore/src/segmentations/PolarGrid.cpp
similarity index 100%
rename from DDSegmentation/src/PolarGrid.cpp
rename to DDCore/src/segmentations/PolarGrid.cpp
diff --git a/DDSegmentation/src/PolarGridRPhi.cpp b/DDCore/src/segmentations/PolarGridRPhi.cpp
similarity index 100%
rename from DDSegmentation/src/PolarGridRPhi.cpp
rename to DDCore/src/segmentations/PolarGridRPhi.cpp
diff --git a/DDSegmentation/src/PolarGridRPhi2.cpp b/DDCore/src/segmentations/PolarGridRPhi2.cpp
similarity index 100%
rename from DDSegmentation/src/PolarGridRPhi2.cpp
rename to DDCore/src/segmentations/PolarGridRPhi2.cpp
diff --git a/DDSegmentation/src/ProjectiveCylinder.cpp b/DDCore/src/segmentations/ProjectiveCylinder.cpp
similarity index 100%
rename from DDSegmentation/src/ProjectiveCylinder.cpp
rename to DDCore/src/segmentations/ProjectiveCylinder.cpp
diff --git a/DDSegmentation/src/Segmentation.cpp b/DDCore/src/segmentations/Segmentation.cpp
similarity index 94%
rename from DDSegmentation/src/Segmentation.cpp
rename to DDCore/src/segmentations/Segmentation.cpp
index daf6a66cb..0de2142f3 100644
--- a/DDSegmentation/src/Segmentation.cpp
+++ b/DDCore/src/segmentations/Segmentation.cpp
@@ -15,6 +15,7 @@
 #include <iomanip>
 
 namespace dd4hep {
+
   namespace DDSegmentation {
 
     using std::cerr;
@@ -37,12 +38,14 @@ namespace dd4hep {
 
     /// Destructor
     Segmentation::~Segmentation() {
+#if 0
       if (_ownsDecoder and _decoder != 0) {
         delete _decoder;
       }
       for (auto& p : _parameters)  {
         if ( p.second ) delete p.second;
       }
+#endif
       _parameters.clear();
     }
   
@@ -97,8 +100,7 @@ namespace dd4hep {
 
     /// Access to parameter by name
     Parameter Segmentation::parameter(const std::string& parameterName) const {
-      map<std::string, Parameter>::const_iterator it;
-      it = _parameters.find(parameterName);
+      map<std::string, Parameter>::const_iterator it = _parameters.find(parameterName);
       if (it != _parameters.end()) {
         return it->second;
       }
@@ -110,20 +112,15 @@ namespace dd4hep {
     /// Access to all parameters
     Parameters Segmentation::parameters() const {
       Parameters pars;
-      map<std::string, Parameter>::const_iterator it;
-      for (it = _parameters.begin(); it != _parameters.end(); ++it) {
-        pars.push_back(it->second);
-      }
+      for ( const auto& it : _parameters )
+        pars.push_back(it.second);
       return pars;
     }
 
     /// Set all parameters from an existing set of parameters
     void Segmentation::setParameters(const Parameters& pars) {
-      Parameters::const_iterator it;
-      for (it = pars.begin(); it != pars.end(); ++it) {
-        Parameter p = *it;
+      for ( const auto* p : pars )
         parameter(p->name())->value() = p->value();
-      }
     }
 
     /// Add a cell identifier to this segmentation. Used by derived classes to define their required identifiers
@@ -179,12 +176,9 @@ namespace dd4hep {
             << "of the segmentation";
         throw std::runtime_error(err.str());
       }
-
-
       std::vector<double>::const_iterator bin = std::upper_bound(cellBoundaries.begin(),
                                                                  cellBoundaries.end(),
                                                                  position-offset);
-
       // need to reduce found bin by one, because upper_bound works that way, lower_bound would not help
       return bin - cellBoundaries.begin() - 1 ;
 
diff --git a/DDSegmentation/src/SegmentationFactory.cpp b/DDCore/src/segmentations/SegmentationFactory.cpp
similarity index 100%
rename from DDSegmentation/src/SegmentationFactory.cpp
rename to DDCore/src/segmentations/SegmentationFactory.cpp
diff --git a/DDSegmentation/src/TiledLayerGridXY.cpp b/DDCore/src/segmentations/TiledLayerGridXY.cpp
similarity index 100%
rename from DDSegmentation/src/TiledLayerGridXY.cpp
rename to DDCore/src/segmentations/TiledLayerGridXY.cpp
diff --git a/DDSegmentation/src/TiledLayerSegmentation.cpp b/DDCore/src/segmentations/TiledLayerSegmentation.cpp
similarity index 100%
rename from DDSegmentation/src/TiledLayerSegmentation.cpp
rename to DDCore/src/segmentations/TiledLayerSegmentation.cpp
diff --git a/DDSegmentation/src/WaferGridXY.cpp b/DDCore/src/segmentations/WaferGridXY.cpp
similarity index 100%
rename from DDSegmentation/src/WaferGridXY.cpp
rename to DDCore/src/segmentations/WaferGridXY.cpp
diff --git a/DDParsersStandAlone/CMakeLists.txt b/DDParsersStandAlone/CMakeLists.txt
index 679a774b4..669f7799b 100644
--- a/DDParsersStandAlone/CMakeLists.txt
+++ b/DDParsersStandAlone/CMakeLists.txt
@@ -20,9 +20,9 @@ option(CMAKE_MACOSX_RPATH "Build with rpath on macos" ON)
 #-----------------------------------------------------------------------------------------------------
 #
 #  project version (Major,minor,patch)
-#  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-#  !! Use the same version numbers in DDSegmentation/CMakeLists.txt    !!
-#  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+#  !! Use the same version numbers as in DDSegmentation/CMakeLists.txt    !!
+#  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 #
 # project version
 SET( DD4hep_VERSION_MAJOR 0  )
diff --git a/DDSegmentation/CMakeLists.txt b/DDSegmentation/CMakeLists.txt
index dbc039d60..44c37e72d 100644
--- a/DDSegmentation/CMakeLists.txt
+++ b/DDSegmentation/CMakeLists.txt
@@ -27,15 +27,9 @@ SET_TARGET_PROPERTIES( DDSegmentation PROPERTIES VERSION ${DDSegmentation_VERSIO
 #if DDSegmentation is build as part of dd4hep
 if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) 
   SET ( DDSegmentation_LIBRARIES DDSegmentation  PARENT_SCOPE )
-  SET ( DDSegmentation_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/DDSegmentation/include PARENT_SCOPE )
   SET ( DDSEGMENTATION_LIBRARIES DDSegmentation  PARENT_SCOPE )
-  SET ( DDSEGMENTATION_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/DDSegmentation/include PARENT_SCOPE )
 endif()
 
-install(DIRECTORY include/DDSegmentation
-  DESTINATION include
-  PATTERN ".svn" EXCLUDE )
-
 install(TARGETS DDSegmentation
   RUNTIME DESTINATION bin
   LIBRARY DESTINATION lib
@@ -50,4 +44,3 @@ install(TARGETS DDSegmentation
 # Create the DDSegmentationConfig.cmake and DDSegmentationConfigVersion files
 configure_file(cmake/DDSegmentationConfig.cmake.in ${CMAKE_INSTALL_PREFIX}/DDSegmentationConfig.cmake)
 
-#install(FILES ${PROJECT_SOURCE_DIR}/DDSegmentationConfig.cmake DESTINATION . )
diff --git a/DDSegmentation/src/bla.cpp b/DDSegmentation/src/bla.cpp
new file mode 100644
index 000000000..e69de29bb
diff --git a/UtilityApps/CMakeLists.txt b/UtilityApps/CMakeLists.txt
index b58dbe9c5..dd0b84d5b 100644
--- a/UtilityApps/CMakeLists.txt
+++ b/UtilityApps/CMakeLists.txt
@@ -9,7 +9,7 @@
 #
 #==========================================================================
 dd4hep_package(UtilityApps
-  USES DDSegmentation DDCore
+  USES DDCore
       [ROOT REQUIRED COMPONENTS Geom]
   )
 #-----------------------------------------------------------------------------------
diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt
index 05fea071a..4521b9b64 100644
--- a/examples/CLICSiD/CMakeLists.txt
+++ b/examples/CLICSiD/CMakeLists.txt
@@ -58,14 +58,37 @@ dd4hep_add_test_reg( CLICSiD_check_overlaps_LONGTEST
                     --tolerance=0.1
   REGEX_PASS " Execution finished..." )
 #
-#  Test saving geometry to file
-dd4hep_add_test_reg( ClientTests_CLICSiD_Save_ROOT_LONGTEST
+#  Test saving geometry to ROOT file
+dd4hep_add_test_reg( CLICSiD_ROOT_Save_LONGTEST
   COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
   EXEC_ARGS  geoPluginRun
   -volmgr -destroy -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/compact.xml
   -plugin DD4hepGeometry2ROOT -output CLICSiD_geometry.root
   REGEX_PASS "\\+\\+\\+ Successfully saved geometry data to file.")
 #
+#  Test restoring geometry from ROOT file: Volume Manager
+dd4hep_add_test_reg( CLICSiD_ROOT_Restore_LONGTEST
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoPluginRun -print WARNING
+  -plugin DD4hepRootLoader CLICSiD_geometry.root
+  REGEX_PASS "\\+\\+\\+ Successfully loaded detector description from file")
+#
+#  Test restoring geometry from ROOT file: Volume Manager
+dd4hep_add_test_reg( CLICSiD_ROOT_Restore_VolMgr_LONGTEST
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoPluginRun -print WARNING
+  -plugin DD4hepRootLoader CLICSiD_geometry.root
+  -plugin DD4hepVolumeMgrTest SiTrackerBarrel
+  REGEX_PASS "\\+\\+\\+ PASSED: Checked 81306 objects. Num.Errors:0")
+#
+#  Test restoring geometry from ROOT file: Volume Manager
+dd4hep_add_test_reg( CLICSiD_ROOT_Restore_Sensitives_LONGTEST
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoPluginRun -print WARNING
+  -plugin DD4hepRootLoader CLICSiD_geometry.root
+  -plugin DD4hepCheckSensitives
+  REGEX_PASS "\\+\\+\\+ Checked 14 SensitiveDetector objects. Num.Errors: 0")
+#
 #---Geant4 Testsing-----------------------------------------------------------------
 #
 if (DD4HEP_USE_GEANT4)
-- 
GitLab