From a10c5342e8df9aff1c49ab7829779b9fecd1b019 Mon Sep 17 00:00:00 2001
From: Markus Frank <Markus.Frank@cern.ch>
Date: Fri, 24 Nov 2023 17:37:16 +0100
Subject: [PATCH] Enable setting of the polish for Geant4 surfaces (requires
 Geant4 11)

---
 DDCore/src/plugins/StandardPlugins.cpp | 2 +-
 DDG4/src/Geant4Converter.cpp           | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp
index ec7554db3..ac92a0d9c 100644
--- a/DDCore/src/plugins/StandardPlugins.cpp
+++ b/DDCore/src/plugins/StandardPlugins.cpp
@@ -124,7 +124,7 @@ static long display(Detector& description, int argc, char** argv) {
   int vislevel = 6, visopt = 1;
   std::string detector = "/world";
   const char* opt = "ogl";
-  for(int i = 0; i < argc && argv[i]; ++i)  {
+  for( int i = 0; i < argc && argv[i]; ++i )  {
     if ( 0 == ::strncmp("-option",argv[i],4) )
       opt = argv[++i];
     else if ( 0 == ::strncmp("-level",argv[i],4) )
diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp
index f1534a86f..2614e9990 100644
--- a/DDG4/src/Geant4Converter.cpp
+++ b/DDG4/src/Geant4Converter.cpp
@@ -1387,13 +1387,16 @@ void* Geant4Converter::handleOpticalSurface(TObject* surface) const    {
     string name = make_NCName(optSurf->GetName());
     g4 = new G4OpticalSurface(name, model, finish, type, optSurf->GetValue());
     g4->SetSigmaAlpha(optSurf->GetSigmaAlpha());
-    // not implemented: g4->SetPolish(s->GetPolish());
+    g4->SetPolish(optSurf->GetPolish());
+
     printout(debugSurfaces ? ALWAYS : DEBUG, "Geant4Converter",
-             "++ Created OpticalSurface: %-18s type:%s model:%s finish:%s",
+             "++ Created OpticalSurface: %-18s type:%s model:%s finish:%s SigmaAlphs: %.3e Polish: %.3e",
              optSurf->GetName(),
              TGeoOpticalSurface::TypeToString(optSurf->GetType()),
              TGeoOpticalSurface::ModelToString(optSurf->GetModel()),
-             TGeoOpticalSurface::FinishToString(optSurf->GetFinish()));
+             TGeoOpticalSurface::FinishToString(optSurf->GetFinish()),
+             optSurf->GetSigmaAlpha(), optSurf->GetPolish());
+
     G4MaterialPropertiesTable* tab = nullptr;
     TListIter it(&optSurf->GetProperties());
     for(TObject* obj = it.Next(); obj; obj = it.Next())  {
-- 
GitLab