From cf356d0361fa3a03a17e402af8c9ce244abcc4d5 Mon Sep 17 00:00:00 2001
From: Frank Gaede <frank.gaede@desy.de>
Date: Fri, 20 Mar 2015 13:54:53 +0000
Subject: [PATCH]  - added new build_type: BUILD_ENVELOPE    to be used to only
 build detector envelopes  - fixed visualization in teve_display to also   
 show the envelope volume  - visualize daughter level in dumpdetector (tabs)

---
 DDCore/include/DD4hep/LCDD.h           |  2 +-
 DDCore/src/plugins/StandardPlugins.cpp |  4 ++++
 UtilityApps/src/dumpdetector.cpp       | 13 ++++++++++++-
 UtilityApps/src/run_plugin.h           |  2 +-
 UtilityApps/src/teve_display.cpp       |  5 +++++
 5 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/DDCore/include/DD4hep/LCDD.h b/DDCore/include/DD4hep/LCDD.h
index 1af20d19e..261cf2252 100644
--- a/DDCore/include/DD4hep/LCDD.h
+++ b/DDCore/include/DD4hep/LCDD.h
@@ -41,7 +41,7 @@ namespace DD4hep {
    * the accessor to the flag returns BUILD_NONE.
    */
   enum LCDDBuildType {
-    BUILD_NONE = 0, BUILD_DEFAULT = 1, BUILD_SIMU = BUILD_DEFAULT, BUILD_RECO, BUILD_DISPLAY
+    BUILD_NONE = 0, BUILD_DEFAULT = 1, BUILD_SIMU = BUILD_DEFAULT, BUILD_RECO, BUILD_DISPLAY, BUILD_ENVELOPE
   };
 
   /// Namespace for the geometry part of the AIDA detector description toolkit
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 97a4ab816..fb84db0ce 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -42,6 +42,10 @@ static LCDDBuildType build_type(const char* value)   {
     return BUILD_DISPLAY;
   else if ( strcmp(value,"3")==0 )
     return BUILD_DISPLAY;
+  else if ( strcmp(value,"BUILD_ENVELOPE")==0 )
+    return BUILD_ENVELOPE;
+  else if ( strcmp(value,"4")==0 )
+    return BUILD_DISPLAY;
   throw runtime_error(string("Invalid build type value: ")+value);
 }
 
diff --git a/UtilityApps/src/dumpdetector.cpp b/UtilityApps/src/dumpdetector.cpp
index 1d056b97d..d0c9ce42d 100644
--- a/UtilityApps/src/dumpdetector.cpp
+++ b/UtilityApps/src/dumpdetector.cpp
@@ -69,11 +69,22 @@ int main(int argc, char** argv ){
 
     DetElement de = (*it) ;
     
+    DetElement mother = de.parent() ;
+    unsigned parentCount = 0 ;
+    while( mother.isValid() ) {
+      mother = mother.parent() ;
+      ++parentCount ;
+    } 
+
     SurfaceManager surfMan( de ) ;
 
     const SurfaceList& sL = surfMan.surfaceList() ;
 
-    std::cout << "DetElement: " << de.name() << "[ path: "<< de.placementPath ()  <<  "] \t surfaces : " <<  ( sL.empty() ? 0 : sL.size()  ) << std::endl ;
+    std::cout << "DetElement: " ;
+    
+    for(unsigned i=0 ; i < parentCount ; ++i ) std::cout << "\t" ;
+
+    std::cout << de.name() << "[ path: "<< de.placementPath ()  <<  "] \t surfaces : " <<  ( sL.empty() ? 0 : sL.size()  ) << std::endl ;
 
     // for( SurfaceList::const_iterator it = sL.begin() ; it != sL.end() ; ++it ){
     //   Surface* surf =  *it ;
diff --git a/UtilityApps/src/run_plugin.h b/UtilityApps/src/run_plugin.h
index 39598b38d..551f78f53 100644
--- a/UtilityApps/src/run_plugin.h
+++ b/UtilityApps/src/run_plugin.h
@@ -73,7 +73,7 @@ namespace {
       "        -build_type <number/string> Specify the build type                         \n"
       "                     [OPTIONAL]     MUST come immediately after the -compact input.\n"
       "                                    Default for each file is: BUILD_DEFAULT [=1]   \n"
-      "                                    Allowed values: BUILD_SIMU [=1], BUILD_RECO [=2] or BUILD_DISPLAY [=3]\n"
+      "                                    Allowed values: BUILD_SIMU [=1], BUILD_RECO [=2], BUILD_DISPLAY [=3] or BUILD_ENVELOPE [=4]\n"
       "        -destroy     [OPTIONAL]     Force destruction of the LCDD instance         \n"
       "                                    before exiting the application                 \n"
       "        -volmgr      [OPTIONAL]     Load and populate phys.volume manager to       \n"
diff --git a/UtilityApps/src/teve_display.cpp b/UtilityApps/src/teve_display.cpp
index 0460b6e09..70c5ff048 100644
--- a/UtilityApps/src/teve_display.cpp
+++ b/UtilityApps/src/teve_display.cpp
@@ -70,9 +70,14 @@ static long teve_display(LCDD& lcdd, int /* argc */, char** /* argv */) {
   TGeoManager* mgr = &lcdd.manager();
   TEveManager::Create();
 
+  // mgr->SetVisOption(1) ;
+  // mgr->SetVisLevel(4) ;
+  
   //  gEve->fGeometries->Add(new TObjString("DefaultGeometry"),mgr);
 
   TEveGeoTopNode* tn = new TEveGeoTopNode(mgr, mgr->GetTopNode());
+  // option 0 in TEve seems to correspond to option 1 in TGeo ( used in geoDisplay ...)
+  tn->SetVisOption(0) ;
   tn->SetVisLevel(4);
 
   /* EvNavHandler *fh = */ new EvNavHandler;
-- 
GitLab