From 8f28d32c3e2752b729f0cf81413c4ff499181099 Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Thu, 20 Aug 2015 17:01:14 +0000
Subject: [PATCH] Fix to previous fix....Correct bitfield64 test for 32 bit
 platforms

---
 DDCore/src/VolumeManager.cpp        | 59 +++++++++++++++--------------
 DDTest/src/test_bitfield64.cc       |  6 +--
 doc/CompileAllOptionPermutations.sh | 10 +++--
 3 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/DDCore/src/VolumeManager.cpp b/DDCore/src/VolumeManager.cpp
index 9391b3d3d..5601fff60 100644
--- a/DDCore/src/VolumeManager.cpp
+++ b/DDCore/src/VolumeManager.cpp
@@ -119,7 +119,8 @@ namespace {
             else {
               cnt = scanPhysicalVolume(parent, e, pv_dau, ids, sd, chain);
             }
-            if (count == 0 && cnt > 0 && !pv_ids.empty()) {
+            // There was a sensitive daughter volume, also add the parent entry.
+            if ( count == 0 && cnt > 0 && sd.isValid() && !pv_ids.empty()) {
               add_entry(sd, parent, e, node, ids, chain);
             }
             count += cnt;
@@ -167,34 +168,36 @@ namespace {
     void add_entry(SensitiveDetector sd, DetElement parent, DetElement e, 
                    const TGeoNode* n, const VolIDs& ids, Chain& nodes) 
     {
-      Readout ro = sd.readout();
-      IDDescriptor iddesc = ro.idSpec();
-      pair<VolumeID, VolumeID> code = encoding(iddesc, ids);
-
-      if (m_entries.find(code.first) == m_entries.end()) {
-        string        sd_name      = sd.name();
-        DetElement    sub_detector = m_lcdd.detector(sd_name);
-        VolumeManager section      = m_volManager.addSubdetector(sub_detector, ro);
-        // This is the block, we effectively have to save for each physical volume with a VolID
-        VolumeManager::Context* context = new VolumeManager::Context;
-        context->identifier = code.first;
-        context->mask       = code.second;
-        context->detector   = parent;
-        context->placement  = PlacedVolume(n);
-        context->element    = e;
-        context->volID      = ids;
-        context->path       = nodes;
-        for (size_t i = nodes.size(); i > 1; --i) {   // Omit the placement of the parent DetElement
-          TGeoMatrix* m = nodes[i - 1]->GetMatrix();
-          context->toWorld.MultiplyLeft(m);
-        }
-        context->toDetector = context->toWorld;
-        context->toDetector.MultiplyLeft(nodes[0]->GetMatrix());
-        context->toWorld.MultiplyLeft(&parent.worldTransformation());
-        if (!section.adoptPlacement(context)) {
-          print_node(sd, parent, e, n, ids, nodes);
+      if ( sd.isValid() )   {
+        Readout ro = sd.readout();
+        IDDescriptor iddesc = ro.idSpec();
+        pair<VolumeID, VolumeID> code = encoding(iddesc, ids);
+
+        if (m_entries.find(code.first) == m_entries.end()) {
+          string        sd_name      = sd.name();
+          DetElement    sub_detector = m_lcdd.detector(sd_name);
+          VolumeManager section      = m_volManager.addSubdetector(sub_detector, ro);
+          // This is the block, we effectively have to save for each physical volume with a VolID
+          VolumeManager::Context* context = new VolumeManager::Context;
+          context->identifier = code.first;
+          context->mask       = code.second;
+          context->detector   = parent;
+          context->placement  = PlacedVolume(n);
+          context->element    = e;
+          context->volID      = ids;
+          context->path       = nodes;
+          for (size_t i = nodes.size(); i > 1; --i) {   // Omit the placement of the parent DetElement
+            TGeoMatrix* m = nodes[i - 1]->GetMatrix();
+            context->toWorld.MultiplyLeft(m);
+          }
+          context->toDetector = context->toWorld;
+          context->toDetector.MultiplyLeft(nodes[0]->GetMatrix());
+          context->toWorld.MultiplyLeft(&parent.worldTransformation());
+          if (!section.adoptPlacement(context)) {
+            print_node(sd, parent, e, n, ids, nodes);
+          }
+          m_entries.insert(code.first);
         }
-        m_entries.insert(code.first);
       }
     }
 
diff --git a/DDTest/src/test_bitfield64.cc b/DDTest/src/test_bitfield64.cc
index 5382f962c..e65b84b9d 100644
--- a/DDTest/src/test_bitfield64.cc
+++ b/DDTest/src/test_bitfield64.cc
@@ -40,10 +40,10 @@ int main(int /* argc */, char** /* argv */ ){
 
     //    std::cout  << " bf value : " << bf << std::endl ;
 
-    test(  bf.getValue() , long64( 0xbebafecacafebabeUL ) , 
+    test(  bf.getValue() , long64( 0xbebafecacafebabeULL ) , 
 	   " initialized with 0xbebafecacafebabeUL - compare as signed " ); 
 
-    test(  (unsigned long) bf.getValue()   , 0xbebafecacafebabeUL  , 
+    test(  (ulong64) bf.getValue()   , 0xbebafecacafebabeULL  , 
 	   " initialized with 0xbebafecacafebabeUL - compare as unsigned " ); 
 
 
@@ -64,7 +64,7 @@ int main(int /* argc */, char** /* argv */ ){
 
     bf3.setValue(  bf.lowWord() , bf.highWord() ) ; 
 
-    test(  bf3.getValue() , bf2.getValue()  , " same value 0xbebafecacafebabeUL from stting low and hiigh word " ); 
+    test(  bf3.getValue() , bf2.getValue()  , " same value 0xbebafecacafebabeUL from setting low and high word " ); 
 
 
     // --------------------------------------------------------------------
diff --git a/doc/CompileAllOptionPermutations.sh b/doc/CompileAllOptionPermutations.sh
index 16eb1eb47..477adef76 100755
--- a/doc/CompileAllOptionPermutations.sh
+++ b/doc/CompileAllOptionPermutations.sh
@@ -1,9 +1,11 @@
 dir_name=`pwd`;
-INSTALL_G4=/home/frankm/SW/g4_10.01.p02_dbg/lib/Geant4-10.1.2;
-INSTALL_LCIO=/home/frankm/SW/lcio/v02-04-03;
-INSTALL_XERCESC=/home/frankm/SW/xercesc;
+SW=/home/frankm/SW;
+
+INSTALL_G4=${SW}/g4_10.01.p02_dbg/lib/Geant4-10.1.2;
+INSTALL_LCIO=${SW}/lcio/v02-04-03;
+INSTALL_XERCESC=${SW}/xercesc;
 CHECKOUT=${dir_name}/../../DD4hep.trunk/checkout;
-export ROOTSYS=/home/frankm/SW/root_v5.34.25_dbg;
+export ROOTSYS=${SW}/root_v5.34.25_dbg;
 . ${ROOTSYS}/bin/thisroot.sh;
 #cat ${ROOTSYS}/bin/thisroot.sh;
 #
-- 
GitLab