From 3f9be74424b673a0a34ff8b3f879e502f30710a7 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 8 Mar 2019 11:26:12 +0100
Subject: [PATCH] Towards a first Geant4 simulation of optical photons -- now
 have to wait for TGeo add-ons

---
 DDCore/src/plugins/Compact2Objects.cpp        | 2 ++
 DDCore/src/plugins/StandardPlugins.cpp        | 6 ++++++
 examples/OpticalSurfaces/src/OpNovice_geo.cpp | 4 ++++
 3 files changed, 12 insertions(+)

diff --git a/DDCore/src/plugins/Compact2Objects.cpp b/DDCore/src/plugins/Compact2Objects.cpp
index 2996f4210..1c5e1fbd4 100644
--- a/DDCore/src/plugins/Compact2Objects.cpp
+++ b/DDCore/src/plugins/Compact2Objects.cpp
@@ -33,7 +33,9 @@
 // Root/TGeo include files
 #include "TGeoManager.h"
 #include "TGeoMaterial.h"
+#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0)
 #include "TGDMLMatrix.h"
+#endif
 
 // C/C++ include files
 #include <climits>
diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index 8495b3701..c383d7556 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -517,6 +517,7 @@ static long root_materials(Detector& description, int argc, char** argv) {
       ::printf("  %-6s Fraction: %7.3f Z=%3d A=%6.2f N=%3d Neff=%6.2f\n",
                elt->GetName(), frac, elt->Z(), elt->A(), elt->N(), elt->Neff());
     }
+#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0)
     virtual void printProperty(elt_h, TNamed* prop, TGDMLMatrix* matrix)   {
       if ( matrix )
         ::printf("  Property: %-20s [%ld x %ld] --> %s\n",
@@ -525,6 +526,7 @@ static long root_materials(Detector& description, int argc, char** argv) {
         ::printf("  Property: %-20s [ERROR: NO TABLE!] --> %s\n",
                  prop->GetName(), prop->GetTitle());
     }
+#endif
     virtual void operator()(TGeoMaterial* mat)  {
       Double_t* mix = mat->IsMixture() ? ((TGeoMixture*)mat)->GetWmixt() : 0;
       elt_h  mh = print(mat);
@@ -532,10 +534,12 @@ static long root_materials(Detector& description, int argc, char** argv) {
         TGeoElement* elt = mat->GetElement(i);
         print(mh, elt, mix ? mix[i] : 1);
       }
+#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0)
       TListIter mat_iter(&mat->GetProperties());
       for(TObject* i = mat_iter.Next(); i; i=mat_iter.Next())   {
         printProperty(mh, (TNamed*)i, description.manager().GetGDMLMatrix(i->GetTitle()));
       }
+#endif
     }
   };
   struct MaterialPrintXML : public MaterialPrint  {
@@ -562,11 +566,13 @@ static long root_materials(Detector& description, int argc, char** argv) {
       elt.setAttr(_U(n),frac);
       elt.setAttr(_U(ref),element->GetName());
     }
+#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0)
     virtual void printProperty(elt_h mat, TNamed* prop, TGDMLMatrix* /* matrix */)   {
       elt_h elt = mat.addChild(_U(property));
       elt.setAttr(_U(name),prop->GetName());
       elt.setAttr(_U(ref), prop->GetTitle());
     }
+#endif
   };
 
   string type = "text", output = "", name = "";
diff --git a/examples/OpticalSurfaces/src/OpNovice_geo.cpp b/examples/OpticalSurfaces/src/OpNovice_geo.cpp
index 6d8921758..a54b16ba6 100644
--- a/examples/OpticalSurfaces/src/OpNovice_geo.cpp
+++ b/examples/OpticalSurfaces/src/OpNovice_geo.cpp
@@ -44,6 +44,7 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector /
   PlacedVolume tankPlace   = description.pickMotherVolume(sdet).placeVolume(tank_vol);
   sdet.setPlacement(tankPlace);
 
+#if ROOT_VERSION_CODE > ROOT_VERSION(6,16,0)
   // Now attach the surface
   OpticalSurfaceManager surfMgr = description.surfaceManager();
   PlacedVolume   hallPlace(description.manager().GetTopNode());
@@ -53,6 +54,9 @@ static Ref_t create_detector(Detector &description, xml_h e, SensitiveDetector /
   BorderSurface  bubbleSurf = BorderSurface(description, sdet, "TankBubble", airSurf,   bubblePlace, tankPlace);
   bubbleSurf.isValid();
   tankSurf.isValid();
+#else
+  bubblePlace.isValid();
+#endif
   return sdet;
 }
 DECLARE_DETELEMENT(DD4hep_OpNovice,create_detector)
-- 
GitLab