From 45921c08b003d5eefa1ac5c5872fa3f45eb3aed7 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Tue, 8 Nov 2016 15:52:01 +0100
Subject: [PATCH] 2016-11-08 M.Frank   - Improve conditions handling. Started
 to implement using simple telescope     detector from C.Burr.   - Add
 variable DD4HEP_LIBRARY_PATH to be used on MacOSX El Capitane     to overcome
 DYLD_LIBRARY_PATH protection issues.   - Fix to copy with negative(rebased)
 IDDDescriptor fields     (affects IDDDescriptor and VolumeManager).     2 New
 tests:     - ClientTests/Bitfield_SidesTest.xml to test readout string:      
 system:8,barrel:-2     - ClientTests/Bitfield_SidesTest2.xml to test readout
 string:       system:16,barrel:16:-5

---
 CMakeLists.txt                                |  13 +-
 DDAlign/src/plugins/AlignmentPlugins.cpp      |  12 +-
 DDCond/include/DDCond/ConditionsDataLoader.h  |   6 +-
 DDCond/include/DDCond/ConditionsInterna.h     |  16 +++
 DDCond/include/DDCond/ConditionsManager.h     |  13 ++
 DDCond/include/DDCond/ConditionsPool.h        |  10 +-
 DDCond/src/ConditionsInterna.cpp              |  59 +++++++--
 DDCond/src/ConditionsManager.cpp              |  25 +++-
 DDCond/src/plugins/ConditionsParser.cpp       |  16 +++
 DDCond/src/plugins/ConditionsPlugins.cpp      |  12 +-
 DDCond/src/plugins/ConditionsUserPool.cpp     |  42 +++++--
 DDCore/include/DD4hep/Dictionary.h            |   2 +
 DDCore/include/DD4hep/LCDD.h                  |   2 +-
 DDCore/include/DD4hep/ROOTUI.h                |  61 ++++++++++
 DDCore/src/IDDescriptor.cpp                   |   5 +-
 DDCore/src/ROOTUI.cpp                         |  86 +++++++++++++
 DDCore/src/VolumeManager.cpp                  |   8 +-
 DDCore/src/plugins/StandardPlugins.cpp        |  17 ++-
 DDCore/src/plugins/VolumeMgrTest.cpp          |  35 +++---
 DDDetectors/src/CylinderShell_geo.cpp         |   3 +-
 UtilityApps/src/run_plugin.h                  |  15 ++-
 cmake/MakeRootMap.cmake                       |   2 +-
 cmake/thisdd4hep.sh                           |   7 ++
 doc/release.notes                             |  17 ++-
 examples/AlignDet/compact/AlephTPC.xml        |   8 +-
 examples/AlignDet/compact/Telescope.xml       | 115 ++++++++++++++++++
 examples/AlignDet/src/AlephTPC_geo.cpp        |  16 ++-
 examples/AlignDet/src/BoxDetector_geo.cpp     |  16 ++-
 examples/AlignDet/src/Telescope_geo.cpp       |  75 ++++++++++++
 examples/ClientTests/CMakeLists.txt           |  20 +++
 .../compact/Bitfield_SidesTest.xml            |  60 +++++++++
 .../compact/Bitfield_SidesTest2.xml           |  60 +++++++++
 .../ClientTests/src/Assemblies_VXD_geo.cpp    |  16 ++-
 examples/ClientTests/src/IronCylinder_geo.cpp |  26 ++--
 .../data/Module1_run-1000...2000.xml          |   8 ++
 examples/Conditions/data/repository.xml       |  10 ++
 36 files changed, 807 insertions(+), 107 deletions(-)
 create mode 100644 DDCore/include/DD4hep/ROOTUI.h
 create mode 100644 DDCore/src/ROOTUI.cpp
 create mode 100644 examples/AlignDet/compact/Telescope.xml
 create mode 100644 examples/AlignDet/src/Telescope_geo.cpp
 create mode 100644 examples/ClientTests/compact/Bitfield_SidesTest.xml
 create mode 100644 examples/ClientTests/compact/Bitfield_SidesTest2.xml
 create mode 100644 examples/Conditions/data/Module1_run-1000...2000.xml
 create mode 100644 examples/Conditions/data/repository.xml

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34823f48d..cf690b2be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,7 @@ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
        FORCE )
  MESSAGE(STATUS "CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} - overwrite with -D CMAKE_INSTALL_PREFIX" )
 ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-
-
+#
 #---Options-------------------------------------------------------------------------
 option(DD4HEP_USE_XERCESC "Enable 'Detector Builders' based on XercesC"   OFF)
 option(DD4HEP_USE_PYROOT  "Enable 'Detector Builders' based on PyROOT"    OFF)  # does not work (compile error)
@@ -24,7 +23,6 @@ option(BUILD_TESTING      "Enable and build tests"   ON)
 option(DD4HEP_USE_CXX11   "Build DD4hep using c++11" OFF)
 option(DD4HEP_USE_CXX14   "Build DD4hep using c++14" OFF)
 option(CMAKE_MACOSX_RPATH "Build with rpath on macos" ON)
- 
 #
 #-----------------------------------------------------------------------------------------------------
 #
@@ -158,3 +156,12 @@ display_std_variables()
 ##############################################################################
 # generate and install following configuration files
 generate_package_configuration_files( DD4hepConfig.cmake DD4hepConfigVersion.cmake )
+if(APPLE)
+  SET ( ENV{DD4HEP_LIBRARY_PATH} $ENV{DYLD_LIBRARY_PATH} )
+else()
+  SET ( ENV{DD4HEP_LIBRARY_PATH} ${LD_LIBRARY_PATH} )
+  SET ( DD4HEP_LIBRARY_PATH ${LD_LIBRARY_PATH} )
+endif()
+
+message(STATUS "DD4HEP_LIBRARY_PATH= ${DD4HEP_LIBRARY_PATH}")
+message(STATUS "DD4HEP_LIBRARY_PATH= $ENV{DD4HEP_LIBRARY_PATH}")
diff --git a/DDAlign/src/plugins/AlignmentPlugins.cpp b/DDAlign/src/plugins/AlignmentPlugins.cpp
index adb146a80..6fddf953f 100644
--- a/DDAlign/src/plugins/AlignmentPlugins.cpp
+++ b/DDAlign/src/plugins/AlignmentPlugins.cpp
@@ -26,12 +26,20 @@ using namespace DD4hep::Alignments;
 namespace {
   /// Plugin function:
   /// Install the alignment manager as an extension to the central LCDD object
-  int ddalign_install_align_mgr (Geometry::LCDD& lcdd, int /* argc */, char** /* argv */)  {
+  int ddalign_install_align_mgr (Geometry::LCDD& lcdd, int argc, char** argv)  {
     Handle<AlignmentsManagerObject> mgr(lcdd.extension<AlignmentsManagerObject>(false));
     if ( !mgr.isValid() )  {
       AlignmentsManager mgr_handle("LCDD_AlignmentManager");
       lcdd.addExtension<AlignmentsManagerObject>(mgr_handle.ptr());
-      printout(INFO,"AlignmentsManager","+++ Successfully installed alignments manager instance to LCDD.");
+      printout(INFO,"AlignmentsManager",
+               "+++ Successfully installed alignments manager instance to LCDD.");
+      mgr = mgr_handle;
+    }
+    if ( argc == 2 )  {
+      if ( ::strncmp(argv[0],"-handle",7)==0 )  {
+        Handle<NamedObject>* h = (Handle<NamedObject>*)argv[1];
+        *h = mgr;
+      }
     }
     return 1;
   }
diff --git a/DDCond/include/DDCond/ConditionsDataLoader.h b/DDCond/include/DDCond/ConditionsDataLoader.h
index 213c89a9d..1bb7e72c1 100644
--- a/DDCond/include/DDCond/ConditionsDataLoader.h
+++ b/DDCond/include/DDCond/ConditionsDataLoader.h
@@ -73,15 +73,15 @@ namespace DD4hep {
       void addSource(const std::string& source, const iov_type& iov);
       /// Load  a condition set given a Detector Element and the conditions name according to their validity
       virtual size_t load(key_type key,
-			  const iov_type& req_validity,
+                          const iov_type& req_validity,
                           RangeConditions& conditions) = 0;
       /// Load  a condition set given a Detector Element and the conditions name according to their validity
       virtual size_t load_range(key_type key,
                                 const iov_type& req_validity,
                                 RangeConditions& conditions) = 0;
       virtual size_t update(const iov_type& req_validity,
-			    RangeConditions& conditions,
-			    iov_type& conditions_validity) = 0;
+                            RangeConditions& conditions,
+                            iov_type& conditions_validity) = 0;
     };
 
   } /* End namespace Conditions             */
diff --git a/DDCond/include/DDCond/ConditionsInterna.h b/DDCond/include/DDCond/ConditionsInterna.h
index c050ddb4f..01374abff 100644
--- a/DDCond/include/DDCond/ConditionsInterna.h
+++ b/DDCond/include/DDCond/ConditionsInterna.h
@@ -75,6 +75,7 @@ namespace DD4hep {
       typedef std::pair<ConditionsListener*,void*> Listener;
       typedef std::set<Listener>                   Listeners;
       typedef ConditionsManager::Dependencies      Dependencies;
+      typedef ConditionsManager::ConditionKeys     ConditionKeys;
       typedef Condition::key_type                  key_type;
       typedef Condition::iov_type                  iov_type;
 
@@ -130,6 +131,9 @@ namespace DD4hep {
       /// Listener invocation when a condition is deregistered from the cache
       void onRemove(Condition condition);
 
+      /// Helper to check iov and user pool and create user pool if not present
+      void __get_checked_pool(const IOV& required_validity, dd4hep_ptr<UserPool>& user_pool);
+      
     public:
       /// Set a single conditions value to be managed.
       /// Requires EXTERNALLY held lock on update pool!
@@ -184,6 +188,18 @@ namespace DD4hep {
       /// Register new condition with the conditions store. Unlocked version, not multi-threaded
       bool registerUnlocked(ConditionsPool* pool, Condition cond);
 
+      /// Prepare all updates for the given keys to the clients with the defined IOV
+      long prepare(const IOV& required_validity,
+                   const ConditionKeys& keys,
+                   dd4hep_ptr<UserPool>& user_pool);
+
+      /// Prepare all updates for the given keys to the clients with the defined IOV
+      long prepare(const IOV& required_validity,
+                   const ConditionKeys&  keys,
+                   dd4hep_ptr<UserPool>& user_pool,
+                   const Dependencies&   dependencies,
+                   bool                  verify_dependencies=true);
+
       /// Prepare all updates to the clients with the defined IOV
       long prepare(const IOV& required_validity, dd4hep_ptr<UserPool>& user_pool);
 
diff --git a/DDCond/include/DDCond/ConditionsManager.h b/DDCond/include/DDCond/ConditionsManager.h
index 8d664f777..fae71cddb 100644
--- a/DDCond/include/DDCond/ConditionsManager.h
+++ b/DDCond/include/DDCond/ConditionsManager.h
@@ -52,6 +52,7 @@ namespace DD4hep {
       typedef std::vector<IOVType>               IOVTypes;
       typedef std::map<IOVType*,Container>       TypeConditions;
       typedef std::map<DetElement,Container>     DetectorConditions;
+      typedef std::set<ConditionKey>             ConditionKeys;
       typedef ConditionDependency                Dependency;
       typedef ConditionsDependencyCollection     Dependencies;
 
@@ -130,6 +131,18 @@ namespace DD4hep {
       /// Full cleanup of all managed conditions.
       void clear();
 
+      /// Prepare all updates for the given keys to the clients with the defined IOV
+      long prepare(const IOV& required_validity,
+                   const ConditionKeys& keys,
+                   dd4hep_ptr<UserPool>& user_pool);
+
+      /// Prepare all updates for the given keys to the clients with the defined IOV
+      long prepare(const IOV& required_validity,
+                   const ConditionKeys&  keys,
+                   dd4hep_ptr<UserPool>& user_pool,
+                   const Dependencies&   dependencies,
+                   bool                  verify_dependencies=true);
+
       /// Prepare all updates to the clients with the defined IOV
       long prepare(const IOV& required_validity, dd4hep_ptr<UserPool>& user_pool);
 
diff --git a/DDCond/include/DDCond/ConditionsPool.h b/DDCond/include/DDCond/ConditionsPool.h
index 332a5e4a0..dda58a31a 100644
--- a/DDCond/include/DDCond/ConditionsPool.h
+++ b/DDCond/include/DDCond/ConditionsPool.h
@@ -121,7 +121,7 @@ namespace DD4hep {
       virtual void popEntries(UpdateEntries& entries) = 0;
       /// Select the conditions matching the key
       virtual void select_range(Condition::key_type key, 
-				const Condition::iov_type& req_validity,
+                                const Condition::iov_type& req_validity,
                                 RangeConditions& result) = 0;
     };
 
@@ -133,9 +133,11 @@ namespace DD4hep {
     class UserPool  {
     public:
       /// Forward definition of the key type
-      typedef Condition::key_type             key_type;
+      typedef Condition::key_type              key_type;
+      /// Forward definition of the condition keys container
+      typedef ConditionsManager::ConditionKeys ConditionKeys;
       /// Forward definition of the dependency container
-      typedef ConditionsManager::Dependencies Dependencies;
+      typedef ConditionsManager::Dependencies  Dependencies;
 
     protected:
       /// The pool's interval of validity
@@ -176,6 +178,8 @@ namespace DD4hep {
       virtual bool insert(Condition cond) = 0;
       /// Prepare user pool for usage (load, fill etc.) according to required IOV
       virtual long prepare(const IOV& required) = 0;
+      /// Prepare user pool for usage (load, fill etc.) according to required IOV
+      virtual long prepare(const IOV& required, const ConditionKeys& keys) = 0;
       /// Evaluate and register all derived conditions from the dependency list
       virtual long compute(const Dependencies& dependencies, void* user_param=0) = 0;
     };
diff --git a/DDCond/src/ConditionsInterna.cpp b/DDCond/src/ConditionsInterna.cpp
index e2a524f44..192eeff89 100644
--- a/DDCond/src/ConditionsInterna.cpp
+++ b/DDCond/src/ConditionsInterna.cpp
@@ -446,32 +446,69 @@ long ConditionsManagerObject::prepare(const Condition::iov_type& required_validi
 }
 #endif
 
-/// Prepare all updates to the clients with the defined IOV
-long ConditionsManagerObject::prepare(const Condition::iov_type& req_iov, dd4hep_ptr<UserPool>& up)   {
+/// Helper to check iov and user pool and create user pool if not present
+void ConditionsManagerObject::__get_checked_pool(const IOV& req_iov,
+                                                 dd4hep_ptr<UserPool>& up)
+{
   const IOVType* typ = check_iov_type<Discrete>(this, &req_iov);
   if ( typ )  {
-    RC valid, expired;
     ConditionsIOVPool* pool = m_rawPool[typ->type];
     if ( 0 == up.get() )  {
       const void* argv[] = {this, pool, 0};
       UserPool* p = createPlugin<UserPool>(m_userType,m_lcdd,2,argv);
       up.adopt(p);
     }
-    /// First push any pending updates and register them to pending pools...
-    pushUpdates();
-    /// Now update/fill the user pool
-    return up->prepare(req_iov);
+    return;
   }
+  // Invalid IOV type. Throw exception
   except("ConditionsManager","+++ Unknown IOV type requested to enable conditions. [%s]",
          Errors::invalidArg().c_str());
-  return -1;
+}
+
+/// Prepare all updates for the given keys to the clients with the defined IOV
+long ConditionsManagerObject::prepare(const IOV&            req_iov,
+                                      const ConditionKeys&  keys,
+                                      dd4hep_ptr<UserPool>& up)
+{
+  RC valid, expired;
+  __get_checked_pool(req_iov, up);
+  /// First push any pending updates and register them to pending pools...
+  pushUpdates();
+  /// Now update/fill the user pool
+  return up->prepare(req_iov,keys);
+}
+
+
+/// Prepare all updates for the given keys to the clients with the defined IOV
+long ConditionsManagerObject::prepare(const IOV&            req_iov,
+                                      const ConditionKeys&  keys,
+                                      dd4hep_ptr<UserPool>& up,
+                                      const Dependencies&   dependencies,
+                                      bool                  verify_dependencies)
+{
+  long num_raw_updates = prepare(req_iov, keys, up);
+  if ( num_raw_updates > 0 || verify_dependencies )   {
+    long num_dep_updates = up->compute(dependencies);
+    return num_raw_updates+num_dep_updates;
+  }
+  return num_raw_updates;
+}
+
+/// Prepare all updates to the clients with the defined IOV
+long ConditionsManagerObject::prepare(const Condition::iov_type& req_iov, dd4hep_ptr<UserPool>& up)   {
+  RC valid, expired;
+  __get_checked_pool(req_iov, up);
+  /// First push any pending updates and register them to pending pools...
+  pushUpdates();
+  /// Now update/fill the user pool
+  return up->prepare(req_iov);
 }
 
 /// Prepare all updates to the clients with the defined IOV
 long ConditionsManagerObject::prepare(const Condition::iov_type& req_iov,
-				      dd4hep_ptr<UserPool>& up,
-				      const Dependencies& dependencies,
-				      bool verify_dependencies)
+                                      dd4hep_ptr<UserPool>& up,
+                                      const Dependencies& dependencies,
+                                      bool verify_dependencies)
 {
   long num_raw_updates = prepare(req_iov, up);
   if ( num_raw_updates > 0 || verify_dependencies )   {
diff --git a/DDCond/src/ConditionsManager.cpp b/DDCond/src/ConditionsManager.cpp
index 580da8bba..01e7625b4 100644
--- a/DDCond/src/ConditionsManager.cpp
+++ b/DDCond/src/ConditionsManager.cpp
@@ -42,7 +42,7 @@ namespace DD4hep {
 ConditionsManager::ConditionsManager(LCDD& lcdd)  {
   assign(new Object(lcdd), "ConditionsManager","");
 }
- 
+
 ConditionsManager& ConditionsManager::initialize()   {
   access()->initialize();
   return *this;
@@ -114,6 +114,23 @@ void ConditionsManager::clear()   {
   access()->clear();
 }
 
+/// Prepare all updates for the given keys to the clients with the defined IOV
+long ConditionsManager::prepare(const IOV& required_validity,
+                                const ConditionKeys& keys,
+                                dd4hep_ptr<UserPool>& user_pool)  {
+  return access()->prepare(required_validity, keys, user_pool);
+}
+
+
+/// Prepare all updates for the given keys to the clients with the defined IOV
+long ConditionsManager::prepare(const IOV& required_validity,
+                                const ConditionKeys&  keys,
+                                dd4hep_ptr<UserPool>& user_pool,
+                                const Dependencies&   dependencies,
+                                bool                  verify_dependencies)  {
+  return access()->prepare(required_validity, keys, user_pool, dependencies, verify_dependencies);
+}
+
 /// Prepare all updates to the clients with the defined new IOV. Changes are not yet applied
 long ConditionsManager::prepare(const IOV& required_validity, dd4hep_ptr<UserPool>& user_pool)   {
   return access()->prepare(required_validity, user_pool);
@@ -121,8 +138,8 @@ long ConditionsManager::prepare(const IOV& required_validity, dd4hep_ptr<UserPoo
 
 /// Prepare all updates to the clients with the defined IOV
 long ConditionsManager::prepare(const IOV& required_validity,
-				dd4hep_ptr<UserPool>& user_pool,
-				const Dependencies& dependencies,
-				bool verify_dependencies)  {
+                                dd4hep_ptr<UserPool>& user_pool,
+                                const Dependencies& dependencies,
+                                bool verify_dependencies)  {
   return access()->prepare(required_validity, user_pool, dependencies, verify_dependencies);
 }
diff --git a/DDCond/src/plugins/ConditionsParser.cpp b/DDCond/src/plugins/ConditionsParser.cpp
index 3ae79d99a..5ac2129b7 100644
--- a/DDCond/src/plugins/ConditionsParser.cpp
+++ b/DDCond/src/plugins/ConditionsParser.cpp
@@ -35,11 +35,13 @@ namespace DD4hep  {
 
   namespace {
     /// Some utility class to specialize the converters:
+    class iov;
     class include;
     class arbitrary;
     class conditions;
   }
   /// Forward declarations for all specialized converters
+  template <> void Converter<iov>::operator()(xml_h seq)  const;
   template <> void Converter<include>::operator()(xml_h seq)  const;
   template <> void Converter<arbitrary>::operator()(xml_h seq)  const;
   template <> void Converter<conditions>::operator()(xml_h seq)  const;
@@ -86,6 +88,18 @@ namespace DD4hep {
     return new Entry(elt,name,e.tag(),_getValidity(element),hash32(name));
   }
 
+  /** Convert iov repository objects
+   *
+   *  @author  M.Frank
+   *  @version 1.0
+   *  @date    01/04/2014
+   */
+  template <> void Converter<iov>::operator()(xml_h element) const {
+    xml_dim_t e = element;
+
+  }
+
+  
   /** Convert arbitrary conditon objects containing standard tags
    *
    *    Function entry expects as a parameter a valid DetElement handle
@@ -130,6 +144,8 @@ namespace DD4hep {
       Converter<conditions>(lcdd,param)(e);
     else if ( tag == "detelement" )
       Converter<conditions>(lcdd,param)(e);
+    else if ( tag == "iov" )         // Processing repository file
+      xml_coll_t(e,_U(star)).for_each(Converter<iov>(lcdd,param));
     else if ( tag == "subdetectors" )
       xml_coll_t(e,_U(star)).for_each(Converter<conditions>(lcdd,param));
     else if ( tag == "detelements" )
diff --git a/DDCond/src/plugins/ConditionsPlugins.cpp b/DDCond/src/plugins/ConditionsPlugins.cpp
index 73c28900b..07d690877 100644
--- a/DDCond/src/plugins/ConditionsPlugins.cpp
+++ b/DDCond/src/plugins/ConditionsPlugins.cpp
@@ -31,12 +31,20 @@ using namespace DD4hep::Conditions;
 namespace {
   /// Plugin function:
   /// Install the alignment manager as an extension to the central LCDD object
-  int ddcond_install_cond_mgr (LCDD& lcdd, int /* argc */, char** /* argv */)  {
+  int ddcond_install_cond_mgr (LCDD& lcdd, int argc, char** argv)  {
     Handle<ConditionsManagerObject> mgr(lcdd.extension<ConditionsManagerObject>(false));
     if ( !mgr.isValid() )  {
       ConditionsManager mgr_handle(lcdd);
       lcdd.addExtension<ConditionsManagerObject>(mgr_handle.ptr());
-      printout(INFO,"ConditionsManager","+++ Successfully installed conditions manager instance to LCDD.");
+      printout(INFO,"ConditionsManager",
+               "+++ Successfully installed conditions manager instance to LCDD.");
+      mgr = mgr_handle;
+    }
+    if ( argc == 2 )  {
+      if ( ::strncmp(argv[0],"-handle",7)==0 )  {
+        Handle<NamedObject>* h = (Handle<NamedObject>*)argv[1];
+        *h = mgr;
+      }
     }
     return 1;
   }
diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp
index 8a53e6452..98a565279 100644
--- a/DDCond/src/plugins/ConditionsUserPool.cpp
+++ b/DDCond/src/plugins/ConditionsUserPool.cpp
@@ -68,6 +68,8 @@ namespace DD4hep {
       virtual bool insert(Condition cond);
       /// Prepare user pool for usage (load, fill etc.) according to required IOV
       virtual long prepare(const IOV& required);
+      /// Prepare user pool for usage (load, fill etc.) according to required IOV
+      virtual long prepare(const IOV& required, const ConditionKeys& keys);
       /// Evaluate and register all derived conditions from the dependency list
       virtual long compute(const Dependencies& dependencies, void* user_param);
     };
@@ -149,10 +151,9 @@ void ConditionsMappedUserPool<MAPPING>::print(const std::string& opt)   const  {
   printout(INFO,"UserPool","+++ %s Conditions for USER pool with IOV: %-32s [%4d entries]",
            opt.c_str(), iov->str().c_str(), count());
   if ( opt == "*" ) {
-    typename MAPPING::const_iterator i=m_conditions.begin();
-    for( ; i != m_conditions.end(); ++i)   {
-      Condition c = (*i).second;
-      printout(INFO,"UserPool","++ %08X/%08X Val:%s %s",(*i).first, c->hash, c->value.c_str(), c.str().c_str());
+    for( const auto& i : m_conditions )   {
+      Condition c = i.second;
+      printout(INFO,"UserPool","++ %08X/%08X Val:%s %s",i.first, c->hash, c->value.c_str(), c.str().c_str());
     }
   }
 }
@@ -192,8 +193,7 @@ Condition ConditionsMappedUserPool<MAPPING>::get(const ConditionKey& key)  const
 template<typename MAPPING>
 bool ConditionsMappedUserPool<MAPPING>::insert(Condition cond)   {
   Condition::Object* o = cond.ptr();
-  pair<typename MAPPING::iterator,bool> res = m_conditions.insert(make_pair(o->hash,o));
-  return res.second;
+  return m_conditions.insert(make_pair(o->hash,o)).second;
 }
 
 /// Remove condition by key from pool.
@@ -231,22 +231,40 @@ long ConditionsMappedUserPool<MAPPING>::prepare(const IOV& required)   {
     m_iov = pool_iov;
     return num_expired;
   }
-  DD4hep::except("ConditionsMappedUserPool","++ Invalid reference to iov pool! [Internal Error]");
+  DD4hep::except("UserPool","++ Invalid reference to iov pool! [Internal Error]");
   return -1;
 }
 
+/// Prepare user pool for usage (load, fill etc.) according to required IOV
+template<typename MAPPING>
+long ConditionsMappedUserPool<MAPPING>::prepare(const IOV& required, const ConditionKeys& keys)   {
+  long num_expired = prepare(required); // Update all what is present! Re-use pre-cond checking!
+  if ( !keys.empty() )  {
+    for ( const auto& k : keys )  {     // Now load all keys, which are not present
+      typename MAPPING::const_iterator i=m_conditions.find(k.hash);
+      if ( i == m_conditions.end() )  {
+        RangeConditions loaded;
+        m_manager->loader()->load(k.hash, required, loaded);
+        if ( loaded.empty() )  {
+          DD4hep::except("UserPool","++ Failed to load condition: %s",k.name.c_str());
+        }
+        for_each(loaded.begin(),loaded.end(),Inserter<MAPPING>(m_conditions));
+      }
+    }
+  }
+  return num_expired;
+}
+
 /// Evaluate and register all derived conditions from the dependency list
 template<typename MAPPING>
 long ConditionsMappedUserPool<MAPPING>::compute(const Dependencies& deps, void* user_param)  {
   long num_updates = 0;
   if ( !deps.empty() )  {
-    typedef Dependencies _D;
     ConditionsDependencyHandler handler(m_manager.ptr(), *this, deps, user_param);
     ConditionsPool* pool = m_manager->registerIOV(*m_iov.iovType, m_iov.keyData);
     // Loop over the dependencies and check if they have to be upgraded
-    for(_D::const_iterator i = deps.begin(); i!=deps.end(); ++i)  {
-      key_type key = (*i).first;
-      typename MAPPING::iterator j = m_conditions.find(key);
+    for ( const auto& i : deps )  {
+      typename MAPPING::iterator j = m_conditions.find(i.first);
       if ( j != m_conditions.end() )  {
         Condition::Object* cond = (*j).second;
         if ( IOV::key_is_contained(m_iov.keyData,cond->iov->keyData) )
@@ -254,7 +272,7 @@ long ConditionsMappedUserPool<MAPPING>::compute(const Dependencies& deps, void*
         /// This condition is no longer valid. remove it! Will be added again afterwards.
         m_conditions.erase(j);
       }
-      const ConditionDependency* d = (*i).second.get();
+      const ConditionDependency* d = i.second.get();
       Condition::Object* cond = handler(d);
       m_manager->registerUnlocked(pool, cond); // Would bulk update be more efficient?
       ++num_updates;
diff --git a/DDCore/include/DD4hep/Dictionary.h b/DDCore/include/DD4hep/Dictionary.h
index 4bdb71898..c64c8b91c 100644
--- a/DDCore/include/DD4hep/Dictionary.h
+++ b/DDCore/include/DD4hep/Dictionary.h
@@ -35,6 +35,7 @@
 #include "DD4hep/objects/VolumeManagerInterna.h"
 
 #include "DD4hep/World.h"
+#include "DD4hep/ROOTUI.h"
 #include "DD4hep/Callback.h"
 #include "DD4hep/LCDDData.h"
 #include "DD4hep/Conditions.h"
@@ -96,6 +97,7 @@ template class pair<DD4hep::Callback,unsigned long>;
 #pragma link C++ class map<string, DD4hep::Handle<DD4hep::NamedObject> >+;
 #pragma link C++ class map<string, DD4hep::Handle<DD4hep::NamedObject> >::iterator;
 #pragma link C++ class map<string, DD4hep::Handle<DD4hep::NamedObject> >::const_iterator;
+#pragma link C++ class DD4hep::ROOTUI;
 
 #ifdef R__MACOSX
 // We only need these declarations for the clang compiler
diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h
index cd80feb2a..bc0036fb6 100644
--- a/DDCore/include/DD4hep/LCDD.h
+++ b/DDCore/include/DD4hep/LCDD.h
@@ -292,7 +292,7 @@ namespace DD4hep {
 
       /// Stupid legacy method
       virtual void dump() const = 0;
-      /// Manipulate geometry using facroy converter
+      /// Manipulate geometry using factory converter
       virtual long apply(const char* factory, int argc, char** argv) = 0;
 
       /// Extend the sensitive detector element with an arbitrary structure accessible by the type
diff --git a/DDCore/include/DD4hep/ROOTUI.h b/DDCore/include/DD4hep/ROOTUI.h
new file mode 100644
index 000000000..d91282a8a
--- /dev/null
+++ b/DDCore/include/DD4hep/ROOTUI.h
@@ -0,0 +1,61 @@
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+#ifndef DD4HEP_DDCORE_DD4HEPUI_H
+#define DD4HEP_DDCORE_DD4HEPUI_H
+
+// Framework includes
+#include "DD4hep/LCDD.h"
+
+/// Namespace for the AIDA detector description toolkit
+namespace DD4hep {
+
+  /// ROOT interactive UI for DD4hep applications
+  /**
+   *
+   *  \author  M.Frank
+   *  \version 1.0
+   *  \ingroup DD4HEP
+   */
+  class ROOTUI  {
+  protected:
+    /// Reference to the LCDD instance object
+    Geometry::LCDD& m_lcdd;
+    Handle<NamedObject> m_condMgr;
+    Handle<NamedObject> m_alignMgr;
+    
+  public:
+    /// Default constructor
+    ROOTUI(Geometry::LCDD& instance);
+    /// Default destructor
+    virtual ~ROOTUI();
+    /// Access to the LCDD instance
+    Geometry::LCDD* instance()  const;
+
+    /// Install the DD4hep conditions manager object
+    Handle<NamedObject> conditionsMgr()  const;
+    /// Load conditions from file
+    long loadConditions(const std::string& fname)  const;
+    
+    /// Install the DD4hep alignment manager object
+    Handle<NamedObject> alignmentMgr()  const;
+    
+    /// LCDD interface: Manipulate geometry using facroy converter
+    virtual long apply(const char* factory, int argc, char** argv) const;
+    /// LCDD interface: Read any geometry description or alignment file
+    virtual void fromXML(const std::string& fname, LCDDBuildType type = BUILD_DEFAULT) const;
+    /// LCDD interface: Re-draw the entire scene
+    virtual void redraw() const;
+  };
+  
+} /* End namespace DD4hep        */
+#endif // DD4HEP_DDCORE_DD4HEPUI_H
diff --git a/DDCore/src/IDDescriptor.cpp b/DDCore/src/IDDescriptor.cpp
index 3d579b4de..d4b5ab7bb 100644
--- a/DDCore/src/IDDescriptor.cpp
+++ b/DDCore/src/IDDescriptor.cpp
@@ -16,6 +16,7 @@
 #include "DD4hep/IDDescriptor.h"
 #include "DD4hep/objects/ObjectsInterna.h"
 #include "DD4hep/InstanceCount.h"
+#include "DD4hep/Printout.h"
 #include <stdexcept>
 #include <cstdlib>
 #include <cmath>
@@ -109,8 +110,8 @@ VolumeID IDDescriptor::encode(const std::vector<VolID>& id_vector) const {
   for (VolIds::const_iterator i = id_vector.begin(); i != id_vector.end(); ++i) {
     Field f = field((*i).first);
     VolumeID vid = (*i).second;
-    vid = vid << f->offset();
-    id |= f->value(vid) << f->offset();
+    int offset = f->offset();
+    id |= ((f->value(vid<<offset) << offset)&f->mask());
   }
   return id;
 }
diff --git a/DDCore/src/ROOTUI.cpp b/DDCore/src/ROOTUI.cpp
new file mode 100644
index 000000000..f6dde3269
--- /dev/null
+++ b/DDCore/src/ROOTUI.cpp
@@ -0,0 +1,86 @@
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework includes
+#include "DD4hep/ROOTUI.h"
+#include "DD4hep/Printout.h"
+
+using namespace std;
+using namespace DD4hep;
+using namespace DD4hep::Geometry;
+
+/// Default constructor
+ROOTUI::ROOTUI(LCDD& instance) : m_lcdd(instance)  {
+}
+
+/// Default destructor
+ROOTUI::~ROOTUI()   {
+}
+
+/// Access to the LCDD instance
+LCDD* ROOTUI::instance()  const   {
+  return &m_lcdd;
+}
+
+/// Install the DD4hep conditions manager object
+Handle<NamedObject> ROOTUI::conditionsMgr()  const  {
+  if ( !m_condMgr.isValid() )  {
+    const void* argv[] = {"-handle",&m_condMgr,0};
+    if ( 1 != apply("DD4hep_ConditionsManagerInstaller",2,(char**)argv) )  {
+      except("ROOTUI","Failed to install the conditions manager object.");
+    }
+    if ( !m_condMgr.isValid() )  {
+      except("ROOTUI","Failed to access the conditions manager object.");
+    }
+  }
+  return m_condMgr;
+}
+
+/// Load conditions from file
+long ROOTUI::loadConditions(const std::string& fname)  const  {
+  Handle<NamedObject> h = conditionsMgr();
+  if ( h.isValid() )  {
+    m_lcdd.fromXML(fname, BUILD_DEFAULT);
+    return 1;
+  }
+  return 0;
+}
+
+/// Install the DD4hep alignment manager object
+Handle<NamedObject> ROOTUI::alignmentMgr()  const  {
+  if ( !m_alignMgr.isValid() )  {
+    const void* argv[] = {"-handle",&m_alignMgr,0};
+    if ( 1 != apply("DD4hep_AlignmentsManagerInstaller",2,(char**)argv) )  {
+      except("ROOTUI","Failed to install the alignment manager object.");
+    }
+    if ( !m_alignMgr.isValid() )  {
+      except("ROOTUI","Failed to access the alignment manager object.");
+    }
+  }
+  return m_alignMgr;
+}
+
+/// LCDD interface: Manipulate geometry using facroy converter
+long ROOTUI::apply(const char* factory, int argc, char** argv) const   {
+  return m_lcdd.apply(factory,argc,argv);
+}
+
+/// LCDD interface: Read any geometry description or alignment file
+void ROOTUI::fromXML(const std::string& fname, LCDDBuildType type) const  {
+  return m_lcdd.fromXML(fname, type);
+}
+
+/// LCDD interface: Re-draw the entire scene
+void ROOTUI::redraw() const   {
+  m_lcdd.worldVolume()->Draw("oglsame");
+}
diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp
index 487cb3a86..f4bcd766b 100644
--- a/DDCore/src/VolumeManager.cpp
+++ b/DDCore/src/VolumeManager.cpp
@@ -271,7 +271,7 @@ namespace {
         IDDescriptor::Field f = iddesc.field(id.first);
         VolumeID msk = f->mask();
         int offset   = f->offset();
-        volume_id   |= f->value(id.second << offset) << offset;
+        volume_id   |= ((f->value(id.second << offset) << offset)&msk);
         mask        |= msk;
       }
       return make_pair(volume_id, mask);
@@ -283,9 +283,9 @@ namespace {
         const PlacedVolume::VolID& id = (*i);
         IDDescriptor::Field f = iddesc.field(id.first);
         VolumeID msk = f->mask();
-        int offset = f->offset();
-        volume_id |= f->value(id.second << offset) << offset;
-        mask |= msk;
+        int      off = f->offset();
+        volume_id |= ((f->value(id.second<<off)<<off)&msk);
+        mask      |= msk;
       }
       return make_pair(volume_id, mask);
     }
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index ea1b822b7..d58f0a646 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -1,4 +1,3 @@
-// $Id$
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
@@ -14,6 +13,7 @@
 
 // Framework include files
 #include "DD4hep/LCDD.h"
+#include "DD4hep/ROOTUI.h"
 #include "DD4hep/Factories.h"
 #include "DD4hep/Printout.h"
 #include "DD4hep/DetectorTools.h"
@@ -21,6 +21,7 @@
 #include "../LCDDImp.h"
 
 // ROOT includes
+#include "TInterpreter.h"
 #include "TGeoManager.h"
 #include "TGeoVolume.h"
 #include "TClass.h"
@@ -80,6 +81,18 @@ static long display(LCDD& lcdd, int argc, char** argv) {
 }
 DECLARE_APPLY(DD4hepGeometryDisplay,display)
 
+static long root_ui(LCDD& lcdd, int /* argc */, char** /* argv */) {
+  char cmd[256];
+  ROOTUI* ui = new ROOTUI(lcdd);
+  ::snprintf(cmd,sizeof(cmd),"DD4hep::ROOTUI* gDD4hepUI = (DD4hep::ROOTUI*)%p;",(void*)ui);
+  gInterpreter->ProcessLine(cmd);
+  printout(ALWAYS,"ROOTUI",
+           "Use the ROOT interpreter variable gDD4hepUI "
+           "to interact with the detector description.");
+  return 1;
+}
+DECLARE_APPLY(DD4hepROOTUI,root_ui)
+
 static long load_compact(LCDD& lcdd, int argc, char** argv) {
   if ( argc > 0 )   {
     LCDDBuildType type = BUILD_DEFAULT;
@@ -262,7 +275,7 @@ static long dump_volume_tree(LCDD& lcdd, int argc, char** argv) {
           ::snprintf(fmt,sizeof(fmt),"%03d %%-%ds %%s (%%s: %%s) Ideal:%p Aligned:%p %c %%s",
                      level+1,2*level+1,(void*)ideal,(void*)aligned, sens);
         }
-        printout(INFO,"+++",fmt,"",
+        printout(INFO,"VolumeDump",fmt,"",
                  aligned->GetName(),
                  volume->GetTitle(),
                  volume->GetShape()->IsA()->GetName(),
diff --git a/DDCore/src/plugins/VolumeMgrTest.cpp b/DDCore/src/plugins/VolumeMgrTest.cpp
index 5ab668974..3adef8226 100644
--- a/DDCore/src/plugins/VolumeMgrTest.cpp
+++ b/DDCore/src/plugins/VolumeMgrTest.cpp
@@ -1,4 +1,3 @@
-// $Id: $
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
@@ -27,7 +26,6 @@ using namespace std;
 using namespace DD4hep;
 using namespace DD4hep::Geometry;
 
-
 namespace  {
   /** @class VolIDTest
    *
@@ -89,11 +87,9 @@ VolIDTest::VolIDTest(LCDD& lcdd, DetElement sdet, size_t depth) : m_det(sdet) {
 void VolIDTest::checkVolume(DetElement e, PlacedVolume pv, const VolIDs& child_ids)  const {
   stringstream err, log;
   VolumeID vid = m_iddesc.encode(child_ids);
-  VolumeID mask = 0xFFFFULL;
-  vid |= mask<<(31+16);
   try {
-    DetElement det         = m_mgr.lookupDetector(vid);
-    DetElement det_elem    = m_mgr.lookupDetElement(vid);
+    DetElement   det       = m_mgr.lookupDetector(vid);
+    DetElement   det_elem  = m_mgr.lookupDetElement(vid);
     PlacedVolume det_place = m_mgr.lookupPlacement(vid);
     if ( pv.ptr() != det_place.ptr() )   {
       err << "Wrong placement "
@@ -116,18 +112,19 @@ void VolIDTest::checkVolume(DetElement e, PlacedVolume pv, const VolIDs& child_i
     err << "Lookup " << pv.name() << " id:" << (void*)vid << " path:" << e.path() << " error:" << ex.what();
   }
   const IDDescriptor::FieldMap& m = m_iddesc.fields();
-  log << "IDS(" << pv.name() << "): ";
-  for(size_t fi=0; fi<m.size(); ++fi)  {
+  log << "IDS(" << pv.name() << ") ";
+  log << " vid:" << setw(16) << hex << setfill('0') << vid << dec << setfill(' ') << " ";
+  for ( size_t fi=0; fi<m.size(); ++fi )    {
     IDDescriptor::Field fld = m_iddesc.field(fi);
+    long val = fld->value(vid);
     if ( find_if(child_ids.begin(),child_ids.end(),FND(fld->name())) == child_ids.end() ) continue;
-    log << fld->name() << "=" << fld->value(vid) << "  ";
+    log << fld->name() << (val>=0?": ":":") << val << "  ";
   }
-  log << " vid:" << (void*)vid;
   if ( !err.str().empty() )   {
     printout(ERROR,m_det.name(),err.str()+" "+log.str());
     throw runtime_error(err.str());
   }
-  printout(INFO,m_det.name(),"OK: "+log.str());
+  printout(INFO,m_det.name(),"OK "+log.str());
 }
 
 /// Walk through tree of detector elements
@@ -174,25 +171,23 @@ void VolIDTest::walk(DetElement e, VolIDs ids, size_t depth, size_t mx_depth)  c
 
 /// Action routine to execute the test
 long VolIDTest::run(LCDD& lcdd,int argc,char** argv)    {
-  cout << "++ Processing plugin...CLICSid_VolMgrTest..." << endl;
-  for(int iarg=1; iarg<argc;++iarg)  {
-    string name = argv[iarg]+1;
+  printout(ALWAYS,"DD4hepVolumeMgrTest","++ Processing plugin...");
+  for(int iarg=0; iarg<argc;++iarg)  {
+    if ( argv[iarg] == 0 ) break;
+    string name = argv[iarg];
     if ( name == "all" || name == "All" || name == "ALL" )  {
       const DetElement::Children& children = lcdd.world().children();
       for (DetElement::Children::const_iterator i=children.begin(); i!=children.end(); ++i)  {
         DetElement sdet = (*i).second;
-        cout << "++ Processing subdetector: " << sdet.name() << endl;
+        printout(INFO,"DD4hepVolumeMgrTest","++ Processing subdetector: %s",sdet.name());
         VolIDTest test(lcdd,sdet,99);
       }
       return 1;
     }
-    cout << "++ Processing subdetector: " << name << endl;
+    printout(INFO,"DD4hepVolumeMgrTest","++ Processing subdetector: %s",name.c_str());
     VolIDTest test(lcdd,lcdd.detector(name),99);
   }
   return 1;
 }
 
-namespace DD4hep {
-  using ::VolIDTest;
-}
-DECLARE_APPLY(CLICSiD_VolMgrTest,VolIDTest::run)
+DECLARE_APPLY(DD4hepVolumeMgrTest,VolIDTest::run)
diff --git a/DDDetectors/src/CylinderShell_geo.cpp b/DDDetectors/src/CylinderShell_geo.cpp
index 43b39fee8..67fcda22c 100644
--- a/DDDetectors/src/CylinderShell_geo.cpp
+++ b/DDDetectors/src/CylinderShell_geo.cpp
@@ -58,6 +58,7 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sensitive)
   for(xml_coll_t m(e,_U(module)); m; ++m)  {
     xml_comp_t mod = m;
     vector<double> rmin,rmax,z;
+    string vis = mod.visStr().empty() ? x_det.visStr() : mod.visStr();
     int num = 0;
     for(xml_coll_t c(m,_U(zplane)); c; ++c, ++num)  {
       xml_comp_t dim(c);
@@ -70,7 +71,7 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sensitive)
     }
     Polycone   cone  (0.,2*M_PI,rmin,rmax,z);
     Volume     volume(name, cone, mat);
-    volume.setVisAttributes(lcdd, x_det.visStr());
+    volume.setVisAttributes(lcdd, vis);
     volume.setSensitiveDetector(sensitive);
     pv = assembly.placeVolume(volume);
     pv.addPhysVolID("barrel",mod.id());
diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h
index f276af34e..43265623c 100644
--- a/UtilityApps/src/run_plugin.h
+++ b/UtilityApps/src/run_plugin.h
@@ -91,7 +91,12 @@ namespace {
       "                                    The lower the level, the more printout...      \n"
       "        -plugin <name> <args>       Execute plugin <name> after loading geometry.  \n"
       "                                    All arguments following until the next '-'     \n"
-      "                                    are considered as arguments to the plugin.     \n";
+      "                                    are considered as arguments to the plugin.     \n"
+      "        -ui                         Install ROOT interpreter UI for DD4hep         \n"
+      "                                    Will show up in the global interpreter variable\n"
+      "                                    'DD4hep::ROOTUI* gDD4hepUI' and allows the user\n"
+      "                                    to interact with the the LCDD instance from the\n"
+      "                                    ROOT interactive prompt.                       \n";
     return cout;
   }
 
@@ -109,13 +114,14 @@ namespace {
 
   //______________________________________________________________________________
   struct Args  {
-    bool        volmgr, dry_run, destroy, interpreter;
+    bool        volmgr, dry_run, destroy, interpreter, ui;
     int         print;
     std::vector<const char*> geo_files, build_types;
     std::vector<std::vector<const char*> > plugins;
 
     //____________________________________________________________________________
     Args() {
+      ui = false;
       volmgr  = false;
       dry_run = false;
       destroy = false;
@@ -153,6 +159,8 @@ namespace {
         interpreter = true;
       else if ( strncmp(argv[i],"-no-interpreter",7)==0 )
         interpreter = false;
+      else if ( strncmp(argv[i],"-ui",3)==0 )
+        ui = true;
       else if ( strncmp(argv[i],"-plugin",5)==0 )   {
         // Need to interprete plugin args here locally.....
         plugins.push_back(std::vector<const char*>());
@@ -260,8 +268,9 @@ namespace {
     LCDD& lcdd = dd4hep_instance();
     // Load all compact files
     load_compact(lcdd, args);
+    if ( args.ui ) run_plugin(lcdd,"DD4hepROOTUI",0,0);
     // Create volume manager and populate it required
-    if ( args.volmgr  ) run_plugin(lcdd,"DD4hepVolumeManager",0,0);
+    if ( args.volmgr ) run_plugin(lcdd,"DD4hepVolumeManager",0,0);
 
     // Create an interactive ROOT application
     if ( !args.dry_run ) {
diff --git a/cmake/MakeRootMap.cmake b/cmake/MakeRootMap.cmake
index 9eccc8591..731273eb5 100644
--- a/cmake/MakeRootMap.cmake
+++ b/cmake/MakeRootMap.cmake
@@ -9,7 +9,7 @@ if( ${ROOT_VERSION_MAJOR} GREATER 5 )
                  WORKING_DIRECTORY ${genmap_install_dir} "
     )  
   if(APPLE)
-    SET ( ENV{DYLD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{DYLD_LIBRARY_PATH} )
+    SET ( ENV{DYLD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{DYLD_LIBRARY_PATH}:$ENV{DD4HEP_LIBRARY_PATH} )
   else()
     SET ( ENV{LD_LIBRARY_PATH} ${genmap_install_dir}:$ENV{LD_LIBRARY_PATH} )
   endif()
diff --git a/cmake/thisdd4hep.sh b/cmake/thisdd4hep.sh
index 74344f14b..9f5c544a8 100644
--- a/cmake/thisdd4hep.sh
+++ b/cmake/thisdd4hep.sh
@@ -108,6 +108,13 @@ dd4hep_add_path PYTHONPATH ${THIS}/python;
 #----ROOT_INCLUDE_PATH--------------------------------------------------------
 dd4hep_add_path ROOT_INCLUDE_PATH ${THIS}/include;
 #-----------------------------------------------------------------------------
+if [ @USE_DYLD@ ];
+then
+    export DD4HEP_LIBRARY_PATH=${DYLD_LIBRARY_PATH};
+else
+    export DD4HEP_LIBRARY_PATH=${LD_LIBRARY_PATH};
+fi;
+#-----------------------------------------------------------------------------
 #
 unset ROOTENV_INIT;
 unset THIS;
diff --git a/doc/release.notes b/doc/release.notes
index 78d1f4637..48caadd06 100644
--- a/doc/release.notes
+++ b/doc/release.notes
@@ -3,13 +3,26 @@
 DD4hep  ----  Release Notes
 =================================
 
+2016-11-08 M.Frank
+  - Improve conditions handling. Started to implement using simple telescope
+    detector from C.Burr.
+  - Add variable DD4HEP_LIBRARY_PATH to be used on MacOSX El Capitane
+    to overcome DYLD_LIBRARY_PATH protection issues.
+  - Fix to copy with negative(rebased) IDDDescriptor fields
+    (affects IDDDescriptor and VolumeManager).
+    2 New tests:
+    - ClientTests/Bitfield_SidesTest.xml to test readout string:
+      system:8,barrel:-2
+    - ClientTests/Bitfield_SidesTest2.xml to test readout string:
+      system:16,barrel:16:-5
+      
 2016-10-18 M.Frank
   Due to pressure of the FCC folks, I tried to implement a more DD4hep like implementation of the
   the segmentation objects. For testing only CartesianGridXY. If this mechanism works,
   it could be a starting recipe for the rest of the segmentations. The draw-back of this approach is,
   that assignments are not reversible:
   DD4hep::CartesianGridXY xy = readout.segmentation();  // Works
-  DD4hep::Segmentation seg = xy;                        // Should not work
+  DD4hep::Segmentation seg = xy;                    // Should not work
 
   Reason: the managed objects are different....at some point in time I will have to find a
   clean solution for this, but the required changes for such a solution shall be manageable.
@@ -43,7 +56,7 @@ DD4hep  ----  Release Notes
 
 2016-07-26 Shaojun Lu  
 	Added new MegatileLayerGridXY segmentation for Scintillator strip Ecal, which is implemented by K.Kotera, 
-        and used by SEcal04Hybrid geometry driver.
+       and used by SEcal04Hybrid geometry driver.
 
  - many ( minor fixes ) by F. Gaede, M. Petric, A Sailer, ...
 
diff --git a/examples/AlignDet/compact/AlephTPC.xml b/examples/AlignDet/compact/AlephTPC.xml
index 989ec9ac0..a1eca27c2 100644
--- a/examples/AlignDet/compact/AlephTPC.xml
+++ b/examples/AlignDet/compact/AlephTPC.xml
@@ -5,15 +5,15 @@
   <info name="Alignment_aleph_tpc"
 	title="Alignment test detector with ALPEH TPC like sectors"
 	author="Markus Frank"
-	url="http://www.cern.ch/lhcb"
+        url="https://github.com/AIDASoft/DD4hep/blob/master/examples/AlignDet/compact/AlephTPC.xml"
 	status="development"
-	version="$Id: compact.xml 513 2013-04-05 14:31:53Z gaede $">
+	version="1.0">
     <comment>Alignment test detector with ALPEH TPC like sectors</comment>        
   </info>
   
   <includes>
-    <gdmlFile  ref="../../../DDDetectors/compact/elements.xml"/>
-    <gdmlFile  ref="../../../DDDetectors/compact/materials.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/>
     <!--
     <xml       ref="file:../DD4hep.trunk/DDExamples/AlignDet/compact/AlephTPC_alignment.xml"/>
     -->
diff --git a/examples/AlignDet/compact/Telescope.xml b/examples/AlignDet/compact/Telescope.xml
new file mode 100644
index 000000000..be92ad0ed
--- /dev/null
+++ b/examples/AlignDet/compact/Telescope.xml
@@ -0,0 +1,115 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0"
+  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+  xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <info name="TelescopeSensor"
+    title="Simple emulation of the EU Telescope"
+    author="Christoph Hombach"
+    url="https://github.com/AIDASoft/DD4hep/blob/master/examples/AlignDet/compact/Telescope.xml"
+    status="development"
+    version="1.0">
+    <comment>Simple emulation of the EU Telescope to test alignment procedures</comment>
+  </info>
+
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/>
+  </includes>
+
+  <define>
+    <constant name="world_side" value="1*m"/>
+    <constant name="world_x" value="world_side/2"/>
+    <constant name="world_y" value="world_side/2"/>
+    <constant name="world_z" value="world_side/2"/>
+    <constant name="CrossingAngle" value="0.020"/>
+  </define>
+
+  <materials>
+  </materials>
+
+  <limits>
+  </limits>
+
+  <display>
+    <vis name="DetVis" alpha="1.0" r="0" g="0.0" b="1.0" showDaughters="true" visible="false"/>
+    <vis name="ModVis" alpha="0.3" r="0.8" g="0.8" b="1.0" showDaughters="true" visible="true"/>
+
+    <vis name="SensorVis" alpha="1.0" r="1.0"    g="0.2"    b="0.2"    showDaughters="false" visible="true"/>
+    <vis name="ChipVis"   alpha="1.0" r="0.7451" g="0.7451" b="0.7451" showDaughters="false" visible="true"/>
+    <vis name="PCBVis"    alpha="1.0" r="0.0000" g="0.3910" b="0.0000" showDaughters="false" visible="true"/>
+  </display>
+
+  <detectors>
+    <comment>No comment so far</comment>
+
+    <detector name="Telescope" type="DD4hep_Example_Telescope"  vis="DetVis" id ="1" readout="TelescopeHits">
+      <!-- Front arm -->
+      <module z="0.0*cm" id="1" vis="ModVis">
+        <sensor thickness="3*mm" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="7*mm" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="2.5*cm" id="2" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="5.0*cm" id="3" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="7.5*cm" id="4" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <!-- DuT -->
+      <module z="25.0*cm" id="5" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="768" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <!-- Back arm -->
+      <module z="42.5*cm" id="6" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="45.0*cm" id="7" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="47.5*cm" id="8" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+
+      <module z="50.0*cm" id="9" vis="ModVis">
+        <sensor thickness="300*micron" pitch="55*micron" NoOfPixY="256" NoOfPixX="256" vis="SensorVis"/>
+        <chip thickness="700*micron" vis="ChipVis"/>
+        <PCB thickness="1.4*mm" vis="PCBVis"/>
+      </module>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="TelescopeHits">
+      <segmentation type="CartesianGridXY" grid_size_x="55*micron" grid_size_y="55*micron" />
+      <id>system:6,sensor:10,x:16,y:16</id>
+    </readout>
+  </readouts>
+
+  <fields>
+  </fields>
+
+</lccdd>
diff --git a/examples/AlignDet/src/AlephTPC_geo.cpp b/examples/AlignDet/src/AlephTPC_geo.cpp
index 99e25d9bf..8c506813f 100644
--- a/examples/AlignDet/src/AlephTPC_geo.cpp
+++ b/examples/AlignDet/src/AlephTPC_geo.cpp
@@ -1,11 +1,17 @@
-// $Id: Tesla_tpc02_geo.cpp 581 2013-05-30 21:05:58Z markus.frank $
-//====================================================================
+//==========================================================================
 //  AIDA Detector description implementation for LCD
-//--------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
 //
-//  Author     : M.Frank
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
 //
-//====================================================================
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework include files
 #include "DD4hep/DetFactoryHelper.h"
 #include "TGeoArb8.h"
 #include <iomanip>
diff --git a/examples/AlignDet/src/BoxDetector_geo.cpp b/examples/AlignDet/src/BoxDetector_geo.cpp
index de1471001..021798e61 100644
--- a/examples/AlignDet/src/BoxDetector_geo.cpp
+++ b/examples/AlignDet/src/BoxDetector_geo.cpp
@@ -1,11 +1,17 @@
-// $Id: BoxDetector_geo.cpp 633 2013-06-21 13:50:50Z markus.frank $
-//====================================================================
+//==========================================================================
 //  AIDA Detector description implementation for LCD
-//--------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
 //
-//  Author     : M.Frank
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
 //
-//====================================================================
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework include files
 #include "DD4hep/DetFactoryHelper.h"
 
 using namespace std;
diff --git a/examples/AlignDet/src/Telescope_geo.cpp b/examples/AlignDet/src/Telescope_geo.cpp
new file mode 100644
index 000000000..514674ba2
--- /dev/null
+++ b/examples/AlignDet/src/Telescope_geo.cpp
@@ -0,0 +1,75 @@
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework include files
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+
+using namespace std;
+using namespace DD4hep;
+using namespace DD4hep::Geometry;
+
+static Ref_t create_element(LCDD& lcdd, xml_h e, SensitiveDetector sd)  {
+  Box         box;
+  Volume      vol;
+  PlacedVolume phv;
+  xml_det_t   x_det  = e;
+  double      small  = 1e-3*dd4hep::mm;
+  string      name   = x_det.nameStr();
+  Material    air    = lcdd.material("Air");
+  DetElement  det    (name,x_det.id());
+  Assembly    envVol (name+"_envelope");
+
+  for(xml_coll_t im(x_det,_U(module)); im; ++im)  {
+    xml_dim_t mod    = im;
+    xml_dim_t sens   = mod.child(_U(sensor));
+    xml_dim_t chip   = mod.child(_Unicode(chip));
+    xml_dim_t pcb    = mod.child(_Unicode(PCB));
+    int    noPixX    = sens.attr<int>(_Unicode(NoOfPixX));
+    int    noPixY    = sens.attr<int>(_Unicode(NoOfPixY));
+    double pitch     = sens.attr<double>(_Unicode(pitch));
+    double mod_thick = sens.thickness()+chip.thickness()+pcb.thickness();
+
+    // Make envelope box for each module a bit bigger to ensure all children are within bounds...
+    box = Box(pitch*noPixX/2e0+small, pitch*noPixY/2e0+small, mod_thick/2e0+small);
+    Volume modvol(_toString(mod.id(),"module_%d"), box, air);
+    modvol.setVisAttributes(lcdd.visAttributes(mod.visStr()));
+
+    box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, sens.thickness()/2e0);
+    vol = Volume(_toString(mod.id(),"sensor_%d"), box, air);
+    vol.setSensitiveDetector(sd);
+    vol.setVisAttributes(lcdd.visAttributes(sens.visStr()));
+    phv = modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()/2e0));
+    phv.addPhysVolID("sensor",mod.id());
+
+    box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, chip.thickness()/2e0);
+    vol = Volume(_toString(mod.id(),"chip_%d"), box, air);
+    vol.setVisAttributes(lcdd.visAttributes(chip.visStr()));
+    modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()+chip.thickness()/2e0));
+
+    box = Box(pitch*noPixX/2e0, pitch*noPixY/2e0, pcb.thickness()/2e0);
+    vol = Volume(_toString(mod.id(),"PCB_%d"), box, air);
+    vol.setVisAttributes(lcdd.visAttributes(pcb.visStr()));
+    modvol.placeVolume(vol, Position(0, 0, -mod_thick/2e0+sens.thickness()+chip.thickness()+pcb.thickness()/2e0));
+
+    envVol.placeVolume(modvol,Position(0e0, 0e0, mod.z()));
+  }
+  envVol.setVisAttributes(lcdd.visAttributes(x_det.visStr()));
+  phv = lcdd.pickMotherVolume(det).placeVolume(envVol,Position(0,0,0));
+  phv.addPhysVolID("system",x_det.id());
+  det.setPlacement(phv);
+  return det;
+}
+
+// first argument is the type from the xml file
+DECLARE_DETELEMENT(DD4hep_Example_Telescope,create_element)
diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt
index e5a054df4..d5d65b7ad 100644
--- a/examples/ClientTests/CMakeLists.txt
+++ b/examples/ClientTests/CMakeLists.txt
@@ -28,6 +28,26 @@ dd4hep_install_dir( compact scripts DESTINATION ${DD4hep_DIR}/examples/ClientTes
 dd4hep_configure_scripts( ClientTests DEFAULT_SETUP WITH_TESTS)
 #---  Testing  ------------------------------------------------------------
 #
+#  Test readout strings of the form: <id>system:8,barrel:-2</id>
+dd4hep_add_test_reg( ClientTests_Bitfield64_BarrelSides
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoPluginRun
+  -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/Bitfield_SidesTest.xml -volmgr -destroy
+  -plugin DD4hepDetectorVolumeDump
+  -plugin DD4hepVolumeDump volids
+  -plugin DD4hepVolumeMgrTest all
+  REGEX_PASS "OK IDS\\(Shell_1\\)  vid\\:0000000000000302 system\\: 2  barrel\\:-1" )
+#
+#
+#  Test readout strings of the form: <id>system:16,barrel:16:-5</id>
+dd4hep_add_test_reg( ClientTests_Bitfield64_BarrelSides2
+  COMMAND    "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh"
+  EXEC_ARGS  geoPluginRun
+  -input file:${CMAKE_CURRENT_SOURCE_DIR}/compact/Bitfield_SidesTest2.xml -volmgr -destroy
+  -plugin DD4hepDetectorVolumeDump
+  -plugin DD4hepVolumeDump volids
+  -plugin DD4hepVolumeMgrTest all
+  REGEX_PASS "OK IDS\\(Shell_1\\)  vid\\:00000000001f0002 system\\: 2  barrel\\:-1" )
 #
 #
 foreach (test Assemblies BoxTrafos IronCylinder LheD_tracker MagnetFields MaterialTester 
diff --git a/examples/ClientTests/compact/Bitfield_SidesTest.xml b/examples/ClientTests/compact/Bitfield_SidesTest.xml
new file mode 100644
index 000000000..9d8986875
--- /dev/null
+++ b/examples/ClientTests/compact/Bitfield_SidesTest.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/>
+  </includes>
+
+  <define>
+    <constant name="world_size" value="30*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+    <constant name="Barrel_rmax" value="500*cm"/>
+    <constant name="Barrel_zmax" value="600*cm"/>
+  </define>
+
+  <display>
+    <vis name="Invisible" showDaughters="false" visible="false"/>
+    <vis name="InvisibleWithChildren" showDaughters="true" visible="false"/>
+    <vis name="VisibleRed"  r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="VisibleBlue" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/>
+    <vis name="VisibleGreen" alpha="1.0" r="0.0" g="1.0" b="0.0" drawingStyle="solid" lineStyle="solid" showDaughters="true" visible="true"/>
+  </display>
+
+  <detectors>
+    <detector id="2" name="Shell" type="DD4hep_CylinderShell" vis="VisibleGreen" readout="ShellHits" >
+      <comment>Containment shell to measure calorimeter escapes</comment>
+      <material name="Air"/>
+      <module name="Barrel" id="0" vis="VisibleBlue">
+	<zplane rmin="Barrel_rmax+20*cm" rmax="Barrel_rmax+22*cm" z="-2*Barrel_zmax"/>
+	<zplane rmin="Barrel_rmax+20*cm" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax"/>
+      </module>
+      <module name="SideA" id="-1" vis="VisibleRed">
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax+10*cm"/>
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax+20*cm"/>
+      </module>
+      <module name="SideB" id="1" vis="VisibleRed">
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="-(2*Barrel_zmax+10*cm)"/>
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="-(2*Barrel_zmax+20*cm)"/>
+      </module>
+    </detector>
+  </detectors>
+  
+  <readouts>
+    <readout name="ShellHits"><id>system:8,barrel:-2</id></readout>
+  </readouts>
+
+  <fields>
+    <field name="GlobalSolenoid" type="solenoid" 
+	   inner_field="5.0*tesla"
+	   outer_field="-1.5*tesla" 
+	   zmax="2*m"
+	   outer_radius="3*m">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/examples/ClientTests/compact/Bitfield_SidesTest2.xml b/examples/ClientTests/compact/Bitfield_SidesTest2.xml
new file mode 100644
index 000000000..f22f4a758
--- /dev/null
+++ b/examples/ClientTests/compact/Bitfield_SidesTest2.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <includes>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/>
+    <gdmlFile  ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/>
+  </includes>
+
+  <define>
+    <constant name="world_size" value="30*m"/>
+    <constant name="world_x" value="world_size"/>
+    <constant name="world_y" value="world_size"/>
+    <constant name="world_z" value="world_size"/>
+    <constant name="Barrel_rmax" value="500*cm"/>
+    <constant name="Barrel_zmax" value="600*cm"/>
+  </define>
+
+  <display>
+    <vis name="Invisible" showDaughters="false" visible="false"/>
+    <vis name="InvisibleWithChildren" showDaughters="true" visible="false"/>
+    <vis name="VisibleRed"  r="1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="VisibleBlue" r="0.0" g="0.0" b="1.0" showDaughters="false" visible="true"/>
+    <vis name="VisibleGreen" alpha="1.0" r="0.0" g="1.0" b="0.0" drawingStyle="solid" lineStyle="solid" showDaughters="true" visible="true"/>
+  </display>
+
+  <detectors>
+    <detector id="2" name="Shell" type="DD4hep_CylinderShell" vis="VisibleGreen" readout="ShellHits" >
+      <comment>Containment shell to measure calorimeter escapes</comment>
+      <material name="Air"/>
+      <module name="Barrel" id="0" vis="VisibleBlue">
+	<zplane rmin="Barrel_rmax+20*cm" rmax="Barrel_rmax+22*cm" z="-2*Barrel_zmax"/>
+	<zplane rmin="Barrel_rmax+20*cm" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax"/>
+      </module>
+      <module name="SideA" id="-1" vis="VisibleRed">
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax+10*cm"/>
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="2*Barrel_zmax+20*cm"/>
+      </module>
+      <module name="SideB" id="1" vis="VisibleRed">
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="-(2*Barrel_zmax+10*cm)"/>
+	<zplane rmin="0" rmax="Barrel_rmax+22*cm" z="-(2*Barrel_zmax+20*cm)"/>
+      </module>
+    </detector>
+  </detectors>
+  
+  <readouts>
+    <readout name="ShellHits"><id>system:16,barrel:16:-5</id></readout>
+  </readouts>
+
+  <fields>
+    <field name="GlobalSolenoid" type="solenoid" 
+	   inner_field="5.0*tesla"
+	   outer_field="-1.5*tesla" 
+	   zmax="2*m"
+	   outer_radius="3*m">
+    </field>
+  </fields>
+
+</lccdd>
diff --git a/examples/ClientTests/src/Assemblies_VXD_geo.cpp b/examples/ClientTests/src/Assemblies_VXD_geo.cpp
index bd0c58751..e7025cd8b 100644
--- a/examples/ClientTests/src/Assemblies_VXD_geo.cpp
+++ b/examples/ClientTests/src/Assemblies_VXD_geo.cpp
@@ -1,11 +1,17 @@
-// $Id: ILDExVXD_geo.cpp 673 2013-08-05 10:01:33Z gaede $
-//====================================================================
+//==========================================================================
 //  AIDA Detector description implementation for LCD
-//--------------------------------------------------------------------
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
 //
-//  Author     : M.Frank
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
 //
-//====================================================================
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework includes
 #include "DD4hep/DetFactoryHelper.h"
 
 using namespace std;
diff --git a/examples/ClientTests/src/IronCylinder_geo.cpp b/examples/ClientTests/src/IronCylinder_geo.cpp
index 995083ae8..70aa27a84 100644
--- a/examples/ClientTests/src/IronCylinder_geo.cpp
+++ b/examples/ClientTests/src/IronCylinder_geo.cpp
@@ -1,16 +1,19 @@
-/*********************************
- * HcalBarrel_geo
- * Implementing a detector
- *
- * Carlos.Solans@cern.ch
- *********************************/
-
+//==========================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+
+// Framework includes
 #include "DD4hep/DetFactoryHelper.h"
-#include "XML/Layering.h"
-
-#include <vector>
 
-using namespace std;
 using namespace DD4hep;
 using namespace DD4hep::Geometry;
 
@@ -43,7 +46,6 @@ static Ref_t create_detector(LCDD& lcdd, xml_h e, SensitiveDetector sens)  {
   calo_plv.addPhysVolID("system",x_det.id());
   calo_plv.addPhysVolID("barrel",0);
   d_det.setPlacement(calo_plv);
-
   return d_det;
 }
 
diff --git a/examples/Conditions/data/Module1_run-1000...2000.xml b/examples/Conditions/data/Module1_run-1000...2000.xml
new file mode 100644
index 000000000..84c7786fb
--- /dev/null
+++ b/examples/Conditions/data/Module1_run-1000...2000.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--- $Id: -->
+<!--- Author  : Markus Frank -->
+<!--- Created : 2016-11-07 -->
+
+<conditions>
+
+</conditions>
diff --git a/examples/Conditions/data/repository.xml b/examples/Conditions/data/repository.xml
new file mode 100644
index 000000000..de1a4cfbd
--- /dev/null
+++ b/examples/Conditions/data/repository.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--- Author  : Markus Frank -->
+<!--- Created : 2016-11-07   -->
+
+<conditions>
+  <iov type="run" start="1000" end="2000" ref="module1_run-1000...2000.xml"/>
+<!--
+  <iov type="run" start="1000" end="2000" ref="module2_run-1000...2000.xml"/>
+-->
+</conditions>
-- 
GitLab