diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index caf2e6a471dbce7bd3f3f72a8158528cc5a0e38d..2c662aa72c92f356885f5a00c59ef3109b3484c2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -12,6 +12,7 @@ default:
   before_script:
     - mkdir -p images && mkdir -p doc/
     - git clone https://eicweb.phy.anl.gov/EIC/detectors/accelerator.git && ln -s accelerator/eic 
+    - git clone https://eicweb.phy.anl.gov/EIC/detectors/ip6.git  eic_ip6 && mkdir ip6_build && cd ip6_build && cmake ../eic_ip6/. -DCMAKE_INSTALL_PREFIX=/usr/local && make -j20 && make install  && cd .. && ln -s eic_ip6/ip6 
     - mkdir build && cd build && cmake ../. -DCMAKE_INSTALL_PREFIX=/usr/local && make -j20 && make install  && cd ..
   artifacts:
     paths:
@@ -35,6 +36,8 @@ env:
     - |
       if [[ "x${CI_PIPELINE_SOURCE}" == "xmerge_request_event"  || "$CI_COMMIT_BRANCH" == "master" ]]; then
         export JUGGLER_DETECTOR_VERSION="${CI_COMMIT_REF_NAME}"
+        echo "BEAMLINE_CONFIG          = ${BEAMLINE_CONFIG}"
+        echo "BEAMLINE_CONFIG_VERSION  = ${BEAMLINE_CONFIG_VERSION}"
         echo "JUGGLER_DETECTOR         = ${JUGGLER_DETECTOR}"
         echo "JUGGLER_DETECTOR_VERSION = ${CI_COMMIT_REF_NAME}"
         echo "JUGGLER_DETECTOR_VERSION=$CI_COMMIT_REF_NAME" >> juggler.env
@@ -50,6 +53,7 @@ compile:
   needs:
     - ["env"]
   script:
+    - mkdir -p build && cd build && cmake ../. -DCMAKE_INSTALL_PREFIX=/usr/local && make -j20 && make install  && cd ..
     - echo "Build successful."
 
 .views:
@@ -102,24 +106,24 @@ detector:config_testing:
     - cat doc/overlap_check.out
   allow_failure: true
 
-benchmarks:reconstruction:
-  stage: deploy
-  variables:
-    JUGGLER_DETECTOR: "$JUGGLER_DETECTOR"
-    JUGGLER_DETECTOR_VERSION: "$JUGGLER_DETECTOR_VERSION"
-  trigger:
-    project: EIC/benchmarks/reconstruction_benchmarks
-    strategy: depend
-  needs: ["env","overlap_check","report"]
-  
-
-benchmarks:physics:
-  stage: deploy
-  variables:
-    JUGGLER_DETECTOR: "$JUGGLER_DETECTOR"
-    JUGGLER_DETECTOR_VERSION: "$JUGGLER_DETECTOR_VERSION"
-  trigger:
-    project: EIC/benchmarks/physics_benchmarks
-    strategy: depend
-  needs: ["env","overlap_check","report"]
+    #benchmarks:reconstruction:
+    #  stage: deploy
+    #  variables:
+    #    JUGGLER_DETECTOR: "$JUGGLER_DETECTOR"
+    #    JUGGLER_DETECTOR_VERSION: "$JUGGLER_DETECTOR_VERSION"
+    #  trigger:
+    #    project: EIC/benchmarks/reconstruction_benchmarks
+    #    strategy: depend
+    #  needs: ["env","overlap_check","report"]
+    #  
+    #
+    #benchmarks:physics:
+    #  stage: deploy
+    #  variables:
+    #    JUGGLER_DETECTOR: "$JUGGLER_DETECTOR"
+    #    JUGGLER_DETECTOR_VERSION: "$JUGGLER_DETECTOR_VERSION"
+    #  trigger:
+    #    project: EIC/benchmarks/physics_benchmarks
+    #    strategy: depend
+    #  needs: ["env","overlap_check","report"]
 
diff --git a/cb_Solenoid.xml b/cb_Solenoid.xml
deleted file mode 100644
index 36ede76391de0c9d7297bb57dc0aa7cec0a9ec44..0000000000000000000000000000000000000000
--- a/cb_Solenoid.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<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 Barrel Solenoid" title="Central Barrel Solenoid"
-        author="Jihee Kim"
-        url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
-        status="development"
-        version="v1 2021-03-15">
-    <comment>Central Barrel Solenoid</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="world_side" value="50*m"/>
-    <constant name="world_x"    value="world_side"/>
-    <constant name="world_y"    value="world_side"/>
-    <constant name="world_z"    value="world_side"/>
-
-    <constant name="tracker_region_zmax" value="6 * m"/>
-    <constant name="tracker_region_rmax" value="6 * m"/>
-
-    <constant name="cb_Solenoid_ID"    value="1"/>
-    <constant name="cb_Solenoid_rmin"  value="0.0 * cm"/>   <!-- Central Barrel Solenoid Inner diameter -->
-    <constant name="cb_Solenoid_rmax"  value="137.0 * cm"/> <!-- Central Barrel Solenoid Outer diameter -->
-    <constant name="cb_Solenoid_z"     value="400.0 * cm"/> <!-- Central Barrel Solenoid Size in Z direction -->
-    <constant name="cb_Solenoid_shift" value="0.0 * cm"/>
-  </define>
-
-  <limits>
-  </limits>
-
-  <regions>
-  </regions>
-
-  <!-- Common Generic visualization attributes -->
-  <comment>Common Generic visualization attributes</comment>
-  <display>
-    <vis name="cb_SolenoidVis" alpha="0.4"  r= "0.1"  g="0.0"  b="0.1"  showDaughters="true" visible="true"/>
-  </display>
-
-  <!-- Define detector -->
-  <detectors>
-    <comment>
-      Central Barrel Solenoid Magnet
-    </comment>
-    <detector id="cb_Solenoid_ID" name="cb_Solenoid" type="cb_Solenoid" insideTrackingVolume="false" vis="cb_SolenoidVis">
-	    <material name="Vacuum"/>  <!-- G4_Galactic -->	    
-      <dimensions rmin="cb_Solenoid_rmin" rmax="cb_Solenoid_rmax" z="cb_Solenoid_z" delta="cb_Solenoid_shift"/>
-    </detector>
-  </detectors>
-
-  <plugins>
-  </plugins>
-
-  <!-- TODO: Define field using field map-->
-  <fields>
-    <field type="solenoid" name="GlobalSolenoid" inner_field="1.5 * tesla" outer_field="0.5*tesla" 
-           zmin="100.0 * cm" zmax="100.0 * cm" inner_radius="100.0 * cm" outer_radius="100.0 * cm"/>
-  </fields>
-</lccdd>
diff --git a/compact/cb_Solenoid.xml b/compact/cb_Solenoid.xml
new file mode 100644
index 0000000000000000000000000000000000000000..2083a62dbdb38140ae6ebd245ed9b4c43da89b19
--- /dev/null
+++ b/compact/cb_Solenoid.xml
@@ -0,0 +1,34 @@
+<lccdd>
+
+  <comment>Central Barrel Solenoid</comment>        
+
+  <define>
+  </define>
+
+  <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <display>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+    <comment>
+      Central Barrel Solenoid Magnet
+    </comment>
+    <detector id="Solenoid_ID" name="cb_Solenoid" type="cb_Solenoid" insideTrackingVolume="false" vis="cb_SolenoidVis">
+	    <material name="Vacuum"/>  <!-- G4_Galactic -->	    
+      <dimensions rmin="cb_Solenoid_rmin" rmax="cb_Solenoid_rmax" z="cb_Solenoid_z" delta="cb_Solenoid_shift"/>
+    </detector>
+  </detectors>
+
+  <plugins>
+  </plugins>
+
+  <!-- TODO: Define field using field map-->
+  <fields>
+  </fields>
+</lccdd>
diff --git a/compact/ce_mrich.xml b/compact/ce_mrich.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ebd1c473ceddbefb04b9b9ea57f544fb7b8fcec2
--- /dev/null
+++ b/compact/ce_mrich.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+  <define>
+  </define>
+
+  <detectors>
+    <detector id="ce_MRICH_ID" name="ce_MRICH" type="refdet_ce_MRICH" readout="MRICHHits" vis="BlueVis" material="Air">
+      <dimensions rmin="ce_MRICHRMin" rmax="ce_MRICHRMax" length="ce_MRICHLength" z="ce_MRICHZMin"/>
+      <modules material="Quartz" thickness="10*cm" width="10*cm" gap="1*cm" />
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="MRICHHits">
+      <segmentation type="CartesianGridXY" grid_size_x="3*mm" grid_size_y="3*mm" />
+      <id>system:8,layer:4,piece:4,module:14,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/compact/definitions.xml b/compact/definitions.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9c2698447922866fb89b079984890dddc1885591
--- /dev/null
+++ b/compact/definitions.xml
@@ -0,0 +1,474 @@
+  <define>
+    <comment>Although not explicit in the design study, the eRHIC crossing angle is not symmetric.</comment>
+    <constant name="CrossingAngle" value="0.025"/>
+    <constant name="ionCrossingAngle" value="0.0166667"/>
+    <constant name="electronCrossingAngle" value="0.00833333"/>
+    <constant name="CrossingSlope" value="0.0166682"/>
+
+    <constant name="Pi" value="3.14159265359"/>
+    <constant name="world_side" value="30*m"/>
+    <constant name="world_x" value="world_side"/>
+    <constant name="world_y" value="world_side"/>
+    <constant name="world_z" value="100*m"/>
+
+    <constant name="mil" value="0.0254*mm"/>
+
+    <comment>
+      ------------
+      Detector IDs
+      ------------
+
+      Note about ACTS tracking geometry construction
+      ----------------------------------------------
+
+      The tracking surfaces need to be structured in a barrel + endcapP + endcapN where 
+      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
+      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.
+      Note, future improvements will likely include a more sophisticated ACTS-dd4hep plugin, 
+      eliminating the need for so many system IDs at construction time.
+
+      This barrel/endcap structure needs IDs to be in increasing order going outward. 
+      The space of IDs for the subassemblies starts at (Subassembly_ID*10+101).
+
+      The unused IDs below are saved for future use.
+    </comment>
+
+
+    <comment> 
+      ===================
+      (1-9) Reserved IDs
+      ===================
+      Unused IDs: 1-9 
+
+      ====================================
+      (10-24) Interaction region beamline 
+      ====================================
+
+      Beampipe ID : 10
+      Unused   IDs: 11-24
+
+    </comment> 
+    <constant name="BeamPipe_ID" value="10"/>
+
+
+    <comment> 
+      ===============================
+      (25-49) Silicon Vertex Tracker
+      ===============================
+      SiVertex subsystem  ID: 25 
+      Layer 1 subassembly ID: 26
+      Layer 2 subassembly ID: 27
+      Layer 3 subassembly ID: 28
+      Layer 4 subassembly ID: 29
+      Layer 5 subassembly ID: 30
+    </comment>
+    <constant name="SiVertexSubAssembly_ID" value="25"/>
+    <comment>
+      Unused values reserved for vertex:
+      constant name="SiVertexSubAssemblyLayer1_ID" value="121"
+      constant name="SiVertexSubAssemblyLayer2_ID" value="122"
+      constant name="SiVertexSubAssemblyLayer3_ID" value="123"
+      constant name="SiVertexSubAssemblyLayer4_ID" value="124"
+      constant name="SiVertexSubAssemblyLayer5_ID" value="125"
+    </comment>
+
+    <comment>
+      ===============================
+      (50-74) Silicon Tracker System
+      ===============================
+
+      SiTracker subsystem  ID: 50
+      Layer 1 subassembly  ID: 51      
+      Layer 2 subassembly  ID: 52      
+      Layer 3 subassembly  ID: 53
+      Layer 4 subassembly  ID: 54
+      Layer 5 subassembly  ID: 55
+
+      (56-70) etc...
+
+      Unused IDs: 71-74
+
+    </comment>
+
+    <constant name="SiTrackerSubAssembly_ID" value="50"/>
+    <constant name="SiTrackerSubAssemblyLayer1_ID" value="51"/>
+    <constant name="SiTrackerSubAssemblyLayer2_ID" value="52"/>
+    <constant name="SiTrackerSubAssemblyLayer3_ID" value="53"/>
+    <constant name="SiTrackerSubAssemblyLayer4_ID" value="54"/>
+    <constant name="SiTrackerSubAssemblyLayer5_ID" value="55"/>
+
+    <constant name="SiTrackerBarrel_Layer1_ID"      value="56"/>
+    <constant name="SiTrackerEndcapP_Layer1_ID"     value="57"/>
+    <constant name="SiTrackerEndcapN_Layer1_ID"     value="58"/>
+
+    <constant name="SiTrackerBarrel_Layer2_ID"      value="59"/>
+    <constant name="SiTrackerEndcapP_Layer2_ID"     value="60"/>
+    <constant name="SiTrackerEndcapN_Layer2_ID"     value="61"/>
+
+    <constant name="SiTrackerBarrel_Layer3_ID"      value="62"/>
+    <constant name="SiTrackerEndcapP_Layer3_ID"     value="63"/>
+    <constant name="SiTrackerEndcapN_Layer3_ID"     value="64"/>
+
+    <constant name="SiTrackerBarrel_Layer4_ID"      value="65"/>
+    <constant name="SiTrackerEndcapP_Layer4_ID"     value="66"/>
+    <constant name="SiTrackerEndcapN_Layer4_ID"     value="67"/>
+
+    <constant name="SiTrackerBarrel_Layer5_ID"      value="68"/>
+    <constant name="SiTrackerEndcapP_Layer5_ID"     value="69"/>
+    <constant name="SiTrackerEndcapN_Layer5_ID"     value="70"/>
+
+    <comment> 
+    ===================
+    (75-99 Reserved IDs
+    ===================
+
+    Unused IDs: 75-99 
+    TBD 
+    </comment>
+
+    <comment> 
+      =====================================
+      (100-109) Electromagnetic Calorimeter
+      =====================================
+
+      ECal     subsystem  ID:  100
+      Barrel   subassembly ID: 101
+      EndcapP  subassembly ID: 102
+      EndcapN  subassembly ID: 103
+      Crystal  subassembly ID: 104
+
+      Unused IDs: 105-109
+
+    </comment>
+    <constant name="ECalSubAssembly_ID" value="100"/>
+    <constant name="ECalBarrel_ID"      value="101"/>
+    <constant name="ECalEndcapP_ID"     value="102"/>
+    <constant name="ECalEndcapN_ID"     value="103"/>
+    <constant name="CrystalEndcap_ID"   value="104"/>
+
+    <comment> 
+      =====================================
+      (110-119Hadronic Calorimeter
+      =====================================
+
+      HCal     subsystem  ID:  110
+      Barrel   subassembly ID: 111
+      EndcapP  subassembly ID: 112
+      EndcapN  subassembly ID: 113
+
+      Unused IDs: 114-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"/>
+
+    <comment> 
+      =====================================
+      (120-129) (near) Forward reserved
+      =====================================
+
+      Forwardtracking ID: 120
+      Forward RICH    ID: 121
+
+      Unused IDs: 123-129
+    </comment>
+    <constant name="ForwardTracking_ID" value="120"/>
+    <constant name="ForwardRICH_ID"     value="121"/>
+
+    <comment> 
+      =====================================
+      (130-139) Backward reserved
+      =====================================
+
+      Modular RICH ID: 130
+      Unused IDs: 131-139
+
+    </comment>
+    <constant name="ce_MRICH_ID"        value="130"/>
+
+    <comment> 
+      =====================================
+      (140-149) Central Magnet
+      =====================================
+
+      Solenoid         ID: 140
+      Solenoid support ID: 141
+      Solenoid Yoke    ID: 142
+
+      Unused IDs: 143-149
+
+    </comment>
+    <constant name="Solenoid_ID"             value="140"/>
+    <constant name="SolenoidSupport_ID"      value="141"/>
+    <constant name="SolenoidYoke_ID"         value="142"/>
+
+    <comment> 
+      =====================================
+      (150-169) Far Forward  Detectors
+      =====================================
+
+      Forward Roman Pot ID: 150
+      Zero Degree Cal.  ID: 160
+
+    </comment>
+    <constant name="ForwardRomanPot_ID" value="150"/>
+    <constant name="ZDC_ID"             value="160"/>
+
+    <comment> 
+      =====================================
+      (170-189) Forward Beamline Magnets
+      =====================================
+    </comment>
+
+    <comment> 
+      =====================================
+      (190-199) Backward Beamline Magnets
+      =====================================
+    </comment>
+
+    <comment>
+      --------------------------
+      Solenoid Magnet Parameters
+      --------------------------
+    </comment>
+
+    <comment>
+      These cb_ parameters don't make sense
+    </comment>
+    <constant name="cb_Solenoid_rmin"  value="0.0 * cm"/>   <comment> Central Barrel Solenoid Inner diameter </comment>
+    <constant name="cb_Solenoid_rmax"  value="137.0 * cm"/> <comment> Central Barrel Solenoid Outer diameter </comment>
+    <constant name="cb_Solenoid_z"     value="400.0 * cm"/> 
+    <constant name="cb_Solenoid_shift" value="0.0 * cm"/><comment> Central Barrel Solenoid Size in Z direction </comment>
+
+    <constant name="Solenoid_thickness"      value="400*mm"/>
+    <constant name="Solenoid_rmin"           value="2000.0*mm"/>
+    <constant name="Solenoid_rmax"           value="Solenoid_rmin + Solenoid_thickness"/>
+    <constant name="SolenoidLength"          value="4050.0*mm"/>
+
+    <constant name="SolenoidBarrelCryostatThickness"      value=" 1.0 * cm"/>
+    <constant name="SolenoidBarrelGapThickness"           value=" 3.3 * cm"/>
+    <constant name="SolenoidBarrelAlConductorThickness"   value="12.0 * cm"/>
+    <constant name="SolenoidBarrelQuenchbackThickness"    value=" 1.5 * cm"/>
+    <constant name="SolenoidBarrelOuterGapThickness"      value=" 5.6 * cm"/>
+    <constant name="SolenoidBarrelOuterCryostatThickness" value=" 1.2 * cm"/>
+
+    <constant name="SolenoidEndPlateGapThickness"           value=" 5.7 * cm"/>
+    <constant name="SolenoidEndPlateCryostatThickness"      value=" 1.5 * cm"/>
+
+    <constant name="SolenoidBarrel_rmin"     value="Solenoid_rmin"/>
+    <constant name="SolenoidBarrelLenth"     value="SolenoidLength"/>
+    <constant name="SolenoidBarrel_zmax"     value="SolenoidBarrelLenth/2.0"/>
+
+    <constant name="SolenoidCoilConductor_rmin" 
+              value="SolenoidBarrel_rmin + SolenoidBarrelCryostatThickness + SolenoidBarrelGapThickness"/>
+    <constant name="SolenoidCoilConductor_rmax" 
+              value="SolenoidCoilConductor_rmin + SolenoidBarrelAlConductorThickness + SolenoidBarrelQuenchbackThickness"/>
+    <constant name="SolenoidBarrel_rmax" 
+              value="SolenoidCoilConductor_rmax + SolenoidBarrelOuterGapThickness + SolenoidBarrelOuterCryostatThickness"/>
+
+    <constant name="SolenoidCoil_zmax" 
+              value="SolenoidBarrel_zmax - SolenoidEndPlateCryostatThickness - SolenoidEndPlateGapThickness"/>
+
+    <constant name="SolenoidalFieldRadius" 
+              value="SolenoidCoilConductor_rmin + SolenoidBarrelAlConductorThickness / 2.0"/>
+
+    <constant name="SolenoidCoilLength" value="SolenoidCoil_zmax*2.0"/>
+
+    <constant name="SolenoidThickness"           value="Solenoid_rmax - Solenoid_rmin"/>
+
+    <constant name="SolenoidYokeEndcapP_rmin"     value="800*mm"/>
+    <constant name="SolenoidYokeEndcapN_rmin"     value="800*mm"/>
+    <constant name="SolenoidYokeEndcapThickness"  value="0.2 * m"/>
+    <constant name="SolenoidYokeEndcap_zmin"      value="SolenoidBarrel_zmax"/>
+    <constant name="SolenoidYokeEndcap_zmax"      value="SolenoidYokeEndcap_zmin + SolenoidYokeEndcapThickness"/>
+
+    <constant name="SolenoidYokeChamferAngle"    value="0.2"/>
+
+    <comment>
+      ============================
+      Tracking Parameters
+      ============================
+    </comment>
+    <constant name="tracker_region_rmax"            value="Solenoid_rmax/2.0"/>
+    <constant name="tracker_region_zmax"            value="SolenoidLength/2.0"/>
+
+    <comment>
+      -------------------------
+      Vertex Tracker Parameters
+      -------------------------
+    </comment>
+    <constant name="VertexTrackerInnerRadius"       value="30.0*mm"/>
+    <constant name="VertexTrackerOuterRadius"       value="Solenoid_rmin/2.0"/>
+    <constant name="VertexTrackerOuterBarrelLength" value="300.0*mm"/>
+
+
+    <comment>
+      --------------------------
+      Silicon Tracker Parameters
+      --------------------------
+    </comment>
+    <constant name="SiliconTrackerInnerRadius"       value="95.0*mm"/>
+    <constant name="SiliconTrackerInnerBarrelLength" value="400.0*mm"/>
+    <constant name="SiliconTrackerOuterRadius"       value="Solenoid_rmax/2.0"/>
+    <constant name="SiliconTrackerOuterBarrelLength" value="SolenoidLength/2.0"/>
+
+    <comment>
+      ------------
+      Calorimeters
+      ------------
+    </comment>
+    <constant name="EcalBarrel_rmin"                       value="SiliconTrackerOuterRadius + 3.0 * cm"/>
+    <constant name="HcalBarrel_rmax"                       value="Solenoid_rmin - 5.0 *cm "/>
+    <constant name="AvailTotalBarrelCalorimetryThickness"  value="HcalBarrel_rmax - EcalBarrel_rmin"/>
+    <constant name="CalBarrelDivider"                      value="0.5"/> <comment> Ecal and Hcal have the same thickness </comment>
+    <constant name="EcalBarrelAvailTotalThickness"         value="AvailTotalBarrelCalorimetryThickness * CalBarrelDivider"/>
+    <constant name="HcalBarrelAvailTotalThickness"         value="AvailTotalBarrelCalorimetryThickness * (1.0 - CalBarrelDivider)"/>
+
+    <constant name="EcalBarrelLength"                      value="SiliconTrackerOuterBarrelLength+50.0*cm"/>
+    <constant name="EcalEndcap_zmin"                       value="EcalBarrelLength/2.0"/>
+
+    <constant name="AvailTotalEndcapCalorimetryThickness"  value="(SolenoidYokeEndcap_zmin - 10.0 * mm) - (EcalEndcap_zmin + 10.0 * mm)"/>
+    <constant name="CalEndcapDivider"                      value="0.5"/> <comment> Ecal and Hcal have the same thickness </comment>
+    <constant name="EcalEndcapAvailTotalThickness"         value="AvailTotalEndcapCalorimetryThickness * CalEndcapDivider"/>
+    <constant name="HcalEndcapAvailTotalThickness"         value="AvailTotalEndcapCalorimetryThickness * (1.0 - CalEndcapDivider)"/>
+
+    <comment> These need to be set in sync with the forward and backward  detectors </comment>
+    <constant name="EcalEndcapP_rmin"                      value="250.0*mm"/>
+    <constant name="EcalEndcapN_rmin"                      value="350.0*mm"/>
+
+    <constant name="HcalEndcapP_rmin"                      value="250.0 * mm"/>
+    <constant name="HcalEndcapN_rmin"                      value="350.0 * mm"/>
+
+    <comment>
+      -------------------------
+      EM Calorimeter Parameters
+      -------------------------
+    </comment>
+    <constant name="CaloSides"                  value="12"/>
+	    
+    <comment>Material Thickness</comment>
+    <constant name="EcalSiliconThickness"       value="9.00 * mm"/>
+    <constant name="EcalCopperThickness"        value="0.05 * mm"/>
+    <constant name="EcalKaptonThickness"        value="0.30 * mm"/>
+    <constant name="EcalAir1Thickness"          value="0.33 * mm"/>
+    <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="EcalFirstLayerThickness"
+	    value="EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
+    <constant name="EcalThinOneLayerThickness"   
+	    value="EcalThinTungstenThickness + EcalAir2Thickness + EcalSiliconThickness + EcalCopperThickness + EcalKaptonThickness + EcalAir1Thickness"/>
+    <constant name="EcalThickOneLayerThickness"   
+	    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((EcalBarrelAvailTotalThickness - EcalFirstLayerThickness) / (EcalThinOneLayerThickness + EcalThickOneLayerThickness))"/>
+    <constant name="EcalBarrelThinLayers"       value="EcalBarrelLayers"/>
+    <constant name="EcalBarrelThickLayers"      value="EcalBarrelLayers"/>
+    <comment> EM Barrel Thickness </comment>
+    <constant name="EcalBarrelThickness"
+	    value="EcalFirstLayerThickness + (EcalBarrelThinLayers * EcalThinOneLayerThickness) + (EcalBarrelThickLayers * EcalThickOneLayerThickness)"/>
+    <constant name="EcalBarrel_rmax"            value="EcalBarrel_rmin + EcalBarrelThickness"/>
+
+    <comment> EM Endcap N Layer; same number of layers for EcalThin and EcalThick </comment>
+    <constant name="EcalEndcapLayers" 
+	    value="floor((EcalEndcapAvailTotalThickness - EcalFirstLayerThickness) / (EcalThinOneLayerThickness + EcalThickOneLayerThickness))"/>
+    <constant name="EcalEndcapThinLayers"       value="EcalEndcapLayers"/>
+    <constant name="EcalEndcapThickLayers"      value="EcalEndcapLayers"/>
+    <comment> EM Endcap Thickness </comment>
+    <constant name="EcalEndcapThickness"        
+	    value="EcalFirstLayerThickness + (EcalEndcapThinLayers * EcalThinOneLayerThickness) + (EcalEndcapThickLayers * EcalThickOneLayerThickness)"/>
+
+    <comment>
+      -------------------------------
+      Hadronic Calorimeter Parameters
+      -------------------------------
+    </comment>
+    <constant name="HcalBarrel_rmin"          value="EcalBarrel_rmax+10.0*mm"/>
+    <constant name="HcalBarrelAvailThickness" value="HcalBarrel_rmax - HcalBarrel_rmin"/>
+    <constant name="HcalBarrelLength"         value="EcalBarrelLength+2.0*EcalEndcapThickness + 10.0*mm "/>
+    <constant name="HcalEndcap_zmin"          value="HcalBarrelLength/2.0"/>
+    <constant name="HcalEndcapAvailThickness" value="(SolenoidYokeEndcap_zmin - 10.0 * mm) - HcalEndcap_zmin"/>
+
+    <comment> Material Thickness </comment>
+    <constant name="HcalSteelThickness"       value="1.89 * cm"/>
+    <constant name="HcalPyrexThickness"       value="1.10 * mm"/>
+    <constant name="HcalRPCGasThickness"      value="1.20 * mm"/>
+    <constant name="HcalG10Thickness"         value="3.00 * mm"/>
+    <constant name="HcalAirThickness"         value="1.60 * mm"/>
+
+    <comment> Layer Thickness </comment>
+    <constant name="HcalOneLayerThickness"
+	    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"/>
+
+    <comment> H Endcap Layers and Thickness </comment>
+    <constant name="HcalEndcapLayers" value="floor(HcalEndcapAvailThickness / HcalOneLayerThickness)"/>
+    <constant name="HcalEndcapThickness" value="HcalEndcapLayers * HcalOneLayerThickness"/>
+
+    <comment>
+      -----------------------
+      Gaseous RICH Parameters
+      -----------------------
+    </comment>
+    <constant name="RICHZMin" value="SolenoidYokeEndcap_zmin + 1 * cm"/>
+    <constant name="RICHRMin" value="15 * cm"/>
+    <constant name="RICHRMax" value="60 * cm"/>
+    <constant name="RICHDepth" value="1 * m"/>
+
+
+    <comment>
+      --------------------------
+      Forward Tracker Parameters
+      --------------------------
+    </comment>
+    <constant name="TempForwardTrackerSpace" value="1.5 * m"/>
+    <constant name="ForwardEcalZMin" value="RICHZMin + RICHDepth + TempForwardTrackerSpace"/>
+    <constant name="ForwardCaloAngle" value="2 * SolenoidYokeChamferAngle"/>
+    <constant name="ForwardEcalRInner" value="10 * cm"/>
+    <constant name="ForwardEcalROuter" value="EcalBarrel_rmin + tan(SolenoidYokeChamferAngle) * (RICHDepth) + tan(ForwardCaloAngle) * (ForwardEcalZMin - RICHZMin - RICHDepth)"/>
+    <constant name="ForwardHcalZMin" value="RICHZMin + RICHDepth + TempForwardTrackerSpace + EcalEndcapThickness + 1 * mm"/>
+    <constant name="ForwardHcalAngle" value="ForwardCaloAngle"/>
+    <constant name="ForwardHcalRInner" value="10 * cm"/>
+    <constant name="ForwardHcalROuter" value="ForwardEcalROuter + tan(ForwardCaloAngle) * (ForwardHcalZMin - ForwardEcalZMin)"/>
+
+    <comment>
+      --------------------------
+      Forward ECal Parameters
+      --------------------------
+    </comment>
+
+    <comment>
+      --------------------------
+      Forward HCal Parameters
+      --------------------------
+    </comment>
+
+
+    <comment>
+      --------------------------
+      ce_MRICH Parameters
+      --------------------------
+    </comment>
+    <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"/>
+
+
+
+
+  </define>
+
diff --git a/compact/display.xml b/compact/display.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ae6af1bf18fd1819d37492fc0e8484eee122e111
--- /dev/null
+++ b/compact/display.xml
@@ -0,0 +1,70 @@
+  <display>
+
+    <vis name="Argonne_Green"        alpha="1" r="119/255" g="179/255" b="0"/>
+    <vis name="Argonne_Violet"       alpha="1" r="91/256" g="0" b="145/256"/>
+    <vis name="Argonne_Process_Blue" alpha="1" r="0/256" g="130/256" b="202/256"/>
+    <vis name="Argonne_Orange"       alpha="1" r="255/256" g="121/256" b="0"/>
+    <vis name="Argonne_Red"          alpha="1" r="205/256" g="32/256" b="44/256"/>
+    <vis name="Argonne_Gold"         alpha="1" r="248/256" g="178/256" b="0/256"/>
+    <vis name="Argonne_Blue"         alpha="1" r="0/256" g="96/256" b="156/256"/>
+    <vis name="Argonne_Teal"         alpha="1" r="0/256" g="161/256" b="156/256"/>
+    <vis name="Argonne_Gray"         alpha="1" r="102/256" g="102/256" b="102/256"/>
+    <vis name="Argonne_Light_Gray"   alpha="1" r="209/256" g="209/256" b="209/256"/>
+    <vis name="Argonne_Off_White"    alpha="1" r="242/256" g="242/256" b="242/256"/>
+    <vis name="Argonne_Delta_Red"    alpha="1" r="161/256" g="43/256" b="47/256"/>
+    <vis name="Argonne_Delta_Green"  alpha="1" r="0" g="120/256" b="54/256"/>
+    <vis name="Argonne_Delta_Blue"   alpha="1" r="11/256" g="31/256" b="143/256"/>
+
+    <vis name="Argonne_Red_1"        alpha="0.5" r="205/256" g="32/256" b="44/256"/>
+
+    <comment>Tracker_Layer_Vis is Argonne_Gold</comment>
+    <vis name="Tracker_Layer_Vis"  alpha="0.5" r="248/256" g="178/256" b="0/256" showDaughters="true" />
+
+    <vis name="InvisibleNoDaughters"      showDaughters="false" visible="false"/>
+    <vis name="InvisibleWithDaughters"    showDaughters="true" visible="false"/>
+
+    <vis name="SiVertexVis" alpha="0.9" r="1" g="0" b="1" showDaughters="true" />
+    <vis name="SiTrackerBarrelVis" alpha="0.5" r="0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="SiTrackerVis" alpha="0.9" r="1.0" g="0.0" b="0.0" showDaughters="true" lineStyle="solid"  drawingStyle="solid" />
+    <vis name="TrackerLayerVis" alpha="0.9" r="0.0" g="1.0" b="0.0" visible="true"  showDaughters="true" />
+
+    <vis name="SiTrackerBarrelVis1" alpha="0.8" r="0.0" g="0.9" b="0.9" showDaughters="true" />
+    <vis name="SiTrackerBarrelVis2" alpha="0.8" r="0.1" g="0.9" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="SiTrackerEndcapVis1" alpha="0.8" r="1.0" g="0.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="SiTrackerEndcapVis2" alpha="0.8" r="1.0" g="0.45" b="0.0" showDaughters="false" visible="true"/>
+    <vis name="SiTrackerSubAssemblyVis" alpha="1" r="0.0" g="0.99" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="SiTrackerLayerVis" alpha="1" r="0.0" g="1" b="0.0" showDaughters="true" visible="true"  lineStyle="solid"  drawingStyle="solid" />
+
+    <vis name="EcalVis" alpha="0.1" r="0.0" g="0.75" b="0.1" showDaughters="false"/>
+    <vis name="EcalEndcapVis" alpha="1.0" r="0.0" g="0.99" b="0.0" showDaughters="false" visible="true" />
+    <vis name="EcalBarrelVis" alpha="1.0" r="0.0" g="0.99" b="0.0" showDaughters="false" visible="true" />
+    <vis name="HcalVis" alpha="0.9" r="0.75" g="0.0" b="0.0" showDaughters="false"/>
+    <vis name="HcalBarrelVis" alpha="1.0" r="0.0" g="0.0" b="0.99" showDaughters="false" visible="true" />
+    <vis name="HcalEndcapVis" alpha="1.0" r="0.0" g="0.0" b="0.99" showDaughters="false" visible="true" />
+
+    <vis name="SolenoidCoilVis" alpha="1.0" r="0.55" g="0.55" b="0.7" showDaughters="true" visible="true" lineStyle="solid" drawingStyle="solid" />
+    <vis name="SolenoidCryostatVis" alpha="0.4" r="0.55" g="0.55" b="0.7" showDaughters="true" visible="true" lineStyle="solid" drawingStyle="solid" />
+    <vis name="SolenoidYokeVis" alpha="0.2" r="0.8" g="0.1" b="0.1" showDaughters="false" visible="true" lineStyle="solid"  drawingStyle="solid" />
+    <vis name="RICHVis" alpha="0.5" r="1" g="0" b="1" showDaughters="false"/>
+    <vis name="BeamPipeVis"    alpha="1"  r= "0.75" g="0.75" b="0.75" showDaughters="true" visible="true"/>
+
+    <vis name="cb_SolenoidVis" alpha="0.4"  r= "0.1"  g="0.0"  b="0.1"  showDaughters="true" visible="true"/>
+
+    <comment>
+      Deprecated colors.
+    </comment>
+    <vis name="GreenVis"       alpha="1.0"  r= "0.0" g="1.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RedVis"         alpha="0.2"  r= "1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RPVis"          alpha="0.99"  r= "1.0" g="0.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RPLayerVis"     alpha="0.99"  r= "0.0" g="0.7" b="0.3" showDaughters="true" visible="true" lineStyle="solid" drawingStyle="solid" />
+    <vis name="BlueVis"        alpha="1.0"  r= "0.0" g="0.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="OrangeVis"      alpha="1.0"  r= "1.0" g="0.45" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RedGreenVis"    alpha="0.5"  r= "1.0" g="1.0" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="BlueGreenVis"   alpha="0.5"  r= "0.0" g="1.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="PurpleVis"      alpha="1.0"  r= "1.0" g="0.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="DoubleRedG"     alpha="0.5"  r= "2.0" g=".10" b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RBG015"         alpha="0.5"  r= "0.0" g=".2"  b="1.0" showDaughters="true" visible="true"/>
+    <vis name="RBG510"         alpha="0.5"  r= "1.0" g=".2"  b="0.0" showDaughters="true" visible="true"/>
+    <vis name="RBG"            alpha="0.5"  r= "1.0" g="1.0" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="GrayVis"        alpha="1.0"  r= "0.75" g="0.75" b="0.75" showDaughters="true" visible="true"/>
+  </display>
diff --git a/compact/ecal.xml b/compact/ecal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..be2a125ca6a76621c663032eb0b4a74ae5d19659
--- /dev/null
+++ b/compact/ecal.xml
@@ -0,0 +1,184 @@
+<lccdd>
+
+  <define>
+    <constant name="CrystalEndcap_rmin"  value="VertexTrackerInnerRadius"/>
+    <constant name="CrystalEndcap_rmax"  value="EcalEndcapN_rmin"/>
+    <constant name="CrystalBox_x_length" value="20.0*mm"/>
+    <constant name="CrystalBox_y_length" value="20.0*mm"/>
+    <constant name="CrystalBox_z_length" value="200.0*mm"/>
+    <constant name="CrystalBox_offset"   value="0.000001*mm"/>
+    <constant name="CrystalEndcap_x_pos" value="0.0*m"/>
+    <constant name="CrystalEndcap_y_pos" value="0.0*m"/>
+    <constant name="CrystalEndcap_z_pos" value="-EcalEndcap_zmin"/>
+  </define>
+
+
+  <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <!-- Common Generic visualization attributes -->
+  <comment>Common Generic visualization attributes</comment>
+  <display>
+  </display>
+
+
+  <detectors>
+
+    <comment>
+      ---------------------
+      Barrel EM Calorimeter
+      ---------------------
+      A layered EM calorimeter with tungsten and silicon (or scintillator) strips
+    </comment>
+    <detector 
+      id="ECalBarrel_ID"
+      name="EcalBarrel"
+      type="DD4hep_EcalBarrel"
+      readout="EcalBarrelHits"
+      calorimeterType="EM_BARREL">
+      <dimensions 
+        numsides="CaloSides" 
+        rmin="EcalBarrel_rmin" 
+        z="EcalBarrelLength"/>
+      <staves vis="EcalBarrelVis"/>
+      <layer repeat="1">
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalBarrelThinLayers">
+        <slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalBarrelThickLayers">
+        <slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+    </detector>
+
+    <comment>
+      -----------------------------
+      Forward Endcap EM Calorimeter
+      -----------------------------
+      A layered EM calorimeter with tungsten and silicon (or scintillator) strips
+    </comment>
+    <detector id="ECalEndcapP_ID" 
+      name="EcalEndcapP" 
+      reflect="false" 
+      type="DD4hep_PolyhedraEndcapCalorimeter2" 
+      readout="EcalEndcapHits" 
+      vis="EcalEndcapVis" 
+      calorimeterType="EM_ENDCAP" >
+      <dimensions 
+        numsides="CaloSides" 
+        zmin="EcalEndcap_zmin" 
+        rmin="EcalEndcapP_rmin" 
+        rmax="EcalBarrel_rmax " />
+      <layer repeat="1">
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalEndcapThinLayers">
+        <slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalEndcapThickLayers">
+        <slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+    </detector>
+
+
+    <comment>
+      -------------------------------
+      Backwards Endcap EM Calorimeter
+      -------------------------------
+      A layered EM calorimeter with tungsten and silicon (or scintillator) strips
+    </comment>
+    <detector id="ECalEndcapN_ID" 
+      name="EcalEndcapN" 
+      type="refdet_PolyhedraEndcapCalorimeter2" 
+      reflect="true" 
+      readout="EcalEndcapHits" 
+      vis="EcalEndcapVis" 
+      calorimeterType="EM_ENDCAP">
+      <dimensions 
+        numsides="CaloSides" 
+        zmin="EcalEndcap_zmin" 
+        rmin="EcalEndcapN_rmin" 
+        rmax="EcalBarrel_rmax " />
+      <layer repeat="1">
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalEndcapThinLayers">
+        <slice material="TungstenDens24" thickness="EcalThinTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+      <layer repeat="EcalEndcapThickLayers">
+        <slice material="TungstenDens24" thickness="EcalThickTungstenThickness"/>
+        <slice material="Air" thickness="EcalAir2Thickness"/>
+        <slice material="Silicon" thickness="EcalSiliconThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="Copper" thickness="EcalCopperThickness"/>
+        <slice material="Kapton" thickness="EcalKaptonThickness"/>
+        <slice material="Air" thickness="EcalAir1Thickness"/>
+      </layer>
+    </detector>
+  </detectors>
+
+  <!--  Definition of the readout segmentation/definition  -->
+  <readouts>
+    <!--  
+    <readout name="PlaneTrackerHits">
+      <segmentation type="CartesianGridXY" grid_size_x="20.0*mm" grid_size_y="20.0*mm" />
+      <id>system:5,module:4,x:32:-16,y:-16</id>
+    </readout>
+    <readout name="CrystalEcalHits">
+      <segmentation type="CartesianGridXY" grid_size_x="CrystalBox_x_length" grid_size_y="CrystalBox_y_length" />
+      <id>system:8,sector:4,module:20,x:48:-8,y:-8</id>
+    </readout>
+    -->
+    <readout name="EcalBarrelHits">
+      <segmentation type="CartesianGridXY" grid_size_x="3.5 * mm" grid_size_y="3.5 * mm"/>
+      <id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
+    </readout>
+    <readout name="EcalEndcapHits">
+      <segmentation type="CartesianGridXY" grid_size_x="3.5 * mm" grid_size_y="3.5 * mm"/>
+      <id>system:8,barrel:3,module:4,layer:6,slice:5,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+  <plugins>
+  </plugins>
+
+<fields>
+</fields>
+</lccdd>
diff --git a/elements.xml b/compact/elements.xml
similarity index 100%
rename from elements.xml
rename to compact/elements.xml
diff --git a/compact/forward_rich.xml b/compact/forward_rich.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d94e9e162592d826ae9e7f1f14216cf6f39fc94f
--- /dev/null
+++ b/compact/forward_rich.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+  <define>
+  </define>
+
+  <detectors>
+    <detector id="ForwardRICH_ID" name="ForwardRICH" type="refdet_ForwardRICH" readout="ForwardRICHHits" vis="BlueVis">
+      <dimensions z0="RICHZMin" length="RICHDepth+20*cm" rmin="RICHRMin" rmax1="RICHRMax*cm" rmax2="RICHRMin+80*cm"/>
+      <radiator material="N2cherenkov" />
+      <mcppmt zdiff="15.0*cm" rmin="SolenoidYokeEndcapP_rmin - 10*cm" rmax="SolenoidYokeEndcapP_rmin + 80*cm" 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" />
+      </mirror>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="ForwardRICHHits">
+      <segmentation type="CartesianGridXY" grid_size_x="3*mm" grid_size_y="3*mm" />
+      <id>system:8,layer:4,piece:4,module:14,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/compact/hcal.xml b/compact/hcal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3edc03e2ba259bb42ed30715350d6c1acf147ab3
--- /dev/null
+++ b/compact/hcal.xml
@@ -0,0 +1,104 @@
+<lccdd>
+
+  <define>
+  </define>
+
+  <limits>
+  </limits>
+
+  <regions>
+  </regions>
+
+  <display>
+  </display>
+
+  <!-- Define detector -->
+  <detectors>
+
+    <detector 
+      id="HCalBarrel_ID" 
+      name="HcalBarrel"
+      type="DD4hep_PolyhedraBarrelCalorimeter2"
+      readout="HcalBarrelHits"
+      calorimeterType="HAD_BARREL"
+      gap="0.*cm"
+      material="Steel235">
+      <dimensions 
+        numsides="CaloSides" 
+        rmin="HcalBarrel_rmin" 
+        z="HcalBarrelLength"/>
+      <staves vis="HcalBarrelVis"/>
+      <layer repeat="HcalBarrelLayers">
+        <slice material="Steel235" thickness="HcalSteelThickness"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="RPCGasDefault" thickness="HcalRPCGasThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="G10" thickness="HcalG10Thickness"/>
+        <slice material="Air" thickness="HcalAirThickness"/>
+      </layer>
+    </detector>
+
+    <detector 
+      id="HCalEndcapP_ID" 
+      name="HcalEndcapP" 
+      type="refdet_PolyhedraEndcapCalorimeter2" 
+      readout="HcalEndcapHits" 
+      vis="HcalEndcapVis" 
+      calorimeterType="HAD_ENDCAP"
+      reflect="false">
+      <dimensions 
+        numsides="CaloSides" 
+        zmin="HcalEndcap_zmin" 
+        rmin="HcalEndcapP_rmin"
+        rmax="HcalBarrel_rmax"/>
+      <layer repeat="HcalEndcapLayers" vis="HcalEndcapVis" >
+        <slice material="Steel235" thickness="HcalSteelThickness"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="RPCGasDefault" thickness="HcalRPCGasThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="G10" thickness="HcalG10Thickness"/>
+        <slice material="Air" thickness="HcalAirThickness"/>
+      </layer>
+    </detector>
+
+    <detector 
+      id="HCalEndcapN_ID" 
+      name="HcalEndcapN" 
+      type="refdet_PolyhedraEndcapCalorimeter2" 
+      readout="HcalEndcapHits" 
+      vis="HcalEndcapVis" 
+      calorimeterType="HAD_ENDCAP" reflect="true">
+      <dimensions 
+        numsides="CaloSides" 
+        zmin="HcalEndcap_zmin" 
+        rmin="HcalEndcapN_rmin" 
+        rmax="HcalBarrel_rmax"/>
+      <layer repeat="HcalEndcapLayers" vis="HcalEndcapVis" >
+        <slice material="Steel235" thickness="HcalSteelThickness"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="RPCGasDefault" thickness="HcalRPCGasThickness" sensitive="yes" limits="cal_limits"/>
+        <slice material="PyrexGlass" thickness="HcalPyrexThickness"/>
+        <slice material="G10" thickness="HcalG10Thickness"/>
+        <slice material="Air" thickness="HcalAirThickness"/>
+      </layer>
+    </detector>
+
+  </detectors>
+  <!--  Definition of the readout segmentation/definition  -->
+  <readouts>
+    <readout name="HcalBarrelHits">
+      <segmentation type="CartesianGridXY" grid_size_x="10 * mm" grid_size_y="10 * mm"/>
+      <id>system:6,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id>
+    </readout>
+    <readout name="HcalEndcapHits">
+      <segmentation type="CartesianGridXY" grid_size_x="10 * mm" grid_size_y="10 * mm"/>
+      <id>system:6,barrel:3,module:4,layer:8,slice:5,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+  <plugins>
+  </plugins>
+
+  <fields>
+  </fields>
+</lccdd>
diff --git a/materials.xml b/compact/materials.xml
similarity index 99%
rename from materials.xml
rename to compact/materials.xml
index 8d643e2bb9a7b97c921c0a6bf7b56672e27a434c..e078ecd408463dca9f254f8568cc951051acb1d7 100644
--- a/materials.xml
+++ b/compact/materials.xml
@@ -2,6 +2,7 @@
 <materials>
   <!--
        Air by weight from
+
        http://www.engineeringtoolbox.com/air-composition-24_212.html
   -->
   <material name="Air">
@@ -12,7 +13,7 @@
   </material>
   <!-- We model vacuum just as very thin air -->
   <material name="Vacuum">
-    <D type="density" unit="g/cm3" value="1.e-25"/>
+    <D type="density" unit="g/cm3" value="0.0000000001"/>
     <fraction n="0.754" ref="N"/>
     <fraction n="0.234" ref="O"/>
     <fraction n="0.012" ref="Ar"/>
diff --git a/compact/refdetector_defs.xml b/compact/refdetector_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..067c46daf62dc40e69288dfaa7d55e0e408fab6d
--- /dev/null
+++ b/compact/refdetector_defs.xml
@@ -0,0 +1,11 @@
+  <!-- Define parameter -->
+  <define>
+    <constant name="world_side" value="50*m"/>
+    <constant name="world_x"    value="world_side"/>
+    <constant name="world_y"    value="world_side"/>
+    <constant name="world_z"    value="world_side"/>
+
+    <constant name="tracker_region_zmax" value="6 * m"/>
+    <constant name="tracker_region_rmax" value="6 * m"/>
+
+  </define>
diff --git a/compact/solenoid.xml b/compact/solenoid.xml
new file mode 100644
index 0000000000000000000000000000000000000000..42ec2920b5562da5ab695ae8e454dc39a8d027b4
--- /dev/null
+++ b/compact/solenoid.xml
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lccdd>
+  <define>
+    <comment>
+      --------------------------
+      Solenoid Magnet Parameters
+      --------------------------
+    </comment>
+  </define>
+
+  <detectors>
+    <comment>
+      ---------------
+      Solenoid Magnet
+      ---------------
+      The solenoid superconducting magnet and surrounding cryostat and
+      yoke endcaps.
+    </comment>
+    <detector 
+      id="Solenoid_ID"
+      name="SolenoidCoilBarrel" 
+      type="DD4hep_MultiLayerTracker" 
+      insideTrackingVolume="false">
+      <layer id="1" 
+        inner_r="Solenoid_rmin" 
+        outer_z="SolenoidBarrel_zmax" 
+        vis="SolenoidCryostatVis">
+        <slice material="Steel235" thickness="SolenoidBarrelCryostatThickness"/>
+        <slice material="Vacuum" thickness="SolenoidBarrelGapThickness"/>
+      </layer>
+      <layer id="2" 
+        inner_r="SolenoidCoilConductor_rmin" 
+        outer_z="SolenoidCoil_zmax" 
+        vis="SolenoidCoilVis">
+        <slice material="Aluminum" thickness="SolenoidBarrelAlConductorThickness"/>
+        <slice material="Aluminum" thickness="SolenoidBarrelQuenchbackThickness"/>
+      </layer>
+      <layer id="3" 
+        inner_r="SolenoidCoilConductor_rmax" 
+        outer_z="SolenoidBarrel_zmax" 
+        vis="SolenoidCryostatVis">
+        <slice material="Vacuum" thickness="SolenoidBarrelOuterGapThickness"/>
+        <slice material="Steel235" thickness="SolenoidBarrelOuterCryostatThickness"/>
+      </layer>
+    </detector>
+
+    <detector 
+      id="SolenoidSupport_ID"
+      name="SolenoidCoilEnds"
+      type="DD4hep_DiskTracker"
+      insideTrackingVolume="false"
+      reflect="true"
+      vis="SolenoidCryostatVis">
+      <layer id="1" 
+        inner_z="SolenoidCoil_zmax" 
+        inner_r="SolenoidCoilConductor_rmin" 
+        outer_r="SolenoidCoilConductor_rmax">
+        <slice material="Vacuum" thickness="SolenoidEndPlateGapThickness/2.0"/>
+      </layer>
+      <!--
+      <layer id="2" 
+        inner_z="SolenoidCoil_zmax + SolenoidEndPlateGapThickness" 
+        inner_r="Solenoid_rmin+SolenoidBarrelCryostatThickness" 
+        outer_r="SolenoidBarrel_rmax-SolenoidBarrelOuterCryostatThickness">
+        <slice material="Steel235" thickness="SolenoidEndPlateCryostatThickness"/>
+      </layer>
+      -->
+    </detector>
+
+    <detector 
+      id="SolenoidYoke_ID"
+      name="SolenoidYokeEndcaps"
+      type="DD4hep_DiskTracker"
+      insideTrackingVolume="false"
+      reflect="true"
+      vis="SolenoidYokeVis">
+      <layer id="1" 
+        vis="PurpleVis"
+        inner_z="SolenoidBarrel_zmax + SolenoidEndPlateGapThickness" 
+        inner_r="SolenoidYokeEndcapP_rmin" 
+        outer_r="SolenoidBarrel_rmax">
+        <slice material="Steel235" thickness="SolenoidYokeEndcapThickness/2.0" vis="SolenoidYokeVis" />
+      </layer>
+    </detector>
+    <!--
+    <detector name="SolenoidYoke" type="SiEIC_Yoke" vis="SolenoidYokeVis">
+      <material name="Steel235"/>
+      <dimensions inner_radius="SolenoidYokeInnerRadius" thickness="SolenoidYokeThickness" rmin="CaloInnerRadius + 10 * mm" angle="SolenoidYokeChamferAngle" inner_z="SolenoidYokeInnerZ"/>
+    </detector>
+    -->
+  </detectors>
+
+  <fields>
+    <field type="solenoid" name="GlobalSolenoid" inner_field="3.0 * tesla" outer_field="0.5*tesla" 
+           zmin="-SolenoidCoil_zmax" zmax="SolenoidCoil_zmax" 
+           inner_radius="SolenoidalFieldRadius" outer_radius="SolenoidalFieldRadius+20*cm"/>
+  </fields>
+
+</lccdd>
diff --git a/reference_detector.xml b/reference_detector.xml
index 83ff3cdb7e409b5929ada0c076a74866ee862c5f..eff07459f239503cc6059cf3198e298f6a60091c 100644
--- a/reference_detector.xml
+++ b/reference_detector.xml
@@ -3,69 +3,134 @@
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
 
   <!-- Some information about detector  -->
-  <info name="Test Detector" title="Test Detector"
-        author="Jihee Kim"
+  <info name="Reference Detector" title="Reference Detector"
+        author="Jihee Kim, Whitney Armstrong"
 	url="https://eicweb.phy.anl.gov/EIC/detectors/reference_detector.git"
 	status="development"
 	version="v1 2021-03-16">
     <comment>Test Detector</comment>        
   </info>
 
-  <!-- Use DD4hep elements and materials definitions -->
+  <define>
+    <include ref="compact/definitions.xml" />
+    <include ref="eic/eic_defs.xml" />
+    <include ref="ip6/ip6_defs.xml" />
+    <!--
+    -->
+  </define>
+
+  <properties>
+    <matrix name="RINDEX__Vacuum" coldim="2" values="
+      1.0*eV 1.0
+      5.1*eV 1.0
+      "/>
+    <matrix name="RINDEX__Air" coldim="2" values="
+      1.0*eV 1.00029
+      5.1*eV 1.00029
+      "/>
+    <matrix name="RINDEX__Quartz" coldim="2" values="
+      1.0*eV 1.46
+      5.1*eV 1.46
+      "/>
+    <matrix name="RINDEX__N2" coldim="2" values="
+      1.0*eV 1.00033
+      4.0*eV 1.00033
+      5.1*eV 1.00033
+      "/>
+    <matrix name="RINDEX__Pyrex" coldim="2" values="
+      1.0*eV 1.5
+      4.0*eV 1.5
+      5.1*eV 1.5
+      "/>
+    <matrix name= "REFLECTIVITY_mirror" coldim="2" values="
+      1.0*eV  0.9
+      4.0*eV  0.9
+      5.1*eV  0.9
+    "/>
+  </properties>
+
   <includes>
-    <gdmlFile ref="elements.xml"/>
-    <gdmlFile ref="materials.xml"/>
+    <gdmlFile ref="compact/elements.xml"/>
+    <gdmlFile ref="compact/materials.xml"/>
   </includes>
 
-  <!-- Define the dimensions of the world volume -->
-  <define>
-    <constant name="world_side" value="50*m"/>
-    <constant name="world_x"    value="world_side"/>
-    <constant name="world_y"    value="world_side"/>
-    <constant name="world_z"    value="world_side"/>
-
-    <constant name="tracker_region_zmax" value="6 * m"/>
-    <constant name="tracker_region_rmax" value="6 * m"/>
+  <materials>
+    <material name="AirOptical">
+      <D type="density" unit="g/cm3" value="0.0012"/>
+      <fraction n="0.754" ref="N"/>
+      <fraction n="0.234" ref="O"/>
+      <fraction n="0.012" ref="Ar"/>
+      <property name="RINDEX" ref="RINDEX__Vacuum"/>
+    </material>
+    <material name="N2cherenkov">
+      <D type="density" value="0.00125" unit="g/cm3"/>
+      <composite n="1" ref="N"/>
+      <property name="RINDEX"  ref="RINDEX__N2"/>
+    </material>
+    <material name="PyrexGlass">
+      <D type="density" value="2.23" unit="g/cm3"/>
+      <fraction n="0.806" ref="SiliconOxide"/>
+      <fraction n="0.130" ref="BoronOxide"/>
+      <fraction n="0.040" ref="SodiumOxide"/>
+      <fraction n="0.023" ref="AluminumOxide"/>
+      <property name="RINDEX" ref="RINDEX__Pyrex"/>
+    </material>
+  </materials>
 
-    <constant name="TestDetector_ID"           value="999"/>
-    <constant name="TestDetector_inner_radius" value="10.0 * cm"/>
-    <constant name="TestDetector_rmin"         value="10.0 * cm"/>
-    <constant name="TestDetector_thickness"    value="100.0 * cm"/>
-    <constant name="TestDetector_inner_z"      value="40.0 * cm"/>
-    <constant name="TestDetector_angle"        value="0.0 * rad"/>
-  </define>
+  <surfaces>
+    <comment> For the values of "finish", model and type, see TGeoOpticalSurface.h !
+    </comment>
+    <opticalsurface finish="polished" model="glisur" name="MirrorOpticalSurface" type="dielectric_metal" value="0">
+      <property name="REFLECTIVITY" ref="REFLECTIVITY_mirror"/>
+      <property name="RINDEX"       coldim="2" values="1.034*eV  1.5   4.136*eV  1.5"/>
+      <!--<property name="EFFICIENCY"   ref="EFFICIENCY0x8b77240"/>-->
+    </opticalsurface>
+    <opticalsurface name="mirror2" finish="polished" model="glisur" type="dielectric_dielectric">
+      <property name="REFLECTIVITY"            coldim="2" values="1.034*eV  0.8   4.136*eV  0.9"/>
+      <property name="EFFICIENCY"              coldim="2" values="2.034*eV  0.8   4.136*eV  1.0"/>
+      <property name="RINDEX"                  coldim="2" values="1.034*eV  1.5   4.136*eV  1.5"/>
+    </opticalsurface>
+  <!-- Define the dimensions of the world volume -->
 
+  </surfaces>
   <limits>
+    <limitset name="EICBeamlineLimits">
+      <limit name="step_length_max" particles="*" value="1.0" unit="mm" />
+      <limit name="track_length_max" particles="*" value="1.0" unit="mm" />
+      <limit name="time_max" particles="*" value="0.1" unit="ns" />
+      <limit name="ekin_min" particles="*" value="0.001" unit="MeV" />
+      <limit name="range_min" particles="*" value="0.1" unit="mm" />
+    </limitset>
+    <limitset name="cal_limits">
+      <limit name="step_length_max" particles="*" value="5.0" unit="mm"/>
+    </limitset>
   </limits>
 
-  <regions>
-  </regions>
-
-  <!-- Common Generic visualization attributes -->
-  <comment>Common Generic visualization attributes</comment>
   <display>
-    <vis name="TestDetectorVis" alpha="0.4"  r= "0.1"  g="0.0"  b="0.1"  showDaughters="true" visible="true"/>
+  <include ref="compact/display.xml" />
   </display>
 
-  <!-- Define detector -->
+  <!--
+  <include ref="reference_detector/vertex_tracker.xml"/>
+  <include ref="compact/silicon_tracker.xml"/>
+  -->
+  <include ref="ip6/beampipe.xml"/>
+  <include ref="compact/solenoid.xml"/>
+  <include ref="compact/ecal.xml"/>
+  <include ref="compact/hcal.xml"/>
+  <include ref="compact/forward_rich.xml"/>
+  <include ref="compact/ce_mrich.xml"/>
+  <!--
+  <include ref="compact/roman_pots.xml"/>
+  -->
+  <include ref="eic/forward_ion_beamline.xml"/>
+  <!--
+  -->
+
   <detectors>
-    <comment>
-      Central Barrel Solenoid Magnet
-    </comment>
-    <detector id="TestDetector_ID" name="TestDetector" type="TestDetector" vis="TestDetectorVis">
-      <dimensions inner_radius="TestDetector_inner_radius" 
-	          rmin="TestDetector_rmin" 
-	          thickness="TestDetector_thickness" 
-	          inner_z="TestDetector_inner_z" 
-	          angle="TestDetector_angle"/>
-      <material name="Steel235"/>
-    </detector>
   </detectors>
+  <readouts>
+  </readouts>
 
-  <plugins>
-  </plugins>
-
-  <fields>
-  </fields>
 
 </lccdd>
diff --git a/scripts/view1/.DAWN_1.history b/scripts/view1/.DAWN_1.history
new file mode 100644
index 0000000000000000000000000000000000000000..f4980ff8cd6dd972e1cba46f982d708156c32e73
--- /dev/null
+++ b/scripts/view1/.DAWN_1.history
@@ -0,0 +1,31 @@
+1.34392e+07
+90
+180
+0
+0
+0
+0
+1
+1
+0.001
+0
+1
+1
+1
+0.5
+0.5
+0.5
+19
+71
+0.001
+0.001
+0.001
+3
+71
+0.001
+0
+0
+1
+evince
+0
+0
diff --git a/scripts/view1/generate_eps b/scripts/view1/generate_eps
index 371e1d90ad31ae49101391d5a6f0e5c127e1193d..c863fbaddfb46cc5d1342d0ca9eb2766b31ac3dd 100755
--- a/scripts/view1/generate_eps
+++ b/scripts/view1/generate_eps
@@ -9,8 +9,8 @@ function print_the_help {
   exit 
 }
 
-FILE_TAG="view1"
-INPUT_FILE="g4_0000.prim"
+FILE_TAG="view01"
+INPUT_FILE="../../g4_0000.prim"
 
 
 POSITIONAL=()
@@ -44,6 +44,7 @@ done
 set -- "${POSITIONAL[@]}" # restore positional parameters
 
 
+# Side  view
 dawncut 1 0 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim 
 dawncut -1 0 0 1 ${FILE_TAG}_temp0.prim  ${FILE_TAG}.prim
 dawn -d ${FILE_TAG}.prim 
@@ -55,3 +56,15 @@ gs -o ${FILE_TAG}.pdf -sDEVICE=pdfwrite \
 pdftoppm ${FILE_TAG}.pdf ${FILE_TAG} -png -singlefile -cropbox
 
 
+# Top view
+dawncut 0 1 0 1 ${INPUT_FILE} ${FILE_TAG}_temp0.prim 
+dawncut 0 -1 0 1 ${FILE_TAG}_temp0.prim  ${FILE_TAG}.prim
+../../bin/dawn_tweak --theta 270
+dawn -d ${FILE_TAG}.prim 
+ps2pdf ${FILE_TAG}.eps ${FILE_TAG}_top_full.pdf
+gs -o ${FILE_TAG}_top.pdf -sDEVICE=pdfwrite \
+  -c "[/CropBox [51 250 550 590] /PAGES pdfmark" \
+  -f ${FILE_TAG}_top_full.pdf
+
+pdftoppm ${FILE_TAG}_top.pdf ${FILE_TAG}_top -png -singlefile -cropbox
+
diff --git a/scripts/view2/.DAWN_1.history b/scripts/view2/.DAWN_1.history
new file mode 100644
index 0000000000000000000000000000000000000000..16311bf7cd15883906fe319c6369ead93e7a9dc8
--- /dev/null
+++ b/scripts/view2/.DAWN_1.history
@@ -0,0 +1,31 @@
+1.34392e+07
+0
+180
+0
+0
+0
+0
+8
+3
+0.001
+0
+1
+1
+1
+0.5
+0.5
+0.5
+19
+71
+0.01
+0.01
+0.01
+3
+70
+0.01
+1
+1
+1
+evince
+0
+0
diff --git a/scripts/view3/.DAWN_1.history b/scripts/view3/.DAWN_1.history
new file mode 100644
index 0000000000000000000000000000000000000000..913400116ec07263b18076d4fb5f78182e8311ff
--- /dev/null
+++ b/scripts/view3/.DAWN_1.history
@@ -0,0 +1,31 @@
+1.34392e+07
+28.5
+151.5
+0
+0
+0
+0
+8
+5
+0.001
+0
+1
+1
+1
+0.5
+0.5
+0.5
+19
+71
+0.01
+0.01
+0.01
+3
+70
+0.01
+1
+1
+1
+evince
+0
+0
diff --git a/scripts/view4/.DAWN_1.history b/scripts/view4/.DAWN_1.history
new file mode 100644
index 0000000000000000000000000000000000000000..9bc2199f6e176952b804ba2ce5a52b156033ee99
--- /dev/null
+++ b/scripts/view4/.DAWN_1.history
@@ -0,0 +1,31 @@
+1.34392e+07
+90
+0
+1
+0
+0
+491.1
+1.2
+5
+0.001
+0
+1
+1
+1
+0.5
+0.5
+0.5
+19
+71
+0.01
+0.01
+0.01
+3
+70
+0.01
+1
+1
+1
+evince
+0
+0
diff --git a/scripts/view7/.DAWN_1.history b/scripts/view7/.DAWN_1.history
new file mode 100644
index 0000000000000000000000000000000000000000..558cf94b7d2e3051f2957f4b56abe311aeae9472
--- /dev/null
+++ b/scripts/view7/.DAWN_1.history
@@ -0,0 +1,31 @@
+1.34392e+07
+0
+180
+0
+0
+0
+0
+18.6
+1
+0.001
+0
+1
+1
+1
+0.5
+0.5
+0.5
+19
+71
+0.01
+0.01
+0.01
+3
+70
+0.01
+1
+1
+1
+evince
+0
+0
diff --git a/src/ForwardRICH_geo.cpp b/src/ForwardRICH_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3dc6417ba4562a43e22227d8f4a7e9ec969c3bd1
--- /dev/null
+++ b/src/ForwardRICH_geo.cpp
@@ -0,0 +1,184 @@
+//==========================================================================
+//  Forward Ring Imaging Cherenkov Detector
+//--------------------------------------------------------------------------
+//
+// Author: C. Peng (ANL)
+// Date: 09/30/2020
+//
+//==========================================================================
+
+#include <XML/Helper.h>
+#include "TMath.h"
+#include "TString.h"
+#include "ref_utils.h"
+#include "Math/Point2D.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "DD4hep/OpticalSurfaces.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
+
+using namespace std;
+using namespace dd4hep;
+using namespace dd4hep::rec;
+
+
+// create the detector
+static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetector sens)
+{
+    xml::DetElement detElem = handle;
+
+    std::string detName = detElem.nameStr();
+    int detID = detElem.id();
+
+    DetElement det(detName, detID);
+    xml::Component dims = detElem.dimensions();
+    xml::Component rads = detElem.child(_Unicode(radiator));
+    xml::Component mir = detElem.child(_Unicode(mirror));
+    xml::Component mcp = detElem.child(_Unicode(mcppmt));
+
+    // dimensions
+    double z0 = dims.z0();
+    double length = dims.length();
+    double rmin = dims.rmin();
+    double rmax1 = dims.attr<double>(_Unicode(rmax1));
+    double rmax2 = dims.attr<double>(_Unicode(rmax2));
+
+    // mirror setting
+    auto mThick = mir.thickness();
+    auto mirZ = mir.attr<double>(_Unicode(zdiff));
+
+    // mcppmt setting
+    auto pRmin = mcp.rmin();
+    auto pRmax = mcp.rmax();
+    auto pThick = mcp.thickness();
+    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));
+
+    // materials
+    auto mirMat = desc.material(mir.materialStr());
+    auto gasMat = desc.material(rads.materialStr());
+    auto mcpMat = desc.material(mcp.materialStr());
+
+    // constants
+    auto richCenterAngle = std::atan((rmin + (rmax2 - rmin)/2.)/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);
+    // 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);
+
+    UnionSolid envShape(env1, env2, Position(0., 0., pZ));
+
+    Volume envVol(detName + "_envelope", envShape, gasMat);
+    envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
+
+    // ---------------
+    // spherical mirrors inside it
+    int ilayer = 1;
+
+    // optical surface
+    OpticalSurfaceManager surfMgr = desc.surfaceManager();
+    OpticalSurface mirSurf  = surfMgr.opticalSurface("MirrorOpticalSurface");
+    // mirror slices
+    int imod = 1;
+    for (xml::Collection_t sl(mir, _Unicode(slice)); sl; ++sl, ++imod) {
+        auto focus = sl.attr<double>(_Unicode(focus));
+        auto wphi = sl.attr<double>(_Unicode(phiw));
+        auto rotZ = sl.attr<double>(_Unicode(rotz));
+        auto mRmin = sl.attr<double>(_Unicode(rmin));
+        auto mRmax = sl.attr<double>(_Unicode(rmax));
+        double curve = 0.;
+        if (sl.hasAttr(_Unicode(curve))) {
+            curve = sl.attr<double>(_Unicode(curve));
+        }
+        // geometry of mirror slice
+        PlacedVolume mirPV;
+        Volume mirVol(Form("mirror_v_dummy%d", imod));
+        mirVol.setMaterial(mirMat);
+        mirVol.setVisAttributes(desc.visAttributes(mir.visStr()));
+        // spherical mirror
+        if (curve > 0.) {
+            // somehow geant4 does not support -wphi/2. to wphi/2., so additonal rotation in Z
+            double mTheta1 = std::asin(mRmin/curve);
+            double mTheta2 = std::asin(mRmax/curve);
+            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
+                           * RotationZ(rotZ)                            // rotate phi angle
+                           * RotationY(rotY)                            // rotate for focus point
+                           * RotationX(180*degree)
+                           * Translation3D(0., 0., -curve)              // move spherical shell to origin
+                           * RotationZ(-wphi/2.);                       // center phi angle to 0. (-wphi/2., wphi/2.)
+            mirPV = envVol.placeVolume(mirVol, tr);
+        // plane mirror
+        } else {
+            mirVol.setSolid(Tube(mRmin, mRmax, mThick/2.0, 0., wphi));
+            Transform3D tr = Translation3D(0., 0., mirZ - halfLength)   // 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);
+        }
+        mirPV.addPhysVolID("layer", ilayer).addPhysVolID("module", imod);
+        DetElement mirDE(det, Form("Mirror_DE%d", imod), imod);
+        mirDE.setPlacement(mirPV);
+        SkinSurface mirSurfBorder(desc, mirDE, Form("RICHmirror%d", imod), mirSurf, mirVol);
+        mirSurfBorder.isValid();
+    }
+    ilayer++;
+
+    // ---------------
+    // photo-detector unit
+    // Fill the photo-detection plane with square shape MCP-PMTs
+    Box mcpShape1(pSize/2.0, pSize/2.0, pThick/2.0);
+    Volume mcpVol1("mcppmt_v_material", mcpShape1, mcpMat);
+
+    // a thin layer of cherenkov gas for accepting optical photons
+    Box mcpShape(pSize/2.0, pSize/2.0, pThick/2.0 + 0.1*mm);
+    Volume mcpVol("mcppmt_v", mcpShape, gasMat);
+    mcpVol.placeVolume(mcpVol1, Position(0., 0., -0.1*mm));
+
+    mcpVol.setVisAttributes(desc.visAttributes(mcp.visStr()));
+    sens.setType("photoncounter");
+    mcpVol.setSensitiveDetector(sens);
+
+    // photo-detector plane envelope
+    for (size_t ipd = 0; ipd < 6; ++ipd) {
+        double phmin = -M_PI/6.;
+        double phmax = M_PI/6.;
+        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);
+        for (size_t i = 0; i < points.size(); ++i) {
+            auto pt = points[i];
+            auto mcpPV = pdVol.placeVolume(mcpVol, Position(pt.x(), pt.y(), 0.));
+            mcpPV.addPhysVolID("layer", ilayer).addPhysVolID("module", i + 1);
+            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
+                        * RotationZ(ipd*M_PI/3.)        // rotate phi angle
+                        * RotationY(-richCenterAngle);  // rotate to perpendicular position
+        auto pdPV = envVol.placeVolume(pdVol, tr);
+        pdPV.addPhysVolID("layer", ilayer).addPhysVolID("piece", ipd + 1);
+    }
+    Volume motherVol = desc.pickMotherVolume(det);
+    PlacedVolume envPV = motherVol.placeVolume(envVol, Position(0, 0, z0 + halfLength));
+    envPV.addPhysVolID("system", detID);
+    det.setPlacement(envPV);
+
+    return det;
+}
+//@}
+
+// clang-format off
+DECLARE_DETELEMENT(refdet_ForwardRICH, createDetector)
+
diff --git a/src/PolyhedraEndcapCalorimeter2_geo.cpp b/src/PolyhedraEndcapCalorimeter2_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3469a1c654074638e943b4b84442b5cfa4ef3a2b
--- /dev/null
+++ b/src/PolyhedraEndcapCalorimeter2_geo.cpp
@@ -0,0 +1,122 @@
+//==========================================================================
+//  AIDA Detector description implementation
+//--------------------------------------------------------------------------
+// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
+// All rights reserved.
+//
+// For the licensing terms see $DD4hepINSTALL/LICENSE.
+// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
+//
+// Author     : M.Frank
+//
+//==========================================================================
+//
+// Modified for TOPSiDE detector
+//
+//==========================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "XML/Layering.h"
+
+using namespace std;
+using namespace dd4hep;
+using namespace dd4hep::detail;
+
+static Ref_t create_detector(Detector& description, xml_h e, SensitiveDetector sens) {
+    xml_det_t x_det = e;
+    xml_dim_t dim = x_det.dimensions();
+    int det_id = x_det.id();
+    bool reflect = x_det.reflect(true);
+    string det_name = x_det.nameStr();
+    Material air = description.air();
+    int numsides = dim.numsides();
+    double rmin = dim.rmin();
+    double rmax = dim.rmax() * std::cos(M_PI / numsides);
+    double zmin = dim.zmin();
+    Layering layering(x_det);
+    double totalThickness = layering.totalThickness();
+    Volume endcapVol("endcap", PolyhedraRegular(numsides, rmin, rmax, totalThickness), air);
+    DetElement endcap("endcap", det_id);
+
+    int l_num = 1;
+    int layerType = 0;
+    double layerZ = -totalThickness / 2;
+
+    endcapVol.setAttributes(description, x_det.regionStr(), x_det.limitsStr(), x_det.visStr());
+
+    for (xml_coll_t xc(x_det, _U(layer)); xc; ++xc) {
+        xml_comp_t x_layer = xc;
+        double l_thick = layering.layer(l_num - 1)->thickness();
+        string l_name = _toString(layerType, "layer%d");
+        int l_repeat = x_layer.repeat();
+        Volume l_vol(l_name, PolyhedraRegular(numsides, rmin, rmax, l_thick), air);
+        vector<PlacedVolume> sensitives;
+
+        int s_num = 1;
+        double sliceZ = -l_thick / 2;
+        for (xml_coll_t xs(x_layer, _U(slice)); xs; ++xs) {
+            xml_comp_t x_slice = xs;
+            string s_name = _toString(s_num, "slice%d");
+            double s_thick = x_slice.thickness();
+            Material s_mat = description.material(x_slice.materialStr());
+            Volume s_vol(s_name, PolyhedraRegular(numsides, rmin, rmax, s_thick), s_mat);
+
+            s_vol.setVisAttributes(description.visAttributes(x_slice.visStr()));
+            sliceZ += s_thick / 2;
+            PlacedVolume s_phv = l_vol.placeVolume(s_vol, Position(0, 0, sliceZ));
+            s_phv.addPhysVolID("slice", s_num);
+            if (x_slice.isSensitive()) {
+                sens.setType("calorimeter");
+                s_vol.setSensitiveDetector(sens);
+                sensitives.push_back(s_phv);
+            }
+            sliceZ += s_thick / 2;
+            s_num++;
+        }
+        l_vol.setVisAttributes(description.visAttributes(x_layer.visStr()));
+        if (l_repeat <= 0) throw std::runtime_error(x_det.nameStr() + "> Invalid repeat value");
+        for (int j = 0; j < l_repeat; ++j) {
+            string phys_lay = _toString(l_num, "layer%d");
+            layerZ += l_thick / 2;
+            DetElement layer_elt(endcap, phys_lay, l_num);
+            PlacedVolume pv = endcapVol.placeVolume(l_vol, Position(0, 0, layerZ));
+            pv.addPhysVolID("layer", l_num);
+            layer_elt.setPlacement(pv);
+            for (size_t ic = 0; ic < sensitives.size(); ++ic) {
+                PlacedVolume sens_pv = sensitives[ic];
+                DetElement comp_elt(layer_elt, sens_pv.volume().name(), l_num);
+                comp_elt.setPlacement(sens_pv);
+            }
+            layerZ += l_thick / 2;
+            ++l_num;
+        }
+        ++layerType;
+    }
+
+    double z_pos = zmin + totalThickness / 2;
+    PlacedVolume pv;
+    // Reflect it.
+    Assembly assembly(det_name);
+    DetElement endcapAssyDE(det_name, det_id);
+    Volume motherVol = description.pickMotherVolume(endcapAssyDE);
+    if (reflect) {
+        pv = assembly.placeVolume(endcapVol,
+                                  Transform3D(RotationZYX(M_PI / numsides, M_PI, 0), Position(0, 0, -z_pos)));
+        pv.addPhysVolID("barrel", 2);
+        Ref_t(endcap)->SetName((det_name + "_backward").c_str());
+        endcap.setPlacement(pv);
+    } else {
+        pv = assembly.placeVolume(endcapVol,
+                                  Transform3D(RotationZYX(M_PI / numsides, 0, 0), Position(0, 0, z_pos)));
+        pv.addPhysVolID("barrel", 1);
+        Ref_t(endcap)->SetName((det_name + "_forward").c_str());
+        endcap.setPlacement(pv);
+    }
+    endcapAssyDE.add(endcap);
+    pv = motherVol.placeVolume(assembly);
+    pv.addPhysVolID("system", det_id);
+    endcapAssyDE.setPlacement(pv);
+    return endcapAssyDE;
+}
+
+// clang-format off
+DECLARE_DETELEMENT(refdet_PolyhedraEndcapCalorimeter2, create_detector)
diff --git a/src/ce_MRICH.cpp b/src/ce_MRICH.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3eec523799ccdb2c0bcc496584a8bcf3265cd989
--- /dev/null
+++ b/src/ce_MRICH.cpp
@@ -0,0 +1,101 @@
+
+#include <XML/Helper.h>
+#include "TMath.h"
+#include "TString.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "DD4hep/OpticalSurfaces.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
+#include "ref_utils.h"
+
+using namespace std;
+using namespace dd4hep;
+using namespace dd4hep::rec;
+
+
+void addModules(Volume &mother, xml::DetElement &detElem, Detector &desc, SensitiveDetector &sens);
+
+
+// create the detector
+static Ref_t createDetector(Detector& desc, xml::Handle_t handle, SensitiveDetector sens)
+{
+    xml::DetElement detElem = handle;
+    std::string detName = detElem.nameStr();
+    int detID = detElem.id();
+
+    DetElement det(detName, detID);
+    xml::Component dims = detElem.dimensions();
+    // xml::Component rads = detElem.child(_Unicode(radiator));
+
+    auto rmin = dims.rmin();
+    auto rmax = dims.rmax();
+    auto length = dims.length();
+    auto z0 = dims.z();
+
+    auto gasMat = desc.material("AirOptical");
+
+    // detector envelope
+    Tube envShape(rmin, rmax, length/2., 0., 2*M_PI);
+    Volume envVol("ce_MRICH_GVol", envShape, gasMat);
+    envVol.setVisAttributes(desc.visAttributes(detElem.visStr()));
+
+    // modules
+    addModules(envVol, detElem, desc, sens);
+
+    // place envelope
+    Volume motherVol = desc.pickMotherVolume(det);
+    PlacedVolume envPV = motherVol.placeVolume(envVol, Position(0, 0, z0));
+    envPV.addPhysVolID("system", detID);
+    det.setPlacement(envPV);
+    return det;
+}
+
+
+void addModules(Volume &mother, xml::DetElement &detElem, Detector &desc, SensitiveDetector &sens)
+{
+    xml::Component dims = detElem.dimensions();
+    xml::Component mods = detElem.child(_Unicode(modules));
+
+    auto rmin = dims.rmin();
+    auto rmax = dims.rmax();
+
+    auto mThick = mods.attr<double>(_Unicode(thickness));
+    auto mWidth = mods.attr<double>(_Unicode(width));
+    auto mGap = mods.attr<double>(_Unicode(gap));
+
+    auto modMat = desc.material(mods.materialStr());
+    auto gasMat = desc.material("AirOptical");
+
+    // single module
+    Box mShape(mWidth/2., mWidth/2., mThick/2. - 0.1*mm);
+    Volume mVol("ce_MRICH_mod_Solid", mShape, modMat);
+
+    // a thin gas layer to detect optical photons
+    Box modShape(mWidth/2., mWidth/2., mThick/2.);
+    Volume modVol("ce_MRICH_mod_Solid_v", modShape, gasMat);
+    // thin gas layer is on top (+z) of the material
+    modVol.placeVolume(mVol, Position(0., 0., -0.1*mm));
+
+    modVol.setVisAttributes(desc.visAttributes(mods.visStr()));
+    sens.setType("photoncounter");
+    modVol.setSensitiveDetector(sens);
+
+    // place modules in the sectors (disk)
+    auto points = ref::utils::fillSquares({0., 0.}, mWidth + mGap, rmin - mGap, rmax + mGap);
+
+    // determine module direction, always facing z = 0
+    double roty = dims.z() > 0. ? M_PI/2. : -M_PI/2.;
+    int imod = 1;
+    for (auto &p : points) {
+        // operations are inversely ordered
+        Transform3D tr = Translation3D(p.x(), p.y(), 0.)        // move to position
+                       * RotationY(roty);                       // facing z = 0.
+        auto modPV = mother.placeVolume(modVol, tr);
+        modPV.addPhysVolID("sector", 1).addPhysVolID("module", imod ++);
+    }
+}
+
+// clang-format off
+DECLARE_DETELEMENT(refdet_ce_MRICH, createDetector)
+
diff --git a/src/ref_utils.cpp b/src/ref_utils.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..629679bdc2acdbe217e3322b45d08225b973dcfa
--- /dev/null
+++ b/src/ref_utils.cpp
@@ -0,0 +1,86 @@
+#include "ref_utils.h"
+
+// some utility functions that can be shared
+namespace ref::utils {
+
+typedef ROOT::Math::XYPoint Point;
+
+// check if a square in a ring
+inline bool in_ring(const Point &pt, double side, double rmin, double rmax, double phmin, double phmax)
+{
+    if (pt.r() > rmax || pt.r() < rmin) {
+        return false;
+    }
+
+    // check four corners
+    std::vector<Point> pts {
+        Point(pt.x() - side/2., pt.y() - side/2.),
+        Point(pt.x() - side/2., pt.y() + side/2.),
+        Point(pt.x() + side/2., pt.y() - side/2.),
+        Point(pt.x() + side/2., pt.y() + side/2.),
+    };
+    for (auto &p : pts) {
+        if (p.r() > rmax || p.r() < rmin || p.phi() > phmax || p.phi() < phmin) {
+            return false;
+        }
+    }
+    return true;
+}
+
+// check if a square is overlapped with the others
+inline bool overlap(const Point &pt, double side, const std::vector<Point> &pts)
+{
+    for (auto &p : pts) {
+        auto pn = (p - pt)/side;
+        if ((std::abs(pn.x()) < 1. - 1e-6) && (std::abs(pn.y()) < 1. - 1e-6)) {
+            return true;
+        }
+    }
+    return false;
+}
+
+// a helper function to recursively fill square in a ring
+void add_square(Point p, std::vector<Point> &res, double lside, double rmin, double rmax,
+                double phmin, double phmax)
+{
+    // outside of the ring or overlapping
+    if (!in_ring(p, lside, rmin, rmax, phmin, phmax) || overlap(p, lside, res)) {
+        return;
+    }
+
+    res.emplace_back(p);
+
+    // check adjacent squares
+    add_square(Point(p.x() + lside, p.y()), res, lside, rmin, rmax, phmin, phmax);
+    add_square(Point(p.x() - lside, p.y()), res, lside, rmin, rmax, phmin, phmax);
+    add_square(Point(p.x(), p.y() + lside), res, lside, rmin, rmax, phmin, phmax);
+    add_square(Point(p.x(), p.y() - lside), res, lside, rmin, rmax, phmin, phmax);
+}
+
+// fill squares
+std::vector<Point> fillSquares(Point ref, double lside, double rmin, double rmax, double phmin, double phmax)
+{
+    // start with a seed square and find one in the ring
+    // move to center
+    ref = ref - Point(int(ref.x()/lside)*lside, int(ref.y()/lside)*lside);
+
+    auto find_seed = [] (const Point &ref, int n, double side, double rmin, double rmax, double phmin, double phmax) {
+        for (int ix = -n; ix < n; ++ix) {
+            for (int iy = -n; iy < n; ++iy) {
+                Point pt(ref.x() + ix*side, ref.y() + iy*side);
+                if (in_ring(pt, side, rmin, rmax, phmin, phmax)) {
+                    return pt;
+                }
+            }
+        }
+        return ref;
+    };
+
+    std::vector<Point> res;
+    ref = find_seed(ref, int(rmax/lside) + 2, lside, rmin, rmax, phmin, phmax);
+    add_square(ref, res, lside, rmin, rmax, phmin, phmax);
+    return res;
+}
+
+
+} // ref::utils
diff --git a/src/ref_utils.h b/src/ref_utils.h
new file mode 100644
index 0000000000000000000000000000000000000000..12cf9a814a64ed978f7c8371a1e3a4c8d36c7543
--- /dev/null
+++ b/src/ref_utils.h
@@ -0,0 +1,14 @@
+#pragma once
+#include <vector>
+#include "Math/Point2D.h"
+
+// some utility functions that can be shared
+namespace ref::utils {
+
+typedef ROOT::Math::XYPoint Point;
+
+// fill squares in a ring
+std::vector<Point> fillSquares(Point ref, double lside, double rmin, double rmax,
+                               double phmin = -M_PI, double phmax = M_PI);
+
+} // ref::utils