diff --git a/compact/definitions.xml b/compact/definitions.xml
index 83e02e2d4e36db572e9581e915d20052b8072e50..77cde0aef6df61e1742f68e1ab3beef5d4d2cdff 100644
--- a/compact/definitions.xml
+++ b/compact/definitions.xml
@@ -354,7 +354,7 @@
     <!--
     <constant name="cb_CTD_zmax"   value="120.0 * cm"/>
     -->	    
-    <constant name="cb_CTD_length" value="SolenoidLength - cb_CTD_zmax"/>
+    <constant name="cb_CTD_length" value="Solenoid_length - cb_CTD_zmax"/>
     <comment> After fix cb_Solenoid parameters  </comment>
     <!--	    
     <constant name="cb_CTD_length" value="cb_Solenoid_z - cb_CTD_zmax"/>
@@ -545,9 +545,9 @@
       Gaseous RICH Parameters
       -----------------------
     </comment>
-    <constant name="RICHZMin"  value="SiliconTrackerOuterBarrelLength/2.0 + 1 * cm"/>
+    <constant name="RICHZMin"  value="SiliconTrackerOuterBarrel_zmax + 1 * cm"/>
     <constant name="RICHRMin"  value="15 * cm"/>
-    <constant name="RICH_rmax0"  value="SiliconTrackerOuterBarrel_zmin"/>
+    <constant name="RICH_rmax0"  value="SiliconTrackerOuterRadius"/>
     <constant name="RICH_rmax1"  value="EcalBarrel_rmin"/>
     <constant name="RICH_rmax2"  value="SolenoidBarrel_rmin-2*cm"/>
     <constant name="RICHDepth" value="1.0*m"/>
@@ -580,7 +580,7 @@
     <constant name="ce_MRICHRMin" value="15*cm"/>
     <constant name="ce_MRICHRMax" value="100*cm"/>
     <constant name="ce_MRICHLength" value="15*cm"/>
-    <constant name="ce_MRICHZMin" value="-EcalEndcap_zmin+10.*cm"/>
+    <constant name="ce_MRICHZMin" value="-EcalEndcapP_zmin+10.*cm"/>
 
     <comment>
       ------------------
@@ -594,7 +594,7 @@
     <constant name="ce_GEM_length"          value="30.0 * cm"/>
     <constant name="ce_GEM_x_pos"           value="0.0 * cm"/>
     <constant name="ce_GEM_y_pos"           value="0.0 * cm"/>
-    <constant name="ce_GEM_z_pos"           value="-SolenoidLength/2.0 + ce_GEM_length/2.0"/>
+    <constant name="ce_GEM_z_pos"           value="-Solenoid_length/2.0 + ce_GEM_length/2.0"/>
     <constant name="ce_GEM_layer"           value="8"/>
     <constant name="ce_GEM_layer_thickness" value="1.0 * cm"/>
 
diff --git a/compact/forward_rich.xml b/compact/forward_rich.xml
index 791a34b2d43cc82181b7301b7137839b8b594fa4..ca0b4ed50fc7f2e49e69cb66055df693700e7bc5 100644
--- a/compact/forward_rich.xml
+++ b/compact/forward_rich.xml
@@ -5,21 +5,44 @@
 
   <detectors>
     <detector id="ForwardRICH_ID" name="ForwardRICH" type="refdet_ForwardRICH" readout="ForwardRICHHits" vis="BlueVis">
-      <dimensions z0="RICHZMin" length="RICHLength" 
+      <dimensions 
+        z0="RICHZMin" 
+        snout_length="RICHLength - RICHDepth"
+        length="RICHLength" 
         rmin="RICHRMin" 
-        rmax1="RICH_rmax1" rmax2="RICH_rmax2"/>
+        rmax0="RICH_rmax0" 
+        rmax1="RICH_rmax1" 
+        rmax2="RICH_rmax2"/>
       <radiator material="N2cherenkov" />
-      <mcppmt zdiff="15.0*cm" rmin="SolenoidYokeEndcapP_rmin - 10*cm" rmax="SolenoidYokeEndcapP_rmin" rtol="1.0*cm" vis="BlueVis"
-              module_size="10*cm" module_gap="0.2*cm" thickness="1.0*cm" material="Quartz" />
-      <tank zdiff="5.0*cm" length="RICHDepth" gas="N2cherenkov" vis="GreenVis"
-            rmin="RICHRMin" rmax1="RICHRMin+40*cm" rmax2="RICHRMin+80*cm" />
-      <mirror zdiff="RICHDepth+7.0*cm" thickness="1*mm" material="PyrexGlass" vis="GrayVis">
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="0*degree" />
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="60*degree" />
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="120*degree" />
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="180*degree" />
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="240*degree" />
-        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICHRMin+80*cm" phiw="59*degree" rotz="300*degree" />
+      <tank 
+        length="RICHDepth" 
+        gas="N2cherenkov"
+        vis="GreenVis"
+        rmin="RICHRMin"
+        rmax1="RICH_rmax1"
+        rmax2="RICH_rmax2" />
+      <comment> What are the following MCP-PMT parameters?</comment>
+      <mcppmt 
+        z0="-20.0*cm" 
+        rmin="RICH_rmax1" 
+        rmax="RICH_rmax2" 
+        rtol="1.0*cm" 
+        vis="BlueVis"
+        module_size="10*cm" 
+        module_gap="0.2*cm" 
+        thickness="1.0*cm" 
+        material="Quartz" />
+      <mirror 
+        z0="RICHLength - 40*cm" 
+        thickness="1*mm" 
+        material="PyrexGlass" 
+        vis="GrayVis">
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="0*degree" />
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="60*degree" />
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="120*degree" />
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="180*degree" />
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="240*degree" />
+        <slice focus="10*cm" curve="300*cm" rmin="RICHRMin" rmax="RICH_rmax1" phiw="59*degree" rotz="300*degree" />
       </mirror>
     </detector>
   </detectors>
diff --git a/reference_detector.xml b/reference_detector.xml
index 0b60d024c06d98ec6a6bcc0a00619aae1829e922..9a5ea5914f6a5d5a50c26cc5a6277e9e9c1f106e 100644
--- a/reference_detector.xml
+++ b/reference_detector.xml
@@ -113,29 +113,21 @@
   <!--
   <include ref="reference_detector/vertex_tracker.xml"/>
   <include ref="compact/silicon_tracker.xml"/>
-<<<<<<< HEAD
   -->
-  <include ref="compact/cb_CTD_Si.xml"/>
-  <include ref="ip6/beampipe.xml"/>
-  <include ref="compact/ffi_ZDC.xml"/>
-=======
   <include ref="ip6/beampipe.xml"/>
-  -->
->>>>>>> 913736c (	modified:   compact/cb_Solenoid.xml)
   <include ref="compact/solenoid.xml"/>
   <include ref="compact/forward_rich.xml"/>
-<<<<<<< HEAD
-  <include ref="compact/ce_mrich.xml"/>
-  <include ref="compact/ce_GEM.xml"/>
-=======
   <include ref="compact/ecal.xml"/>
->>>>>>> 913736c (	modified:   compact/cb_Solenoid.xml)
   <!--
+  <include ref="compact/cb_CTD_Si.xml"/>
+  <include ref="compact/ce_mrich.xml"/>
+  <include ref="compact/ce_GEM.xml"/>
+  <include ref="compact/ffi_ZDC.xml"/>
   <include ref="compact/hcal.xml"/>
   <include ref="compact/roman_pots.xml"/>
   -->
-  <include ref="eic/forward_ion_beamline.xml"/>
   <!--
+  <include ref="eic/forward_ion_beamline.xml"/>
   -->
 
   <detectors>
diff --git a/src/ForwardRICH_geo.cpp b/src/ForwardRICH_geo.cpp
index 3dc6417ba4562a43e22227d8f4a7e9ec969c3bd1..b88bcd7c5ccb16799b2893e75898f53566ad81e3 100644
--- a/src/ForwardRICH_geo.cpp
+++ b/src/ForwardRICH_geo.cpp
@@ -36,17 +36,20 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
     xml::Component rads = detElem.child(_Unicode(radiator));
     xml::Component mir = detElem.child(_Unicode(mirror));
     xml::Component mcp = detElem.child(_Unicode(mcppmt));
+    xml::Component tank = detElem.child(_Unicode(tank));
 
     // dimensions
     double z0 = dims.z0();
     double length = dims.length();
     double rmin = dims.rmin();
+    double rmax0 = dims.attr<double>(_Unicode(rmax0));
     double rmax1 = dims.attr<double>(_Unicode(rmax1));
     double rmax2 = dims.attr<double>(_Unicode(rmax2));
+    double snout_length = dims.attr<double>(_Unicode(snout_length));
 
     // mirror setting
     auto mThick = mir.thickness();
-    auto mirZ = mir.attr<double>(_Unicode(zdiff));
+    auto mirZ = mir.attr<double>(_Unicode(z0));
 
     // mcppmt setting
     auto pRmin = mcp.rmin();
@@ -55,27 +58,32 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
     auto pSize = mcp.attr<double>(_Unicode(module_size));
     auto pGap = mcp.attr<double>(_Unicode(module_gap));
     auto pTol = mcp.attr<double>(_Unicode(rtol));
-    auto pZ = mcp.attr<double>(_Unicode(zdiff));
+    auto pZ = mcp.attr<double>(_Unicode(z0));
+
+    // tank parameters
+    double tank_length = length - snout_length;
 
     // materials
     auto mirMat = desc.material(mir.materialStr());
     auto gasMat = desc.material(rads.materialStr());
     auto mcpMat = desc.material(mcp.materialStr());
 
+    double front_offset = snout_length+tank_length/2.0;
+
     // constants
-    auto richCenterAngle = std::atan((rmin + (rmax2 - rmin)/2.)/mirZ);
+    auto richCenterAngle = std::atan((rmin + (rmax1 - rmin)/2.)/(front_offset+mirZ));
     //std::cout << richCenterAngle*180./M_PI << std::endl;
 
     // an envelope for the detector
     // use a complicated shape to avoid conflict with the other parts
     // cone for radiator and the first set of mirrors
     double halfLength = length/2.;
-    Cone env1(halfLength, rmin, rmax1, rmin, rmax2);
+    Cone env1(snout_length/2.0, rmin, rmax0, rmin, rmax1);
     // envelope for detection plane
     // Cone env2(halfLength - pZ/2., rmin, pRmax, rmin, rmax2);
-    Tube env2(rmin, pRmax + pTol + pGap + 1.0*cm, (length - pZ)/2., 0., 2*M_PI);
+    Tube env2(rmin, pRmax + pTol + pGap + 1.0*cm, tank_length/2., 0., 2*M_PI);
 
-    UnionSolid envShape(env1, env2, Position(0., 0., pZ));
+    UnionSolid envShape(env2, env1, Position(0., 0., -tank_length/2.-snout_length/2));
 
     Volume envVol(detName + "_envelope", envShape, gasMat);
     envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
@@ -112,7 +120,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
             double rotY = -std::asin(focus/curve);
             mirVol.setSolid(Sphere(curve, curve + mThick, mTheta1, mTheta2, 0., wphi));
             // action is in a reverse order
-            Transform3D tr = Translation3D(0., 0., mirZ - halfLength)   // move for z position
+            Transform3D tr = Translation3D(0., 0., mirZ - front_offset)   // move for z position
                            * RotationZ(rotZ)                            // rotate phi angle
                            * RotationY(rotY)                            // rotate for focus point
                            * RotationX(180*degree)
@@ -122,7 +130,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
         // plane mirror
         } else {
             mirVol.setSolid(Tube(mRmin, mRmax, mThick/2.0, 0., wphi));
-            Transform3D tr = Translation3D(0., 0., mirZ - halfLength)   // move for z position
+            Transform3D tr = Translation3D(0., 0., mirZ - front_offset)   // move for z position
                            * RotationZ(rotZ)                            // rotate phi angle
                            * RotationZ(-wphi/2.);                       // center phi angle to 0. (-wphi/2., wphi/2.)
             mirPV = envVol.placeVolume(mirVol, tr);
@@ -152,11 +160,11 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
 
     // photo-detector plane envelope
     for (size_t ipd = 0; ipd < 6; ++ipd) {
-        double phmin = -M_PI/6.;
-        double phmax = M_PI/6.;
+        double phmin = -M_PI/6.5; // added 0.5 to make it smaller
+        double phmax = M_PI/6.5;
         Tube pdEnvShape(pRmin - pTol - pGap, pRmax + pTol + pGap, pThick/2.0 + 0.1*cm, phmin, phmax);
         Volume pdVol("pd_envelope", pdEnvShape, desc.material("AirOptical"));
-        auto points = ref::utils::fillSquares({0., 0.}, pSize + pGap, pRmin - pTol - pGap, pRmax + pTol + pGap, phmin, phmax);
+        auto points = ref::utils::fillSquares({0., 0.}, pSize + pGap, pRmin + pTol + pGap, pRmax + pTol + pGap, phmin, phmax);
         for (size_t i = 0; i < points.size(); ++i) {
             auto pt = points[i];
             auto mcpPV = pdVol.placeVolume(mcpVol, Position(pt.x(), pt.y(), 0.));
@@ -164,7 +172,7 @@ static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetec
             DetElement mcpDE(det, Form("MCPPMT_DE%d_%d", ipd + 1, i + 1), i + 1);
             mcpDE.setPlacement(mcpPV);
         }
-        Transform3D tr = Translation3D(0., 0., -halfLength + pZ + pThick/2.0)   // move for z position
+        Transform3D tr = Translation3D(0., 0., -front_offset + pZ + pThick/2.0)   // move for z position
                         * RotationZ(ipd*M_PI/3.)        // rotate phi angle
                         * RotationY(-richCenterAngle);  // rotate to perpendicular position
         auto pdPV = envVol.placeVolume(pdVol, tr);
diff --git a/src/cb_CTD_Si.cpp b/src/cb_CTD_Si.cpp
index 4aed32b4ac10437149b7555c171b3f2253c9fa31..a6a683eb0f4e1aff231e5a672ecd1f17c5f3e755 100644
--- a/src/cb_CTD_Si.cpp
+++ b/src/cb_CTD_Si.cpp
@@ -1,4 +1,9 @@
 #include <XML/Helper.h>
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "DD4hep/OpticalSurfaces.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
 //////////////////////////////////
 // Central Barrel Tracker Silicon
 //////////////////////////////////
diff --git a/src/ce_GEM.cpp b/src/ce_GEM.cpp
index 92315945fb6edfe117b2e846c984a879fa0fbe61..24e4bff197a798de69b1b0d07d43713225aa4f78 100644
--- a/src/ce_GEM.cpp
+++ b/src/ce_GEM.cpp
@@ -1,3 +1,8 @@
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "DD4hep/OpticalSurfaces.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
 #include <XML/Helper.h>
 //////////////////////////////////
 // Electron Endcap GEM Tracking
diff --git a/src/ffi_ZDC.cpp b/src/ffi_ZDC.cpp
index 61ca838b5a701dde41475fb106b6756a3d7c291a..43c31e31fd77a2cc44f9e635b90215c736a75ab3 100644
--- a/src/ffi_ZDC.cpp
+++ b/src/ffi_ZDC.cpp
@@ -1,3 +1,8 @@
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "DD4hep/OpticalSurfaces.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
 #include <XML/Helper.h>
 ///////////////////////////////////////////
 // Far Forward Ion Zero Degree Calorimeter