From eab8c1ac77b5ffde79cdffe01b25378dd6367948 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Wed, 25 Jan 2017 20:36:51 +0100
Subject: [PATCH] Fix various warnings from coverty

---
 .../include/DDCond/ConditionsManagerObject.h  |  27 +++-
 DDCond/include/DDCond/ConditionsPool.h        |   2 -
 DDCond/include/DDCond/ConditionsRepository.h  |   2 +-
 DDCond/include/DDCond/ConditionsSlice.h       |  23 +++-
 DDCond/src/ConditionsManager.cpp              |   2 +
 DDCond/src/ConditionsSlice.cpp                |  10 ++
 DDCond/src/plugins/ConditionsUserPool.cpp     |  89 ++++++++-----
 DDCore/include/DD4hep/DetAlign.h              |   4 +-
 DDCore/include/DD4hep/Detector.h              |   6 +-
 DDCore/include/DD4hep/IOV.h                   |   2 +-
 DDCore/include/DD4hep/OpaqueData.h            |   4 +-
 DDCore/src/ConditionsData.cpp                 |   3 +-
 DDCore/src/Errors.cpp                         |   1 -
 DDCore/src/plugins/Compact2Objects.cpp        |   3 +
 DDCore/src/plugins/StandardPlugins.cpp        | 120 +++++++++++++++++-
 DDDB/include/DDDB/DDDBConversion.h            |   6 +-
 DDDB/src/DDDBConversion.cpp                   |   4 +-
 DDDB/src/DDDBPlugins.cpp                      |  20 +--
 DDDetectors/src/LayeringExtensionPlugin.cpp   |   1 -
 DDEve/include/DDEve/EventControl.h            |   1 -
 DDEve/include/DDEve/Utilities.h               |   3 +-
 DDEve/src/EventControl.cpp                    |  10 +-
 DDEve/src/Utilities.cpp                       |   2 +-
 DDG4/include/DDG4/Geant4GeneratorAction.h     |   6 +
 DDG4/include/DDG4/Geant4HitCollection.h       |   6 +-
 .../DDG4/Geant4InteractionVertexBoost.h       |   2 +
 .../DDG4/Geant4InteractionVertexSmear.h       |   4 +
 DDG4/include/DDG4/Geant4IsotropeGenerator.h   |   4 +
 DDG4/include/DDG4/Geant4OutputAction.h        |   4 +
 DDG4/include/DDG4/Geant4Particle.h            |  24 ++--
 DDG4/include/DDG4/Geant4TrackingAction.h      |   8 +-
 DDG4/plugins/Geant4MaterialScanner.cpp        |   8 +-
 DDG4/src/Geant4GeneratorAction.cpp            |   2 +-
 DDG4/src/Geant4ParticleHandler.cpp            |   8 +-
 DDG4/src/Geant4ParticlePrint.cpp              |  54 ++++----
 DDG4/src/Geant4SensDetAction.cpp              |   2 +-
 DDG4/src/Geant4StackingAction.cpp             |   2 +-
 DDG4/src/Geant4SteppingAction.cpp             |   2 +-
 DDG4/src/Geant4TrackingAction.cpp             |   2 +-
 doc/LaTex/DD4hep-setup.tex                    |   1 +
 doc/LaTex/DDAlignManual.tex                   |   7 +
 41 files changed, 369 insertions(+), 122 deletions(-)

diff --git a/DDCond/include/DDCond/ConditionsManagerObject.h b/DDCond/include/DDCond/ConditionsManagerObject.h
index f9e6a6715..445f67064 100644
--- a/DDCond/include/DDCond/ConditionsManagerObject.h
+++ b/DDCond/include/DDCond/ConditionsManagerObject.h
@@ -70,30 +70,52 @@ namespace DD4hep {
       Listeners              m_onRemove;
       /// Reference to the data loader userd by this instance
       Loader                 m_loader;
+      /// Property: Flag to indicate if items should be loaded (or not)
+      bool                   m_doLoad = true;
+      /// Property: Flag to indicate if unloaded items should be saved to the slice (or not)
+      bool                   m_doOutputUnloaded = false;
+
       /// Register callback listener object
       void registerCallee(Listeners& listeners, const Listener& callee, bool add);
 
     public:
+
       /// Default constructor
       ConditionsManagerObject(LCDD& lcdd);
+
       /// Default destructor
       virtual ~ConditionsManagerObject();
+
       /// Access to the detector description instance
-      LCDD& lcdd() const                    {  return m_lcdd;          }
+      LCDD& lcdd() const                    {  return m_lcdd;              }
+
       /// Access to the data loader
-      ConditionsDataLoader* loader()  const {  return m_loader.get();  }
+      ConditionsDataLoader* loader()  const {  return m_loader.get();      }
+
+      /// Access to load flag
+      bool doLoadConditions()  const        {  return m_doLoad;            }
+
+      /// Access to flag to indicate if unloaded items should be saved to the slice (or not)
+      bool doOutputUnloaded()  const        {  return m_doOutputUnloaded;  }
+
       /// Listener invocation when a condition is registered to the cache
       void onRegister(Condition condition);
+
       /// Listener invocation when a condition is deregistered from the cache
       void onRemove(Condition condition);
+
       /// (Un)Registration of conditions listeners with callback when a new condition is registered
       void callOnRegister(const Listener& callee, bool add);
+
       /// (Un)Registration of conditions listeners with callback when a condition is unregistered
       void callOnRemove(const Listener& callee, bool add);
+
       /// Access the used/registered IOV types
       const std::vector<const IOVType*> iovTypesUsed() const;
+
       /// Create IOV from string
       void fromString(const std::string& iov_str, IOV& iov);
+
       /// Register IOV using new string data
       ConditionsPool* registerIOV(const std::string& data);
 
@@ -147,6 +169,7 @@ namespace DD4hep {
       /// Full cleanup of all managed conditions.
       /** @return pair<Number of pools cleared, Number of conditions cleaned up and removed> */
       virtual std::pair<int,int> clear() = 0;
+
     };
   }    /* End namespace Geometry                       */
 }      /* End namespace DD4hep                         */
diff --git a/DDCond/include/DDCond/ConditionsPool.h b/DDCond/include/DDCond/ConditionsPool.h
index fad04760a..b2f4f3992 100644
--- a/DDCond/include/DDCond/ConditionsPool.h
+++ b/DDCond/include/DDCond/ConditionsPool.h
@@ -18,7 +18,6 @@
 #include "DDCond/ConditionsManager.h"
 
 // C/C++ include files
-#include <set>
 
 /// Namespace for the AIDA detector description toolkit
 namespace DD4hep {
@@ -139,7 +138,6 @@ namespace DD4hep {
     public:
       /// Forward definition of the key type
       typedef Condition::key_type                  key_type;
-      typedef std::set<ConditionKey>               ConditionKeys;
       typedef ConditionDependency                  Dependency;
       typedef ConditionsDependencyCollection       Dependencies;
       typedef ConditionsManager::Result            Result;
diff --git a/DDCond/include/DDCond/ConditionsRepository.h b/DDCond/include/DDCond/ConditionsRepository.h
index 579766117..05c462092 100644
--- a/DDCond/include/DDCond/ConditionsRepository.h
+++ b/DDCond/include/DDCond/ConditionsRepository.h
@@ -70,7 +70,7 @@ namespace DD4hep {
       int load(const std::string& input, Data& data)  const;
     };
 
-  } /* End namespace Geometry               */
+  } /* End namespace Conditions             */
 } /* End namespace DD4hep                   */
 
 #endif /* DD4HEP_CONDITIONS_CONDITIONSREPOSITORY_H  */
diff --git a/DDCond/include/DDCond/ConditionsSlice.h b/DDCond/include/DDCond/ConditionsSlice.h
index 18fc914fd..7a8a256e9 100644
--- a/DDCond/include/DDCond/ConditionsSlice.h
+++ b/DDCond/include/DDCond/ConditionsSlice.h
@@ -178,14 +178,22 @@ namespace DD4hep {
       dd4hep_ptr<UserPool> pool;
 
     protected:
+      /// Container of conditions required by this slice
       ConditionsProxy      m_conditions;
+      /// Container of derived conditions required by this slice
       ConditionsProxy      m_derived;
-
+      /// If flag conditonsManager["OutputUnloadedConditions"]=true: will contain conditions not loaded
+      ConditionsProxy      m_missingConditions;
+      /// If flag conditonsManager["OutputUnloadedConditions"]=true: will contain conditions not computed
+      ConditionsProxy      m_missingDerivations;
+      
       /// Default assignment operator
       ConditionsSlice& operator=(const ConditionsSlice& copy) = delete;
 
-      /// Add a new conditions entry
+      /// Add a new conditions descriptor entry
       bool insert_condition(Descriptor* entry);
+      /// Add a new condition to the user pool
+      bool insert_condition(Condition condition);
 
     public:
       /// Default constructor
@@ -202,6 +210,11 @@ namespace DD4hep {
       const ConditionsProxy& derived() const     { return m_derived;      }
       /// Number of entries
       size_t size() const  { return m_conditions.size()+m_derived.size(); }
+      /// Access the map of missing conditions (only valid after preparation)
+      ConditionsProxy& missingConditions()  { return m_missingConditions; }
+      /// Access the map of missing computational conditions (only valid after preparation)
+      ConditionsProxy& missingDerivations() { return m_missingDerivations;}
+
       /// Clear the container. Destroys the contained stuff
       void clear();
       /// Clear the conditions access and the user pool.
@@ -222,6 +235,12 @@ namespace DD4hep {
         Descriptor* e = new ConditionsLoaderDescriptor<T>(key,loadinfo);
         return insert_condition(e);
       }
+      /// Add a condition directly to the slice
+      /** Note: The user pool must exist. This call ONLY allows to update the user pool.
+       */
+      bool insert(Condition condition)   {
+        return insert_condition(condition);
+      }
     };
 
     /// Populate the conditions slice from the conditions manager (convenience)
diff --git a/DDCond/src/ConditionsManager.cpp b/DDCond/src/ConditionsManager.cpp
index 1117a63f6..a02052eb6 100644
--- a/DDCond/src/ConditionsManager.cpp
+++ b/DDCond/src/ConditionsManager.cpp
@@ -50,6 +50,8 @@ ConditionsManagerObject::ConditionsManagerObject(LCDD& ref_lcdd)
   : NamedObject(), m_lcdd(ref_lcdd)
 {
   InstanceCount::increment(this);
+  declareProperty("LoadConditions",           m_doLoad);
+  declareProperty("OutputUnloadedConditions", m_doOutputUnloaded);
 }
 
 /// Default destructor
diff --git a/DDCond/src/ConditionsSlice.cpp b/DDCond/src/ConditionsSlice.cpp
index 8e71f67b7..ac7c14584 100644
--- a/DDCond/src/ConditionsSlice.cpp
+++ b/DDCond/src/ConditionsSlice.cpp
@@ -111,6 +111,16 @@ bool ConditionsSlice::insert_condition(Descriptor* entry)   {
   return false;
 }
 
+/// Add a new condition to the user pool
+bool ConditionsSlice::insert_condition(Condition condition)   {
+  if ( condition.isValid() )  {
+    return pool->insert(condition);
+  }
+  DD4hep::except("ConditionsSlice",
+                 "insert_condition: Cannot insert invalid conditions to the user pool!");
+  return false;
+}
+
 namespace  {
   
   struct SliceOper  : public ConditionsSelect  {
diff --git a/DDCond/src/plugins/ConditionsUserPool.cpp b/DDCond/src/plugins/ConditionsUserPool.cpp
index 6ba4e8ca9..33bbad547 100644
--- a/DDCond/src/plugins/ConditionsUserPool.cpp
+++ b/DDCond/src/plugins/ConditionsUserPool.cpp
@@ -330,7 +330,11 @@ ConditionsMappedUserPool<MAPPING>::prepare_VSN_1(const IOV&              require
   typedef std::vector<pair<Condition::key_type,ConditionsDescriptor*> > _Missing;
   const auto& slice_cond = slice.conditions();
   const auto& slice_calc = slice.derived();
-  IOV pool_iov(required.iovType);
+  auto&  slice_miss_cond = slice.missingConditions();
+  auto&  slice_miss_calc = slice.missingDerivations();
+  bool   do_load         = m_manager->doLoadConditions();
+  bool   do_output_miss  = m_manager->doOutputUnloaded();
+  IOV    pool_iov(required.iovType);
   Result result;
 
   // This is a critical operation, because we have to ensure the
@@ -340,6 +344,8 @@ ConditionsMappedUserPool<MAPPING>::prepare_VSN_1(const IOV&              require
   lock_guard<mutex> guard(lock);
 
   m_conditions.clear();
+  slice_miss_cond.clear();
+  slice_miss_calc.clear();
   pool_iov.reset().invert();
   m_iovPool->select(required, Operators::mapConditionsSelect(m_conditions), pool_iov);
   m_iov = pool_iov;
@@ -369,47 +375,66 @@ ConditionsMappedUserPool<MAPPING>::prepare_VSN_1(const IOV&              require
   // Now we load the missing conditions from the conditions loader
   //
   if ( num_cond_miss > 0 )  {
-    ConditionsDataLoader::LoadedItems loaded;
-    size_t updates = m_loader->load_many(required, cond_missing, loaded, pool_iov);
-    if ( updates > 0 )  {
-      // Need to compute the intersection: All missing entries are required....
-      _Missing load_missing(cond_missing.size()+loaded.size());
-      // Note: cond_missing is already sorted (doc of 'set_difference'). No need to re-sort....
-      _Missing::iterator load_last = set_difference(begin(cond_missing), last_cond,
-                                                    begin(loaded), end(loaded),
-                                                    begin(load_missing), COMP());
-      int num_load_miss = int(load_last-begin(load_missing));
-      printout(num_load_miss==0 ? DEBUG : ERROR,"UserPool",
-               "Found %ld out of %d conditions, which CANNOT be loaded...",
-               num_load_miss, int(loaded.size()));
-
-      for_each(loaded.begin(),loaded.end(),Inserter<MAPPING>(m_conditions,&m_iov));
-      result.loaded  = slice_cond.size()-num_load_miss;
-      result.missing = num_load_miss+num_calc_miss;
-      if ( cond_missing.size() != loaded.size() )  {
-        // ERROR!
+    if ( do_load )  {
+      ConditionsDataLoader::LoadedItems loaded;
+      size_t updates = m_loader->load_many(required, cond_missing, loaded, pool_iov);
+      if ( updates > 0 )  {
+        // Need to compute the intersection: All missing entries are required....
+        _Missing load_missing(cond_missing.size()+loaded.size());
+        // Note: cond_missing is already sorted (doc of 'set_difference'). No need to re-sort....
+        _Missing::iterator load_last = set_difference(begin(cond_missing), last_cond,
+                                                      begin(loaded), end(loaded),
+                                                      begin(load_missing), COMP());
+        int num_load_miss = int(load_last-begin(load_missing));
+        printout(num_load_miss==0 ? DEBUG : ERROR,"UserPool",
+                 "Found %ld out of %d conditions, which CANNOT be loaded...",
+                 num_load_miss, int(loaded.size()));
+        if ( do_output_miss )  {
+          copy(begin(load_missing), load_last, inserter(slice_miss_cond, slice_miss_cond.begin()));
+        }
+        for_each(loaded.begin(),loaded.end(),Inserter<MAPPING>(m_conditions,&m_iov));
+        result.loaded  = slice_cond.size()-num_load_miss;
+        result.missing = num_load_miss+num_calc_miss;
+        if ( cond_missing.size() != loaded.size() )  {
+          // ERROR!
+        }
       }
     }
+    else if ( do_output_miss )  {
+      copy(begin(cond_missing), last_cond, inserter(slice_miss_cond, slice_miss_cond.begin()));
+    }
   }
   //
   // Now we update the already existing dependencies, which have expired
   //
   if ( num_calc_miss > 0 )  {
-    ConditionsDependencyCollection deps(calc_missing.begin(), last_calc, _to_dep);
-    ConditionsDependencyHandler handler(m_manager, *this, deps, user_param);
-    for(auto i=begin(deps); i != end(deps); ++i)   {
-      const ConditionDependency* d = (*i).second.get();
-      typename MAPPING::iterator j = m_conditions.find(d->key());
-      // If we would know, that dependencies are only ONE level, we could skip this search....
-      if ( j == m_conditions.end() )  {
-        handler(d);
+    if ( do_load )  {
+      ConditionsDependencyCollection deps(calc_missing.begin(), last_calc, _to_dep);
+      ConditionsDependencyHandler handler(m_manager, *this, deps, user_param);
+      for(auto i=begin(deps); i != end(deps); ++i)   {
+        const ConditionDependency* d = (*i).second.get();
+        typename MAPPING::iterator j = m_conditions.find(d->key());
+        // If we would know, that dependencies are only ONE level, we could skip this search....
+        if ( j == m_conditions.end() )  {
+          handler(d);
+          continue;
+        }
+        // printout(INFO,"UserPool","Already calcluated: %s",d->name());
         continue;
       }
-      // printout(INFO,"UserPool","Already calcluated: %s",d->name());
-      continue;
+      result.computed = handler.num_callback;
+      result.missing -= handler.num_callback;
+      if ( do_output_miss && result.computed < deps.size() )  {
+        for(auto i=calc_missing.begin(); i != last_calc; ++i)   {
+          typename MAPPING::iterator j = m_conditions.find((*i).first);
+          if ( j == m_conditions.end() )
+            slice_miss_calc.insert(*i);
+        }
+      }
+    }
+    else if ( do_output_miss )  {
+      copy(begin(calc_missing), last_calc, inserter(slice_miss_calc, slice_miss_calc.begin()));
     }
-    result.computed = handler.num_callback;
-    result.missing -= handler.num_callback;
   }
   return result;
 }
diff --git a/DDCore/include/DD4hep/DetAlign.h b/DDCore/include/DD4hep/DetAlign.h
index 3bec3f220..2ae95bfb3 100644
--- a/DDCore/include/DD4hep/DetAlign.h
+++ b/DDCore/include/DD4hep/DetAlign.h
@@ -89,11 +89,11 @@ namespace DD4hep {
       /// Access to the alignments information
       Container alignments() const;
       /// Access to alignment objects from a given pool
-      Alignment get(const std::string& key,  const UserPool& pool);
+      Alignment get(const std::string&  key, const UserPool& pool);
       /// Access to alignment objects from a given pool
       Alignment get(Alignment::key_type key, const UserPool& pool);
       /// Access to alignment objects. Only alignments in the pool are accessed.
-      Alignment get(const std::string& key,  const Alignment::iov_type& iov);
+      Alignment get(const std::string&  key, const Alignment::iov_type& iov);
       /// Access to alignment objects. Only alignments in the pool are accessed.
       Alignment get(Alignment::key_type key, const Alignment::iov_type& iov);
     };
diff --git a/DDCore/include/DD4hep/Detector.h b/DDCore/include/DD4hep/Detector.h
index b913261ab..10d37719f 100644
--- a/DDCore/include/DD4hep/Detector.h
+++ b/DDCore/include/DD4hep/Detector.h
@@ -359,12 +359,12 @@ namespace DD4hep {
       /// Access to the physical volume of this detector element
       PlacedVolume placement() const;
       /// Set the physical volumes of the detector element
-      DetElement& setPlacement(const PlacedVolume& volume);
+      DetElement&  setPlacement(const PlacedVolume& volume);
       /// The cached VolumeID of this subdetector element
-      VolumeID volumeID() const;
+      VolumeID     volumeID() const;
 
       /// Add new child to the detector structure
-      DetElement& add(DetElement sub_element);
+      DetElement&  add(DetElement sub_element);
       /// Access to the list of children
       const Children& children() const;
       /// Access to individual children by name
diff --git a/DDCore/include/DD4hep/IOV.h b/DDCore/include/DD4hep/IOV.h
index b1c9b4325..ff10f206e 100644
--- a/DDCore/include/DD4hep/IOV.h
+++ b/DDCore/include/DD4hep/IOV.h
@@ -33,7 +33,7 @@ namespace DD4hep {
    */
   class IOVType   {
   public:
-    enum { UNKNOWN_IOV = ~0x0 } _IOVTypes;
+    enum _IOVTypes { UNKNOWN_IOV = ~0x0 };
     /// integer identifier ised internally
     unsigned int type = UNKNOWN_IOV;
     /// String name
diff --git a/DDCore/include/DD4hep/OpaqueData.h b/DDCore/include/DD4hep/OpaqueData.h
index 76ea989ed..06bb8fd2f 100644
--- a/DDCore/include/DD4hep/OpaqueData.h
+++ b/DDCore/include/DD4hep/OpaqueData.h
@@ -81,11 +81,11 @@ namespace DD4hep {
   class OpaqueDataBlock : public OpaqueData   {
 
   protected:
-    enum {
+    enum _DataTypes  {
       PLAIN_DATA = 1<<0,
       ALLOC_DATA = 1<<1,
       BOUND_DATA = 1<<2
-    } _DataTypes;
+    };
     /// 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*>)];
diff --git a/DDCore/src/ConditionsData.cpp b/DDCore/src/ConditionsData.cpp
index d20d82ec8..b159d18f7 100644
--- a/DDCore/src/ConditionsData.cpp
+++ b/DDCore/src/ConditionsData.cpp
@@ -1,4 +1,3 @@
-// $Id$
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
@@ -49,7 +48,7 @@ AbstractMap::AbstractMap(const AbstractMap& c)
 }
 
 /// Default constructor
-AbstractMap::AbstractMap() : clientData(0) {
+AbstractMap::AbstractMap() : clientData(0), classID(0) {
   InstanceCount::increment(this);
 }
 
diff --git a/DDCore/src/Errors.cpp b/DDCore/src/Errors.cpp
index 7cf1de286..3ed958777 100644
--- a/DDCore/src/Errors.cpp
+++ b/DDCore/src/Errors.cpp
@@ -11,7 +11,6 @@
 //  \version 1.0
 //
 //==========================================================================
-// $Id$
 
 // Framework include files
 #include "DD4hep/Errors.h"
diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index 9feb22ab4..fae3f7b7b 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -17,6 +17,7 @@
 #include "DD4hep/DD4hepUnits.h"
 #include "DD4hep/FieldTypes.h"
 #include "DD4hep/Printout.h"
+//#include "DD4hep/Mixture.h"
 #include "DD4hep/Plugins.h"
 #include "DD4hep/objects/SegmentationsInterna.h"
 #include "DD4hep/objects/DetectorInterna.h"
@@ -328,6 +329,7 @@ template <> void Converter<Material>::operator()(xml_h e) const {
 #endif
     //throw 1;
     mat = mix = new TGeoMixture(matname, composites.size(), dens_val);
+    //mat = mix = new Mixture(matname, composites.size(), dens_val);
     size_t ifrac = 0;
     vector<double> composite_fractions;
     double composite_fractions_total = 0.0;
@@ -361,6 +363,7 @@ template <> void Converter<Material>::operator()(xml_h e) const {
       else
         throw_print("Compact2Objects[ERROR]: Converting material:" + mname + " Element missing: " + nam);
     }
+    mix->SetRadLen(0e0);
 
     //fg: calling SetDensity for TGeoMixture results in incorrect radLen and intLen ( computed only from first element ) 
     // // Update estimated density if not provided.
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 5e9b5f407..1942cbcdc 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -17,6 +17,7 @@
 #include "DD4hep/DD4hepUI.h"
 #include "DD4hep/Factories.h"
 #include "DD4hep/Printout.h"
+#include "DD4hep/DD4hepUnits.h"
 #include "DD4hep/DetectorTools.h"
 #include "DD4hep/PluginCreators.h"
 #include "DD4hep/DD4hepRootPersistency.h"
@@ -176,8 +177,8 @@ static long root_elements(LCDD& lcdd, int argc, char** argv) {
   for(int i=0; i<argc; ++i)  {
     if ( argv[i][0] == '-' )  {
       char c = ::tolower(argv[i][1]);
-      if ( c == 't' ) type = argv[++i];
-      else if ( c == 'o' ) output = argv[++i];
+      if ( c == 't' && i+1<argc ) type = argv[++i];
+      else if ( c == 'o' && i+1<argc ) output = argv[++i];
       else  {
         ::printf("DD4hepElementTable -opt [-opt]                         \n"
                  "  -type   <string>    Output format: text or xml       \n"
@@ -231,6 +232,121 @@ static long root_elements(LCDD& lcdd, int argc, char** argv) {
 }
 DECLARE_APPLY(DD4hepElementTable,root_elements)
 
+/// Basic entry point to dump the ROOT TGeoElementTable object
+/**
+ *  Dump the elment table to stdout or file.
+ *
+ *  Factory: DD4hepElementTable -format xml/text(default) -output <file-name>
+ *
+ *  \author  M.Frank
+ *  \version 1.0
+ *  \date    01/04/2014
+ */
+static long root_materials(LCDD& lcdd, int argc, char** argv) {
+  struct MaterialPrint {
+    typedef XML::Element elt_h;
+    MaterialPrint() = default;
+    virtual ~MaterialPrint() = default;
+    virtual elt_h print(TGeoMaterial* m)  {
+      ::printf("%-8s %-32s  Aeff=%7.3f Zeff=%7.4f rho=%8.3f [g/mole] radlen=%8.3g [cm] intlen=%8.3g [cm] index=%3d\n",
+               m->IsMixture() ? "Mixture" : "Material",
+               m->GetName(), m->GetA(), m->GetZ(), m->GetDensity(),
+               m->GetRadLen(), m->GetIntLen(), m->GetIndex());
+      return elt_h(0);
+    }
+    virtual void print(elt_h, TGeoElement* e, double frac)   {
+      ::printf("  %-6s Fraction: %7.3f Z=%3d A=%6.2f N=%3d Neff=%6.2f\n",
+               e->GetName(), frac, e->Z(), e->A(), e->N(), e->Neff());
+    }
+    virtual void operator()(TGeoMaterial* m)  {
+      Double_t* mix = m->IsMixture() ? ((TGeoMixture*)m)->GetWmixt() : 0;
+      elt_h  mh = print(m);
+      for(int n=m->GetNelements(), i=0; i<n; ++i)   {
+        TGeoElement* e = m->GetElement(i);
+        print(mh, e, mix ? mix[i] : 1);
+      }
+    }
+  };
+  struct MaterialPrintXML : public MaterialPrint  {
+    elt_h root;
+    MaterialPrintXML(elt_h r) : root(r) {}
+    virtual ~MaterialPrintXML() {}
+    virtual elt_h print(TGeoMaterial* m)  {
+      elt_h elt = root.addChild(_U(material));
+      elt.setAttr(_U(name),m->GetName());
+      if ( ::strlen(m->GetTitle())>0 )   {
+        elt.setAttr(_U(formula),m->GetTitle());
+      }
+      else if ( m->GetNelements() == 1 )   {
+        elt.setAttr(_U(formula),m->GetElement(0)->GetName());
+      }
+      elt_h D = elt.addChild(_U(D));
+      D.setAttr(_U(type),"density");
+      D.setAttr(_U(value),m->GetDensity());
+      D.setAttr(_U(unit),"g/cm3");
+      return elt;
+    }
+    virtual void print(elt_h mat, TGeoElement* e, double frac)  {
+      elt_h elt = mat.addChild(_U(composite));
+      elt.setAttr(_U(n),frac);
+      elt.setAttr(_U(ref),e->GetName());
+    }
+  };
+
+  string type = "text", output = "";
+  for(int i=0; i<argc; ++i)  {
+    if ( argv[i][0] == '-' )  {
+      char c = ::tolower(argv[i][1]);
+      if ( c == 't' && i+1<argc ) type = argv[++i];
+      else if ( c == 'o' && i+1<argc ) output = argv[++i];
+      else  {
+        ::printf("DD4hepElementTable -opt [-opt]                         \n"
+                 "  -type   <string>    Output format: text or xml       \n"
+                 "  -output <file-name> Output file specifier (xml only) \n"
+                 "\n");
+        exit(EINVAL);
+      }
+    }
+  }
+
+  XML::Document doc(0);
+  XML::DocumentHandler docH;
+  XML::Element  element(0);
+  if ( type == "xml" )  {
+     const char comment[] = "\n"
+    "      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"
+    "      ++++   Linear collider detector description in C++       ++++\n"
+    "      ++++   DD4hep Detector description generator.            ++++\n"
+    "      ++++                                                     ++++\n"
+    "      ++++   Parser:"
+    XML_IMPLEMENTATION_TYPE
+    "                ++++\n"
+    "      ++++                                                     ++++\n"
+    "      ++++   Table of elements as defined in ROOT: " ROOT_RELEASE  "     ++++\n"
+    "      ++++                                                     ++++\n"
+    "      ++++                              M.Frank CERN/LHCb      ++++\n"
+    "      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n  ";
+     doc = docH.create("materials", comment);
+     element = doc.root();
+  }
+  dd4hep_ptr<MaterialPrint> printer(element
+                                   ? new MaterialPrintXML(element)
+                                   : new MaterialPrint());
+  TObject* obj = 0;
+  TList* mats = lcdd.manager().GetListOfMaterials();
+  dd4hep_ptr<TIterator> iter(mats->MakeIterator());
+  while( (obj=iter->Next()) != 0 )  {
+    TGeoMaterial* mat = (TGeoMaterial*)obj;
+    (*printer)(mat);
+  }
+  if ( element )   {
+    XML::DocumentHandler dH;
+    dH.output(doc, output);
+  }
+  return 1;
+}
+DECLARE_APPLY(DD4hepMaterialTable,root_materials)
+
 /// Basic entry point to interprete an XML document
 /**
  *  - The file URI to be opened 
diff --git a/DDDB/include/DDDB/DDDBConversion.h b/DDDB/include/DDDB/DDDBConversion.h
index a711d089d..9b3fdbe37 100644
--- a/DDDB/include/DDDB/DDDBConversion.h
+++ b/DDDB/include/DDDB/DDDBConversion.h
@@ -114,8 +114,8 @@ namespace DD4hep {
      */
     class Atom  {
     public:
-      double A, Zeff;
-      Atom() : A(0), Zeff(0) {}
+      double A = 0E0, Zeff = 0E0;
+      Atom() = default;
     };
 
     /// Intermediate structure representing data of a Isotope
@@ -123,7 +123,7 @@ namespace DD4hep {
      */
     class Isotope : public Named  {
     public:
-      double A,Z,density;
+      double A = 0E0,Z = 0E0,density = 0E0;
       /// Default constructor
       Isotope();
       /// Default destructor
diff --git a/DDDB/src/DDDBConversion.cpp b/DDDB/src/DDDBConversion.cpp
index 6fc55fa63..45ebbaa4f 100644
--- a/DDDB/src/DDDBConversion.cpp
+++ b/DDDB/src/DDDBConversion.cpp
@@ -42,7 +42,7 @@ namespace DD4hep  {
   using namespace DDDB;
 
   /// Default constructor
-  dddb::dddb() : top(0), structure(0), geometry(0)  {
+  dddb::dddb() : world{0E0,0E0,0E0}, top(0), structure(0), geometry(0)  {
     InstanceCount::increment(this);
   }
 
@@ -197,7 +197,7 @@ namespace DD4hep  {
 
   /// Default constructor
   Shape::Shape() : type(0), zplanes(), boolean_ops() {
-    ::memset(&s.box,0,sizeof(s));
+    ::memset(&s,0,sizeof(s));
     InstanceCount::increment(this);
   }
   
diff --git a/DDDB/src/DDDBPlugins.cpp b/DDDB/src/DDDBPlugins.cpp
index 1ef1d605b..3034f818b 100644
--- a/DDDB/src/DDDBPlugins.cpp
+++ b/DDDB/src/DDDBPlugins.cpp
@@ -153,15 +153,17 @@ namespace {
      *  @date    01/04/2014
      */
     struct DumpActor {
-      struct Counters {
-        long totConditions;
-        long numConditions;
-        long numAlignments;
-        long numDetElements;
-        long numDetAlignmentKeys;
-        long numDetConditionKeys;
-        long numNoCatalogs;
-        long numDetPlacements;
+      struct Counters  final {
+        long totConditions = 0;
+        long numConditions = 0;
+        long numAlignments = 0;
+        long numDetElements = 0;
+        long numDetAlignmentKeys = 0;
+        long numDetConditionKeys = 0;
+        long numNoCatalogs = 0;
+        long numDetPlacements = 0;
+        Counters() = default;
+        ~Counters() = default;
         void reset() {
           totConditions=numConditions=numAlignments=numNoCatalogs=0;
           numDetElements=numDetConditionKeys=numDetAlignmentKeys=0;
diff --git a/DDDetectors/src/LayeringExtensionPlugin.cpp b/DDDetectors/src/LayeringExtensionPlugin.cpp
index deb50e634..3dc8c6213 100644
--- a/DDDetectors/src/LayeringExtensionPlugin.cpp
+++ b/DDDetectors/src/LayeringExtensionPlugin.cpp
@@ -1,4 +1,3 @@
-// $Id: $
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
diff --git a/DDEve/include/DDEve/EventControl.h b/DDEve/include/DDEve/EventControl.h
index a636e93df..96bd6dedb 100644
--- a/DDEve/include/DDEve/EventControl.h
+++ b/DDEve/include/DDEve/EventControl.h
@@ -1,4 +1,3 @@
-// $Id: $
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
diff --git a/DDEve/include/DDEve/Utilities.h b/DDEve/include/DDEve/Utilities.h
index 834febc71..63492c055 100644
--- a/DDEve/include/DDEve/Utilities.h
+++ b/DDEve/include/DDEve/Utilities.h
@@ -29,7 +29,8 @@ namespace DD4hep {
     int findNodeWithMatrix(TGeoNode* p, TGeoNode* n, TGeoHMatrix* mat, std::string* sub_path=0);
 
     std::pair<bool,TEveElement*> 
-    createEveShape(int level, int max_level, TEveElement* p, TGeoNode* n, TGeoHMatrix mat, const std::string& node_name);
+    createEveShape(int level, int max_level, TEveElement* p, TGeoNode* n, const
+                   TGeoHMatrix& mat, const std::string& node_name);
 
     std::pair<bool,TEveElement*> 
     LoadDetElement(Geometry::DetElement element,int levels, TEveElement* parent);
diff --git a/DDEve/src/EventControl.cpp b/DDEve/src/EventControl.cpp
index 88c100048..872aa546e 100644
--- a/DDEve/src/EventControl.cpp
+++ b/DDEve/src/EventControl.cpp
@@ -1,4 +1,3 @@
-// $Id: $
 //==========================================================================
 //  AIDA Detector description implementation for LCD
 //--------------------------------------------------------------------------
@@ -38,7 +37,8 @@ ClassImp(EventControl)
 /// Standard constructor
 EventControl::EventControl(Display* display, unsigned int width, unsigned int height) 
 : FrameControl(&display->client(), "EventControl GUI", width, height), EventConsumer(), 
-  m_display(display), m_dataGroup(0), m_dataFrame(0), m_numEvtFrame(0), m_input1(0), m_input2(0),
+  m_display(display), m_dataGroup(0), m_dataFrame(0), m_eventGroup(0),
+  m_numEvtFrame(0), m_input1(0), m_input2(0), m_numEvtLabel(0),
   m_open(0), m_prev(0), m_next(0), m_goto(0)
 {
   SetWindowName("XX GUI");
@@ -48,7 +48,11 @@ EventControl::EventControl(Display* display, unsigned int width, unsigned int he
 
 /// Default destructor
 EventControl::~EventControl()   {
-  m_display->eventHandler().Unsubscribe(this);
+  try {
+    m_display->eventHandler().Unsubscribe(this);
+  }
+  catch(...)  {
+  }
   InstanceCount::decrement(this);
 }
 
diff --git a/DDEve/src/Utilities.cpp b/DDEve/src/Utilities.cpp
index 89cdfbcd3..594ad13aa 100644
--- a/DDEve/src/Utilities.cpp
+++ b/DDEve/src/Utilities.cpp
@@ -74,7 +74,7 @@ void Utilities::MakeNodesVisible(TEveElement* e, bool visible, int level)   {
 }
 
 std::pair<bool,TEveElement*> 
-Utilities::createEveShape(int level, int max_level, TEveElement* p, TGeoNode* n, TGeoHMatrix mat, const std::string& nam)  {
+Utilities::createEveShape(int level, int max_level, TEveElement* p, TGeoNode* n, const TGeoHMatrix& mat, const std::string& nam)  {
   TGeoVolume* vol = n ? n->GetVolume() : 0;
   bool created = false;
 
diff --git a/DDG4/include/DDG4/Geant4GeneratorAction.h b/DDG4/include/DDG4/Geant4GeneratorAction.h
index 354c52d41..f1f5749dc 100644
--- a/DDG4/include/DDG4/Geant4GeneratorAction.h
+++ b/DDG4/include/DDG4/Geant4GeneratorAction.h
@@ -51,6 +51,8 @@ namespace DD4hep {
     protected:
       Callback m_calls;
     public:
+      /// Inhibit default constructor
+      Geant4GeneratorAction() = delete;
       /// Standard constructor
       Geant4GeneratorAction(Geant4Context* context, const std::string& name);
       /// Default destructor
@@ -78,6 +80,8 @@ namespace DD4hep {
       /// Reference to the shared action
       Geant4GeneratorAction* m_action;
     public:
+      /// Inhibit default constructor
+      Geant4SharedGeneratorAction() = delete;
       /// Standard constructor
       Geant4SharedGeneratorAction(Geant4Context* context, const std::string& nam);
       /// Default destructor
@@ -114,6 +118,8 @@ namespace DD4hep {
       /// The list of action objects to be called
       Actors<Geant4GeneratorAction> m_actors;
     public:
+      /// Inhibit default constructor
+      Geant4GeneratorActionSequence() = delete;
       /// Standard constructor
       Geant4GeneratorActionSequence(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4HitCollection.h b/DDG4/include/DDG4/Geant4HitCollection.h
index f36d9a25c..e026b45bf 100644
--- a/DDG4/include/DDG4/Geant4HitCollection.h
+++ b/DDG4/include/DDG4/Geant4HitCollection.h
@@ -260,12 +260,12 @@ namespace DD4hep {
       void getData(const ComponentCast& cast, std::vector<void*>* result);
 
     public:
-      enum {
+      enum OptimizationFlags  {
         OPTIMIZE_NONE = 0,
         OPTIMIZE_REPEATEDLOOKUP = 1<<0,
         OPTIMIZE_MAPPEDLOOKUP   = 1<<1,
         OPTIMIZE_LAST
-      } OptimizationFlags;
+      };
 
       /// Initializing constructor (C++ version)
       template <typename TYPE>
@@ -287,7 +287,7 @@ namespace DD4hep {
       {
         newInstance();
         m_hits.reserve(200);
-        m_flags.value = 0;//OPTIMIZE_REPEATEDLOOKUP;
+        m_flags.value = OPTIMIZE_NONE;
       }
       /// Default destructor
       virtual ~Geant4HitCollection();
diff --git a/DDG4/include/DDG4/Geant4InteractionVertexBoost.h b/DDG4/include/DDG4/Geant4InteractionVertexBoost.h
index 3003fe75e..06da5648b 100644
--- a/DDG4/include/DDG4/Geant4InteractionVertexBoost.h
+++ b/DDG4/include/DDG4/Geant4InteractionVertexBoost.h
@@ -48,6 +48,8 @@ namespace DD4hep {
       void boost(Interaction* interaction)  const;
 
     public:
+      /// Inhibit default constructor
+      Geant4InteractionVertexBoost() = delete;
       /// Standard constructor
       Geant4InteractionVertexBoost(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h
index ac5762ab2..da4cf5506 100644
--- a/DDG4/include/DDG4/Geant4InteractionVertexSmear.h
+++ b/DDG4/include/DDG4/Geant4InteractionVertexSmear.h
@@ -56,6 +56,10 @@ namespace DD4hep {
       void smear(Interaction* interaction)  const;
       
     public:
+      /// Inhibit default constructor
+      Geant4InteractionVertexSmear() = delete;
+      /// Inhibit copy constructor
+      Geant4InteractionVertexSmear(const Geant4InteractionVertexSmear& copy) = delete;
       /// Standard constructor
       Geant4InteractionVertexSmear(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4IsotropeGenerator.h b/DDG4/include/DDG4/Geant4IsotropeGenerator.h
index 9cd295112..37e4b18ab 100644
--- a/DDG4/include/DDG4/Geant4IsotropeGenerator.h
+++ b/DDG4/include/DDG4/Geant4IsotropeGenerator.h
@@ -57,6 +57,10 @@ namespace DD4hep {
       void getParticleDirectionUniform(int num, ROOT::Math::XYZVector& direction, double& momentum) const;
 
     public:
+      /// Inhibit default constructor
+      Geant4IsotropeGenerator() = delete;
+      /// Inhibit copy constructor
+      Geant4IsotropeGenerator(const Geant4IsotropeGenerator& copy) = delete;
       /// Standard constructor
       Geant4IsotropeGenerator(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4OutputAction.h b/DDG4/include/DDG4/Geant4OutputAction.h
index b7ebfdbb3..3f309c99b 100644
--- a/DDG4/include/DDG4/Geant4OutputAction.h
+++ b/DDG4/include/DDG4/Geant4OutputAction.h
@@ -60,6 +60,10 @@ namespace DD4hep {
       /// Reference to MC truth object
       Geant4ParticleMap* m_truth;
     public:
+      /// Inhibit default constructor
+      Geant4OutputAction() = delete;
+      /// Inhibit copy constructor
+      Geant4OutputAction(const Geant4OutputAction& copy) = delete;
       /// Standard constructor
       Geant4OutputAction(Geant4Context* c, const std::string& nam);
       /// Default destructor
diff --git a/DDG4/include/DDG4/Geant4Particle.h b/DDG4/include/DDG4/Geant4Particle.h
index 721c6a0ef..f88e083ae 100644
--- a/DDG4/include/DDG4/Geant4Particle.h
+++ b/DDG4/include/DDG4/Geant4Particle.h
@@ -105,18 +105,18 @@ namespace DD4hep {
     public:
       typedef std::set<int> Particles;
       /// Reference counter
-      int ref;           //! not persistent
-      int id, g4Parent, reason, mask;
-      int steps, secondaries, pdgID;
-      int status, colorFlow[2];
-      char charge, _spare[3];
-      float spin[3];
+      int ref = 0;           //! not persistent
+      int id  = 0, g4Parent = 0, reason = 0, mask = 0;
+      int steps  = 0, secondaries = 0, pdgID = 0;
+      int status = 0, colorFlow[2] {0,0};
+      char charge = 0, _spare[3] {0,0,0};
+      float spin[3] {0E0,0E0,0E0};
       // 12 ints + 4 floats should be aligned to 8 bytes....
-      double vsx, vsy, vsz;
-      double vex, vey, vez;
-      double psx, psy, psz;
-      double pex, pey, pez;
-      double mass, time, properTime;
+      double vsx = 0E0, vsy = 0E0, vsz = 0E0;
+      double vex = 0E0, vey = 0E0, vez = 0E0;
+      double psx = 0E0, psy = 0E0, psz = 0E0;
+      double pex = 0E0, pey = 0E0, pez = 0E0;
+      double mass = 0E0, time = 0E0, properTime = 0E0;
       /// The list of daughters of this MC particle
       Particles parents;
       Particles daughters;
@@ -127,7 +127,7 @@ namespace DD4hep {
 #else
       dd4hep_ptr<ParticleExtension> extension;   //! not persisten. ROOT cannot handle
 #endif
-      const G4VProcess *process;                 //! not persistent
+      const G4VProcess *process = 0;             //! not persistent
       /// Default constructor
       Geant4Particle();
       /// Constructor with ID initialization
diff --git a/DDG4/include/DDG4/Geant4TrackingAction.h b/DDG4/include/DDG4/Geant4TrackingAction.h
index c688bb901..e6f2da7ef 100644
--- a/DDG4/include/DDG4/Geant4TrackingAction.h
+++ b/DDG4/include/DDG4/Geant4TrackingAction.h
@@ -43,6 +43,8 @@ namespace DD4hep {
     public:
       typedef Geant4SharedTrackingAction shared_type;
     public:
+      /// Inhibit default constructor
+      Geant4TrackingAction() = delete;
       /// Inhibit copy constructor
       Geant4TrackingAction(const Geant4TrackingAction& copy) = delete;
       /// Standard constructor
@@ -79,6 +81,8 @@ namespace DD4hep {
       /// Reference to the shared action
       Geant4TrackingAction* m_action;
     public:
+      /// Inhibit default constructor
+      Geant4SharedTrackingAction() = delete;
       /// Inhibit copy constructor
       Geant4SharedTrackingAction(const Geant4TrackingAction& copy) = delete;
       /// Standard constructor
@@ -123,8 +127,10 @@ namespace DD4hep {
       /// The list of action objects to be called
       Actors<Geant4TrackingAction> m_actors;
     public:
+      /// Inhibit default constructor
+      Geant4TrackingActionSequence() = delete;
       /// Inhibit copy constructor
-      Geant4TrackingActionSequence(const Geant4TrackingAction& copy) = delete;
+      Geant4TrackingActionSequence(const Geant4TrackingActionSequence& copy) = delete;
       /// Standard constructor
       Geant4TrackingActionSequence(Geant4Context* context, const std::string& name);
       /// Default destructor
diff --git a/DDG4/plugins/Geant4MaterialScanner.cpp b/DDG4/plugins/Geant4MaterialScanner.cpp
index 64ea8294e..4b53d9c5f 100644
--- a/DDG4/plugins/Geant4MaterialScanner.cpp
+++ b/DDG4/plugins/Geant4MaterialScanner.cpp
@@ -54,9 +54,9 @@ namespace DD4hep {
       };
       typedef std::vector<StepInfo*> Steps;
 
-      double m_sumX0;
-      double m_sumLambda;
-      double m_sumPath;
+      double m_sumX0     = 0E0;
+      double m_sumLambda = 0E0;
+      double m_sumPath   = 0E0;
       Steps  m_steps;
 
     public:
@@ -124,7 +124,7 @@ Geant4MaterialScanner::StepInfo& Geant4MaterialScanner::StepInfo::operator=(cons
 
 /// Standard constructor
 Geant4MaterialScanner::Geant4MaterialScanner(Geant4Context* ctxt, const string& nam)
-: Geant4SteppingAction(ctxt,nam)
+  : Geant4SteppingAction(ctxt,nam)
 {
   m_needsControl = true;
   eventAction().callAtBegin(this,&Geant4MaterialScanner::beginEvent);
diff --git a/DDG4/src/Geant4GeneratorAction.cpp b/DDG4/src/Geant4GeneratorAction.cpp
index c54dbb16d..7b5a74a96 100644
--- a/DDG4/src/Geant4GeneratorAction.cpp
+++ b/DDG4/src/Geant4GeneratorAction.cpp
@@ -41,7 +41,7 @@ Geant4GeneratorAction::~Geant4GeneratorAction() {
 
 /// Standard constructor
 Geant4SharedGeneratorAction::Geant4SharedGeneratorAction(Geant4Context* ctxt, const string& nam)
-  : Geant4GeneratorAction(ctxt, nam)
+  : Geant4GeneratorAction(ctxt, nam), m_action(0)
 {
   InstanceCount::increment(this);
 }
diff --git a/DDG4/src/Geant4ParticleHandler.cpp b/DDG4/src/Geant4ParticleHandler.cpp
index bca44ea9f..92d7f8968 100644
--- a/DDG4/src/Geant4ParticleHandler.cpp
+++ b/DDG4/src/Geant4ParticleHandler.cpp
@@ -49,7 +49,8 @@ typedef ReferenceBitMask<int> PropertyMask;
 
 /// Standard constructor
 Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const string& nam)
-: Geant4GeneratorAction(ctxt,nam), Geant4MonteCarloTruth(), m_userHandler(0), m_primaryMap(0)
+  : Geant4GeneratorAction(ctxt,nam), Geant4MonteCarloTruth(),
+    m_ownsParticles(false), m_userHandler(0), m_primaryMap(0)
 {
   InstanceCount::increment(this);
   //generatorAction().adopt(this);
@@ -69,7 +70,10 @@ Geant4ParticleHandler::Geant4ParticleHandler(Geant4Context* ctxt, const string&
 }
 
 /// No default constructor
-Geant4ParticleHandler::Geant4ParticleHandler() : Geant4GeneratorAction(0,"") {
+Geant4ParticleHandler::Geant4ParticleHandler()
+  : Geant4GeneratorAction(0,""), Geant4MonteCarloTruth(),
+    m_ownsParticles(false), m_userHandler(0), m_primaryMap(0)
+{
 }
 
 /// Default destructor
diff --git a/DDG4/src/Geant4ParticlePrint.cpp b/DDG4/src/Geant4ParticlePrint.cpp
index 25dc0b9e3..73a5d6ece 100644
--- a/DDG4/src/Geant4ParticlePrint.cpp
+++ b/DDG4/src/Geant4ParticlePrint.cpp
@@ -118,33 +118,39 @@ void Geant4ParticlePrint::printParticle(const std::string& prefix, const G4Event
     for (int ihc=0, nhc=hc->GetNumberOfCollections(); ihc<nhc; ++ihc)   {
       G4VHitsCollection* c = hc->GetHC(ihc);
       Geant4HitCollection* coll = dynamic_cast<Geant4HitCollection*>(c);
-      size_t nhits = coll->GetSize();
-      for(size_t i=0; i<nhits; ++i)   {
-        Geant4HitData* h = coll->hit(i);
-        Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h);
-        if ( 0 != trk_hit )   {
-          Geant4HitData::Contribution& t = trk_hit->truth;
-          int trackID = t.trackID;
-          int trueID  = truth->particleID(trackID);
-          if ( trueID == p->id )   {
-            print("+++ %20s           %s[%d]  (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i,
-                  trk_hit->position.x(),trk_hit->position.y(),trk_hit->position.z());
-          }
-        }
-        Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h);
-        if ( 0 != cal_hit )   {
-          Geant4HitData::Contributions& contrib = cal_hit->truth;
-          for(Geant4HitData::Contributions::iterator j=contrib.begin(); j!=contrib.end(); ++j)  {
-            Geant4HitData::Contribution& t = *j;
+      if ( coll )  {
+        size_t nhits = coll->GetSize();
+        for(size_t i=0; i<nhits; ++i)   {
+          Geant4HitData* h = coll->hit(i);
+          Geant4Tracker::Hit* trk_hit = dynamic_cast<Geant4Tracker::Hit*>(h);
+          if ( 0 != trk_hit )   {
+            Geant4HitData::Contribution& t = trk_hit->truth;
             int trackID = t.trackID;
             int trueID  = truth->particleID(trackID);
             if ( trueID == p->id )   {
               print("+++ %20s           %s[%d]  (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i,
-                    cal_hit->position.x(),cal_hit->position.y(),cal_hit->position.z());
+                    trk_hit->position.x(),trk_hit->position.y(),trk_hit->position.z());
+            }
+          }
+          Geant4Calorimeter::Hit* cal_hit = dynamic_cast<Geant4Calorimeter::Hit*>(h);
+          if ( 0 != cal_hit )   {
+            Geant4HitData::Contributions& contrib = cal_hit->truth;
+            for(Geant4HitData::Contributions::iterator j=contrib.begin(); j!=contrib.end(); ++j)  {
+              Geant4HitData::Contribution& t = *j;
+              int trackID = t.trackID;
+              int trueID  = truth->particleID(trackID);
+              if ( trueID == p->id )   {
+                print("+++ %20s           %s[%d]  (%+.2e,%+.2e,%+.2e)[mm]","",c->GetName().c_str(),i,
+                      cal_hit->position.x(),cal_hit->position.y(),cal_hit->position.z());
+              }
             }
           }
         }
       }
+      else  {
+        print("+++ Hit unknown hit collection type: %s --> %s",
+              c->GetName(),typeName(typeid(*c)).c_str());
+      }
     }
   }
 }
@@ -182,9 +188,13 @@ void Geant4ParticlePrint::printParticles(const G4Event* e, const ParticleMap& pa
         num_calo_hits,num_tracker_hits,num_process,num_parent);
 }
 
-void Geant4ParticlePrint::printParticleTree(const G4Event* e, const ParticleMap& particles, int level, Geant4ParticleHandle p)  const  {
-  char txt[32];
-  size_t len = sizeof(txt)-1;
+void Geant4ParticlePrint::printParticleTree(const G4Event* e,
+                                            const ParticleMap& particles,
+                                            int level,
+                                            Geant4ParticleHandle p)  const
+{
+  char txt[64];
+  size_t len = sizeof(txt)-33; // Careful about overruns...
   // Ensure we do not overwrite the array
   if ( level>int(len)-3 ) level=len-3;
 
diff --git a/DDG4/src/Geant4SensDetAction.cpp b/DDG4/src/Geant4SensDetAction.cpp
index 7488ed7d0..f7c6d6460 100644
--- a/DDG4/src/Geant4SensDetAction.cpp
+++ b/DDG4/src/Geant4SensDetAction.cpp
@@ -239,7 +239,7 @@ long long int Geant4Sensitive::cellID(const G4Step* s) {
 
 /// Standard constructor
 Geant4SensDetActionSequence::Geant4SensDetActionSequence(Geant4Context* ctxt, const string& nam)
-  : Geant4Action(ctxt, nam), m_hce(0)
+  : Geant4Action(ctxt, nam), m_hce(0), m_detector(0)
 {
   m_needsControl = true;
   context()->sensitiveActions().insert(name(), this);
diff --git a/DDG4/src/Geant4StackingAction.cpp b/DDG4/src/Geant4StackingAction.cpp
index acffe5b88..091771d5d 100644
--- a/DDG4/src/Geant4StackingAction.cpp
+++ b/DDG4/src/Geant4StackingAction.cpp
@@ -41,7 +41,7 @@ Geant4StackingAction::~Geant4StackingAction() {
 
 /// Standard constructor
 Geant4SharedStackingAction::Geant4SharedStackingAction(Geant4Context* ctxt, const string& nam)
-  : Geant4StackingAction(ctxt, nam)
+  : Geant4StackingAction(ctxt, nam), m_action(0)
 {
   InstanceCount::increment(this);
 }
diff --git a/DDG4/src/Geant4SteppingAction.cpp b/DDG4/src/Geant4SteppingAction.cpp
index 461c830a2..5914422a2 100644
--- a/DDG4/src/Geant4SteppingAction.cpp
+++ b/DDG4/src/Geant4SteppingAction.cpp
@@ -44,7 +44,7 @@ void Geant4SteppingAction::operator()(const G4Step*, G4SteppingManager*) {
 
 /// Standard constructor
 Geant4SharedSteppingAction::Geant4SharedSteppingAction(Geant4Context* ctxt, const string& nam)
-  : Geant4SteppingAction(ctxt, nam)
+  : Geant4SteppingAction(ctxt, nam), m_action(0)
 {
   InstanceCount::increment(this);
 }
diff --git a/DDG4/src/Geant4TrackingAction.cpp b/DDG4/src/Geant4TrackingAction.cpp
index 2571a059d..417770c5d 100644
--- a/DDG4/src/Geant4TrackingAction.cpp
+++ b/DDG4/src/Geant4TrackingAction.cpp
@@ -123,7 +123,7 @@ void Geant4TrackingAction::mark(const G4Track* track) const    {
 
 /// Standard constructor
 Geant4SharedTrackingAction::Geant4SharedTrackingAction(Geant4Context* ctxt, const string& nam)
-  : Geant4TrackingAction(ctxt, nam)
+  : Geant4TrackingAction(ctxt, nam), m_action(0)
 {
   InstanceCount::increment(this);
 }
diff --git a/doc/LaTex/DD4hep-setup.tex b/doc/LaTex/DD4hep-setup.tex
index a28575bfb..21cf6d4e5 100644
--- a/doc/LaTex/DD4hep-setup.tex
+++ b/doc/LaTex/DD4hep-setup.tex
@@ -23,6 +23,7 @@
 \newcommand{\DDH}{{$\tt{DD4hep}$\space}}
 \newcommand{\DDG}{{\tt{DDG4}\space}}
 \newcommand{\DDA}{{\tt{DDAlign}\space}}
+\newcommand{\DDC}{{\tt{DDCond}\space}}
 \newcommand{\DDR}{{\tt{DDRec}\space}}
 %
 % ===  Custom title page  ================================
diff --git a/doc/LaTex/DDAlignManual.tex b/doc/LaTex/DDAlignManual.tex
index 092b9fb4e..bf9fc648a 100644
--- a/doc/LaTex/DDAlignManual.tex
+++ b/doc/LaTex/DDAlignManual.tex
@@ -73,6 +73,7 @@ version          & Date & Author \\[0.2cm] \hline
                  &      &        \\
 1.0              & 01/04/2014 & Markus Frank CERN/LHCb  \\
 1.1              & 30/04/2014 & Markus Frank CERN/LHCb  \\
+1.2              & 28/02/2017 & Markus Frank CERN/LHCb  \\
                  &      &        \\        \hline 
 \end{tabular}
 }}}
@@ -181,6 +182,7 @@ actual ROOT based implementation.
 smallish changes to the ideal geometry. The mechanism to achieve this 
 is described in the following.
 
+
 %=============================================================================
 \begin{figure}[h]
   \begin{center}
@@ -192,6 +194,8 @@ is described in the following.
   \end{center}
   \vspace{-0.5cm}
 \end{figure}
+
+
 %=============================================================================
 \subsection{Detector Element Tree and the Geometry Hierarchy}
 \label{subsect:detelement-hierarchy}
@@ -251,6 +255,9 @@ a volume it is e.g. irrelevant if the volume is sensitive or not.
     \label{fig:dd4hep-aligned-hierarchies}
   \end{center}
 \end{figure}
+
+
+
 %=============================================================================
 \subsection{Alignment Parameters of Detector Components}
 \label{subsect:ddalign-intro-aligments}
-- 
GitLab