From dfdd9f5018b0335fb64cc9e3982e1f5e2272e96e Mon Sep 17 00:00:00 2001
From: tmadlener <thomas.madlener@desy.de>
Date: Wed, 21 Jun 2023 15:55:02 +0200
Subject: [PATCH] Add conversion from TGeoPara to G4Para

---
 DDCore/include/DD4hep/Shapes.h    | 1 +
 DDG4/src/Geant4Converter.cpp      | 2 ++
 DDG4/src/Geant4ShapeConverter.cpp | 9 +++++++++
 3 files changed, 12 insertions(+)

diff --git a/DDCore/include/DD4hep/Shapes.h b/DDCore/include/DD4hep/Shapes.h
index 2faa1a276..a186bb448 100644
--- a/DDCore/include/DD4hep/Shapes.h
+++ b/DDCore/include/DD4hep/Shapes.h
@@ -45,6 +45,7 @@
 #include <TGeoScaledShape.h>
 #include <TGeoCompositeShape.h>
 #include <TGeoShapeAssembly.h>
+#include <TGeoPara.h>
 #if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0)
 #include <TGeoTessellated.h>
 #endif
diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp
index 52f56ddd2..f1534a86f 100644
--- a/DDG4/src/Geant4Converter.cpp
+++ b/DDG4/src/Geant4Converter.cpp
@@ -610,6 +610,8 @@ void* Geant4Converter::handleSolid(const string& name, const TGeoShape* shape) c
       solid = convertShape<TGeoTrap>(shape);
     else if (isa == TGeoArb8::Class()) 
       solid = convertShape<TGeoArb8>(shape);
+    else if (isa == TGeoPara::Class())
+      solid = convertShape<TGeoPara>(shape);
 #if ROOT_VERSION_CODE > ROOT_VERSION(6,21,0)
     else if (isa == TGeoTessellated::Class()) 
       solid = convertShape<TGeoTessellated>(shape);
diff --git a/DDG4/src/Geant4ShapeConverter.cpp b/DDG4/src/Geant4ShapeConverter.cpp
index 8cab4d936..78855d744 100644
--- a/DDG4/src/Geant4ShapeConverter.cpp
+++ b/DDG4/src/Geant4ShapeConverter.cpp
@@ -31,6 +31,7 @@
 #include <G4Trap.hh>
 #include <G4Cons.hh>
 #include <G4Hype.hh>
+#include <G4Para.hh>
 #include <G4Torus.hh>
 #include <G4Sphere.hh>
 #include <G4CutTubs.hh>
@@ -140,6 +141,14 @@ namespace dd4hep {
       return new G4GenericTrap(sh->GetName(), sh->GetDz() * CM_2_MM, vertices);
     }
 
+    template <> G4VSolid* convertShape<TGeoPara>(const TGeoShape* shape) {
+      const auto* sh = static_cast<const TGeoPara*>(shape);
+      return new G4Para(sh->GetName(),
+                        sh->GetX() * CM_2_MM, sh->GetY() * CM_2_MM, sh->GetZ() * CM_2_MM,
+                        sh->GetAlpha() * DEGREE_2_RAD, sh->GetTheta() * DEGREE_2_RAD,
+                        sh->GetPhi() * DEGREE_2_RAD);
+    }
+
     template <> G4VSolid* convertShape<TGeoXtru>(const TGeoShape* shape)  {
       const TGeoXtru* sh = (const TGeoXtru*) shape;
       std::size_t nz = sh->GetNz();
-- 
GitLab