From 877c69f935d8447a028b8fce5cbb6108f30525d7 Mon Sep 17 00:00:00 2001
From: Dave Casper <dcasper@uci.edu>
Date: Wed, 5 Jul 2023 11:29:40 -0700
Subject: [PATCH] Add 5m of material in front of trench

---
 .../TrenchGeoModel/data/Trench.gdml           | 26 ++++++++++++++++++-
 .../src/TrenchDetectorFactory.cxx             |  3 ++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml b/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml
index 476363b73..891db127d 100644
--- a/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml
+++ b/FaserGeometryCommon/TrenchGeoModel/data/Trench.gdml
@@ -10,6 +10,7 @@
         <constant name="RampLengthZ" value="8422"/>
         <constant name="RampMinThickness" value="2000"/>
         <constant name="RampSlope" value="0.08533"/>
+        <constant name="WallThickness" value="5000" />
     </define>
     <materials>
         <isotope N="1.400000000000000e+01" Z="7.000000000000000e+00" name="N140x8e46440">
@@ -196,6 +197,7 @@
                           v5x="-RampWidth/2" v5y="-RampMinThickness" v6x="RampWidth/2" v6y="-RampMinThickness" v7x="RampWidth/2" v7y="0" v8x="-RampWidth/2" v8y="0"
                           dz="RampLengthZ/2" />
         <box name="world" lunit="mm" x="WorldSize" y="WorldSize" z="WorldSize" />
+        <box name="faserWall"  lunit="mm" x="RampWidth" y="(RampSlope*RampLengthZ+RampMinThickness)" z="WallThickness" />
         <xtru name="trenchOutline" lunit="mm">        
             <twoDimVertex x="-249.75647241976003" y="-3162.7618497323056"/>
             <twoDimVertex x="436.065806982358" y="-3162.7608114181166"/>
@@ -212,6 +214,11 @@
             <section zOrder="0" zPosition="-375.0" xOffset="0" yOffset="0" scalingFactor="1" />
             <section zOrder="1" zPosition="375.0" xOffset="0" yOffset="0" scalingFactor="1" />
         </xtru>
+        <union name="rampAndWall">
+            <first ref="ramp"/>
+            <second ref="faserWall"/>
+            <position name="WallShift" unit="mm" y="-RampMinThickness+(RampSlope*RampLengthZ+RampMinThickness)/2" z="-(RampLengthZ+WallThickness)/2"/>
+        </union>
         <subtraction name="faserTrench">
             <first ref="ramp"/>
             <firstpositionref ref="RampinWorldpos"/>
@@ -224,17 +231,34 @@
             <rotation name="Xrotation" unit="deg" x="90"/>
             <position name="Yshift" unit="mm" y="75"/>
         </subtraction>
+        <subtraction name="faserTrenchAndWall">
+            <first ref="rampAndWall"/>
+            <firstpositionref ref="RampinWorldpos"/>
+            <firstrotationref ref="RampinWorldrot"/>
+            <second ref="trenchOutline"/>
+            <!--
+            <rotationref ref="Subrot"/>
+            <positionref ref="Subpos"/>
+            -->
+            <rotation name="Xrotation" unit="deg" x="90"/>
+            <position name="Yshift" unit="mm" y="75"/>
+        </subtraction>
     </solids>
     <structure>
         <volume name="Trench">
             <solidref ref="faserTrench"/>
             <materialref ref="Concrete"/>
         </volume>
+        <volume name="TrenchAndWall">
+            <solidref ref="faserTrenchAndWall"/>
+            <materialref ref="Concrete"/>
+        </volume>
         <volume name="World" >
             <materialref ref="Air" />
             <solidref ref="world" />
             <physvol>
-                <volumeref ref="Trench" />
+<!--                <volumeref ref="Trench" /> -->
+                <volumeref ref="TrenchAndWall" />
                 <!--
                 <rotationref ref="RampinWorldrot"/>
                 <positionref ref="RampinWorldpos"/>
diff --git a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx
index da787acdf..c06054c48 100644
--- a/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx
+++ b/FaserGeometryCommon/TrenchGeoModel/src/TrenchDetectorFactory.cxx
@@ -77,7 +77,8 @@ void TrenchDetectorFactory::create(GeoPhysVol *world)
     xercesParser.ParseFileAndNavigate(resolvedFile);
     // std::cout << "done parsing " << resolvedFile << std::endl;
 
-    const GeoLogVol* trenchLog  = controller.retrieveLogicalVolume("Trench").first;
+//    const GeoLogVol* trenchLog  = controller.retrieveLogicalVolume("Trench").first;
+    const GeoLogVol* trenchLog  = controller.retrieveLogicalVolume("TrenchAndWall").first;
     GeoPhysVol*      trenchPhys = new GeoPhysVol(trenchLog);
     GeoNameTag *tag = new GeoNameTag("Trench");
     world->add(tag);
-- 
GitLab