From b17dad6ba023a88c024abddc9e96ee7e85670d04 Mon Sep 17 00:00:00 2001
From: Whitney Armstrong <warmstrong@anl.gov>
Date: Mon, 12 Apr 2021 20:14:29 -0500
Subject: [PATCH] Added ci_GEM

Squashed commit from Marshall

	new file:   ci_GEM.xml
	new file:   compact/ci_GEM.xml
	new file:   compact/ci_HCAL.xml
	modified:   compact/definitions.xml
	modified:   compact/display.xml
	modified:   compact/materials.xml
	modified:   reference_detector.xml
	modified:   src/cb_CTD_Si.cpp
	new file:   src/ci_GEM.cpp
	new file:   src/ci_HCAL.cpp
---
 ci_GEM.xml              | 70 +++++++++++++++++++++++++++++++++++
 compact/ci_GEM.xml      | 71 ++++++++++++++++++++++++++++++++++++
 compact/ci_HCAL.xml     | 66 +++++++++++++++++++++++++++++++++
 compact/definitions.xml | 81 +++++++++++++++++++++++++++++------------
 compact/display.xml     |  3 ++
 compact/materials.xml   |  3 +-
 reference_detector.xml  |  5 ++-
 src/cb_CTD_Si.cpp       |  3 +-
 src/ci_GEM.cpp          | 59 ++++++++++++++++++++++++++++++
 src/ci_HCAL.cpp         | 56 ++++++++++++++++++++++++++++
 10 files changed, 390 insertions(+), 27 deletions(-)
 create mode 100644 ci_GEM.xml
 create mode 100644 compact/ci_GEM.xml
 create mode 100644 compact/ci_HCAL.xml
 create mode 100644 src/ci_GEM.cpp
 create mode 100644 src/ci_HCAL.cpp

diff --git a/ci_GEM.xml b/ci_GEM.xml
new file mode 100644
index 00000000..7614dd5f
--- /dev/null
+++ b/ci_GEM.xml
@@ -0,0 +1,70 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+>
+
+  <!-- Some information about detector  -->
+  <info name="Central Ion GEM" title="Central Ion GEM"
+        author="Marshall Scott"
+        url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
+        status="development"
+        version="v1 2021-03-23">
+    <comment>Central Ion GEM</comment>        
+  </info>
+
+  <!-- Use DD4hep elements and materials definitions -->
+  <includes>
+    <gdmlFile ref="elements.xml"/>
+    <gdmlFile ref="materials.xml"/>
+  </includes>
+
+  <!-- Define the dimensions of the world volume -->
+  <define>
+    <constant name="ci_GEM_id"      value="1">
+    <constant name="ci_GEM_rin"     value="10 * cm">
+    <constant name="ci_GEM_rout"    value="95 * cm">
+    <constant name="ci_GEM_sizez"   value="30 * cm">
+    <constant name="ci_GEM_shiftz"  value="0 * cm">
+    <constant name="ci_GEM_posz"    value="0 * cm">
+    <constant name="ci_GEM_posx"    value="0 * cm">
+    <constant name="ci_GEM_nlayers" value="8">
+  </define>
+
+   <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <!-- Common Generic visualization attributes -->
+  <!-- change this -->
+  <comment>Common Generic visualization attributes</comment>
+  <display>
+    <vis name="ci_GEMVis"  r= "0.8"  g="0.4"  b="0.3" alpha="0.8" showDaughters="true" visible="true"/>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+    <comment>
+      Central Ion GEM
+    </comment>
+    <detector id="ci_GEM_id" name="ci_GEM" type="ci_GEM" insideTrackingVolume="false" vis="ci_GEMVis">
+	    <material name="Ar10CO2"/>  <!-- G4_Galactic -->	    
+      <dimensions rmin="ci_GEM_rin" rmax="ci_GEM_rout" sizez="ci_GEM_sizez" delta="ci_GEM_shiftz"	z="ci_GEM_posz" x="ci_GEM_posx" nlayers="ci_GEM_nlayers"/>
+      <layer id="0" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="1" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="2" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="3" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="4" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="5" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="6" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+      <layer id="7" z="-sizez * 0.5 + (5 + 3. * id) * cm" inner_r="rmin + (1. + 0.5 * id) * cm" outer_r="rmax + (-25. + 2. * id) * cm" dz="1 * cm" />
+    </detector>
+  </detectors>
+
+  <plugins>
+  </plugins>
+
+
+
+
diff --git a/compact/ci_GEM.xml b/compact/ci_GEM.xml
new file mode 100644
index 00000000..4591c4f7
--- /dev/null
+++ b/compact/ci_GEM.xml
@@ -0,0 +1,71 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <!-- Some information about detector  -->
+  <info name="Central Ion GEM" title="Central Ion GEM"
+        author="Marshall Scott"
+        url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
+        status="development"
+        version="v1 2021-03-23">
+    <comment>Central Ion GEM</comment>        
+  </info>
+
+  <!-- Use DD4hep elements and materials definitions -->
+  <includes>
+  </includes>
+
+  <define>
+  	<!--
+    <constant name="ci_GEM_id"      value="1">
+    <constant name="ci_GEM_rin"     value="10 * cm">
+    <constant name="ci_GEM_rout"    value="95 * cm">
+    <constant name="ci_GEM_sizez"   value="30 * cm">
+    <constant name="ci_GEM_shiftz"  value="0 * cm">
+    <constant name="ci_GEM_posz"    value="0 * cm">
+    <constant name="ci_GEM_posx"    value="0 * cm">
+    <constant name="ci_GEM_nlayers" value="8">
+    -->
+  </define>
+
+   <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <display>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+    <comment>
+      Central Ion GEM
+    </comment>
+    <detector id="ci_GEM_id" name="ci_GEM" type="ci_GEM" insideTrackingVolume="false" vis="ci_GEMVis" readout="ci_GEM_Hits">
+      <material name="Ar10CO2"/>  
+      <comment> position of the front face of the detector </comment>
+      <position x="0" y="0" z="SiliconTrackerOuterBarrel_zmax"/>
+      <dimensions rmin="ci_GEM_rin" rmax="ci_GEM_rout" z_length="ci_GEM_sizez" z_offset="ci_GEM_shiftz"	z="ci_GEM_posz" x="ci_GEM_posx" number="ci_GEM_nlayers" rmax1="ci_HCAL_lay_rin -1. * cm"/>
+      <layer id="0" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 0) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 0) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 0) * cm" dz="1 * cm" />
+      <layer id="1" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 1) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 1) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 1) * cm" dz="1 * cm" />
+      <layer id="2" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 2) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 2) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 2) * cm" dz="1 * cm" />
+      <layer id="3" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 3) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 3) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 3) * cm" dz="1 * cm" />
+      <layer id="4" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 4) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 4) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 4) * cm" dz="1 * cm" />
+      <layer id="5" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 5) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 5) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 5) * cm" dz="1 * cm" />
+      <layer id="6" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 6) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 6) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 6) * cm" dz="1 * cm" />
+      <layer id="7" z="-ci_GEM_sizez * 0.5 + (5 + 3. * 7) * cm" inner_r="ci_GEM_rin + (1. + 0.5 * 7) * cm" outer_r="ci_GEM_rout + (-25. + 2. * 7) * cm" dz="1 * cm" />
+    </detector>
+  </detectors>
+  <readouts>
+    <readout name="ci_GEM_Hits">
+      <segmentation type="CartesianGridXY" grid_size_x="1.0*mm" grid_size_y="1.0*mm" />
+      <id>system:8,layer:8,x:32:-16,y:-16</id>  
+    </readout>
+  </readouts>
+
+
+  <plugins>
+  </plugins>
+
+</lccdd>
diff --git a/compact/ci_HCAL.xml b/compact/ci_HCAL.xml
new file mode 100644
index 00000000..4762fe68
--- /dev/null
+++ b/compact/ci_HCAL.xml
@@ -0,0 +1,66 @@
+<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" 
+       xmlns:xs="http://www.w3.org/2001/XMLSchema" 
+       xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
+
+  <!-- Some information about detector-->  
+  <info name="Central Ion HCAL" title="Central Ion HCAL"
+        author="Marshall Scott"
+        url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
+        status="development"
+        version="v1 2021-03-31">
+    <comment>Central Ion HCAL</comment>        
+  </info>
+   
+  <includes>
+  </includes>
+
+  <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <display>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+    <comment>
+      Central Ion HCAL
+    </comment>
+    <detector id="ci_HCAL_id" name="ci_HCAL" type="ci_HCAL" insideTrackingVolume="false" vis="ci_HCALVis" readout="ci_HCAL_Hits">
+	    <material name="Iron"/>	    
+      <dimensions rmin="ci_HCAL_rin" rmax="ci_HCAL_rout" z_length="ci_HCAL_sizez" z_offset="ci_HCAL_shiftz"	z="ci_HCAL_posz" x="ci_HCAL_posx" number="ci_HCAL_nlayers" rmin1="ci_HCAL_lay_rin" rmax1="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness"/>
+      <layer id="0"  z="-ci_HCAL_sizez * 0.5 + (1 + 0) * ci_HCAL_lay_thickness + (1 + 0) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="1"  z="-ci_HCAL_sizez * 0.5 + (1 + 1) * ci_HCAL_lay_thickness + (1 + 1) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="2"  z="-ci_HCAL_sizez * 0.5 + (1 + 2) * ci_HCAL_lay_thickness + (1 + 2) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="3"  z="-ci_HCAL_sizez * 0.5 + (1 + 3) * ci_HCAL_lay_thickness + (1 + 3) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="4"  z="-ci_HCAL_sizez * 0.5 + (1 + 4) * ci_HCAL_lay_thickness + (1 + 4) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="5"  z="-ci_HCAL_sizez * 0.5 + (1 + 5) * ci_HCAL_lay_thickness + (1 + 5) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="6"  z="-ci_HCAL_sizez * 0.5 + (1 + 6) * ci_HCAL_lay_thickness + (1 + 6) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="7"  z="-ci_HCAL_sizez * 0.5 + (1 + 7) * ci_HCAL_lay_thickness + (1 + 7) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="8"  z="-ci_HCAL_sizez * 0.5 + (1 + 8) * ci_HCAL_lay_thickness + (1 + 8) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="9"  z="-ci_HCAL_sizez * 0.5 + (1 + 9) * ci_HCAL_lay_thickness + (1 + 9) * 5 * cm"   inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="10" z="-ci_HCAL_sizez * 0.5 + (1 + 10) * ci_HCAL_lay_thickness + (1 + 10) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="11" z="-ci_HCAL_sizez * 0.5 + (1 + 11) * ci_HCAL_lay_thickness + (1 + 11) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="12" z="-ci_HCAL_sizez * 0.5 + (1 + 12) * ci_HCAL_lay_thickness + (1 + 12) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="13" z="-ci_HCAL_sizez * 0.5 + (1 + 13) * ci_HCAL_lay_thickness + (1 + 13) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="14" z="-ci_HCAL_sizez * 0.5 + (1 + 14) * ci_HCAL_lay_thickness + (1 + 14) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="15" z="-ci_HCAL_sizez * 0.5 + (1 + 15) * ci_HCAL_lay_thickness + (1 + 15) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="16" z="-ci_HCAL_sizez * 0.5 + (1 + 16) * ci_HCAL_lay_thickness + (1 + 16) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="17" z="-ci_HCAL_sizez * 0.5 + (1 + 17) * ci_HCAL_lay_thickness + (1 + 17) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="18" z="-ci_HCAL_sizez * 0.5 + (1 + 18) * ci_HCAL_lay_thickness + (1 + 18) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+      <layer id="19" z="-ci_HCAL_sizez * 0.5 + (1 + 19) * ci_HCAL_lay_thickness + (1 + 19) * 5 * cm" inner_r="ci_HCAL_lay_rin" outer_r="ci_HCAL_lay_rout" dz="ci_HCAL_lay_thickness" />
+    </detector>
+  </detectors>
+  <readouts>
+    <readout name="ci_HCAL_Hits">
+      <segmentation type="CartesianGridXY" grid_size_x="1.0*mm" grid_size_y="1.0*mm" />
+      <id>system:8,layer:8,x:32:-16,y:-16</id>  
+    </readout>
+  </readouts>
+
+
+  <plugins>
+  </plugins>
+</lccdd>
diff --git a/compact/definitions.xml b/compact/definitions.xml
index 70d2b520..36d9cf55 100644
--- a/compact/definitions.xml
+++ b/compact/definitions.xml
@@ -26,7 +26,7 @@
       endcapP/endcapN are the endcaps at positive/negative z values. 
       See https://acts.readthedocs.io/en/latest/plugins/dd4hep.html for more details.
 
-      The tracking geometry needs to beconstructed from cylinders from the inside out. For this reason
+      The tracking geometry needs to be constructed from cylinders from the inside out. For this reason
       each layer needs its own subsystem assembly. This increases the number of top level system IDs. 
       For example the silicon tracker needs 3 IDs for each area (endcap+barrel+endcap) and a subassembly for each
       layer. Therefore it needs a minimum of 20 IDs. Therefore we will allocate blocks of ~25 for each major subsystem.
@@ -127,7 +127,7 @@
 
     <comment> 
     ===================
-    (75-99 Reserved IDs
+    (75-99) Reserved IDs
     ===================
 
     Unused IDs: 75-99 
@@ -156,7 +156,7 @@
 
     <comment> 
       =====================================
-      (110-119Hadronic Calorimeter
+      (110-119) Hadronic Calorimeter
       =====================================
 
       HCal     subsystem  ID:  110
@@ -164,13 +164,13 @@
       EndcapP  subassembly ID: 112
       EndcapN  subassembly ID: 113
 
-      Unused IDs: 114-119
+      Unused IDs: 115-119
     </comment>
     <constant name="HCalSubAssembly_ID" value="110"/>
     <constant name="HCalBarrel_ID"      value="111"/>
     <constant name="HCalEndcapP_ID"     value="112"/>
     <constant name="HCalEndcapN_ID"     value="113"/>
-
+    <constant name="ci_HCAL_id"         value="200"/>
     <comment> 
       =====================================
       (120-129) (near) Forward reserved
@@ -183,6 +183,7 @@
     </comment>
     <constant name="ForwardTracking_ID" value="120"/>
     <constant name="ForwardRICH_ID"     value="121"/>
+    <constant name="ci_GEM_id"          value="122"/>
 
     <comment> 
       =====================================
@@ -319,6 +320,9 @@
       Tracking Parameters
       ============================
     </comment>
+
+    <constant name="ForwardTrackingGEMLength" value="30.0*cm"/>
+
     <constant name="tracker_region_rmax"            value="Solenoid_rmax/2.0"/>
     <constant name="tracker_region_zmax"            value="Solenoid_length/2.0"/>
 
@@ -340,7 +344,7 @@
     <constant name="SiliconTrackerInnerRadius"       value="95.0*mm"/>
     <constant name="SiliconTrackerInnerBarrelLength" value="300.0*mm"/>
     <constant name="SiliconTrackerOuterRadius"       value="Solenoid_rmax/3.0"/>
-    <constant name="SiliconTrackerOuterBarrelLength" value="Solenoid_length/2.5"/>
+    <constant name="SiliconTrackerOuterBarrelLength" value="Solenoid_length/2.5 - ForwardTrackingGEMLength"/>
     <constant name="SiliconTrackerOuterBarrel_zmax"  value="SiliconTrackerOuterBarrelLength/2.0"/>
 
     <comment>
@@ -413,7 +417,7 @@
 
     </comment>
     <constant name="CaloSides"                  value="12"/>
-	    
+      
     <comment>Material Thickness</comment>
     <constant name="EcalSiliconThickness"       value="9.00 * mm" />
     <constant name="EcalCopperThickness"        value="0.05 * mm" />
@@ -422,32 +426,32 @@
     <constant name="EcalAir2Thickness"          value="0.25 * mm" />
     <constant name="EcalThinTungstenThickness"  value="2.50 * mm" />
     <constant name="EcalThickTungstenThickness" value="5.00 * mm" />
-	    
+      
     <comment> Layer Thickness  </comment>
     <constant name="EcalLayer1_thickness"
-	      value="EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
+        value="EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
     <constant name="EcalLayer2_thickness"   
-	      value="EcalThinTungstenThickness + EcalAir2Thickness + EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
+        value="EcalThinTungstenThickness + EcalAir2Thickness + EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
     <constant name="EcalLayer3_thickness"   
-	      value="EcalThickTungstenThickness + EcalAir2Thickness + EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
-	    
+        value="EcalThickTungstenThickness + EcalAir2Thickness + EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
+      
     <comment> EM Barrel N Layer; same number of layers for EcalThin and EcalThick</comment>
     <constant name="EcalBarrelLayers" 
-	      value="floor((EcalBarrel_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
+        value="floor((EcalBarrel_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
     <constant name="EcalBarrelLayer1_NRepeat"       value="1"/>
     <constant name="EcalBarrelLayer2_NRepeat"       value="EcalBarrelLayers"/>
     <constant name="EcalBarrelLayer3_NRepeat"       value="EcalBarrelLayers"/>
 
     <comment> EM Barrel Thickness </comment>
     <constant name="EcalBarrelThickness"
-	      value="EcalBarrelLayer1_NRepeat*EcalLayer1_thickness + EcalBarrelLayer2_NRepeat * EcalLayer2_thickness + EcalBarrelLayer3_NRepeat * EcalLayer3_thickness"/>
+        value="EcalBarrelLayer1_NRepeat*EcalLayer1_thickness + EcalBarrelLayer2_NRepeat * EcalLayer2_thickness + EcalBarrelLayer3_NRepeat * EcalLayer3_thickness"/>
     <constant name="EcalBarrel_rmax"            value="EcalBarrel_rmin + EcalBarrelThickness"/>
 
     <comment> EM Endcap N Layer; same number of layers for EcalThin and EcalThick </comment>
     <constant name="EcalEndcapPLayers" 
-	      value="floor((EcalEndcapP_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
+        value="floor((EcalEndcapP_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
     <constant name="EcalEndcapNLayers" 
-	      value="floor((EcalEndcapN_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
+        value="floor((EcalEndcapN_TotalThickness - EcalLayer1_thickness) / (EcalLayer2_thickness + EcalLayer3_thickness))"/>
     <constant name="EcalEndcapPLayer1_NRepeat"      value="1"/>
     <constant name="EcalEndcapNLayer1_NRepeat"      value="1"/>
     <constant name="EcalEndcapPLayer2_NRepeat"      value="EcalEndcapPLayers"/>
@@ -457,9 +461,9 @@
 
     <comment> EM Endcap Thickness </comment>
     <constant name="EcalEndcapPThickness"        
-	      value="EcalEndcapPLayer1_NRepeat*EcalLayer1_thickness + EcalEndcapPLayer2_NRepeat*EcalLayer2_thickness + EcalEndcapPLayer3_NRepeat*EcalLayer3_thickness "/>
+        value="EcalEndcapPLayer1_NRepeat*EcalLayer1_thickness + EcalEndcapPLayer2_NRepeat*EcalLayer2_thickness + EcalEndcapPLayer3_NRepeat*EcalLayer3_thickness "/>
     <constant name="EcalEndcapNThickness"        
-	      value="EcalEndcapNLayer1_NRepeat*EcalLayer1_thickness + EcalEndcapNLayer2_NRepeat*EcalLayer2_thickness + EcalEndcapNLayer3_NRepeat*EcalLayer3_thickness"/>
+        value="EcalEndcapNLayer1_NRepeat*EcalLayer1_thickness + EcalEndcapNLayer2_NRepeat*EcalLayer2_thickness + EcalEndcapNLayer3_NRepeat*EcalLayer3_thickness"/>
 
 
     <comment>
@@ -482,8 +486,8 @@
 
     <comment> Layer Thickness </comment>
     <constant name="HcalOneLayerThickness"
-	    value="HcalSteelThickness + (2 * HcalPyrexThickness) + HcalRPCGasThickness + HcalG10Thickness + HcalAirThickness"/>
-	    
+      value="HcalSteelThickness + (2 * HcalPyrexThickness) + HcalRPCGasThickness + HcalG10Thickness + HcalAirThickness"/>
+      
     <comment> H Barrel Layers and Thickness </comment>
     <constant name="HcalBarrelLayers" value="floor(HcalBarrelAvailThickness / HcalOneLayerThickness)"/>
     <constant name="HcalBarrelThickness" value="HcalBarrelLayers * HcalOneLayerThickness"/>
@@ -518,17 +522,17 @@
     <comment> Global parameters </comment>
     <constant name="ffi_ZDC_width"             value="60.0 * cm"/>
     <constant name="ffi_ZDC_thickness"         value="200.0 * cm"/>
-    <comment> Original Global parameters </comment>	    
+    <comment> Original Global parameters </comment>     
     <!--
     <constant name="ffi_ZDC_thickness"         value="250.0 * cm"/>
-    -->	    
+    -->     
     <constant name="ffi_ZDC_ECAL_thickness"    value="30.0 * cm"/>
     <constant name="ffi_ZDC_ECAL_inner_radius" value="0.0 * cm"/>
     <constant name="ffi_ZDC_ECAL_outer_radius" value="60.0 * cm"/>
     <constant name="ffi_ZDC_ECAL_width"        value="5.0 * cm"/>
     <constant name="ffi_ZDC_ECAL_gap"          value="5.0 * mm"/>
     <constant name="ffi_ZDC_ECAL_ntower"       value="10"/>
-    <comment> Original number of towers parameter  </comment>	
+    <comment> Original number of towers parameter  </comment> 
     <!--
     <constant name="ffi_ZDC_ECAL_ntower"       value="20"/>
     -->
@@ -575,6 +579,7 @@
     <constant name="ce_MRICHLength" value="BackwardCherenkovLength"/>
     <constant name="ce_MRICHZMin"   value="-EcalEndcapN_zmin+ce_MRICHLength"/>
 
+
     <comment>
       ------------------
       ce_GEM Parameters
@@ -591,5 +596,35 @@
     <constant name="ce_GEM_layer"           value="8"/>
     <constant name="ce_GEM_layer_thickness" value="1.0 * cm"/>
 
+    <comment>
+      --------------------------
+      Central Ion HCal Parameters
+      --------------------------
+    </comment>
+    <constant name="ci_HCAL_rin"     value="90 * cm"/><comment> Orginally 0, changed to not overlap solenoid </comment>
+    <constant name="ci_HCAL_rout"    value="300 * cm"/>
+    <constant name="ci_HCAL_sizez"   value="160 * cm"/>
+    <constant name="ci_HCAL_shiftz"  value="5 * cm"/>
+    <constant name="ci_HCAL_posz"    value="0 * cm"/>
+   
+    <constant name="ci_HCAL_nlayers"       value="20"/>
+    <constant name="ci_HCAL_lay_rin"       value="ci_HCAL_rin"/> <comment> Orginally 80cm, changed to not overlap solenoid </comment>
+    <constant name="ci_HCAL_lay_rout"      value="ci_HCAL_rout - 1 * cm"/>
+    <constant name="ci_HCAL_lay_thickness" value="2* cm"/>
+    <constant name="ci_HCAL_lay_gapz"      value="2* cm"/>
+
+    <comment>
+      --------------------------
+      Central Ion GEM Parameters
+      --------------------------
+    </comment>
+    <constant name="ci_GEM_rin"     value="10 * cm"/>
+    <constant name="ci_GEM_rout"    value="95 * cm"/>
+    <constant name="ci_GEM_sizez"   value="30 * cm"/>
+    <constant name="ci_GEM_shiftz"  value="0 * cm"/>
+    <constant name="ci_GEM_posz"    value="0 * cm"/>
+    <constant name="ci_GEM_posx"    value="0 * cm"/>
+    <constant name="ci_GEM_nlayers" value="8"/>
+
   </define>
 
diff --git a/compact/display.xml b/compact/display.xml
index 5befdb0e..d0733f6d 100644
--- a/compact/display.xml
+++ b/compact/display.xml
@@ -56,6 +56,9 @@
     <vis name="ce_GEMVis"          alpha="0.1"  r= "0.1"  g="0.0"  b="1.0"  showDaughters="true" visible="true"/>
     <vis name="cb_GEM_layerVis"    alpha="0.8"  r= "0.8"  g="0.4"  b="0.3"  showDaughters="true" visible="true"/>
 
+    <vis name="ci_GEMVis"  r= "0.8"  g="0.4"  b="0.3" alpha="0.8" showDaughters="true" visible="true"/>
+    <vis name="ci_HCALVis"  r= "0.6"  g="0"  b="0.6" alpha="1.0" showDaughters="true" visible="true"/>
+
     <comment>
       Deprecated colors.
     </comment>
diff --git a/compact/materials.xml b/compact/materials.xml
index 837b7f02..d8955f0b 100644
--- a/compact/materials.xml
+++ b/compact/materials.xml
@@ -11,7 +11,7 @@
     <fraction n="0.234" ref="O"/>
     <fraction n="0.012" ref="Ar"/>
   </material>
-  <!-- We model vakuum just as very thin air -->
+  <!-- We model vacuum just as very thin air -->
   <material name="Vacuum">
     <D type="density" unit="g/cm3" value="0.0000000001"/>
     <fraction n="0.754" ref="N"/>
@@ -185,7 +185,6 @@
     <composite n="1" ref="W"/>
     <composite n="4" ref="O"/>
   </material>
-
   <material name="Ar10CO2">
     <D type="density" value="1.802" unit="mg / cm3"/>
     <composite n="0.891" ref="Argon"/>
diff --git a/reference_detector.xml b/reference_detector.xml
index 6d46ffad..b040d8db 100644
--- a/reference_detector.xml
+++ b/reference_detector.xml
@@ -121,14 +121,17 @@
   <include ref="compact/ce_mrich.xml"/>
   <include ref="compact/ce_GEM.xml"/>
   <include ref="compact/ffi_ZDC.xml"/>
+  <include ref="compact/ci_GEM.xml"/>
 
   <!--
+  <include ref="compact/ci_HCAL.xml"/>
   <include ref="compact/forward_rich.xml"/>
-  <include ref="compact/hcal.xml"/>
   <include ref="compact/roman_pots.xml"/>
+  <include ref="compact/hcal.xml"/>
   -->
   <include ref="eic/forward_ion_beamline.xml"/>
 
+
   <detectors>
   </detectors>
   <readouts>
diff --git a/src/cb_CTD_Si.cpp b/src/cb_CTD_Si.cpp
index a6a683eb..96c53cce 100644
--- a/src/cb_CTD_Si.cpp
+++ b/src/cb_CTD_Si.cpp
@@ -48,8 +48,9 @@ static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens)
 
     if (layerROut[i] > ROut)
       continue; 
-
+    
     string logic_layer_name = detName + _toString(i, "_Logic_lay_%d");
+    if (i==7){logic_layer_name = detName + _toString(20, "_Logic_lay_%d");}
     Volume layerVol(logic_layer_name,Tube(layerRIn[i], layerROut[i], SizeZ / 2.0, 0.0, 360.0 * deg), slice_mat);
     layerVol.setVisAttributes(desc,x_layer.visStr());
     sens.setType("tracker");
diff --git a/src/ci_GEM.cpp b/src/ci_GEM.cpp
new file mode 100644
index 00000000..6b26f5e2
--- /dev/null
+++ b/src/ci_GEM.cpp
@@ -0,0 +1,59 @@
+#include <XML/Helper.h>
+///////////////////////////
+// Central Ion GEM
+///////////////////////////
+
+using namespace dd4hep;
+
+static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens)
+{
+
+  xml::DetElement detElem   = handle;
+  std::string     detName   = detElem.nameStr();
+  int             detID     = detElem.id();
+  xml::Component  dims      = detElem.dimensions();
+  xml::Component  pos       = detElem.position();
+  double          SizeZ     = dims.z_length(); // Size in Z direction
+  double          ROut      = dims.rmax();     // Outer radius
+  double          RIn       = dims.rmin();     // Inner radius
+  double          ShiftZ    = dims.z_offset();
+  double          X         = dims.x();
+  double          Z         = dims.z();
+  int             Nlayers   = dims.number();
+  double          HCAL_rmin = dims.rmax1(); // Maximum radius that the layer can be
+  Material        mat       = desc.material(detElem.materialStr());
+  Material        vac       = desc.material("Vacuum");
+
+  // Outer Volume
+  Tube   ci_GEM_GVol_Solid(RIn, ROut, SizeZ / 2., 0., 360 * deg);
+  Volume detVol("ci_GEM_GVol_Logic", ci_GEM_GVol_Solid, vac);
+
+  // Adding layers to placed volume
+  for (xml_coll_t li(detElem, _U(layer)); li; ++li) {
+    xml_comp_t  x_layer    = li;
+    std::string layer_name = detName + _toString(x_layer.id(), "_layer%d");
+    double      outer_r    = x_layer.outer_r();
+    if (outer_r > HCAL_rmin) {
+      outer_r = HCAL_rmin;
+    }
+
+    Volume layer_vol(layer_name, Tube(x_layer.inner_r(), outer_r, x_layer.dz()), mat);
+    layer_vol.setVisAttributes(desc.visAttributes(detElem.visStr()));
+    sens.setType("tracker");
+    layer_vol.setSensitiveDetector(sens);
+    Position     layer_pos(0, 0, x_layer.z());
+    PlacedVolume layer_phv = detVol.placeVolume(layer_vol, layer_pos);
+    layer_phv.addPhysVolID("layer", x_layer.id());
+  }
+
+  DetElement   det(detName, detID);
+  Volume       motherVol = desc.pickMotherVolume(det);
+  Transform3D  tr(RotationZYX(0.0, 0.0, 0.0), Position(pos.x(), pos.x(), pos.z() + SizeZ / 2.0));
+  PlacedVolume detPV = motherVol.placeVolume(detVol, tr);
+  detPV.addPhysVolID("system", detID);
+  det.setPlacement(detPV);
+
+  return det;
+}
+// clang-format off
+DECLARE_DETELEMENT(ci_GEM, createDetector)
diff --git a/src/ci_HCAL.cpp b/src/ci_HCAL.cpp
new file mode 100644
index 00000000..8cd0cc74
--- /dev/null
+++ b/src/ci_HCAL.cpp
@@ -0,0 +1,56 @@
+#include <XML/Helper.h>
+///////////////////////////
+// Central Ion GEM
+///////////////////////////
+
+using namespace dd4hep;
+
+static Ref_t createDetector(Detector& desc, xml_h handle, SensitiveDetector sens)
+{
+
+  xml::DetElement detElem = handle;
+  std::string     detName = detElem.nameStr();
+  int             detID   = detElem.id();
+  xml::Component  dims    = detElem.dimensions();
+  double RIn              = dims.rmin();
+  double ROut             = dims.rmax();
+  double SizeZ            = dims.z_length();
+  double ShiftZ           = dims.z_offset();
+  double PosZ             = dims.z();
+  double lay_RIn          = dims.rmin1();
+  double lay_ROut         = dims.rmax1();
+  double lay_dz           = dims.dz();
+  Material mat_iron       = desc.material("Iron");
+  Material mat_vac        = desc.material("Vacuum");
+
+  //Outer volume  
+  Tube    ci_Hcal_Solid(RIn, ROut, SizeZ / 2., 0., 360 * dd4hep::deg);
+  Volume  envelopeVol("ci_Hcal_Logic", ci_Hcal_Solid, mat_vac);
+
+  //Iron tube for the layers
+  Tube ci_Hcal_detSolid(lay_RIn, lay_ROut, lay_dz / 2., 0., 360 * dd4hep::deg);
+
+  //Adding layers to placed detector volume
+  for (xml_coll_t li(detElem,_U(layer)); li; ++li){
+    xml_comp_t x_layer = li;
+  	std::string layer_name = detName + _toString(x_layer.id(), "_layer%d");
+    Volume layer_vol(layer_name, ci_Hcal_detSolid, mat_iron);
+    layer_vol.setVisAttributes(detElem.visStr());
+    sens.setType("calorimeter");
+    layer_vol.setSensitiveDetector(sens);
+  	Position layer_pos(0, 0, x_layer.z());
+  	PlacedVolume layer_phv = envelopeVol.placeVolume(layer_vol, layer_pos);
+  	layer_phv.addPhysVolID("layer", x_layer.id());
+  }
+  
+  DetElement   det(detName, detID);
+  Volume       motherVol = desc.pickMotherVolume(det);
+  Transform3D  tr(RotationZYX(0,0,0), Position(0, 0, ShiftZ));
+  PlacedVolume detPV     = motherVol.placeVolume(envelopeVol, tr);
+  detPV.addPhysVolID("system", detID);
+  det.setPlacement(detPV);
+
+  return det;
+}
+// clang-format off
+DECLARE_DETELEMENT(ci_HCAL, createDetector)
-- 
GitLab