From 37305c42690675a24f1aa4ed91470923bb79dec0 Mon Sep 17 00:00:00 2001
From: Wouter Deconinck <wdconinc@gmail.com>
Date: Thu, 2 Sep 2021 18:27:00 -0500
Subject: [PATCH] Guard header inclusion in version check

---
 DDG4/plugins/Geant4CerenkovPhysics.cpp      | 5 ++++-
 DDG4/plugins/Geant4OpticalPhotonPhysics.cpp | 4 ++++
 DDG4/plugins/Geant4ScintillationPhysics.cpp | 5 ++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/DDG4/plugins/Geant4CerenkovPhysics.cpp b/DDG4/plugins/Geant4CerenkovPhysics.cpp
index ef95e456f..0c50390dc 100644
--- a/DDG4/plugins/Geant4CerenkovPhysics.cpp
+++ b/DDG4/plugins/Geant4CerenkovPhysics.cpp
@@ -28,7 +28,6 @@
 #include "DDG4/Geant4PhysicsList.h"
 
 /// Geant4 include files
-#include "G4OpticalParameters.hh"
 #include "G4ParticleTableIterator.hh"
 #include "G4ParticleDefinition.hh"
 #include "G4ParticleTypes.hh"
@@ -36,6 +35,10 @@
 #include "G4ProcessManager.hh"
 #include "G4Version.hh"
 
+#if G4VERSION_NUMBER >= 1070
+#include "G4OpticalParameters.hh"
+#endif
+
 #include "G4Cerenkov.hh"
 
 /// Namespace for the AIDA detector description toolkit
diff --git a/DDG4/plugins/Geant4OpticalPhotonPhysics.cpp b/DDG4/plugins/Geant4OpticalPhotonPhysics.cpp
index a7c6c4c89..22eb4ce35 100644
--- a/DDG4/plugins/Geant4OpticalPhotonPhysics.cpp
+++ b/DDG4/plugins/Geant4OpticalPhotonPhysics.cpp
@@ -40,6 +40,10 @@
 #include "G4ParticleTable.hh"
 #include "G4ProcessManager.hh"
 
+#if G4VERSION_NUMBER >= 1070
+#include "G4OpticalParameters.hh"
+#endif
+
 /// Namespace for the AIDA detector description toolkit
 namespace dd4hep {
 
diff --git a/DDG4/plugins/Geant4ScintillationPhysics.cpp b/DDG4/plugins/Geant4ScintillationPhysics.cpp
index d2d9b7dc7..ed486895d 100644
--- a/DDG4/plugins/Geant4ScintillationPhysics.cpp
+++ b/DDG4/plugins/Geant4ScintillationPhysics.cpp
@@ -29,7 +29,6 @@
 
 /// Geant4 include files
 #include "G4Version.hh"
-#include "G4OpticalParameters.hh"
 #include "G4ParticleTableIterator.hh"
 #include "G4ParticleDefinition.hh"
 #include "G4LossTableManager.hh"
@@ -39,6 +38,10 @@
 #include "G4EmSaturation.hh"
 #include "G4Threading.hh"
 
+#if G4VERSION_NUMBER >= 1070
+#include "G4OpticalParameters.hh"
+#endif
+
 #include "G4Scintillation.hh"
 
 /// Namespace for the AIDA detector description toolkit
-- 
GitLab