diff --git a/Detector/DetCEPCv4/CMakeLists.txt b/Detector/DetCEPCv4/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..8d245fbd7245610a0bbb8648822399085c06105c
--- /dev/null
+++ b/Detector/DetCEPCv4/CMakeLists.txt
@@ -0,0 +1,39 @@
+###############################################################################
+# Package: DetCEPCv4 
+# Ref to Package: DetFCCeeIDEA
+# Based on package: lcgeo
+################################################################################
+gaudi_subdir(DetCEPCv4 v0r0)
+
+gaudi_depends_on_subdirs(GaudiKernel)
+
+
+find_package(DD4hep COMPONENTS DDRec DDG4 DDParsers REQUIRED)
+find_package(Geant4)
+include(${Geant4_USE_FILE})
+
+set(CMAKE_MODULE_PATH  ${CMAKE_MODULE_PATH}  ${DD4hep_ROOT}/cmake )
+include( DD4hep )
+
+find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
+
+install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/compact DESTINATION Detector/DetCEPCv4)
+
+set(DetCEPCv4_src
+    src/tracker/VXD04_geo.cpp
+    src/tracker/FTD_Simple_Staggered_geo.cpp
+    src/tracker/SIT_Simple_Pixel_geo.cpp 
+    src/tracker/TPC10_geo.cpp
+    src/tracker/SET_Simple_Planar_geo.cpp
+    src/other/BoxSupport_o1_v01_geo.cpp
+    src/other/TubeSupport_o1_v01_geo.cpp
+)
+
+gaudi_add_module(DetCEPCv4
+                  ${DetCEPCv4_src}
+		  INCLUDE_DIRS DD4hep ROOT Geant4 src/include
+		  LINK_LIBRARIES GaudiKernel DD4hep ${DD4hep_COMPONENT_LIBRARIES} ROOT Geant4)
+
+set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
+message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}")
+dd4hep_generate_rootmap(DetCEPCv4)
diff --git a/Detector/DetCEPCv4/compact/Beampipe_o1_v01_01.xml b/Detector/DetCEPCv4/compact/Beampipe_o1_v01_01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..fdc6a5014fb2ea369b02bd41d27d097b79bfdc8e
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Beampipe_o1_v01_01.xml
@@ -0,0 +1,215 @@
+<lccdd>
+
+  <detectors>        
+
+
+<detector name="Tube" type="DD4hep_Beampipe_o1_v01" vis="BeamPipeVis" id="ILDDetID_NOTUSED">
+
+  <envelope vis="BlueVis">
+    <shape type="Assembly"/>
+  </envelope>
+  
+  <type_flags type="DetType_SUPPORT + DetType_BEAMPIPE "/>
+
+  <parameter crossingangle="CepC_Main_Crossing_Angle" />
+  
+  <!-- central tube -->
+  <section type ="Center"                
+	   start="0*mm"                                  end="TUBE_innerCylinder_zEnd"
+           rMin1="TUBE_innerCylinder_rInner"  rMin2="TUBE_innerCylinder_rInner"       
+	   rMax1="TUBE_innerCylinder_rInner+TUBE_innerCylinder_thickness"        rMax2="TUBE_innerCylinder_rInner+TUBE_innerCylinder_thickness"
+	   material="G4_Be" name="IPInnerTube" />
+
+  <!-- first cone -->
+  <section type ="Center"
+           start="TUBE_firstCone_zStart"                               end="TUBE_firstCone_zEnd"
+           rMin1="TUBE_firstCone_rInnerStart"                          rMin2="TUBE_firstCone_rInnerEnd"
+           rMax1="TUBE_firstCone_rInnerStart+TUBE_firstCone_RadThickness" rMax2="TUBE_firstCone_rInnerEnd+TUBE_firstCone_RadThickness"
+           material="G4_Cu" name="IPInnerBulge" />
+
+  <!-- second cylinder -->
+  <section type ="Center"  
+           start="TUBE_secondCylinder_zStart"                               end="TUBE_secondCylinder_zEnd" 
+           rMin1="TUBE_secondCylinder_rInner"                               rMin2="TUBE_secondCylinder_rInner"
+           rMax1="TUBE_secondCylinder_rInner+TUBE_secondCylinder_thickness" rMax2="TUBE_secondCylinder_rInner+TUBE_secondCylinder_thickness"
+           material="G4_Cu" name="IPOuterTube" />
+
+  <!-- second cone, split into parts -->
+  <section type ="Center" 
+           start="TUBE_secondCone_part1_zStart"                                end="TUBE_secondCone_part4_zEnd"
+           rMin1="TUBE_secondCone_part1_rInnerStart"                             rMin2="TUBE_secondCone_part4_rInnerEnd"
+           rMax1="TUBE_secondCone_part1_rInnerStart+TUBE_secondCone_part1_RadThickness"  rMax2="TUBE_secondCone_part4_rInnerEnd+TUBE_secondCone_part4_RadThickness"
+           material="BeampipeBeCableMix" name="IPOuterTube" />
+
+  <!--section type ="Center" 
+           start="TUBE_secondCone_part2_zStart"                                end="TUBE_secondCone_part2_zEnd"
+           rMin1="TUBE_secondCone_part2_rInnerStart"                             rMin2="TUBE_secondCone_part2_rInnerEnd"
+           rMax1="TUBE_secondCone_part2_rInnerStart+TUBE_secondCone_part2_RadThickness"  rMax2="TUBE_secondCone_part2_rInnerEnd+TUBE_secondCone_part2_RadThickness"
+           material="BeampipeBeCableMix" name="IPOuterTube" />
+
+  <section type ="Center" 
+           start="TUBE_secondCone_part3_zStart"                                end="TUBE_secondCone_part3_zEnd"
+           rMin1="TUBE_secondCone_part3_rInnerStart"                             rMin2="TUBE_secondCone_part3_rInnerEnd"
+           rMax1="TUBE_secondCone_part3_rInnerStart+TUBE_secondCone_part3_RadThickness"  rMax2="TUBE_secondCone_part3_rInnerEnd+TUBE_secondCone_part3_RadThickness"
+           material="BeampipeBeCableMix" name="IPOuterTube" />
+
+  <section type ="Center" 
+           start="TUBE_secondCone_part4_zStart"                                end="TUBE_secondCone_part4_zEnd"
+           rMin1="TUBE_secondCone_part4_rInnerStart"                             rMin2="TUBE_secondCone_part4_rInnerEnd"
+           rMax1="TUBE_secondCone_part4_rInnerStart+TUBE_secondCone_part4_RadThickness"  rMax2="TUBE_secondCone_part4_rInnerEnd+TUBE_secondCone_part4_RadThickness"
+           material="BeampipeBeCableMix" name="IPOuterTube" /-->
+
+
+  <section type ="PunchedCenter"         
+	   start="TUBE_secondCone_part4_zEnd"    end="TUBE_secondCone_part4_zEnd+TUBE_cupola_thickness"   
+	   rMin1="0.0*mm"                        rMin2="TUBE_lumiTube_rInner" 
+	   rMax1 ="TUBE_secondCone_part4_rInnerEnd+TUBE_secondCone_part4_thickness"    rMax2="TUBE_secondCone_part4_rInnerEnd+TUBE_secondCone_part4_thickness" 
+	   material="G4_Be" name="LumiCalFront" />
+
+  <section type ="DnstreamClippedFront"  
+	   start="TUBE_secondCone_part4_zEnd+TUBE_cupola_thickness"    end="BeamCal_min_z-5*mm"
+           rMin1="TUBE_lumiTube_rInner" rMin2="TUBE_lumiTube_rInner"
+	   rMax1 ="TUBE_lumiTube_rInner+TUBE_lumiTube_thickness"    rMax2="TUBE_lumiTube_rInner+TUBE_lumiTube_thickness" 
+	   material="stainless_steel" name="LumiCalInner" />
+
+  <section type ="PunchedDnstream"       
+	   start="BeamCal_min_z-5*mm"            end="BeamCal_min_z-4*mm"         
+	   rMin1="14*mm"                         rMin2="16*mm"
+           rMax1 ="TUBE_lumiTube_rInner+TUBE_lumiTube_thickness"                      rMax2="TUBE_lumiTube_rInner+TUBE_lumiTube_thickness"       
+           material="stainless_steel" name="BeamCalFront" />
+
+  <!-- inside beamcal -->
+  <section type ="UpstreamSlicedFront"   
+	   start="BeamCal_min_z-4*mm"                end="BeamCal_min_z + top_BeamCal_thickness"
+           rMin1="TUBE_incoming_inBeamcal_InnerRadius"  rMin2="TUBE_incoming_inBeamcal_InnerRadius"
+           rMax1="TUBE_incoming_inBeamcal_OuterRadius"  rMax2="TUBE_incoming_inBeamcal_OuterRadius"
+           material="stainless_steel" name="BeamCalLinkUpstream" />
+
+  <section type ="Upstream"
+           start="BeamCal_min_z + top_BeamCal_thickness"   end="BeamCal_min_z + top_BeamCal_thickness+TUBE_transition_length"
+	   rMin1="TUBE_incoming_inBeamcal_InnerRadius" rMin2="TUBE_incoming_beamcalToQD0_InnerRadius"
+	   rMax1="TUBE_incoming_inBeamcal_OuterRadius"  rMax2="TUBE_incoming_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeamCalLinkUpstreamTrans" />
+
+  <section type ="Upstream"
+           start="BeamCal_min_z + top_BeamCal_thickness+TUBE_transition_length"   end="TUBE_QD0_Lstar-TUBE_transition_length"
+           rMin1="TUBE_incoming_beamcalToQD0_InnerRadius"  rMin2="TUBE_incoming_beamcalToQD0_InnerRadius"
+           rMax1="TUBE_incoming_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"  rMax2="TUBE_incoming_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeamCalToQD0Upstream" />
+
+  <section type ="Upstream"
+           start="TUBE_QD0_Lstar-TUBE_transition_length"   end="TUBE_QD0_Lstar"
+           rMin1="TUBE_incoming_beamcalToQD0_InnerRadius"  rMin2="TUBE_incoming_QD0andBeyond_InnerRadius"
+           rMax1="TUBE_incoming_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"  rMax2="TUBE_incoming_QD0andBeyond_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeamCalToQD0UpstreamTrans" />
+
+  <section type ="Upstream"
+           start="TUBE_QD0_Lstar"                    end="TUBE_QD0_Lstar+TUBE_QD0_length"
+           rMin1="TUBE_incoming_QD0andBeyond_InnerRadius"          rMin2="TUBE_incoming_QD0andBeyond_InnerRadius"
+           rMax1="TUBE_incoming_QD0andBeyond_InnerRadius+20*mm"    rMax2="TUBE_incoming_QD0andBeyond_InnerRadius+20*mm"
+           material="stainless_steel" name="QD0CryoUpstream" />
+
+  <section type ="Upstream"
+           start="TUBE_QD0_Lstar+TUBE_QD0_length"    end="10*m"
+           rMin1="TUBE_incoming_QD0andBeyond_InnerRadius"          rMin2="TUBE_incoming_QD0andBeyond_InnerRadius"
+           rMax1="TUBE_incoming_QD0andBeyond_InnerRadius+TUBE_upstream_thickness"    rMax2="TUBE_incoming_QD0andBeyond_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeyondQD0Upstream" />
+
+
+
+  <!-- inside beamcal -->
+  <section type ="Dnstream"              
+	   start="BeamCal_min_z-4*mm"                     end="BeamCal_min_z + top_BeamCal_thickness"
+           rMin1="TUBE_outgoing_inBeamcal_InnerRadius"  rMin2="TUBE_outgoing_inBeamcal_InnerRadius"
+           rMax1="TUBE_outgoing_inBeamcal_OuterRadius"  rMax2="TUBE_outgoing_inBeamcal_OuterRadius"
+	   material="stainless_steel" name="BeamCalLinkDnstream" />
+
+  <section type ="Dnstream"              
+	   start="BeamCal_min_z + top_BeamCal_thickness" end="BeamCal_min_z + top_BeamCal_thickness+TUBE_transition_length"
+           rMin1="TUBE_outgoing_inBeamcal_InnerRadius"  rMin2="TUBE_outgoing_beamcalToQD0_InnerRadius"
+           rMax1="TUBE_outgoing_inBeamcal_OuterRadius"  rMax2="TUBE_outgoing_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"
+	   material="stainless_steel" name="BeamCalLinkDnstreamTrans" />
+
+
+  <section type ="Dnstream"
+           start="BeamCal_min_z + top_BeamCal_thickness+TUBE_transition_length"   end="TUBE_QDEX1A_Lstar"
+           rMin1="TUBE_outgoing_beamcalToQD0_InnerRadius"  rMin2="TUBE_outgoing_beamcalToQD0_InnerRadius"
+           rMax1="TUBE_outgoing_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"  rMax2="TUBE_outgoing_beamcalToQD0_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeamCalToQDEX1ADnstream" />
+
+  <section type ="Dnstream"
+           start="TUBE_QDEX1A_Lstar"                    end="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"
+           rMin1="TUBE_outgoing_QD0andBeyond_InnerRadius"          rMin2="TUBE_outgoing_QD0andBeyond_InnerRadius"
+           rMax1="TUBE_outgoing_QD0andBeyond_InnerRadius+20*mm"    rMax2="TUBE_outgoing_QD0andBeyond_InnerRadius+20*mm"
+           material="stainless_steel" name="QDEX1A" />
+
+  <section type ="Dnstream"
+           start="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"         end="10*m"
+           rMin1="TUBE_outgoing_QD0andBeyond_InnerRadius"          rMin2="TUBE_outgoing_QD0andBeyond_InnerRadius"
+           rMax1="TUBE_outgoing_QD0andBeyond_InnerRadius+TUBE_upstream_thickness"    rMax2="TUBE_outgoing_QD0andBeyond_InnerRadius+TUBE_upstream_thickness"
+           material="stainless_steel" name="BeyondQD0Dnstream" />
+
+</detector>
+
+<detector name="QD0_cryostat" type="TubeSupport_o1_v01" vis="BeamPipeVis" id="ILDDetID_NOTUSED" reflect="true">
+
+  <envelope vis="BlueVis">
+    <shape type="Assembly"/>
+  </envelope>
+
+  <type_flags type="DetType_SUPPORT + DetType_BEAMPIPE "/>
+
+  <section start="TUBE_QD0_Lstar-20*mm" end="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"
+	   rMin="235.*mm" rMax="250.*mm"
+	   material="stainless_steel"
+	   name="qd0_cryostat"/>
+
+  <section start="TUBE_QD0_Lstar-20*mm" end="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"
+	   rMin="235.*mm" rMax="250.*mm"
+	   material="stainless_steel"
+	   name="qd0_cryostat_wall"/>
+
+  <!-- some attempt to model other materials in cryostat -->
+  <section start="TUBE_QD0_Lstar-20*mm" end="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"
+	   rMin="110.*mm" rMax="160.*mm"
+	   material="stainless_steel"
+	   name="qd0_cryostat_interiorMaterialPlaceholder"/>
+
+  <section start="TUBE_QD0_Lstar-35*mm" end="TUBE_QD0_Lstar-20*mm"
+	   rMin="TUBE_QD0_Lstar*tan(CepC_Main_Crossing_Angle/2.)+TUBE_outgoing_QD0andBeyond_InnerRadius+TUBE_upstream_thickness+1*mm" rMax="250*mm"
+	   material="stainless_steel"
+	   name="qd0_cryostat_frontface"/>
+
+
+</detector>
+
+<detector name="QD0_support" type="BoxSupport_o1_v01" vis="BeamPipeVis" id="ILDDetID_NOTUSED" reflect="true">
+
+  <envelope vis="BlueVis">
+    <shape type="Assembly"/>
+  </envelope>
+
+  <type_flags type="DetType_SUPPORT + DetType_BEAMPIPE "/>
+
+  <section start="TUBE_QD0_Lstar+20*mm" end="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length"
+	   rMin="275.*mm" rMax="300*mm"
+	   material="stainless_steel"
+	   name="qd0_support"/>
+
+  <section start="Ecal_endcap_zmin" end="Ecal_endcap_zmin+Ecal_barrel_thickness"
+	   rMin="EcalEndcapRing_outer_radius + 2*env_safety" rMax="EcalEndcap_inner_radius - 2*env_safety"
+	   material="stainless_steel"
+	   name="forward_support_tube"/>
+
+  <section start="top_LHCal_min_z + top_LHCal_thickness+10*mm" end="BeamCal_min_z + top_BeamCal_thickness+4600*mm"
+	   rMin="305*mm" rMax="325*mm"
+	   material="stainless_steel"
+	   name="forward_support_tube"/>
+
+</detector>
+
+
+
+  </detectors>        
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/CepC_v4-onlyTracker.xml b/Detector/DetCEPCv4/compact/CepC_v4-onlyTracker.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4c6e2d616c85648a018cecf07d7c1f6ce7874527
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/CepC_v4-onlyTracker.xml
@@ -0,0 +1,77 @@
+<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">
+  <info name="CepC_v04"
+        title="CepC detctor used for the optimisation"
+        author="C.D.Fu"
+        url="http://cepc.ihep.ac.cn"
+        status="experimental"
+        version="v04">
+    <comment>CepC detector simulation models used for detector optimisation </comment>
+  </info>
+  <includes>
+    <gdmlFile  ref="elements.xml"/>
+    <gdmlFile  ref="materials.xml"/>
+  </includes>
+  <define>
+    <include ref="top_defs_CepC_v04.xml"/>
+    <include ref="top_defs.xml"/>
+    <include ref="basic_defs.xml"/>
+    <include ref="envelope_defs.xml"/>
+    <include ref="tube_defs.xml"/>
+    <include ref="misc_defs.xml"/>
+    <include ref="tracker_defs.xml"/>
+    <include ref="fcal_defs.xml"/>
+    <include ref="ecal_defs.xml"/>
+    <include ref="hcal_defs.xml"/>
+    <include ref="yoke_defs.xml"/>
+    <include ref="services_defs.xml"/>
+    <include ref="detector_types.xml"/>
+    <include ref="limits.xml"/>
+    <!-- Readout slice in ecal for reconstruction -->
+    <constant name="Ecal_readout_segmentation_slice0" value="4"/>
+    <constant name="Ecal_readout_segmentation_slice1" value="10"/>
+    <!-- Readout slice in hcal for reconstruction -->
+    <constant name="Hcal_readout_segmentation_slice" value="3"/>
+  </define>
+  <limits>
+    <limitset name="cal_limits">
+      <limit name="step_length_max" particles="*" value="cal_steplimit_val" unit="cal_steplimit_unit" />
+    </limitset>
+    <limitset name="TPC_limits">
+      <limit name="step_length_max" particles="*" value="tpc_steplimit_val" unit="tpc_steplimit_unit" />
+    </limitset>
+    <limitset name="Tracker_limits">
+      <limit name="step_length_max" particles="*" value="tracker_steplimit_val" unit="tracker_steplimit_unit" />
+    </limitset>
+  </limits>
+  <include ref="display.xml"/>
+  <include ref="Beampipe_o1_v01_01.xml"/>
+  <include ref="vxd07.xml"/>
+  <include ref="ftd_simple_staggered_02.xml"/>
+  <include ref="sit_simple_pixel_sensors_01.xml"/>
+  <include ref="tpc10_01.xml"/>
+  <include ref="set_simple_planar_sensors_01.xml"/>
+  <!--include ref="SEcal05_siw_Barrel.xml"/>
+  <include ref="SEcal05_siw_Endcaps.xml"/>
+  <include ref="SEcal05_siw_ECRing.xml"/>
+  <include ref="Hcal_Barrel_SD_v01.xml"/>
+  <include ref="Hcal_Endcaps_SD_v01.xml"/>
+  <include ref="Hcal_EndcapRing_SD_v01.xml"/>
+  <include ref="Yoke05_Barrel.xml"/>
+  <include ref="Yoke05_Endcaps.xml"/>
+  <include ref="LumiCal.xml"/-->
+
+  <!--include ref="LHCal01.xml"/>
+  <include ref="BeamCal08.xml"/-->
+
+  <!--include ref="coil03.xml"/-->
+  <!--include ref="SServices00.xml"/-->
+  <plugins>
+    <plugin name="DD4hepVolumeManager"/>
+    <plugin name="InstallSurfaceManager"/>
+  </plugins>
+  <!--include ref="Field_Solenoid_Map_s_4.0T.xml"/>
+  <include ref="Field_AntiDID_Map_s.xml"/>
+  <include ref="Field_FwdMagnets_Ideal_1000GeV.xml"/-->
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/CepC_v4-onlyVXD.xml b/Detector/DetCEPCv4/compact/CepC_v4-onlyVXD.xml
new file mode 100644
index 0000000000000000000000000000000000000000..42b18131fd7b248fdb0bd70c3e42d578051ba925
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/CepC_v4-onlyVXD.xml
@@ -0,0 +1,77 @@
+<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">
+  <info name="CepC_v04"
+        title="CepC detctor used for the optimisation"
+        author="C.D.Fu"
+        url="http://cepc.ihep.ac.cn"
+        status="experimental"
+        version="v04">
+    <comment>CepC detector simulation models used for detector optimisation </comment>
+  </info>
+  <includes>
+    <gdmlFile  ref="elements.xml"/>
+    <gdmlFile  ref="materials.xml"/>
+  </includes>
+  <define>
+    <include ref="top_defs_CepC_v04.xml"/>
+    <include ref="top_defs.xml"/>
+    <include ref="basic_defs.xml"/>
+    <include ref="envelope_defs.xml"/>
+    <include ref="tube_defs.xml"/>
+    <include ref="misc_defs.xml"/>
+    <include ref="tracker_defs.xml"/>
+    <include ref="fcal_defs.xml"/>
+    <include ref="ecal_defs.xml"/>
+    <include ref="hcal_defs.xml"/>
+    <include ref="yoke_defs.xml"/>
+    <include ref="services_defs.xml"/>
+    <include ref="detector_types.xml"/>
+    <include ref="limits.xml"/>
+    <!-- Readout slice in ecal for reconstruction -->
+    <constant name="Ecal_readout_segmentation_slice0" value="4"/>
+    <constant name="Ecal_readout_segmentation_slice1" value="10"/>
+    <!-- Readout slice in hcal for reconstruction -->
+    <constant name="Hcal_readout_segmentation_slice" value="3"/>
+  </define>
+  <limits>
+    <limitset name="cal_limits">
+      <limit name="step_length_max" particles="*" value="cal_steplimit_val" unit="cal_steplimit_unit" />
+    </limitset>
+    <limitset name="TPC_limits">
+      <limit name="step_length_max" particles="*" value="tpc_steplimit_val" unit="tpc_steplimit_unit" />
+    </limitset>
+    <limitset name="Tracker_limits">
+      <limit name="step_length_max" particles="*" value="tracker_steplimit_val" unit="tracker_steplimit_unit" />
+    </limitset>
+  </limits>
+  <include ref="display.xml"/>
+  <include ref="Beampipe_o1_v01_01.xml"/>
+  <include ref="vxd07.xml"/>
+  <!--include ref="ftd_simple_staggered_02.xml"/>
+  <include ref="sit_simple_pixel_sensors_01.xml"/>
+  <include ref="tpc10_01.xml"/>
+  <include ref="set_simple_planar_sensors_01.xml"/-->
+  <!--include ref="SEcal05_siw_Barrel.xml"/>
+  <include ref="SEcal05_siw_Endcaps.xml"/>
+  <include ref="SEcal05_siw_ECRing.xml"/>
+  <include ref="Hcal_Barrel_SD_v01.xml"/>
+  <include ref="Hcal_Endcaps_SD_v01.xml"/>
+  <include ref="Hcal_EndcapRing_SD_v01.xml"/>
+  <include ref="Yoke05_Barrel.xml"/>
+  <include ref="Yoke05_Endcaps.xml"/>
+  <include ref="LumiCal.xml"/-->
+
+  <!--include ref="LHCal01.xml"/>
+  <include ref="BeamCal08.xml"/-->
+
+  <!--include ref="coil03.xml"/-->
+  <!--include ref="SServices00.xml"/-->
+  <plugins>
+    <plugin name="DD4hepVolumeManager"/>
+    <plugin name="InstallSurfaceManager"/>
+  </plugins>
+  <!--include ref="Field_Solenoid_Map_s_4.0T.xml"/>
+  <include ref="Field_AntiDID_Map_s.xml"/>
+  <include ref="Field_FwdMagnets_Ideal_1000GeV.xml"/-->
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/CepC_v4.xml b/Detector/DetCEPCv4/compact/CepC_v4.xml
new file mode 100644
index 0000000000000000000000000000000000000000..393a40e9002e23cdfb6975e88e1117b53441becb
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/CepC_v4.xml
@@ -0,0 +1,77 @@
+<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">
+  <info name="CepC_v04"
+        title="CepC detctor used for the optimisation"
+        author="C.D.Fu"
+        url="http://cepc.ihep.ac.cn"
+        status="experimental"
+        version="v04">
+    <comment>CepC detector simulation models used for detector optimisation </comment>
+  </info>
+  <includes>
+    <gdmlFile  ref="elements.xml"/>
+    <gdmlFile  ref="materials.xml"/>
+  </includes>
+  <define>
+    <include ref="top_defs_CepC_v04.xml"/>
+    <include ref="top_defs.xml"/>
+    <include ref="basic_defs.xml"/>
+    <include ref="envelope_defs.xml"/>
+    <include ref="tube_defs.xml"/>
+    <include ref="misc_defs.xml"/>
+    <include ref="tracker_defs.xml"/>
+    <include ref="fcal_defs.xml"/>
+    <include ref="ecal_defs.xml"/>
+    <include ref="hcal_defs.xml"/>
+    <include ref="yoke_defs.xml"/>
+    <include ref="services_defs.xml"/>
+    <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
+    <include ref="limits.xml"/>
+    <!-- Readout slice in ecal for reconstruction -->
+    <constant name="Ecal_readout_segmentation_slice0" value="4"/>
+    <constant name="Ecal_readout_segmentation_slice1" value="10"/>
+    <!-- Readout slice in hcal for reconstruction -->
+    <constant name="Hcal_readout_segmentation_slice" value="3"/>
+  </define>
+  <limits>
+    <limitset name="cal_limits">
+      <limit name="step_length_max" particles="*" value="cal_steplimit_val" unit="cal_steplimit_unit" />
+    </limitset>
+    <limitset name="TPC_limits">
+      <limit name="step_length_max" particles="*" value="tpc_steplimit_val" unit="tpc_steplimit_unit" />
+    </limitset>
+    <limitset name="Tracker_limits">
+      <limit name="step_length_max" particles="*" value="tracker_steplimit_val" unit="tracker_steplimit_unit" />
+    </limitset>
+  </limits>
+  <include ref="display.xml"/>
+  <include ref="Beampipe_o1_v01_01.xml"/>
+  <!--include ref="vxd07.xml"/>
+  <include ref="ftd_simple_staggered_02.xml"/>
+  <include ref="sit_simple_pixel_sensors_01.xml"/>
+  <include ref="tpc10_01.xml"/>
+  <include ref="set_simple_planar_sensors_01.xml"/-->
+  <include ref="SEcal05_siw_Barrel.xml"/>
+  <include ref="SEcal05_siw_Endcaps.xml"/>
+  <include ref="SEcal05_siw_ECRing.xml"/>
+  <!--include ref="Hcal_Barrel_SD_v01.xml"/>
+  <include ref="Hcal_Endcaps_SD_v01.xml"/>
+  <include ref="Hcal_EndcapRing_SD_v01.xml"/>
+  <include ref="Yoke05_Barrel.xml"/>
+  <include ref="Yoke05_Endcaps.xml"/>
+  <include ref="LumiCal.xml"/-->
+
+  <!--include ref="LHCal01.xml"/>
+  <include ref="BeamCal08.xml"/-->
+
+  <!--include ref="coil03.xml"/-->
+  <!--include ref="SServices00.xml"/-->
+  <plugins>
+    <plugin name="DD4hepVolumeManager"/>
+    <plugin name="InstallSurfaceManager"/>
+  </plugins>
+  <!--include ref="Field_Solenoid_Map_s_4.0T.xml"/>
+  <include ref="Field_AntiDID_Map_s.xml"/>
+  <include ref="Field_FwdMagnets_Ideal_1000GeV.xml"/-->
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/Hcal_Barrel_SD_v01.xml b/Detector/DetCEPCv4/compact/Hcal_Barrel_SD_v01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bfee3f1b9cea39cc91b3e3938af66e2f45344d65
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Hcal_Barrel_SD_v01.xml
@@ -0,0 +1,47 @@
+<lccdd>
+
+  <detectors>
+    <detector name="HcalBarrel" type="Hcal_Barrel_SD_v01" id="ILDDetID_HCAL" readout="HCalBarrelRPCHits" vis="GreenVis" insideTrackingVolume="false" >
+      <comment>Hadron Calorimeter Barrel</comment>
+
+      <envelope vis="ILD_HCALVis">
+        <shape type="BooleanShape" operation="Subtraction" material="Air" >
+          <shape type="Cone" z="Hcal_half_length + env_safety/2" rmin1="0.0" rmax1="Hcal_outer_radius + env_safety" rmin2="0.0" rmax2="Hcal_outer_radius + env_safety"/>
+          <shape type="PolyhedraRegular"  numsides="Hcal_inner_symmetry" rmin="0.0"
+                 rmax="Hcal_inner_radius - env_safety" dz="2*(Hcal_half_length + env_safety)"/>
+        </shape>
+        <rotation x="0" y="0" z="90*deg-180*deg/Hcal_inner_symmetry"/>
+      </envelope>
+      <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_HADRONIC " />
+
+      <staves  material = "Steel304L"  vis="BlueVis"/>
+
+      <!-- The layer structure reference in the following paper-->
+      <!-- ???  -->
+      <layer repeat="HcalBarrelSD_nlayers" vis="SeeThrough">
+        <slice material = "Steel304L"      thickness = "HcalSD_radiator_thickness"                    vis="BlueVis"   />
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"   />
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   />
+        <slice material = "epoxy"          thickness = "HcalSD_electronics_mask_thickness"            vis="GreenVis" />
+        <slice material = "PCB"            thickness = "HcalSD_PCB_thickness"                         vis="CyanVis" />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_anode_thickness"                 vis="MagentaVis" />
+        <slice material = "graphite"       thickness = "HcalSD_graphite_anode_thickness"              vis="Invisible" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_anode_thickness"                 vis="RedVis" />
+        <slice material = "RPCGAS2"        thickness = "HcalSD_sensitive_gas_gap"   sensitive = "yes"   vis="YellowVis" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_cathode_thickness"               vis="RedVis" />
+        <slice material = "graphite"       thickness = "HcalSD_graphite_cathode_thickness"            vis="Invisible" />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_cathode_thickness"               vis="MagentaVis" />
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   />
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"   />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="HCalBarrelRPCHits">
+      <segmentation type="CartesianGridXY" grid_size_x="HcalSD_cells_size" grid_size_y="HcalSD_cells_size"/>
+      <id>system:5,module:3,stave:3,tower:5,layer:6,slice:4,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/Hcal_EndcapRing_SD_v01.xml b/Detector/DetCEPCv4/compact/Hcal_EndcapRing_SD_v01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ee89545a0187d2cc8e87318e770aa9e7f408800d
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Hcal_EndcapRing_SD_v01.xml
@@ -0,0 +1,56 @@
+<lccdd>
+
+  <detectors>
+    <detector name="HcalRing" type="Hcal_EndcapRing_SD_v01" id="ILDDetID_HCAL_RING" readout="HCalECRingRPCHits" vis="SeeThrough" insideTrackingVolume="false" >
+      <comment>Hadron Calorimeter EndcapRing</comment>
+
+      <envelope vis="ILD_HCALVis">
+        <shape type="BooleanShape" operation="Subtraction" material="Air">
+          <shape type="BooleanShape" operation="Intersection" material="Air">
+            <shape type="Box" dx="HcalEndcapRing_outer_radius + 2.0*env_safety" dy="HcalEndcapRing_outer_radius + 2.0*env_safety"
+                   dz="HcalEndcapRing_max_z + 2.0*env_safety"/> <!--Box defined the coordinate system-->
+            <shape type="PolyhedraRegular" numsides="HcalEndcapRingSD_inner_symmetry" rmin="HcalEndcapRing_inner_radius - env_safety"
+                   rmax="HcalEndcapRing_outer_radius + env_safety" dz="2.0*HcalEndcapRing_max_z + env_safety" material="Air"/>
+            <rotation x="0" y="0" z="90*deg-180*deg/HcalEndcapRingSD_inner_symmetry"/>
+          </shape>
+
+          <shape type="Box" dx="HcalEndcapRing_outer_radius + 2.0*env_safety" dy="HcalEndcapRing_outer_radius + 2.0*env_safety"
+                 dz="HcalEndcapRing_min_z - env_safety"/>
+        </shape>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_HADRONIC + DetType_AUXILIARY " />
+
+      <!-- absorber material
+        -->
+      <staves  material = "Steel304L"  vis="GreenVis"/>
+      <material name="Steel304L"/>
+
+      <layer repeat="HcalEndcapRingSD_nlayers" vis="SeeThrough">
+        <slice material = "Steel304L"      thickness = "HcalSD_radiator_thickness"                    vis="BlueVis"   />
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"   />
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   />
+        <slice material = "epoxy"          thickness = "HcalSD_electronics_mask_thickness"            vis="GreenVis" />
+        <slice material = "PCB"            thickness = "HcalSD_PCB_thickness"                         vis="CyanVis" />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_anode_thickness"                 vis="MagentaVis" />
+        <slice material = "graphite"       thickness = "HcalSD_graphite_anode_thickness"              vis="Invisible" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_anode_thickness"                 vis="RedVis" />
+        <slice material = "RPCGAS2"        thickness = "HcalSD_sensitive_gas_gap"  sensitive = "yes"   vis="YellowVis" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_cathode_thickness"               vis="RedVis" />
+        <slice material = "graphite"       thickness = "HcalSD_graphite_cathode_thickness"            vis="Invisible" />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_cathode_thickness"               vis="MagentaVis" />
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   />
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"   />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="HCalECRingRPCHits">
+      <segmentation type="CartesianGridXY" grid_size_x="HcalSD_cells_size" grid_size_y="HcalSD_cells_size"/>
+      <id>system:5,module:3,stave:4,tower:3,layer:6,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
+
diff --git a/Detector/DetCEPCv4/compact/Hcal_Endcaps_SD_v01.xml b/Detector/DetCEPCv4/compact/Hcal_Endcaps_SD_v01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3b77b0fa6104dd0cd1e60b439d185ed6eb9af23c
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Hcal_Endcaps_SD_v01.xml
@@ -0,0 +1,53 @@
+<lccdd>
+
+<detectors>
+<detector id="ILDDetID_HCAL_ENDCAP" name="HcalEndcap" type="Hcal_Endcaps_SD_v01" readout="HCalEndcapRPCHits"  vis="SeeThrough" calorimeterType="HAD_ENDCAP">
+ <comment>Hadron Calorimeter Endcap</comment>
+
+
+    <envelope vis="ILD_HCALVis">    
+      <shape type="BooleanShape" operation="Subtraction" material="Air"><!--2. create center box hole -->
+        <shape type="BooleanShape" operation="Subtraction" material="Air"><!--1. create Endcaps envelope -->
+          <shape type="Tube" rmin="0.0" rmax="HcalEndcap_outer_radius + env_safety" dz="HcalEndcap_max_z + env_safety"/>
+          <shape type="Tube" rmin="0.0" rmax="HcalEndcap_outer_radius + 2.0*env_safety" dz="HcalEndcap_min_z - env_safety"/>
+        </shape>
+        <shape type="Box" dx="HcalEndcap_inner_radius - env_safety" dy="HcalEndcap_inner_radius - env_safety" 
+               dz="HcalEndcap_max_z + 2.0*env_safety"/>
+      </shape>
+      <rotation x="0" y="0" z="0"/>
+    </envelope>
+
+    <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_HADRONIC " />
+    <material name="Steel304L"/><!-- radiator and the thickness has been defined in the main xml file-->
+    <staves  material = "Steel235"  vis="SeeThrough"/>
+
+
+      <!-- slice: from inner  to outer -->  
+    <layer repeat="HcalEndcapSD_nlayers" vis="SeeThrough">  
+        <slice material = "Steel304L"      thickness = "HcalSD_radiator_thickness"                    vis="BlueVis"   />   
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"  /> 
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   />
+        <slice material = "epoxy"          thickness = "HcalSD_electronics_mask_thickness"            vis="GreenVis"  />
+        <slice material = "PCB"            thickness = "HcalSD_PCB_thickness"                         vis="CyanVis"   />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_anode_thickness"                 vis="MagentaVis"/>
+        <slice material = "graphite"       thickness = "HcalSD_graphite_anode_thickness"              vis="Invisible" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_anode_thickness"                 vis="RedVis"    />
+        <slice material = "RPCGAS2"        thickness = "HcalSD_sensitive_gas_gap"   sensitive = "yes"   vis="YellowVis" />
+        <slice material = "FloatGlass"     thickness = "HcalSD_glass_cathode_thickness"               vis="RedVis"    />
+        <slice material = "graphite"       thickness = "HcalSD_graphite_cathode_thickness"            vis="Invisible" />
+        <slice material = "mylar"          thickness = "HcalSD_mylar_cathode_thickness"               vis="MagentaVis"/>
+        <slice material = "Steel304L"      thickness = "HcalSD_steel_casette_thickness"               vis="BlueVis"   /> 
+        <slice material = "Air"            thickness = "HcalSD_airgap_thickness"                      vis="WhiteVis"  />  
+    </layer>
+
+</detector>
+</detectors>
+
+<readouts>
+  <readout name="HCalEndcapRPCHits">
+    <segmentation type="CartesianGridXY" grid_size_x="HcalSD_cells_size" grid_size_y="HcalSD_cells_size" offset_x="HcalSD_cells_size/2.0" offset_y="HcalSD_cells_size/2.0" />
+    <id>system:5,module:3,stave:3,tower:5,layer:6,x:32:-16,y:-16</id>
+  </readout>
+</readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/LumiCal.xml b/Detector/DetCEPCv4/compact/LumiCal.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6d0be653eac20a99d565418b4e980e9f00514f65
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/LumiCal.xml
@@ -0,0 +1,88 @@
+<!--
+   LumiCal parameters for ILD
+  -->
+
+<lccdd>
+  <detectors>
+
+    <detector name="Lcal" type="LumiCal_o1_v03" vis="BlueVis" id="ILDDetID_LCAL"
+              readout="LumiCalCollection" insideTrackingVolume="false" >
+
+      <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_ELECTROMAGNETIC + DetType_FORWARD " />
+
+      <!-- LumiCal envelope is rotated according to the CepC_Main_Crossing_Angle at +z and -z -->
+      <envelope vis="ILD_FCALVis">
+        <shape type="BooleanShape" operation="Intersection" material="Air">
+          <!-- shape type="Box" dx="LumiCal_outer_radius*2.0" dy="LumiCal_outer_radius*2.0" dz="LumiCal_max_z*2.0"/ -->
+          <shape type="Box" dx="Lcal_services_rmax*2.0" dy="Lcal_services_rmax*2.0" dz="LumiCal_max_z*2.0"/>
+
+          <shape type="BooleanShape" operation="Union" material="Air">
+            <!-- -z -->
+            <shape type="BooleanShape" operation="Subtraction" material="Air">
+              <shape type="Tube" rmin="LumiCal_inner_radius - env_safety" rmax="Lcal_services_rmax + env_safety" dz="LumiCal_max_z/COS_halfCrossingAngle + env_safety"/>
+              <shape type="Tube" rmin="0.0" rmax="Lcal_services_rmax + 1.5*env_safety" dz="LumiCal_min_z/COS_halfCrossingAngle+LumiCal_thickness - env_safety"/>
+              <position x="0" y="0" z="LumiCal_thickness"/>
+            </shape>
+
+            <!-- +z -->
+            <shape type="BooleanShape" operation="Subtraction" material="Air">
+              <shape type="Tube" rmin="LumiCal_inner_radius - env_safety" rmax="Lcal_services_rmax + env_safety" dz="LumiCal_max_z/COS_halfCrossingAngle + env_safety"/>
+              <shape type="Tube" rmin="0.0" rmax="Lcal_services_rmax + 1.5*env_safety" dz="LumiCal_min_z/COS_halfCrossingAngle+LumiCal_thickness - env_safety"/>
+              <position x="0" y="0" z="-LumiCal_thickness"/>
+            </shape>
+
+            <!-- Angle between -z and +z -->
+            <rotation x="0" y="CepC_Main_Crossing_Angle" z="0"/>
+            <position x="0" y="0" z="0"/>
+          </shape>
+
+          <!-- Use big box to define the global coordination -->
+          <rotation x="0" y="-CepC_Main_Crossing_Angle*0.5" z="0"/>
+          <position x="0" y="0" z="0"/>
+        </shape>
+      </envelope>
+
+      <!-- layerstaggerphi is in cellPhiSize units i.e. 0.5 means the stagger is 0.5*cellPhiSize -->
+      <parameter crossingangle="CepC_Main_Crossing_Angle"
+                 cutoutspanningangle="40*deg"
+                 incomingbeampiperadius="BCal_TubeIncomingRadius"
+                 />
+
+      <dimensions inner_r = "LumiCal_inner_radius"
+                  inner_z = "LumiCal_min_z"
+                  outer_r = "LumiCal_outer_radius"
+                  servicesRmax = "Lcal_services_rmax"
+                  layerstagger = "0.5"
+                  outerPhi0    = "Lcal_offset_phi"
+                  modules = "Lcal_n_tiles"
+                  phi_sectors = "Lcal_nstrips_phi/Lcal_n_tiles"
+                  r_sectors = "Lcal_nstrips_theta"
+                  phi_gap = "2.*Lcal_tile_gap"
+                  r_gap = "Lcal_tile_gap" />
+
+
+      <layer repeat="30" vis="SeeThrough">
+        <slice material = "TungstenDens24" thickness = "Lcal_tungsten_thickness"                   vis="BCLayerVis1"/>
+        <slice material = "fanele1" thickness = "( Lcal_support_thickness - 0.02*mm) / 2."     vis="Invisible"/>
+        <slice material = "Silicon" thickness = "Lcal_silicon_thickness"        sensitive = "yes"  vis="BCLayerVis2"/>
+        <slice material = "G4_Al"   thickness = "0.02*mm"                                      vis="BCLayerVis3"/>
+        <slice material = "fanele2" thickness = "( Lcal_support_thickness - 0.02*mm) / 2."      vis="Invisible"/>
+        <slice material = "Air"     thickness = "Lcal_layer_gap" />
+      </layer>
+
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="LumiCalCollection">
+      <segmentation type="PolarGridRPhi"
+                    grid_size_r="(Lcal_sensor_rmax-Lcal_sensor_rmin)/Lcal_nstrips_theta"
+                    grid_size_phi="360/Lcal_nstrips_phi*degree"
+                    offset_r="Lcal_sensor_rmin"
+                    offset_phi="Lcal_offset_phi"
+                    />
+      <id>system:8,barrel:3,layer:8,slice:8,r:32:-16,phi:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/SEcal05_siw_Barrel.xml b/Detector/DetCEPCv4/compact/SEcal05_siw_Barrel.xml
new file mode 100644
index 0000000000000000000000000000000000000000..a1cb5b4ea23fabf1a1f1a5aa07d2c2d15a29b2ae
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/SEcal05_siw_Barrel.xml
@@ -0,0 +1,97 @@
+<lccdd>
+  <detectors>
+
+    <detector name="EcalBarrel" type="SEcal05_Barrel" id="ILDDetID_ECAL" readout="EcalBarrelCollection" vis="BlueVis" >
+
+      <comment>EM Calorimeter Barrel</comment>
+
+      <envelope vis="ILD_ECALVis">
+        <shape type="PolyhedraRegular" numsides="Ecal_symmetry"  rmin="Ecal_inner_radius - env_safety"
+               rmax="Ecal_outer_radius + env_safety" dz="2.*Ecal_half_length + env_safety"  material = "Air" vis="Invisible" />
+        <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/Ecal_symmetry"/>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_ELECTROMAGNETIC " />
+
+
+      <dimensions numsides="Ecal_symmetry" rmin="Ecal_inner_radius" rmax="Ecal_outer_radius" z="Ecal_half_length" />
+      <staves  material = "G4_W"  vis="BlueVis"/>
+
+      <!-- this has all sort of assumptions in it...like even/odd number in first/second stack -->
+
+      <layer repeat="Ecal_nlayers1/2" vis="SeeThrough" >
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."   vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness" vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"         vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="Invisible"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"    thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"           thickness = "Ecal_radiator_layers_set1_thickness"   vis="BlueVis"   radiator="yes"/>
+        <slice material = "CarbonFiber"    thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="Invisible"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+
+      <layer repeat="(Ecal_nlayers2+1)/2" vis="SeeThrough">
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="Invisible"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"    thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"           thickness = "Ecal_radiator_layers_set2_thickness"   vis="BlueVis"   radiator="yes"/>
+        <slice material = "CarbonFiber"    thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="Invisible"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="EcalBarrelCollection">
+      <segmentation type="MegatileLayerGridXY"/>
+      <id>system:5,module:3,stave:4,tower:5,layer:6,wafer:6,cellX:32:-16,cellY:-16</id>
+    </readout>
+  </readouts>
+
+  <plugins>
+    <plugin name="DD4hep_CaloFaceBarrelSurfacePlugin">
+      <argument value="EcalBarrel"/>
+      <argument value="length=2.*Ecal_half_length"    />
+      <argument value="radius=Ecal_inner_radius"  />
+      <argument value="phi0=0"    />
+      <argument value="symmetry=Ecal_symmetry"/>
+      <argument value="systemID=ILDDetID_ECAL"/>
+      <comment> <argument value="encoding=system:5,side:-2,layer:9,module:8,sensor:8"/> </comment>
+    </plugin>
+  </plugins>
+  
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/SEcal05_siw_ECRing.xml b/Detector/DetCEPCv4/compact/SEcal05_siw_ECRing.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d4cde98f4497ecd9081e48bb2bdccf0dda972360
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/SEcal05_siw_ECRing.xml
@@ -0,0 +1,90 @@
+<lccdd>
+
+  <detectors>
+    <detector name="EcalPlug" type="SEcal05_ECRing" id="ILDDetID_ECAL_PLUG" readout="EcalEndcapRingCollection" vis="BlueVis" >
+      <comment>EM Calorimeter Endcaps</comment>
+
+      <envelope vis="ILD_ECALVis">
+        <shape type="BooleanShape" operation="Subtraction" material="Air">
+          <shape type="BooleanShape" operation="Subtraction" material="Air">
+            <shape type="Box" dx="EcalEndcapRing_outer_radius + env_safety" dy="EcalEndcapRing_outer_radius + env_safety"
+                   dz="EcalEndcapRing_max_z + env_safety"/>
+            <shape type="Tube" rmin="0" rmax="EcalEndcapRing_inner_radius - env_safety" dz="2.0*EcalEndcapRing_max_z + env_safety"/>
+
+            <position x="0.5*(EcalEndcapRing_min_z + EcalEndcapRing_max_z)*tan(CepC_Main_Crossing_Angle/2)" y="0" z="0"/>
+            <!-- position x="0" y="0" z="0"/ -->
+
+          </shape>
+          <shape type="Box" dx="EcalEndcapRing_outer_radius + 1.5*env_safety" dy="EcalEndcapRing_outer_radius + 1.5*env_safety"
+                 dz="EcalEndcapRing_min_z - env_safety"/>
+        </shape>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_ELECTROMAGNETIC + DetType_AUXILIARY " />
+
+      <staves  material = "G4_W"  vis="GreenVis"/>
+
+      <layer repeat="Ecal_nlayers1/2" vis="SeeThrough" >
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     limits="cal_limits" vis="RedVis"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"   thickness = "Ecal_radiator_layers_set1_thickness"   vis="GreenVis"   />
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     limits="cal_limits" vis="RedVis"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+      <layer repeat="(Ecal_nlayers2+1)/2" vis="SeeThrough">
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     limits="cal_limits" vis="RedVis"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"   thickness = "Ecal_radiator_layers_set2_thickness"   vis="GreenVis"   />
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     limits="cal_limits" vis="RedVis"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="EcalEndcapRingCollection">
+      <segmentation type="CartesianGridXY" grid_size_x="Ecal_cells_size" grid_size_y="Ecal_cells_size"/>
+      <id>system:5,module:3,stave:4,tower:3,layer:6,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+
+
+</lccdd>
+
diff --git a/Detector/DetCEPCv4/compact/SEcal05_siw_Endcaps.xml b/Detector/DetCEPCv4/compact/SEcal05_siw_Endcaps.xml
new file mode 100644
index 0000000000000000000000000000000000000000..58931301fe84f2cff3bca62594778d319b46422f
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/SEcal05_siw_Endcaps.xml
@@ -0,0 +1,101 @@
+<lccdd>
+  <detectors>
+
+    <detector name="EcalEndcap" type="SEcal05_Endcaps" id="ILDDetID_ECAL_ENDCAP" readout="EcalEndcapsCollection" vis="BlueVis" >
+      <comment>EM Calorimeter Endcaps</comment>
+
+      <envelope vis="ILD_ECALVis">
+        <shape type="BooleanShape" operation="Subtraction" material="Air">
+          <shape type="BooleanShape" operation="Subtraction" material="Air">
+            <shape type="PolyhedraRegular"  numsides="EcalEndcap_symmetry" rmin="0"
+                   rmax="EcalEndcap_outer_radius + env_safety" dz="2.0*EcalEndcap_max_z + env_safety"/>
+            <shape type="PolyhedraRegular"  numsides="EcalEndcap_symmetry" rmin="0"
+                   rmax="EcalEndcap_outer_radius + 2.*env_safety" dz="2.0*EcalEndcap_min_z - env_safety"/>
+          </shape>
+          <shape type="Box" dx="EcalEndcap_inner_radius - env_safety"
+                 dy="EcalEndcap_inner_radius - env_safety" dz="(EcalEndcap_max_z + env_safety )"/>
+          <rotation x="0*deg" y="0*deg" z="-180*deg/EcalEndcap_symmetry"/>
+        </shape>
+        <rotation x="0*deg" y="0*deg" z="180*deg/EcalEndcap_symmetry"/>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_ELECTROMAGNETIC " />
+
+      <staves  material = "G4_W"  vis="BlueVis"/>
+
+      <layer repeat="Ecal_nlayers1/2" vis="SeeThrough" >
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="RedVis"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"   thickness = "Ecal_radiator_layers_set1_thickness"   vis="BlueVis"   />
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="RedVis"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+
+      <layer repeat="(Ecal_nlayers2+1)/2" vis="SeeThrough">
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="RedVis"    />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+        <slice material = "G4_W"   thickness = "Ecal_radiator_layers_set2_thickness"   vis="BlueVis"   />
+        <slice material = "CarbonFiber"         thickness = "Ecal_fiber_thickness_slabAbs"                    vis="Invisible" />
+	<!--slice material = "G4_AIR"         thickness = "1e-9*mm"                      vis="Invisible" /-->
+        <slice material = "GroundOrHVMix"  thickness = "Ecal_Slab_ground_thickness"              vis="Invisible" />
+        <!--slice material = "G4_AIR"         thickness = "2e-9*mm"                      vis="Invisible" /-->
+        <slice material = "Si"             thickness = "Ecal_Si_thickness" sensitive = "yes"     vis="RedVis"    />
+        <slice material = "G4_AIR"         thickness = "Ecal_Slab_glue_gap"                      vis="Invisible" />
+	<slice material = "PCB"            thickness = "Ecal_Slab_PCB_thickness"    vis="Invisible"/>
+	<slice material = "G4_AIR"         thickness = "Ecal_Slab_ASIC_thickness"   vis="Invisible"/>
+	<slice material = "G4_Cu"          thickness = "Ecal_Slab_copper_thickness"        vis="Invisible" />
+	<slice material = "G4_Al"          thickness = "Ecal_Slab_shielding"        vis="Invisible" />
+        <slice material = "G4_AIR"         thickness = "Ecal_Alveolus_Air_Gap/2."                vis="Invisible" />
+      </layer>
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="EcalEndcapsCollection">
+      <segmentation type="MegatileLayerGridXY"/>
+      <id>system:5,module:3,stave:4,tower:5,layer:6,wafer:6,cellX:32:-16,cellY:-16</id>
+    </readout>
+  </readouts>
+
+  <plugins>
+    <plugin name="DD4hep_CaloFaceEndcapSurfacePlugin">
+      <argument value="EcalEndcap"/>
+      <argument value="zpos=EcalEndcap_min_z"    />
+      <argument value="radius=EcalEndcap_outer_radius"  />
+      <argument value="phi0=0"    />
+      <argument value="symmetry=EcalEndcap_symmetry"/>
+      <argument value="systemID=ILDDetID_ECAL_ENDCAP"/>
+      <comment> <argument value="encoding=system:5,side:-2,layer:9,module:8,sensor:8"/> </comment>
+    </plugin>
+  </plugins>
+
+  
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/SServices00.xml b/Detector/DetCEPCv4/compact/SServices00.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d34161c48a4cac746eeb9ad13d158ee8d4195c1f
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/SServices00.xml
@@ -0,0 +1,15 @@
+<!-- 
+     SService00 parameters for ILD_*_v2
+-->
+<lccdd>
+<detectors>
+
+<detector name="SServices00" type="SServices00" id="ILDDetID_NOTUSED" vis="RedVis" insideTrackingVolume="false" sensitive="no">
+  <type_flags type=" DetType_SUPPORT " />
+  
+  <TPC_Cooling number_of_rings="0"/> <!-- Daniel's understanding (via Dimitra) -->
+
+
+</detector>
+</detectors>
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/Yoke05_Barrel.xml b/Detector/DetCEPCv4/compact/Yoke05_Barrel.xml
new file mode 100644
index 0000000000000000000000000000000000000000..00c8d26420b532947ee63a14c43542c267b8f352
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Yoke05_Barrel.xml
@@ -0,0 +1,37 @@
+<!-- comment>Calorimeters</comment -->
+<lccdd>
+  <detectors>
+    <detector name="YokeBarrel" type="Yoke05_Barrel" id="ILDDetID_YOKE" readout="YokeBarrelCollection" vis="YellowVis" insideTrackingVolume="false" buildType="BUILD_ENVELOPE">
+      <envelope vis="ILD_YOKEVis">
+        <shape type="BooleanShape" operation="Intersection" material="Air" >
+          <shape type="Box" dx="Yoke_outer_radius + env_safety" dy="Yoke_outer_radius + env_safety"
+                 dz="Yoke_half_length + env_safety"/> <!--Box defined the coordinate system-->
+          <shape type="PolyhedraRegular" numsides="Yoke_symmetry"  rmin="Yoke_inner_radius"
+                 rmax="Yoke_outer_radius" dz="2.0*Yoke_half_length"  material = "Air" />
+          <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/Yoke_symmetry"/>
+        </shape>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_BARREL + DetType_MUON " />
+
+      <dimensions numsides="Yoke_symmetry" rmin="Yoke_inner_radius" rmax="Yoke_outer_radius"
+                  zhalf="Yoke_half_length"  material="Air"/>
+      <position x="0*mm" y="0*mm" z="0*mm"/>
+      <rotation x="0*deg" y="0*deg" z="0*deg"/>
+      <staves  material = "Iron"  vis="BlueVis"/>
+      <layer repeat="14" vis="SeeThrough">
+        <slice material = "Air"            thickness = "15.0*mm"                    vis="YellowVis" />
+        <slice material = "G4_POLYSTYRENE" thickness = "10.0*mm" sensitive = "yes"  vis="CyanVis"   />
+        <slice material = "Air"            thickness = "15.0*mm"                    vis="YellowVis" />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="YokeBarrelCollection">
+      <segmentation type="CartesianGridXZ" grid_size_x="Yoke_cells_size" grid_size_z="Yoke_cells_size"/>
+      <id>system:5,module:3,stave:4,tower:3,layer:6,x:32:-16,z:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/Yoke05_Endcaps.xml b/Detector/DetCEPCv4/compact/Yoke05_Endcaps.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6115d54d883e03bb70002cba6ae92bd9314621cd
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/Yoke05_Endcaps.xml
@@ -0,0 +1,44 @@
+<!-- comment>Calorimeters</comment -->
+<lccdd>
+  <detectors>
+    <detector name="YokeEndcap" type="Yoke05_Endcaps" id="ILDDetID_YOKE_ENDCAP" readout="YokeEndcapsCollection" vis="YellowVis" insideTrackingVolume="false" >
+
+      <envelope vis="ILD_YOKEVis">
+        <shape type="BooleanShape" operation="Subtraction" material="Air">
+          <shape type="BooleanShape" operation="Subtraction" material="Air">
+            <shape type="BooleanShape" operation="Intersection" material="Air">
+              <shape type="Box" dx="YokeEndcap_outer_radius + 1.5*env_safety" dy="YokeEndcap_outer_radius + 1.5*env_safety"
+                     dz="YokeEndcap_max_z + env_safety"/>
+              <shape type="PolyhedraRegular" numsides="YokeEndcap_symmetry"  rmin="YokeEndcap_inner_radius - env_safety"
+                     rmax="YokeEndcap_outer_radius + env_safety" dz="2.*YokeEndcap_max_z + env_safety" />
+              <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/YokeEndcap_symmetry"/>
+            </shape>
+            <shape type="Box" dx="YokeEndcap_outer_radius + 1.5*env_safety" dy="YokeEndcap_outer_radius + 1.5*env_safety"
+                   dz="YokeEndcapPlug_min_z - env_safety"/>
+          </shape>
+          <shape type="PolyhedraRegular" numsides="YokeEndcapPlug_symmetry"  rmin="YokeEndcapPlug_outer_radius + env_safety"
+                 rmax="YokeEndcap_outer_radius + 2.0*env_safety" dz="2.*YokeEndcap_min_z - env_safety" />
+          <rotation x="0*deg" y="0*deg" z="90*deg-180*deg/YokeEndcapPlug_symmetry"/>
+        </shape>
+      </envelope>
+
+      <type_flags type=" DetType_CALORIMETER + DetType_ENDCAP + DetType_MUON " />
+
+      <dimensions numsides="12" rmin="Yoke_inner_radius" z="Yoke_barrel_halfZ" />
+      <material name="Iron"/>
+      <layer repeat="12" vis="SeeThrough">
+        <slice material = "Air"            thickness = "15.0*mm"                    vis="YellowVis" />
+        <slice material = "G4_POLYSTYRENE" thickness = "10.0*mm" sensitive = "yes"  vis="CyanVis"   />
+        <slice material = "Air"            thickness = "15.0*mm"                    vis="YellowVis" />
+      </layer>
+    </detector>
+  </detectors>
+
+  <readouts>
+    <readout name="YokeEndcapsCollection">
+      <segmentation type="CartesianGridXY" grid_size_x="Yoke_cells_size" grid_size_y="Yoke_cells_size"/>
+      <id>system:5,module:3,stave:4,tower:3,layer:6,x:32:-16,y:-16</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/basic_defs.xml b/Detector/DetCEPCv4/compact/basic_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..aae7f42f3f30ae849ae11a3cc05e7d015f783824
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/basic_defs.xml
@@ -0,0 +1,33 @@
+<define>
+
+  <constant name="world_side"             value="30*m"/>
+  <constant name="world_x"                value="world_side/2"/>
+  <constant name="world_y"                value="world_side/2"/>
+  <constant name="world_z"                value="world_side/2"/>
+
+  <constant name="ILDDetID_NOTUSED"      value="  0"/>
+  <constant name="ILDDetID_VXD"          value="  1"/>
+  <constant name="ILDDetID_SIT"          value="  2"/>
+  <constant name="ILDDetID_FTD"          value="  3"/>
+  <constant name="ILDDetID_TPC"          value="  4"/>
+  <constant name="ILDDetID_SET"          value="  5"/>
+  <constant name="ILDDetID_ETD"          value="  6"/>
+
+  <constant name="ILDDetID_ECAL"         value=" 20"/>
+  <constant name="ILDDetID_ECAL_PLUG"    value=" 21"/>
+  <constant name="ILDDetID_HCAL"         value=" 22"/>
+  <constant name="ILDDetID_HCAL_RING"    value=" 23"/>
+  <constant name="ILDDetID_LCAL"         value=" 24"/>
+  <constant name="ILDDetID_BCAL"         value=" 25"/>
+  <constant name="ILDDetID_LHCAL"        value=" 26"/>
+  <constant name="ILDDetID_YOKE"         value=" 27"/>
+  <constant name="ILDDetID_COIL"         value=" 28"/>
+  <constant name="ILDDetID_ECAL_ENDCAP"  value=" 29"/>
+  <constant name="ILDDetID_HCAL_ENDCAP"  value=" 30"/>
+  <constant name="ILDDetID_YOKE_ENDCAP"  value=" 31"/>
+
+  <constant name="ILDDetID_bwd"       value="- 1"/>
+  <constant name="ILDDetID_barrel"    value="  0"/>
+  <constant name="ILDDetID_fwd"       value="  1"/>
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/coil03.xml b/Detector/DetCEPCv4/compact/coil03.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3f176d2827f53c0cab3790f2c0d5dc0e494a94fd
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/coil03.xml
@@ -0,0 +1,30 @@
+<!-- 
+     Coil parameters for ILD_o1_v5  
+-->
+<lccdd>
+<detectors>
+
+<detector name="Coil" type="SCoil02" vis="CoilVis" id="ILDDetID_COIL" insideTrackingVolume="false" sensitive="no">
+
+  <!-- fg: taken from SCoil02.cc::PreLoadScriptAction() : 
+       there the variable Hcal_R_max was used, which was set from Hcal_module_radius in the SHcal driver - 
+       here we simply use the value Hcal_outer_radius defined in ILD_l1_v01
+
+       -> now (03/2015) done in main compact file ILD_l1_v01.xml
+  -->
+
+  <envelope vis="ILD_COILVis">
+    <shape type="Tube" rmin="Coil_inner_radius" rmax="Coil_outer_radius" 
+	   dz="Coil_half_length" material="Air"/>
+  </envelope>
+
+  <type_flags type=" DetType_SUPPORT + DetType_COIL " />
+
+  <!--fg: for now only a simple aluminum cylinder is created inside the envelope -->
+  <tube rmin="Coil_inner_radius+env_safety" rmax="Coil_outer_radius-env_safety" 
+	dz="Coil_half_length-env_safety" material="G4_Al"/>
+
+</detector>
+
+</detectors>
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/detector_types.xml b/Detector/DetCEPCv4/compact/detector_types.xml
new file mode 100644
index 0000000000000000000000000000000000000000..60a3d4f90ed03c0cefdf13c8289345bfbb0ac9c6
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/detector_types.xml
@@ -0,0 +1,74 @@
+<!--
+    define global constants with enums defined in 
+    $DD4hepINSTALL/DDCore/include/DD4hep/DetType.h
+    NB: if that file is changed this file needs to
+        be manually updated correspondingly !!
+
+   author: F.Gaede, DESY 02/2016
+-->
+<define>
+  <constant name="DetType_TRACKER"         value =  " 0x1 "/>
+  <constant name="DetType_CALORIMETER"     value =  " 0x2 "/>
+  <constant name="DetType_CHERENKOV"       value =  " 0x4 "/>
+  <constant name="DetType_ENDCAP"          value =  " 0x8 "/>
+  <constant name="DetType_BARREL"          value =  " 0x10 "/>
+  <constant name="DetType_FORWARD"         value =  " 0x20 "/>
+  <constant name="DetType_VERTEX"          value =  " 0x40 "/>
+  <constant name="DetType_STRIP"           value =  " 0x80 "/>
+  <constant name="DetType_PIXEL"           value =  " 0x100 "/>
+  <constant name="DetType_GASEOUS"         value =  " 0x200 "/>
+  <constant name="DetType_WIRE"            value =  " 0x400 "/>
+  <constant name="DetType_ELECTROMAGNETIC" value =  " 0x800 "/>
+  <constant name="DetType_HADRONIC"        value =  " 0x1000 "/>
+  <constant name="DetType_MUON"            value =  " 0x2000 "/>
+  <constant name="DetType_SUPPORT"         value =  " 0x4000 "/>
+  <constant name="DetType_BEAMPIPE"        value =  " 0x8000 "/>
+  <constant name="DetType_COIL"            value =  " 0x10000 "/>
+  <constant name="DetType_AUXILIARY"       value =  " 0x20000 "/>
+  <!-- <constant name="DetType_bit_ 18 " value =  " 0x40000 "/> -->
+  <!-- <constant name="DetType_bit_ 19 " value =  " 0x80000 "/> -->
+  <!-- <constant name="DetType_bit_ 20 " value =  " 0x100000 "/> -->
+  <!-- <constant name="DetType_bit_ 21 " value =  " 0x200000 "/> -->
+  <!-- <constant name="DetType_bit_ 22 " value =  " 0x400000 "/> -->
+  <!-- <constant name="DetType_bit_ 23 " value =  " 0x800000 "/> -->
+  <!-- <constant name="DetType_bit_ 24 " value =  " 0x1000000 "/> -->
+  <!-- <constant name="DetType_bit_ 25 " value =  " 0x2000000 "/> -->
+  <!-- <constant name="DetType_bit_ 26 " value =  " 0x4000000 "/> -->
+  <!-- <constant name="DetType_bit_ 27 " value =  " 0x8000000 "/> -->
+  <!-- <constant name="DetType_bit_ 28 " value =  " 0x10000000 "/> -->
+  <!-- <constant name="DetType_bit_ 29 " value =  " 0x20000000 "/> -->
+  <!-- <constant name="DetType_bit_ 30 " value =  " 0x40000000 "/> -->
+  <!-- <constant name="DetType_bit_ 31 " value =  " 0x80000000 "/> -->
+  <!-- <constant name="DetType_bit_ 32 " value =  " 0x100000000 "/> -->
+  <!-- <constant name="DetType_bit_ 33 " value =  " 0x200000000 "/> -->
+  <!-- <constant name="DetType_bit_ 34 " value =  " 0x400000000 "/> -->
+  <!-- <constant name="DetType_bit_ 35 " value =  " 0x800000000 "/> -->
+  <!-- <constant name="DetType_bit_ 36 " value =  " 0x1000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 37 " value =  " 0x2000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 38 " value =  " 0x4000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 39 " value =  " 0x8000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 40 " value =  " 0x10000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 41 " value =  " 0x20000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 42 " value =  " 0x40000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 43 " value =  " 0x80000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 44 " value =  " 0x100000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 45 " value =  " 0x200000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 46 " value =  " 0x400000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 47 " value =  " 0x800000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 48 " value =  " 0x1000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 49 " value =  " 0x2000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 50 " value =  " 0x4000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 51 " value =  " 0x8000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 52 " value =  " 0x10000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 53 " value =  " 0x20000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 54 " value =  " 0x40000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 55 " value =  " 0x80000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 56 " value =  " 0x100000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 57 " value =  " 0x200000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 58 " value =  " 0x400000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 59 " value =  " 0x800000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 60 " value =  " 0x1000000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 61 " value =  " 0x2000000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 62 " value =  " 0x4000000000000000 "/> -->
+  <!-- <constant name="DetType_bit_ 63 " value =  " 0x8000000000000000 "/> -->
+</define>
diff --git a/Detector/DetCEPCv4/compact/display.xml b/Detector/DetCEPCv4/compact/display.xml
new file mode 100644
index 0000000000000000000000000000000000000000..edce857792caffe2c79ee4569620e39a7e3ce521
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/display.xml
@@ -0,0 +1,52 @@
+  <display>
+    <!-- fixme:  white comes out as red !!!???? |  vis name="WhiteVis"         alpha="0.0" r="1.0" g="1.0"  b="1.0"   showDaughters="true"  visible="true"/ -->
+    <vis name="WhiteVis"         alpha="0.0" r=".96" g=".96"  b=".96"   showDaughters="true"  visible="true"/>
+    <vis name="LightGrayVis"         alpha="0.0" r=".75" g=".75"  b=".75"   showDaughters="true"  visible="true"/>
+    <vis name="Invisible"         alpha="0.0" r="0" g="0"  b="0"   showDaughters="false"  visible="false"/>
+    <vis name="SeeThrough"         alpha="0.0" r="0" g="0"  b="0"   showDaughters="true"  visible="false"/>
+    <vis name="RedVis"           alpha="1.0" r="1.0" g="0.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="GreenVis"         alpha="1.0" r="0.0" g="1.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="BlueVis"          alpha="1.0" r="0.0" g="0.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="CyanVis"          alpha="1.0" r="0.0" g="1.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="MagentaVis"       alpha="1.0" r="1.0" g="0.0"  b="1.0"   showDaughters="true"  visible="true"/>
+    <vis name="YellowVis"        alpha="1.0" r="1.0" g="1.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="BlackVis"         alpha="1.0" r="0.0" g="0.0"  b="0.0"   showDaughters="true"  visible="true"/>
+    <vis name="GrayVis"          alpha="1.0" r="0.5" g="0.5"  b="0.5"   showDaughters="true"  visible="true"/>
+
+    <vis name="TubeVis"   alpha="0.1" r="1.0" g="0.7"  b="0.5"   showDaughters="true"  visible="true"/>
+    <vis name="BeamPipeVis" alpha="0.0" r="0.0" g="1.0" b="0.0" showDaughters="true" visible="false"/>
+    <vis name="VacVis"   alpha="1.0" r="0.0" g="0.0"  b="0.0"   showDaughters="true"  visible="false"/>
+
+    <vis name="TPCVis"        alpha="0.1" r="0" g="0"  b="0"         showDaughters="true"  visible="true"/>
+    <vis name="TPCMotherVis"  alpha="0.1" r="0.9" g="0.9"  b="0.9"   showDaughters="true"  visible="false"/>
+
+    <vis name="VXDVis"        alpha="0.1" r="0.1" g=".5"  b=".5"   showDaughters="true"  visible="true"/>
+    <vis name="VXDLayerVis"   alpha="1.0" r="0.1" g=".5"  b=".5"   showDaughters="true"  visible="true"/>
+    <vis name="VXDSupportVis" alpha="1.0" r="0.0" g="1.0" b="0.0"  showDaughters="true"  visible="true"/>
+
+    <vis name="FTDVis"           alpha="1.0" r="0.0" g="0.1"  b="0.0"   showDaughters="true"  visible="false"/>
+    <vis name="FTDSensitiveVis" alpha="1.0"  r="1.0"  g="1.0" b="0.45" showDaughters="true" visible="true"/>
+    <vis name="FTDSupportVis"   alpha="1.0"  r="1.0"  g="0.5" b="0.5"  showDaughters="true" visible="true"/>
+    <vis name="FTDHolePetalVis" alpha="1.0"  r="0.5"  g="0.5" b="1.0" showDaughters="true" visible="true"/>
+    <vis name="FTDCylVis"       alpha="0.45" r="0.2"  g="0.9" b="0.98" showDaughters="true" visible="true"/>
+    <vis name="FTDCablesVis"    alpha="1.0"  r="0.0"  g="0.9" b="0.0"  showDaughters="true" visible="true"/>
+
+    <vis name="MyBeamCalVis"  alpha="0.5"  r="1.0" g="1.0"  b="1.0" showDaughters="true"  visible="false"/>
+    <vis name="BCLayerVis1"   alpha="1.0"  r="1.0" g="0.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="BCLayerVis2"   alpha="1.0"  r="0.0" g="1.0"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="BCLayerVis3"   alpha="1.0"  r="0.0" g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+    <vis name="BCLayerVis4"   alpha="1.0"  r="1.0" g="0.0"  b="1.0" showDaughters="true"  visible="true"/>
+
+    <!-- colors used in Mokka and CED for ILD -->
+    <vis name="ILD_SITVis"  alpha="1.0" r="0.86" g="0.86"  b="0.86" showDaughters="true"  visible="true"/>
+    <vis name="ILD_SETVis"  alpha="1.0" r="0.86" g="0.86"  b="0.86" showDaughters="true"  visible="true"/>
+    <vis name="ILD_TPCVis"  alpha="1.0" r="0.96" g="0.95"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="ILD_ECALVis" alpha="1.0" r="0.48" g="0.95"  b="0.0" showDaughters="true"  visible="true"/>
+    <vis name="ILD_HCALVis" alpha="1.0" r="0.76" g="0.76"  b="0.19" showDaughters="true"  visible="true"/>
+    <vis name="ILD_YOKEVis" alpha="1.0" r="0.09" g="0.76"  b="0.76" showDaughters="true"  visible="true"/>
+    <vis name="ILD_COILVis" alpha="1.0" r="0.28" g="0.28"  b="0.86" showDaughters="true"  visible="true"/>
+    <vis name="ILD_FTDVis"  alpha="1.0" r="0.39" g="0.1"   b="0.57" showDaughters="true"  visible="true"/>
+    <vis name="ILD_FCALVis" alpha="1.0" r="0.67" g="0.66"  b="0.67" showDaughters="true"  visible="true"/>
+
+  </display>
+
diff --git a/Detector/DetCEPCv4/compact/ecal_defs.xml b/Detector/DetCEPCv4/compact/ecal_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..53243de3a495a5fa877c67a56ec0f3f370ad3203
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/ecal_defs.xml
@@ -0,0 +1,57 @@
+<define>
+
+  <constant name="Ecal_Barrel_halfZ" value="TPC_Ecal_Hcal_barrel_halfZ"/>
+
+  <constant name="Ecal_nlayers1" value="20"/>
+  <constant name="Ecal_nlayers2" value="10"/>
+  <constant name="Ecal_nlayers3" value="0"/>
+  <constant name="Ecal_radiator_layers_set1_thickness" value="2.1*mm"/>
+  <constant name="Ecal_radiator_layers_set2_thickness" value="4.2*mm"/>
+  <constant name="Ecal_radiator_layers_set3_thickness" value="0*mm"/>
+
+  <constant name="Ecal_barrel_number_of_towers" value="5"/>
+
+  <constant name="Ecal_fiber_thickness_structure" value="0.42*mm"/> <!-- 0.5*(3.82 - 2.1 - 2*0.44)=  -->
+  <constant name="Ecal_fiber_thickness_alveolus" value="0.44*mm"/> <!--  0.88 / 2 -->
+  <constant name="Ecal_fiber_thickness_slabAbs" value="0.15*mm"/>
+
+  <constant name="Ecal_front_face_thickness" value="0.66*mm"/> <!-- 4.04 - 2.1 - 0.44 - 2*0.42  = 0.66 -->
+  <constant name="Ecal_support_thickness" value="14.49*mm"/> <!-- 14.93 - 0.44 -->
+
+  <constant name="Ecal_lateral_face_thickness" value="(1.10+0.5)*mm"/> <!-- 1.54 - 0.44  --> <!-- 0.5 for the 1mm tolerance between modules -->
+
+  <constant name="Ecal_Alveolus_Air_Gap" value="0.5*mm"/>
+  <constant name="Ecal_Si_thickness" value=".5*mm"/>
+  <constant name="Ecal_Slab_H_fiber_thickness" value="0.55*mm"/>
+  <constant name="Ecal_Slab_ASIC_thickness" value="1e-6*mm"/>
+  <constant name="Ecal_Slab_PCB_thickness" value="0.8*mm"/>
+  <constant name="Ecal_Slab_copper_thickness" value="0.40*mm"/>
+  <constant name="Ecal_Slab_glue_gap" value="0.1*mm"/>
+  <constant name="Ecal_Slab_ground_thickness" value="0.1*mm"/>
+  <constant name="Ecal_Slab_shielding" value="0.1*mm"/>
+
+  <constant name="Ecal_guard_ring_size" value="0.5*mm"/>
+  <constant name="Ecal_n_wafers_per_tower" value="2"/>
+
+  <constant name="Ecal_barrel_z_modules" value="5"/>
+  <constant name="Ecal_Barrel_Preshower" value="0"/>
+  <constant name="Ecal_layer_pattern" type="string" value="0"/>
+  <constant name="Ecal_end_of_slab_strategy" value="1"/>
+  <constant name="Ecal_cells_across_megatile" value="18"/>
+  <constant name="Ecal_strips_across_megatile" value="1"/>
+  <constant name="Ecal_strips_along_megatile" value="1"/>
+  <constant name="Ecal_Endcap_Preshower" value="0"/>
+
+  <!-- constant name="Ecal_cables_gap" value="100.*mm"/ -->
+  <constant name="Ecal_cables_gap" value="Ecal_endcap_zmin-TPC_Ecal_Hcal_barrel_halfZ"/>
+
+  <constant name="Ecal_Slab_Plug_length" value="8*mm"/>
+
+  <!-- needed only for ecal ring driver... -->
+  <constant name="Ecal_cells_size" value="10.*mm"/>
+  <constant name="Ecal_Sc_reflector_thickness" value="0.057*mm"/>
+  <constant name="Ecal_Sc_thickness" value="2.0*mm"/>
+  <constant name="Ecal_Slab_Sc_PCB_thickness" value="0.8*mm"/>
+
+</define>
+
diff --git a/Detector/DetCEPCv4/compact/elements.xml b/Detector/DetCEPCv4/compact/elements.xml
new file mode 100644
index 0000000000000000000000000000000000000000..e714c3a5cd544e748dd2941967cff515c0b77efc
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/elements.xml
@@ -0,0 +1,884 @@
+<materials>
+ <element Z="89" formula="Ac" name="Ac" >
+  <atom type="A" unit="g/mol" value="227.028" />
+ </element>
+ <material formula="Ac" name="Actinium" state="solid" >
+  <RL type="X0" unit="cm" value="0.601558" />
+  <NIL type="lambda" unit="cm" value="21.2048" />
+  <D type="density" unit="g/cm3" value="10.07" />
+  <composite n="1" ref="Ac" />
+ </material>
+ <element Z="47" formula="Ag" name="Ag" >
+  <atom type="A" unit="g/mol" value="107.868" />
+ </element>
+ <material formula="Ag" name="Silver" state="solid" >
+  <RL type="X0" unit="cm" value="0.854292" />
+  <NIL type="lambda" unit="cm" value="15.8546" />
+  <D type="density" unit="g/cm3" value="10.5" />
+  <composite n="1" ref="Ag" />
+ </material>
+ <element Z="13" formula="Al" name="Al" >
+  <atom type="A" unit="g/mol" value="26.9815" />
+ </element>
+ <material formula="Al" name="Aluminum" state="solid" >
+  <RL type="X0" unit="cm" value="8.89632" />
+  <NIL type="lambda" unit="cm" value="38.8766" />
+  <D type="density" unit="g/cm3" value="2.699" />
+  <composite n="1" ref="Al" />
+ </material>
+ <element Z="95" formula="Am" name="Am" >
+  <atom type="A" unit="g/mol" value="243.061" />
+ </element>
+ <material formula="Am" name="Americium" state="solid" >
+  <RL type="X0" unit="cm" value="0.42431" />
+  <NIL type="lambda" unit="cm" value="15.9812" />
+  <D type="density" unit="g/cm3" value="13.67" />
+  <composite n="1" ref="Am" />
+ </material>
+ <element Z="18" formula="Ar" name="Ar" >
+  <atom type="A" unit="g/mol" value="39.9477" />
+ </element>
+ <material formula="Ar" name="Argon" state="gas" >
+  <RL type="X0" unit="cm" value="11762.1" />
+  <NIL type="lambda" unit="cm" value="71926" />
+  <D type="density" unit="g/cm3" value="0.00166201" />
+  <composite n="1" ref="Ar" />
+ </material>
+ <element Z="33" formula="As" name="As" >
+  <atom type="A" unit="g/mol" value="74.9216" />
+ </element>
+ <material formula="As" name="Arsenic" state="solid" >
+  <RL type="X0" unit="cm" value="2.0838" />
+  <NIL type="lambda" unit="cm" value="25.7324" />
+  <D type="density" unit="g/cm3" value="5.73" />
+  <composite n="1" ref="As" />
+ </material>
+ <element Z="85" formula="At" name="At" >
+  <atom type="A" unit="g/mol" value="209.987" />
+ </element>
+ <material formula="At" name="Astatine" state="solid" >
+  <RL type="X0" unit="cm" value="0.650799" />
+  <NIL type="lambda" unit="cm" value="22.3202" />
+  <D type="density" unit="g/cm3" value="9.32" />
+  <composite n="1" ref="At" />
+ </material>
+ <element Z="79" formula="Au" name="Au" >
+  <atom type="A" unit="g/mol" value="196.967" />
+ </element>
+ <material formula="Au" name="Gold" state="solid" >
+  <RL type="X0" unit="cm" value="0.334436" />
+  <NIL type="lambda" unit="cm" value="10.5393" />
+  <D type="density" unit="g/cm3" value="19.32" />
+  <composite n="1" ref="Au" />
+ </material>
+ <element Z="5" formula="B" name="B" >
+  <atom type="A" unit="g/mol" value="10.811" />
+ </element>
+ <material formula="B" name="Boron" state="solid" >
+  <RL type="X0" unit="cm" value="22.2307" />
+  <NIL type="lambda" unit="cm" value="32.2793" />
+  <D type="density" unit="g/cm3" value="2.37" />
+  <composite n="1" ref="B" />
+ </material>
+ <element Z="56" formula="Ba" name="Ba" >
+  <atom type="A" unit="g/mol" value="137.327" />
+ </element>
+ <material formula="Ba" name="Barium" state="solid" >
+  <RL type="X0" unit="cm" value="2.37332" />
+  <NIL type="lambda" unit="cm" value="51.6743" />
+  <D type="density" unit="g/cm3" value="3.5" />
+  <composite n="1" ref="Ba" />
+ </material>
+ <element Z="4" formula="Be" name="Be" >
+  <atom type="A" unit="g/mol" value="9.01218" />
+ </element>
+ <material formula="Be" name="Beryllium" state="solid" >
+  <RL type="X0" unit="cm" value="35.276" />
+  <NIL type="lambda" unit="cm" value="39.4488" />
+  <D type="density" unit="g/cm3" value="1.848" />
+  <composite n="1" ref="Be" />
+ </material>
+ <element Z="83" formula="Bi" name="Bi" >
+  <atom type="A" unit="g/mol" value="208.98" />
+ </element>
+ <material formula="Bi" name="Bismuth" state="solid" >
+  <RL type="X0" unit="cm" value="0.645388" />
+  <NIL type="lambda" unit="cm" value="21.3078" />
+  <D type="density" unit="g/cm3" value="9.747" />
+  <composite n="1" ref="Bi" />
+ </material>
+ <element Z="97" formula="Bk" name="Bk" >
+  <atom type="A" unit="g/mol" value="247.07" />
+ </element>
+ <material formula="Bk" name="Berkelium" state="solid" >
+  <RL type="X0" unit="cm" value="0.406479" />
+  <NIL type="lambda" unit="cm" value="15.6902" />
+  <D type="density" unit="g/cm3" value="14" />
+  <composite n="1" ref="Bk" />
+ </material>
+ <element Z="35" formula="Br" name="Br" >
+  <atom type="A" unit="g/mol" value="79.9035" />
+ </element>
+ <material formula="Br" name="Bromine" state="gas" >
+  <RL type="X0" unit="cm" value="1615.12" />
+  <NIL type="lambda" unit="cm" value="21299" />
+  <D type="density" unit="g/cm3" value="0.0070721" />
+  <composite n="1" ref="Br" />
+ </material>
+ <element Z="6" formula="C" name="C" >
+  <atom type="A" unit="g/mol" value="12.0107" />
+ </element>
+ <material formula="C" name="Carbon" state="solid" >
+  <RL type="X0" unit="cm" value="21.3485" />
+  <NIL type="lambda" unit="cm" value="40.1008" />
+  <D type="density" unit="g/cm3" value="2" />
+  <composite n="1" ref="C" />
+ </material>
+ <element Z="20" formula="Ca" name="Ca" >
+  <atom type="A" unit="g/mol" value="40.078" />
+ </element>
+ <material formula="Ca" name="Calcium" state="solid" >
+  <RL type="X0" unit="cm" value="10.4151" />
+  <NIL type="lambda" unit="cm" value="77.3754" />
+  <D type="density" unit="g/cm3" value="1.55" />
+  <composite n="1" ref="Ca" />
+ </material>
+ <element Z="48" formula="Cd" name="Cd" >
+  <atom type="A" unit="g/mol" value="112.411" />
+ </element>
+ <material formula="Cd" name="Cadmium" state="solid" >
+  <RL type="X0" unit="cm" value="1.03994" />
+  <NIL type="lambda" unit="cm" value="19.46" />
+  <D type="density" unit="g/cm3" value="8.65" />
+  <composite n="1" ref="Cd" />
+ </material>
+ <element Z="58" formula="Ce" name="Ce" >
+  <atom type="A" unit="g/mol" value="140.115" />
+ </element>
+ <material formula="Ce" name="Cerium" state="solid" >
+  <RL type="X0" unit="cm" value="1.19506" />
+  <NIL type="lambda" unit="cm" value="27.3227" />
+  <D type="density" unit="g/cm3" value="6.657" />
+  <composite n="1" ref="Ce" />
+ </material>
+ <element Z="98" formula="Cf" name="Cf" >
+  <atom type="A" unit="g/mol" value="251.08" />
+ </element>
+ <material formula="Cf" name="Californium" state="solid" >
+  <RL type="X0" unit="cm" value="0.568328" />
+  <NIL type="lambda" unit="cm" value="22.085" />
+  <D type="density" unit="g/cm3" value="10" />
+  <composite n="1" ref="Cf" />
+ </material>
+ <element Z="17" formula="Cl" name="Cl" >
+  <atom type="A" unit="g/mol" value="35.4526" />
+ </element>
+ <material formula="Cl" name="Chlorine" state="gas" >
+  <RL type="X0" unit="cm" value="6437.34" />
+  <NIL type="lambda" unit="cm" value="38723.9" />
+  <D type="density" unit="g/cm3" value="0.00299473" />
+  <composite n="1" ref="Cl" />
+ </material>
+ <element Z="96" formula="Cm" name="Cm" >
+  <atom type="A" unit="g/mol" value="247.07" />
+ </element>
+ <material formula="Cm" name="Curium" state="solid" >
+  <RL type="X0" unit="cm" value="0.428706" />
+  <NIL type="lambda" unit="cm" value="16.2593" />
+  <D type="density" unit="g/cm3" value="13.51" />
+  <composite n="1" ref="Cm" />
+ </material>
+ <element Z="27" formula="Co" name="Co" >
+  <atom type="A" unit="g/mol" value="58.9332" />
+ </element>
+ <material formula="Co" name="Cobalt" state="solid" >
+  <RL type="X0" unit="cm" value="1.53005" />
+  <NIL type="lambda" unit="cm" value="15.2922" />
+  <D type="density" unit="g/cm3" value="8.9" />
+  <composite n="1" ref="Co" />
+ </material>
+ <element Z="24" formula="Cr" name="Cr" >
+  <atom type="A" unit="g/mol" value="51.9961" />
+ </element>
+ <material formula="Cr" name="Chromium" state="solid" >
+  <RL type="X0" unit="cm" value="2.0814" />
+  <NIL type="lambda" unit="cm" value="18.1933" />
+  <D type="density" unit="g/cm3" value="7.18" />
+  <composite n="1" ref="Cr" />
+ </material>
+ <element Z="55" formula="Cs" name="Cs" >
+  <atom type="A" unit="g/mol" value="132.905" />
+ </element>
+ <material formula="Cs" name="Cesium" state="solid" >
+  <RL type="X0" unit="cm" value="4.4342" />
+  <NIL type="lambda" unit="cm" value="95.317" />
+  <D type="density" unit="g/cm3" value="1.873" />
+  <composite n="1" ref="Cs" />
+ </material>
+ <element Z="29" formula="Cu" name="Cu" >
+  <atom type="A" unit="g/mol" value="63.5456" />
+ </element>
+ <material formula="Cu" name="Copper" state="solid" >
+  <RL type="X0" unit="cm" value="1.43558" />
+  <NIL type="lambda" unit="cm" value="15.5141" />
+  <D type="density" unit="g/cm3" value="8.96" />
+  <composite n="1" ref="Cu" />
+ </material>
+ <element Z="66" formula="Dy" name="Dy" >
+  <atom type="A" unit="g/mol" value="162.497" />
+ </element>
+ <material formula="Dy" name="Dysprosium" state="solid" >
+  <RL type="X0" unit="cm" value="0.85614" />
+  <NIL type="lambda" unit="cm" value="22.2923" />
+  <D type="density" unit="g/cm3" value="8.55" />
+  <composite n="1" ref="Dy" />
+ </material>
+ <element Z="68" formula="Er" name="Er" >
+  <atom type="A" unit="g/mol" value="167.256" />
+ </element>
+ <material formula="Er" name="Erbium" state="solid" >
+  <RL type="X0" unit="cm" value="0.788094" />
+  <NIL type="lambda" unit="cm" value="21.2923" />
+  <D type="density" unit="g/cm3" value="9.066" />
+  <composite n="1" ref="Er" />
+ </material>
+ <element Z="63" formula="Eu" name="Eu" >
+  <atom type="A" unit="g/mol" value="151.964" />
+ </element>
+ <material formula="Eu" name="Europium" state="solid" >
+  <RL type="X0" unit="cm" value="1.41868" />
+  <NIL type="lambda" unit="cm" value="35.6178" />
+  <D type="density" unit="g/cm3" value="5.243" />
+  <composite n="1" ref="Eu" />
+ </material>
+ <element Z="9" formula="F" name="F" >
+  <atom type="A" unit="g/mol" value="18.9984" />
+ </element>
+ <material formula="F" name="Fluorine" state="gas" >
+  <RL type="X0" unit="cm" value="20838.2" />
+  <NIL type="lambda" unit="cm" value="59094.3" />
+  <D type="density" unit="g/cm3" value="0.00158029" />
+  <composite n="1" ref="F" />
+ </material>
+ <element Z="26" formula="Fe" name="Fe" >
+  <atom type="A" unit="g/mol" value="55.8451" />
+ </element>
+ <material formula="Fe" name="Iron" state="solid" >
+  <RL type="X0" unit="cm" value="1.75749" />
+  <NIL type="lambda" unit="cm" value="16.959" />
+  <D type="density" unit="g/cm3" value="7.874" />
+  <composite n="1" ref="Fe" />
+ </material>
+ <element Z="87" formula="Fr" name="Fr" >
+  <atom type="A" unit="g/mol" value="223.02" />
+ </element>
+ <material formula="Fr" name="Francium" state="solid" >
+  <RL type="X0" unit="cm" value="6.18826" />
+  <NIL type="lambda" unit="cm" value="212.263" />
+  <D type="density" unit="g/cm3" value="1" />
+  <composite n="1" ref="Fr" />
+ </material>
+ <element Z="31" formula="Ga" name="Ga" >
+  <atom type="A" unit="g/mol" value="69.7231" />
+ </element>
+ <material formula="Ga" name="Gallium" state="solid" >
+  <RL type="X0" unit="cm" value="2.1128" />
+  <NIL type="lambda" unit="cm" value="24.3351" />
+  <D type="density" unit="g/cm3" value="5.904" />
+  <composite n="1" ref="Ga" />
+ </material>
+ <element Z="64" formula="Gd" name="Gd" >
+  <atom type="A" unit="g/mol" value="157.252" />
+ </element>
+ <material formula="Gd" name="Gadolinium" state="solid" >
+  <RL type="X0" unit="cm" value="0.947208" />
+  <NIL type="lambda" unit="cm" value="23.9377" />
+  <D type="density" unit="g/cm3" value="7.9004" />
+  <composite n="1" ref="Gd" />
+ </material>
+ <element Z="32" formula="Ge" name="Ge" >
+  <atom type="A" unit="g/mol" value="72.6128" />
+ </element>
+ <material formula="Ge" name="Germanium" state="solid" >
+  <RL type="X0" unit="cm" value="2.3013" />
+  <NIL type="lambda" unit="cm" value="27.3344" />
+  <D type="density" unit="g/cm3" value="5.323" />
+  <composite n="1" ref="Ge" />
+ </material>
+ <element Z="1" formula="H" name="H" >
+  <atom type="A" unit="g/mol" value="1.00794" />
+ </element>
+ <material formula="H" name="Hydrogen" state="gas" >
+  <RL type="X0" unit="cm" value="752776" />
+  <NIL type="lambda" unit="cm" value="421239" />
+  <D type="density" unit="g/cm3" value="8.3748e-05" />
+  <composite n="1" ref="H" />
+ </material>
+ <element Z="2" formula="He" name="He" >
+  <atom type="A" unit="g/mol" value="4.00264" />
+ </element>
+ <material formula="He" name="Helium" state="gas" >
+  <RL type="X0" unit="cm" value="567113" />
+  <NIL type="lambda" unit="cm" value="334266" />
+  <D type="density" unit="g/cm3" value="0.000166322" />
+  <composite n="1" ref="He" />
+ </material>
+ <element Z="72" formula="Hf" name="Hf" >
+  <atom type="A" unit="g/mol" value="178.485" />
+ </element>
+ <material formula="Hf" name="Hafnium" state="solid" >
+  <RL type="X0" unit="cm" value="0.517717" />
+  <NIL type="lambda" unit="cm" value="14.7771" />
+  <D type="density" unit="g/cm3" value="13.31" />
+  <composite n="1" ref="Hf" />
+ </material>
+ <element Z="80" formula="Hg" name="Hg" >
+  <atom type="A" unit="g/mol" value="200.599" />
+ </element>
+ <material formula="Hg" name="Mercury" state="solid" >
+  <RL type="X0" unit="cm" value="0.475241" />
+  <NIL type="lambda" unit="cm" value="15.105" />
+  <D type="density" unit="g/cm3" value="13.546" />
+  <composite n="1" ref="Hg" />
+ </material>
+ <element Z="67" formula="Ho" name="Ho" >
+  <atom type="A" unit="g/mol" value="164.93" />
+ </element>
+ <material formula="Ho" name="Holmium" state="solid" >
+  <RL type="X0" unit="cm" value="0.822447" />
+  <NIL type="lambda" unit="cm" value="21.8177" />
+  <D type="density" unit="g/cm3" value="8.795" />
+  <composite n="1" ref="Ho" />
+ </material>
+ <element Z="53" formula="I" name="I" >
+  <atom type="A" unit="g/mol" value="126.904" />
+ </element>
+ <material formula="I" name="Iodine" state="solid" >
+  <RL type="X0" unit="cm" value="1.72016" />
+  <NIL type="lambda" unit="cm" value="35.6583" />
+  <D type="density" unit="g/cm3" value="4.93" />
+  <composite n="1" ref="I" />
+ </material>
+ <element Z="49" formula="In" name="In" >
+  <atom type="A" unit="g/mol" value="114.818" />
+ </element>
+ <material formula="In" name="Indium" state="solid" >
+  <RL type="X0" unit="cm" value="1.21055" />
+  <NIL type="lambda" unit="cm" value="23.2468" />
+  <D type="density" unit="g/cm3" value="7.31" />
+  <composite n="1" ref="In" />
+ </material>
+ <element Z="77" formula="Ir" name="Ir" >
+  <atom type="A" unit="g/mol" value="192.216" />
+ </element>
+ <material formula="Ir" name="Iridium" state="solid" >
+  <RL type="X0" unit="cm" value="0.294142" />
+  <NIL type="lambda" unit="cm" value="9.01616" />
+  <D type="density" unit="g/cm3" value="22.42" />
+  <composite n="1" ref="Ir" />
+ </material>
+ <element Z="19" formula="K" name="K" >
+  <atom type="A" unit="g/mol" value="39.0983" />
+ </element>
+ <material formula="K" name="Potassium" state="solid" >
+  <RL type="X0" unit="cm" value="20.0871" />
+  <NIL type="lambda" unit="cm" value="138.041" />
+  <D type="density" unit="g/cm3" value="0.862" />
+  <composite n="1" ref="K" />
+ </material>
+ <element Z="36" formula="Kr" name="Kr" >
+  <atom type="A" unit="g/mol" value="83.7993" />
+ </element>
+ <material formula="Kr" name="Krypton" state="gas" >
+  <RL type="X0" unit="cm" value="3269.44" />
+  <NIL type="lambda" unit="cm" value="43962.9" />
+  <D type="density" unit="g/cm3" value="0.00347832" />
+  <composite n="1" ref="Kr" />
+ </material>
+ <element Z="57" formula="La" name="La" >
+  <atom type="A" unit="g/mol" value="138.905" />
+ </element>
+ <material formula="La" name="Lanthanum" state="solid" >
+  <RL type="X0" unit="cm" value="1.32238" />
+  <NIL type="lambda" unit="cm" value="29.441" />
+  <D type="density" unit="g/cm3" value="6.154" />
+  <composite n="1" ref="La" />
+ </material>
+ <element Z="3" formula="Li" name="Li" >
+  <atom type="A" unit="g/mol" value="6.94003" />
+ </element>
+ <material formula="Li" name="Lithium" state="solid" >
+  <RL type="X0" unit="cm" value="154.997" />
+  <NIL type="lambda" unit="cm" value="124.305" />
+  <D type="density" unit="g/cm3" value="0.534" />
+  <composite n="1" ref="Li" />
+ </material>
+ <element Z="71" formula="Lu" name="Lu" >
+  <atom type="A" unit="g/mol" value="174.967" />
+ </element>
+ <material formula="Lu" name="Lutetium" state="solid" >
+  <RL type="X0" unit="cm" value="0.703651" />
+  <NIL type="lambda" unit="cm" value="19.8916" />
+  <D type="density" unit="g/cm3" value="9.84" />
+  <composite n="1" ref="Lu" />
+ </material>
+ <element Z="12" formula="Mg" name="Mg" >
+  <atom type="A" unit="g/mol" value="24.305" />
+ </element>
+ <material formula="Mg" name="Magnesium" state="solid" >
+  <RL type="X0" unit="cm" value="14.3859" />
+  <NIL type="lambda" unit="cm" value="58.7589" />
+  <D type="density" unit="g/cm3" value="1.74" />
+  <composite n="1" ref="Mg" />
+ </material>
+ <element Z="25" formula="Mn" name="Mn" >
+  <atom type="A" unit="g/mol" value="54.938" />
+ </element>
+ <material formula="Mn" name="Manganese" state="solid" >
+  <RL type="X0" unit="cm" value="1.96772" />
+  <NIL type="lambda" unit="cm" value="17.8701" />
+  <D type="density" unit="g/cm3" value="7.44" />
+  <composite n="1" ref="Mn" />
+ </material>
+ <element Z="42" formula="Mo" name="Mo" >
+  <atom type="A" unit="g/mol" value="95.9313" />
+ </element>
+ <material formula="Mo" name="Molybdenum" state="solid" >
+  <RL type="X0" unit="cm" value="0.959107" />
+  <NIL type="lambda" unit="cm" value="15.6698" />
+  <D type="density" unit="g/cm3" value="10.22" />
+  <composite n="1" ref="Mo" />
+ </material>
+ <element Z="7" formula="N" name="N" >
+  <atom type="A" unit="g/mol" value="14.0068" />
+ </element>
+ <material formula="N" name="Nitrogen" state="gas" >
+  <RL type="X0" unit="cm" value="32602.2" />
+  <NIL type="lambda" unit="cm" value="72430.3" />
+  <D type="density" unit="g/cm3" value="0.0011652" />
+  <composite n="1" ref="N" />
+ </material>
+ <element Z="11" formula="Na" name="Na" >
+  <atom type="A" unit="g/mol" value="22.9898" />
+ </element>
+ <material formula="Na" name="Sodium" state="solid" >
+  <RL type="X0" unit="cm" value="28.5646" />
+  <NIL type="lambda" unit="cm" value="102.463" />
+  <D type="density" unit="g/cm3" value="0.971" />
+  <composite n="1" ref="Na" />
+ </material>
+ <element Z="41" formula="Nb" name="Nb" >
+  <atom type="A" unit="g/mol" value="92.9064" />
+ </element>
+ <material formula="Nb" name="Niobium" state="solid" >
+  <RL type="X0" unit="cm" value="1.15783" />
+  <NIL type="lambda" unit="cm" value="18.4846" />
+  <D type="density" unit="g/cm3" value="8.57" />
+  <composite n="1" ref="Nb" />
+ </material>
+ <element Z="60" formula="Nd" name="Nd" >
+  <atom type="A" unit="g/mol" value="144.236" />
+ </element>
+ <material formula="Nd" name="Neodymium" state="solid" >
+  <RL type="X0" unit="cm" value="1.11667" />
+  <NIL type="lambda" unit="cm" value="26.6308" />
+  <D type="density" unit="g/cm3" value="6.9" />
+  <composite n="1" ref="Nd" />
+ </material>
+ <element Z="10" formula="Ne" name="Ne" >
+  <atom type="A" unit="g/mol" value="20.18" />
+ </element>
+ <material formula="Ne" name="Neon" state="gas" >
+  <RL type="X0" unit="cm" value="34504.8" />
+  <NIL type="lambda" unit="cm" value="114322" />
+  <D type="density" unit="g/cm3" value="0.000838505" />
+  <composite n="1" ref="Ne" />
+ </material>
+ <element Z="28" formula="Ni" name="Ni" >
+  <atom type="A" unit="g/mol" value="58.6933" />
+ </element>
+ <material formula="Ni" name="Nickel" state="solid" >
+  <RL type="X0" unit="cm" value="1.42422" />
+  <NIL type="lambda" unit="cm" value="15.2265" />
+  <D type="density" unit="g/cm3" value="8.902" />
+  <composite n="1" ref="Ni" />
+ </material>
+ <element Z="93" formula="Np" name="Np" >
+  <atom type="A" unit="g/mol" value="237.048" />
+ </element>
+ <material formula="Np" name="Neptunium" state="solid" >
+  <RL type="X0" unit="cm" value="0.289676" />
+  <NIL type="lambda" unit="cm" value="10.6983" />
+  <D type="density" unit="g/cm3" value="20.25" />
+  <composite n="1" ref="Np" />
+ </material>
+ <element Z="8" formula="O" name="O" >
+  <atom type="A" unit="g/mol" value="15.9994" />
+ </element>
+ <material formula="O" name="Oxygen" state="gas" >
+  <RL type="X0" unit="cm" value="25713.8" />
+  <NIL type="lambda" unit="cm" value="66233.9" />
+  <D type="density" unit="g/cm3" value="0.00133151" />
+  <composite n="1" ref="O" />
+ </material>
+ <element Z="76" formula="Os" name="Os" >
+  <atom type="A" unit="g/mol" value="190.225" />
+ </element>
+ <material formula="Os" name="Osmium" state="solid" >
+  <RL type="X0" unit="cm" value="0.295861" />
+  <NIL type="lambda" unit="cm" value="8.92553" />
+  <D type="density" unit="g/cm3" value="22.57" />
+  <composite n="1" ref="Os" />
+ </material>
+ <element Z="15" formula="P" name="P" >
+  <atom type="A" unit="g/mol" value="30.9738" />
+ </element>
+ <material formula="P" name="Phosphorus" state="solid" >
+  <RL type="X0" unit="cm" value="9.63879" />
+  <NIL type="lambda" unit="cm" value="49.9343" />
+  <D type="density" unit="g/cm3" value="2.2" />
+  <composite n="1" ref="P" />
+ </material>
+ <element Z="91" formula="Pa" name="Pa" >
+  <atom type="A" unit="g/mol" value="231.036" />
+ </element>
+ <material formula="Pa" name="Protactinium" state="solid" >
+  <RL type="X0" unit="cm" value="0.38607" />
+  <NIL type="lambda" unit="cm" value="13.9744" />
+  <D type="density" unit="g/cm3" value="15.37" />
+  <composite n="1" ref="Pa" />
+ </material>
+ <element Z="82" formula="Pb" name="Pb" >
+  <atom type="A" unit="g/mol" value="207.217" />
+ </element>
+ <material formula="Pb" name="Lead" state="solid" >
+  <RL type="X0" unit="cm" value="0.561253" />
+  <NIL type="lambda" unit="cm" value="18.2607" />
+  <D type="density" unit="g/cm3" value="11.35" />
+  <composite n="1" ref="Pb" />
+ </material>
+ <element Z="46" formula="Pd" name="Pd" >
+  <atom type="A" unit="g/mol" value="106.415" />
+ </element>
+ <material formula="Pd" name="Palladium" state="solid" >
+  <RL type="X0" unit="cm" value="0.765717" />
+  <NIL type="lambda" unit="cm" value="13.7482" />
+  <D type="density" unit="g/cm3" value="12.02" />
+  <composite n="1" ref="Pd" />
+ </material>
+ <element Z="61" formula="Pm" name="Pm" >
+  <atom type="A" unit="g/mol" value="144.913" />
+ </element>
+ <material formula="Pm" name="Promethium" state="solid" >
+  <RL type="X0" unit="cm" value="1.04085" />
+  <NIL type="lambda" unit="cm" value="25.4523" />
+  <D type="density" unit="g/cm3" value="7.22" />
+  <composite n="1" ref="Pm" />
+ </material>
+ <element Z="84" formula="Po" name="Po" >
+  <atom type="A" unit="g/mol" value="208.982" />
+ </element>
+ <material formula="Po" name="Polonium" state="solid" >
+  <RL type="X0" unit="cm" value="0.661092" />
+  <NIL type="lambda" unit="cm" value="22.2842" />
+  <D type="density" unit="g/cm3" value="9.32" />
+  <composite n="1" ref="Po" />
+ </material>
+ <element Z="59" formula="Pr" name="Pr" >
+  <atom type="A" unit="g/mol" value="140.908" />
+ </element>
+ <material formula="Pr" name="Praseodymium" state="solid" >
+  <RL type="X0" unit="cm" value="1.1562" />
+  <NIL type="lambda" unit="cm" value="27.1312" />
+  <D type="density" unit="g/cm3" value="6.71" />
+  <composite n="1" ref="Pr" />
+ </material>
+ <element Z="78" formula="Pt" name="Pt" >
+  <atom type="A" unit="g/mol" value="195.078" />
+ </element>
+ <material formula="Pt" name="Platinum" state="solid" >
+  <RL type="X0" unit="cm" value="0.305053" />
+  <NIL type="lambda" unit="cm" value="9.46584" />
+  <D type="density" unit="g/cm3" value="21.45" />
+  <composite n="1" ref="Pt" />
+ </material>
+ <element Z="94" formula="Pu" name="Pu" >
+  <atom type="A" unit="g/mol" value="244.064" />
+ </element>
+ <material formula="Pu" name="Plutonium" state="solid" >
+  <RL type="X0" unit="cm" value="0.298905" />
+  <NIL type="lambda" unit="cm" value="11.0265" />
+  <D type="density" unit="g/cm3" value="19.84" />
+  <composite n="1" ref="Pu" />
+ </material>
+ <element Z="88" formula="Ra" name="Ra" >
+  <atom type="A" unit="g/mol" value="226.025" />
+ </element>
+ <material formula="Ra" name="Radium" state="solid" >
+  <RL type="X0" unit="cm" value="1.22987" />
+  <NIL type="lambda" unit="cm" value="42.6431" />
+  <D type="density" unit="g/cm3" value="5" />
+  <composite n="1" ref="Ra" />
+ </material>
+ <element Z="37" formula="Rb" name="Rb" >
+  <atom type="A" unit="g/mol" value="85.4677" />
+ </element>
+ <material formula="Rb" name="Rubidium" state="solid" >
+  <RL type="X0" unit="cm" value="7.19774" />
+  <NIL type="lambda" unit="cm" value="100.218" />
+  <D type="density" unit="g/cm3" value="1.532" />
+  <composite n="1" ref="Rb" />
+ </material>
+ <element Z="75" formula="Re" name="Re" >
+  <atom type="A" unit="g/mol" value="186.207" />
+ </element>
+ <material formula="Re" name="Rhenium" state="solid" >
+  <RL type="X0" unit="cm" value="0.318283" />
+  <NIL type="lambda" unit="cm" value="9.5153" />
+  <D type="density" unit="g/cm3" value="21.02" />
+  <composite n="1" ref="Re" />
+ </material>
+ <element Z="45" formula="Rh" name="Rh" >
+  <atom type="A" unit="g/mol" value="102.906" />
+ </element>
+ <material formula="Rh" name="Rhodium" state="solid" >
+  <RL type="X0" unit="cm" value="0.746619" />
+  <NIL type="lambda" unit="cm" value="13.2083" />
+  <D type="density" unit="g/cm3" value="12.41" />
+  <composite n="1" ref="Rh" />
+ </material>
+ <element Z="86" formula="Rn" name="Rn" >
+  <atom type="A" unit="g/mol" value="222.018" />
+ </element>
+ <material formula="Rn" name="Radon" state="gas" >
+  <RL type="X0" unit="cm" value="697.777" />
+  <NIL type="lambda" unit="cm" value="23532" />
+  <D type="density" unit="g/cm3" value="0.00900662" />
+  <composite n="1" ref="Rn" />
+ </material>
+ <element Z="44" formula="Ru" name="Ru" >
+  <atom type="A" unit="g/mol" value="101.065" />
+ </element>
+ <material formula="Ru" name="Ruthenium" state="solid" >
+  <RL type="X0" unit="cm" value="0.764067" />
+  <NIL type="lambda" unit="cm" value="13.1426" />
+  <D type="density" unit="g/cm3" value="12.41" />
+  <composite n="1" ref="Ru" />
+ </material>
+ <element Z="16" formula="S" name="S" >
+  <atom type="A" unit="g/mol" value="32.0661" />
+ </element>
+ <material formula="S" name="Sulfur" state="solid" >
+  <RL type="X0" unit="cm" value="9.74829" />
+  <NIL type="lambda" unit="cm" value="55.6738" />
+  <D type="density" unit="g/cm3" value="2" />
+  <composite n="1" ref="S" />
+ </material>
+ <element Z="51" formula="Sb" name="Sb" >
+  <atom type="A" unit="g/mol" value="121.76" />
+ </element>
+ <material formula="Sb" name="Antimony" state="solid" >
+  <RL type="X0" unit="cm" value="1.30401" />
+  <NIL type="lambda" unit="cm" value="25.8925" />
+  <D type="density" unit="g/cm3" value="6.691" />
+  <composite n="1" ref="Sb" />
+ </material>
+ <element Z="21" formula="Sc" name="Sc" >
+  <atom type="A" unit="g/mol" value="44.9559" />
+ </element>
+ <material formula="Sc" name="Scandium" state="solid" >
+  <RL type="X0" unit="cm" value="5.53545" />
+  <NIL type="lambda" unit="cm" value="41.609" />
+  <D type="density" unit="g/cm3" value="2.989" />
+  <composite n="1" ref="Sc" />
+ </material>
+ <element Z="34" formula="Se" name="Se" >
+  <atom type="A" unit="g/mol" value="78.9594" />
+ </element>
+ <material formula="Se" name="Selenium" state="solid" >
+  <RL type="X0" unit="cm" value="2.64625" />
+  <NIL type="lambda" unit="cm" value="33.356" />
+  <D type="density" unit="g/cm3" value="4.5" />
+  <composite n="1" ref="Se" />
+ </material>
+ <element Z="14" formula="Si" name="Si" >
+  <atom type="A" unit="g/mol" value="28.0854" />
+ </element>
+ <material formula="Si" name="Silicon" state="solid" >
+  <RL type="X0" unit="cm" value="9.36607" />
+  <NIL type="lambda" unit="cm" value="45.7531" />
+  <D type="density" unit="g/cm3" value="2.33" />
+  <composite n="1" ref="Si" />
+ </material>
+ <element Z="62" formula="Sm" name="Sm" >
+  <atom type="A" unit="g/mol" value="150.366" />
+ </element>
+ <material formula="Sm" name="Samarium" state="solid" >
+  <RL type="X0" unit="cm" value="1.01524" />
+  <NIL type="lambda" unit="cm" value="24.9892" />
+  <D type="density" unit="g/cm3" value="7.46" />
+  <composite n="1" ref="Sm" />
+ </material>
+ <element Z="50" formula="Sn" name="Sn" >
+  <atom type="A" unit="g/mol" value="118.71" />
+ </element>
+ <material formula="Sn" name="Tin" state="solid" >
+  <RL type="X0" unit="cm" value="1.20637" />
+  <NIL type="lambda" unit="cm" value="23.4931" />
+  <D type="density" unit="g/cm3" value="7.31" />
+  <composite n="1" ref="Sn" />
+ </material>
+ <element Z="38" formula="Sr" name="Sr" >
+  <atom type="A" unit="g/mol" value="87.6166" />
+ </element>
+ <material formula="Sr" name="Strontium" state="solid" >
+  <RL type="X0" unit="cm" value="4.237" />
+  <NIL type="lambda" unit="cm" value="61.0238" />
+  <D type="density" unit="g/cm3" value="2.54" />
+  <composite n="1" ref="Sr" />
+ </material>
+ <element Z="73" formula="Ta" name="Ta" >
+  <atom type="A" unit="g/mol" value="180.948" />
+ </element>
+ <material formula="Ta" name="Tantalum" state="solid" >
+  <RL type="X0" unit="cm" value="0.409392" />
+  <NIL type="lambda" unit="cm" value="11.8846" />
+  <D type="density" unit="g/cm3" value="16.654" />
+  <composite n="1" ref="Ta" />
+ </material>
+ <element Z="65" formula="Tb" name="Tb" >
+  <atom type="A" unit="g/mol" value="158.925" />
+ </element>
+ <material formula="Tb" name="Terbium" state="solid" >
+  <RL type="X0" unit="cm" value="0.893977" />
+  <NIL type="lambda" unit="cm" value="23.0311" />
+  <D type="density" unit="g/cm3" value="8.229" />
+  <composite n="1" ref="Tb" />
+ </material>
+ <element Z="43" formula="Tc" name="Tc" >
+  <atom type="A" unit="g/mol" value="97.9072" />
+ </element>
+ <material formula="Tc" name="Technetium" state="solid" >
+  <RL type="X0" unit="cm" value="0.833149" />
+  <NIL type="lambda" unit="cm" value="14.0185" />
+  <D type="density" unit="g/cm3" value="11.5" />
+  <composite n="1" ref="Tc" />
+ </material>
+ <element Z="52" formula="Te" name="Te" >
+  <atom type="A" unit="g/mol" value="127.603" />
+ </element>
+ <material formula="Te" name="Tellurium" state="solid" >
+  <RL type="X0" unit="cm" value="1.41457" />
+  <NIL type="lambda" unit="cm" value="28.1797" />
+  <D type="density" unit="g/cm3" value="6.24" />
+  <composite n="1" ref="Te" />
+ </material>
+ <element Z="90" formula="Th" name="Th" >
+  <atom type="A" unit="g/mol" value="232.038" />
+ </element>
+ <material formula="Th" name="Thorium" state="solid" >
+  <RL type="X0" unit="cm" value="0.51823" />
+  <NIL type="lambda" unit="cm" value="18.353" />
+  <D type="density" unit="g/cm3" value="11.72" />
+  <composite n="1" ref="Th" />
+ </material>
+ <element Z="22" formula="Ti" name="Ti" >
+  <atom type="A" unit="g/mol" value="47.8667" />
+ </element>
+ <material formula="Ti" name="Titanium" state="solid" >
+  <RL type="X0" unit="cm" value="3.5602" />
+  <NIL type="lambda" unit="cm" value="27.9395" />
+  <D type="density" unit="g/cm3" value="4.54" />
+  <composite n="1" ref="Ti" />
+ </material>
+ <element Z="81" formula="Tl" name="Tl" >
+  <atom type="A" unit="g/mol" value="204.383" />
+ </element>
+ <material formula="Tl" name="Thallium" state="solid" >
+  <RL type="X0" unit="cm" value="0.547665" />
+  <NIL type="lambda" unit="cm" value="17.6129" />
+  <D type="density" unit="g/cm3" value="11.72" />
+  <composite n="1" ref="Tl" />
+ </material>
+ <element Z="69" formula="Tm" name="Tm" >
+  <atom type="A" unit="g/mol" value="168.934" />
+ </element>
+ <material formula="Tm" name="Thulium" state="solid" >
+  <RL type="X0" unit="cm" value="0.754428" />
+  <NIL type="lambda" unit="cm" value="20.7522" />
+  <D type="density" unit="g/cm3" value="9.321" />
+  <composite n="1" ref="Tm" />
+ </material>
+ <element Z="92" formula="U" name="U" >
+  <atom type="A" unit="g/mol" value="238.029" />
+ </element>
+ <material formula="U" name="Uranium" state="solid" >
+  <RL type="X0" unit="cm" value="0.31663" />
+  <NIL type="lambda" unit="cm" value="11.4473" />
+  <D type="density" unit="g/cm3" value="18.95" />
+  <composite n="1" ref="U" />
+ </material>
+ <element Z="23" formula="V" name="V" >
+  <atom type="A" unit="g/mol" value="50.9415" />
+ </element>
+ <material formula="V" name="Vanadium" state="solid" >
+  <RL type="X0" unit="cm" value="2.59285" />
+  <NIL type="lambda" unit="cm" value="21.2187" />
+  <D type="density" unit="g/cm3" value="6.11" />
+  <composite n="1" ref="V" />
+ </material>
+ <element Z="74" formula="W" name="W" >
+  <atom type="A" unit="g/mol" value="183.842" />
+ </element>
+ <material formula="W" name="Tungsten" state="solid" >
+  <RL type="X0" unit="cm" value="0.350418" />
+  <NIL type="lambda" unit="cm" value="10.3057" />
+  <D type="density" unit="g/cm3" value="19.3" />
+  <composite n="1" ref="W" />
+ </material>
+ <element Z="54" formula="Xe" name="Xe" >
+  <atom type="A" unit="g/mol" value="131.292" />
+ </element>
+ <material formula="Xe" name="Xenon" state="gas" >
+  <RL type="X0" unit="cm" value="1546.2" />
+  <NIL type="lambda" unit="cm" value="32477.9" />
+  <D type="density" unit="g/cm3" value="0.00548536" />
+  <composite n="1" ref="Xe" />
+ </material>
+ <element Z="39" formula="Y" name="Y" >
+  <atom type="A" unit="g/mol" value="88.9058" />
+ </element>
+ <material formula="Y" name="Yttrium" state="solid" >
+  <RL type="X0" unit="cm" value="2.32943" />
+  <NIL type="lambda" unit="cm" value="34.9297" />
+  <D type="density" unit="g/cm3" value="4.469" />
+  <composite n="1" ref="Y" />
+ </material>
+ <element Z="70" formula="Yb" name="Yb" >
+  <atom type="A" unit="g/mol" value="173.038" />
+ </element>
+ <material formula="Yb" name="Ytterbium" state="solid" >
+  <RL type="X0" unit="cm" value="1.04332" />
+  <NIL type="lambda" unit="cm" value="28.9843" />
+  <D type="density" unit="g/cm3" value="6.73" />
+  <composite n="1" ref="Yb" />
+ </material>
+ <element Z="30" formula="Zn" name="Zn" >
+  <atom type="A" unit="g/mol" value="65.3955" />
+ </element>
+ <material formula="Zn" name="Zinc" state="solid" >
+  <RL type="X0" unit="cm" value="1.74286" />
+  <NIL type="lambda" unit="cm" value="19.8488" />
+  <D type="density" unit="g/cm3" value="7.133" />
+  <composite n="1" ref="Zn" />
+ </material>
+ <element Z="40" formula="Zr" name="Zr" >
+  <atom type="A" unit="g/mol" value="91.2236" />
+ </element>
+ <material formula="Zr" name="Zirconium" state="solid" >
+  <RL type="X0" unit="cm" value="1.56707" />
+  <NIL type="lambda" unit="cm" value="24.2568" />
+  <D type="density" unit="g/cm3" value="6.506" />
+  <composite n="1" ref="Zr" />
+ </material>
+</materials>
\ No newline at end of file
diff --git a/Detector/DetCEPCv4/compact/envelope_defs.xml b/Detector/DetCEPCv4/compact/envelope_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..63f0b2bb5bac88ccd217f8984522c71be423443a
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/envelope_defs.xml
@@ -0,0 +1,166 @@
+<!-- ################### ENVELOPE PARAMETERS ######################################################## 
+     avoid hardcoded numbers in here: they should all be defined in the top_defs.xml file -->
+
+<define>
+  
+
+  <comment> suggested naming convention:
+
+    main parameters:
+
+    DET_inner_radius    : inner radius of tube like envelope  ( inscribed cylinder )
+    DET_outer_radius    : outer radius of tube like envelope  ( inscribed cylinder )
+    DET_half_length     : half length along z axis
+    DET_min_z           : smallest absolute value on z-axis
+    DET_max_z           : largest  absolute value on z-axis
+    DET_inner_symmetry  : number of sides on the inside  ( 0 for tube )
+    DET_outer_symmetry  : number of sides on the inside  ( 0 for tube )
+    DET_inner_phi0      : optional rotation of the inner polygon ( in r-phi plane )
+    DET_outer_phi0      : optional rotation of the outer polygon ( in r-phi plane )
+
+    additional parameters for cutting away volumes/shapes use one of the above with a number
+    appended and/or an extra specifiaction such as cone ( for a cut away cone )
+
+    DET_inner_radius_1
+    DET_outer_radius_2
+    DET_cone_min_z
+    DET_cone_max_z
+
+  </comment>
+
+  <constant name="env_safety" value="0.1*mm"/>
+
+
+
+  <!-- a few defined parameters needed for envelopes -->
+  <constant name="TUBE_IPOuterTube_start_radius"  value="TUBE_IPInnerBulge_end_innerradius"/>
+  <constant name="TUBE_IPOuterBulge_end_z"        value="top_Lcal_z_begin - TUBE_Lcal_clearance"/>
+  <constant name="TUBE_IPOuterBulge_end_radius"   value="Lcal_outer_radius-LumiCal_tubebulge_overshoot"/>
+  <constant name="TUBE_IPInnerBulge_end_envradius"   value="TUBE_IPInnerBulge_end_innerradius + TUBE_inner_maxthick"/>
+  <constant name="TUBE_IPOuterTube_end_envradius"    value="TUBE_IPInnerBulge_end_envradius"/>
+
+  <constant name="TUBE_IPOuterBulge_start_envradius"   value="TUBE_IPInnerBulge_end_innerradius+TUBE_outer_maxthick"/>
+  <constant name="TUBE_IPOuterBulge_end_envradius"   value="TUBE_IPOuterBulge_end_radius+TUBE_outer_maxthick"/>
+
+
+
+  <constant name="VXD_inner_radius"   value="top_VXD_inner_radius"/>
+  <constant name="VXD_outer_radius"   value="top_VXD_outer_radius"/>
+  <constant name="VXD_half_length"    value="top_VXD_half_length"/>
+  <constant name="VXD_cone_min_z"     value="TUBE_IPInnerTube_end_z"/>
+  <!--constant name="VXD_cone_max_z"     value="TUBE_IPInnerBulge_end_z"/-->
+  <constant name="VXD_cone_max_z"     value="VXD_half_length"/>
+  <!--constant name="VXD_cone_max_z"     value="125.1*mm "/-->
+  <constant name="VXD_inner_radius_1" value="TUBE_IPInnerBulge_end_envradius + env_safety "/>
+
+
+  <constant name="SIT_inner_radius"    value="SIT1_Radius - env_safety"/>
+  <constant name="SIT_outer_radius_1"  value="SIT2_Radius - env_safety"/>
+  <constant name="SIT_half_length_1"   value="SIT1_Half_Length_Z + env_safety "/>
+  <constant name="SIT_outer_radius"    value="SIT2_Radius / cos(pi/8) "/>
+  <constant name="SIT_half_length"     value="SIT2_Half_Length_Z + env_safety "/>
+
+  <constant name="TPC_inner_radius"    value="top_TPC_inner_radius"/>
+  <constant name="TPC_outer_radius"    value="top_TPC_outer_radius"/>
+  <constant name="TPC_half_length"     value="TPC_Ecal_Hcal_barrel_halfZ"/>
+
+  <constant name="ftd4to7_tpc_radial_gap" value="20*mm"/>
+  <constant name="FTD_TUBE_cable_clearance" value="10*mm"/>
+
+  <constant name="FTD_inner_radius"    value=" TUBE_IPOuterBulge_start_envradius + FTD_TUBE_cable_clearance"/>
+  <constant name="FTD_outer_radius_1"  value=" SIT_inner_radius   - env_safety"/>
+  <constant name="FTD_outer_radius_2"  value=" SIT_outer_radius_1 - env_safety"/>
+  <constant name="FTD_outer_radius"    value=" TPC_inner_radius - ftd4to7_tpc_radial_gap"/>
+  <constant name="FTD_half_length"     value=" TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="FTD_min_z_0"         value=" VXD_half_length   + env_safety"/>
+  <constant name="FTD_min_z_1"         value=" SIT_half_length_1 + env_safety"/>
+  <constant name="FTD_min_z_2"         value=" SIT_half_length   + env_safety"/>
+  <constant name="FTD_cone_min_z"      value=" TUBE_IPOuterTube_end_z "/>
+  <constant name="FTD_cone_radius"     value=" TUBE_IPOuterBulge_end_envradius + FTD_TUBE_cable_clearance/2.0"/>
+
+
+  <constant name="SET_inner_radius"    value="TPC_outer_radius+ env_safety "/>
+  <constant name="SET_outer_radius"    value="SET_inner_radius+ Ecal_Tpc_gap - 6*env_safety "/>
+  <constant name="SET_half_length"     value="TPC_half_length"/>
+
+  <constant name="Ecal_inner_radius"    value="TPC_outer_radius+Ecal_Tpc_gap"/>
+  <constant name="Ecal_outer_radius"    value="Ecal_inner_radius+Ecal_barrel_thickness"/>
+  <constant name="Ecal_half_length"     value="TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="Ecal_symmetry"        value="Ecal_Hcal_symmetry"/>
+
+  <constant name="Hcal_inner_radius"    value="Ecal_outer_radius+Hcal_Ecal_gap"/>
+  <constant name="Hcal_outer_radius"    value="(Hcal_inner_radius+Hcal_barrel_thickness)/cos(pi/Hcal_outer_symmetry)"/> <!-- cos(pi/16)   -->
+  <constant name="Hcal_half_length"     value="TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="Hcal_inner_symmetry"  value="Ecal_Hcal_symmetry"/>
+
+  <constant name="EcalEndcap_inner_radius"    value="Ecal_endcap_center_box_size/2.0"/>
+  <constant name="EcalEndcap_outer_radius"    value="Ecal_outer_radius+Ecal_endcap_extra_size"/>
+  <constant name="EcalEndcap_min_z"           value="Ecal_endcap_zmin"/>
+  <constant name="EcalEndcap_max_z"           value="EcalEndcap_min_z+(Ecal_outer_radius-Ecal_inner_radius)"/>
+  <constant name="EcalEndcap_symmetry"        value="Ecal_Hcal_symmetry"/>
+
+  <constant name="HcalEndcap_inner_radius"    value="Hcal_endcap_center_box_size/2.0"/>
+  <constant name="HcalEndcap_outer_radius"    value="Hcal_outer_radius - Hcal_endcap_cryostat_gap"/>
+  <constant name="HcalEndcap_min_z"           value="Hcal_endcap_zmin"/>
+  <constant name="HcalEndcap_max_z"           value="HcalEndcap_min_z+Hcal_endcap_thickness"/>
+
+  <constant name="HcalEndcapRing_symmetry"        value="Ecal_Hcal_symmetry"/>
+  <constant name="HcalEndcapRing_inner_radius"    value="EcalEndcap_outer_radius+Hcal_radial_ring_inner_gap"/>
+  <!--constant name="HcalEndcapRing_outer_radius"    value="HcalEndcap_outer_radius*cos(pi/HcalEndcapRing_symmetry)"/-->
+  <constant name="HcalEndcapRing_outer_radius"    value="HcalEndcap_outer_radius"/>
+  <constant name="HcalEndcapRing_min_z"           value="EcalEndcap_min_z"/>
+  <constant name="HcalEndcapRing_max_z"           value="EcalEndcap_max_z"/>
+
+  <constant name="Coil_inner_radius"    value="Hcal_outer_radius+Hcal_Coil_additional_gap"/>
+  <constant name="Coil_outer_radius"    value="Hcal_outer_radius+Hcal_Coil_additional_gap+Coil_thickness"/>
+  <constant name="Coil_half_length"     value="TPC_Ecal_Hcal_barrel_halfZ+Coil_extra_size"/>
+
+  <constant name="Yoke_inner_radius"    value="Coil_outer_radius+top_Hcal_Yoke_gap"/>
+  <constant name="Yoke_outer_radius"    value="Yoke_inner_radius+top_Yoke_thickness"/>
+  <constant name="Yoke_half_length"     value="top_Yoke_half_length"/>
+  <constant name="Yoke_symmetry"        value="top_Yoke_symmetry"/>
+
+  <!-- Yoke05_Endcaps geometry driver include Yoke endcap plug -->
+  <!--constant name="YokeEndcap_inner_radius"    value="Yoke_endcap_inner_radius"/>
+  <constant name="YokeEndcap_outer_radius"    value="Yoke_outer_radius"/ -->
+  <!-- updated to take size from HCAL -->
+  <constant name="YokeEndcap_inner_radius"    value="Yoke_endcap_inner_radius"/>
+  <constant name="YokeEndcap_outer_radius"    value="Yoke_inner_radius+top_Yoke_thickness"/>
+  <constant name="YokeEndcap_min_z"           value="Yoke_Z_start_endcaps"/>
+  <constant name="YokeEndcap_max_z"           value="YokeEndcap_min_z+(Yoke_outer_radius-Yoke_inner_radius)"/>
+  <constant name="YokeEndcap_symmetry"        value="Yoke_symmetry"/>
+
+  <constant name="YokeEndcapPlug_inner_radius"    value="YokeEndcap_inner_radius"/>
+  <constant name="YokeEndcapPlug_outer_radius"    value="Hcal_outer_radius"/>
+  <constant name="YokeEndcapPlug_min_z"           value="HcalEndcap_max_z + env_safety*2.0"/>
+  <constant name="YokeEndcapPlug_max_z"           value="YokeEndcap_min_z"/>
+  <constant name="YokeEndcapPlug_symmetry"        value="Yoke_symmetry"/>
+
+  <constant name="EcalEndcapRing_inner_radius"    value="Lcal_outer_radius + Ecal_Lcal_ring_gap"/>
+  <constant name="EcalEndcapRing_outer_radius"    value="Ecal_endcap_center_box_size/2.0-Ecal_EC_Ring_gap"/>
+  <constant name="EcalEndcapRing_min_z"           value="EcalEndcap_min_z"/>
+  <constant name="EcalEndcapRing_max_z"           value="EcalEndcap_max_z"/>
+
+  <!-- forward calorimeters -->
+  <constant name="COS_halfCrossingAngle"         value="cos(CepC_Main_Crossing_Angle/2. )" />
+
+  <!-- The values are copied from dimensions in LHCal.xml -->
+  <constant name="LHCal_thickness"               value="top_LHCal_thickness"/>
+  <constant name="LHCal_inner_radius"            value="top_LHCal_inner_radius"/>
+  <constant name="LHCal_outer_radius"            value="top_LHCal_outer_radius"/>
+  <constant name="LHCal_min_z"                   value="top_LHCal_min_z"/>
+  <constant name="LHCal_max_z"                   value="LHCal_min_z+LHCal_thickness"/>
+
+  <!-- BeamCal envelope is rotated according to the ILC_Main_Crossing_Angle -->
+  <constant name="BeamCal_thickness"             value="top_BeamCal_thickness"/>
+  <constant name="BeamCal_inner_radius"          value="BCal_rInner"/>
+  <constant name="BeamCal_outer_radius"          value="BCal_rOuter"/>
+  <constant name="BeamCal_min_z"                 value="LHcal_zend + LHcal_BCal_clearance - top_BCal_dGraphite"/>
+  <constant name="BeamCal_max_z"                 value="BeamCal_min_z + BeamCal_thickness"/>
+
+  <constant name="Lcal_inner_radius" value="top_Lcal_inner_radius"/>
+  <constant name="Lcal_z_begin" value="top_Lcal_z_begin"/>
+
+  <!-- ########### END ENVELOPE PARAMETERS ############################################################## -->
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/fcal_defs.xml b/Detector/DetCEPCv4/compact/fcal_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..dedab6b46a68cd0b301754f6b59c4ca3b509b570
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/fcal_defs.xml
@@ -0,0 +1,45 @@
+<define>
+
+  <constant name="Lcal_nstrips_phi" value="48"/>
+  <constant name="Lcal_nstrips_theta" value="64"/>
+
+  <constant name="LumiCal_inner_radius"          value="80*mm"/>
+  <constant name="LumiCal_outer_radius"          value="202.086*mm"/>
+
+  <constant name="Lcal_n_tiles" value="12"/>
+  <constant name="Lcal_tile_gap" value="1.2*mm"/>
+
+  <constant name="LcalHalfTilePhi"  value="180./Lcal_n_tiles*degree"/>
+  <constant name="CosHalfTilePhi"   value=" cos( LcalHalfTilePhi )"/>
+
+  <constant name="Lcal_sensor_rmin" value=" LumiCal_inner_radius*CosHalfTilePhi + Lcal_tile_gap"/>
+  <constant name="Lcal_sensor_rmax" value=" LumiCal_outer_radius*CosHalfTilePhi - Lcal_tile_gap"/>
+
+  <constant name="Lcal_offset_phi" value=" 360./Lcal_nstrips_phi/2.*degree"/>
+
+  <constant name="Lcal_services_rmax" value="EcalEndcapRing_inner_radius-1.0*mm"/>
+
+  <constant name="Lcal_tungsten_thickness" value="3.5*mm"/>
+  <constant name="Lcal_silicon_thickness" value="0.32*mm"/>
+  <constant name="Lcal_support_thickness" value="0.22*mm"/>
+  <constant name="Lcal_layer_gap" value="0.25*mm"/>
+
+  <constant name="LumiCal_thickness"    value="128.7*mm"/>
+  <constant name="LumiCal_min_z"        value="top_Lcal_z_begin" />
+  <constant name="LumiCal_max_z"        value="LumiCal_min_z + LumiCal_thickness" />
+
+  <constant name="ECal_LHcal_clearance" value="45*mm"/>
+  <constant name="LHcal_min_z" value="Ecal_endcap_zmax+ECal_LHcal_clearance"/>
+  <constant name="LHcal_cell_size" value="10*mm"/>
+
+  <constant name="BCal_cutoutSpanning" value="45*degree"/>
+  <constant name="BCal_SpanningPhi" value="360*degree-BCal_cutoutSpanning"/>
+  <constant name="BCal_TubeIncomingRadius" value="top_BeamCal_tubeIncoming_radius"/>
+  <constant name="BCal_TubeIncomingClearance" value="top_BeamCal_tubeIncoming_clearance"/>
+  <constant name="BCal_dAbsorber" value="3.5*mm"/>
+  <constant name="BCal_dGraphite" value="top_BCal_dGraphite"/>
+  <constant name="BCal_rGraphite" value="LHCal_inner_radius-10.0*mm"/>
+  <constant name="BCal_nLayers" value="top_BCal_nLayers"/>
+  <constant name="BeamCal_cell_size" value="3.5*mm"/>
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/ftd_simple_staggered_02.xml b/Detector/DetCEPCv4/compact/ftd_simple_staggered_02.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5290ca82904cf998e38061cf95e8a4be37537acd
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/ftd_simple_staggered_02.xml
@@ -0,0 +1,70 @@
+<!--
+   FTD parameters for ILD_o1_v5
+   from database : ftd_simple_staggered_02
+  -->
+
+<lccdd>
+  <detectors>
+
+
+    <detector name="FTD" type="FTD_Simple_Staggered" vis="FTDVis" id="ILDDetID_FTD" limits="Tracker_limits" readout="FTDCollection" insideTrackingVolume="true">
+
+      <envelope vis="ILD_FTDVis">
+
+        <shape type="BooleanShape" operation="Subtraction" material="Air" >
+          <shape type="BooleanShape" operation="Subtraction" material="Air" >
+            <shape type="BooleanShape" operation="Subtraction" material="Air" >
+              <shape type="BooleanShape" operation="Subtraction" material="Air" >
+                <shape type="BooleanShape" operation="Subtraction" material="Air" >
+                  <shape type="Tube" rmin="FTD_inner_radius"   rmax="FTD_outer_radius" dz="FTD_half_length"  />
+                  <shape type="Tube" rmin="0." rmax="FTD_outer_radius+env_safety" dz="FTD_min_z_0" />
+                </shape>
+                <shape type="Tube" rmin="FTD_outer_radius_1" rmax="FTD_outer_radius+env_safety" dz="FTD_min_z_2-petal_cp_support_thickness-petal_support_zoffset" />
+              </shape>
+              <shape type="Tube" rmin="FTD_outer_radius_2" rmax="FTD_outer_radius+env_safety" dz="FTD_min_z_2" />
+            </shape>
+            <shape type="Cone" rmin1="0" rmax1="FTD_inner_radius" rmin2="0" rmax2="FTD_cone_radius"
+                   z="(FTD_half_length-FTD_cone_min_z)/2. + env_safety "/>
+            <position x="0" y="0" z="FTD_cone_min_z+(FTD_half_length-FTD_cone_min_z)/2."/>
+          </shape>
+          <shape type="Cone" rmin1="0" rmax1="FTD_inner_radius" rmin2="0" rmax2="FTD_cone_radius"
+                 z="(FTD_half_length-FTD_cone_min_z)/2. + env_safety "/>
+          <position x="0" y="0" z="-FTD_cone_min_z-(FTD_half_length-FTD_cone_min_z)/2."/>
+          <rotation x="0" y="180.*deg" z="0" />
+        </shape>
+      </envelope>
+
+      <type_flags type="DetType_TRACKER +  DetType_ENDCAP  + DetType_PIXEL + DetType_STRIP "/>
+
+      <!-- SQL command: "select * from common_parameters;"  -->
+      <common_parameters ftd1_vtx3_distance_z="top_FTD1_vtx3_distance_z"
+                         ftd7_ecal_distance_z="top_FTD7_ecal_distance_z" ftd1_sit1_radial_diff="-1*mm" ftd2_sit1_radial_diff="-1*mm" ftd3_sit2_radial_diff="-1*mm"
+                         ftd4to7_tpc_radial_gap="20*mm" beamtube_clearance="15*mm" cables_thickness="0.08*mm" cable_shield_thickness="0.1*mm" outer_cylinder_total_thickness="1*mm"
+                         petal_half_angle_support="11.25*deg" petal_y_ratio="0.5015*mm"
+                         support_spaceframe_width="10*mm"/>
+
+      <!-- SQL command: "select * from extended_reconstruction_parameters;"  -->
+      <extended_reconstruction_parameters strip_width="0.001*mm" strip_length="250*mm" strip_pitch="0.01*mm" strip_angle="5*deg"  />
+
+      <!-- SQL command: "select * from disks;"  -->
+      <disk disk_number="1" z_position_ReltoTPCLength="0" disk_si_thickness="0.02*mm" petal_cp_support_dxMax="72*mm" padUp_Si_dxMax="68*mm" petal_cp_support_thickness="1*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="1" double_sided="0"  />
+      <disk disk_number="2" z_position_ReltoTPCLength="FTD_disk2_zPosRelToTpcLength" disk_si_thickness="0.02*mm" petal_cp_support_dxMax="72*mm" padUp_Si_dxMax="68*mm" petal_cp_support_thickness="1*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="1" double_sided="0"  />
+      <disk disk_number="3" z_position_ReltoTPCLength="FTD_disk3_zPosRelToTpcLength" disk_si_thickness="0.2*mm" petal_cp_support_dxMax="122.49*mm" padUp_Si_dxMax="118.46*mm" petal_cp_support_thickness="2*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="0" double_sided="1"  />
+      <disk disk_number="4" z_position_ReltoTPCLength="FTD_disk4_zPosRelToTpcLength" disk_si_thickness="0.2*mm" petal_cp_support_dxMax="122.49*mm" padUp_Si_dxMax="118.46*mm" petal_cp_support_thickness="2*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="0" double_sided="1"  />
+      <disk disk_number="5" z_position_ReltoTPCLength="FTD_disk5_zPosRelToTpcLength" disk_si_thickness="0.2*mm" petal_cp_support_dxMax="122.49*mm" padUp_Si_dxMax="118.46*mm" petal_cp_support_thickness="2*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="0" double_sided="1"  />
+      <disk disk_number="6" z_position_ReltoTPCLength="FTD_disk6_zPosRelToTpcLength" disk_si_thickness="0.2*mm" petal_cp_support_dxMax="122.49*mm" padUp_Si_dxMax="118.46*mm" petal_cp_support_thickness="2*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="0" double_sided="1"  />
+      <disk disk_number="7" z_position_ReltoTPCLength="0" disk_si_thickness="0.2*mm" petal_cp_support_dxMax="122.49*mm" padUp_Si_dxMax="118.46*mm" petal_cp_support_thickness="2*mm" petal_support_zoffset="1.5*mm" sensor_is_pixel="0" double_sided="1"  />
+
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="FTDCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+  </readouts>
+
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/hcal_defs.xml b/Detector/DetCEPCv4/compact/hcal_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..12f7ba31c749056b80cd53abd81378c13773c787
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/hcal_defs.xml
@@ -0,0 +1,85 @@
+<define>
+
+
+  <constant name="Hcal_radiator_thickness" value="20.0*mm"/>
+  <constant name="Hcal_chamber_thickness" value="6.73*mm"/>
+  <constant name="Hcal_back_plate_thickness" value="15*mm"/>
+  <constant name="Hcal_lateral_structure_thickness" value="10*mm"/>
+  <constant name="Hcal_stave_gaps" value="3*mm"/>
+  <constant name="Hcal_modules_gap" value="0.001*mm"/>
+  <constant name="Hcal_layer_air_gap" value="2*mm"/>
+  <constant name="Hcal_middle_stave_gaps" value="10*mm"/>
+  <constant name="Hcal_nlayers" value="40"/>
+  <constant name="Hcal_fiber_gap" value="1.5*mm"/>
+  <constant name="Hcal_Cu_thickness" value="0.1*mm"/>
+  <constant name="Hcal_PCB_thickness" value="0.7*mm"/>
+  <constant name="Hcal_scintillator_thickness" value="3.0*mm"/>
+  <constant name="Hcal_cells_size" value="10*mm"/>
+  <constant name="Hcal_endcap_lateral_structure_thickness" value="5.0*mm"/>
+  <constant name="Hcal_endcap_layer_air_gap" value="2.5*mm"/>
+  <constant name="Hcal_endcap_nlayers" value="40"/> <!-- needed for ring only? -->
+
+  <!-- fg:
+      copy extra parameters for SDHcal from ILD_o2_v01 here
+      maybe they should all be renamed to SDHCal_ for clarity ? 
+     TK: Yes, here are they ... HcalSD_  
+  -->
+  <constant name="HcalSD_cells_size" value="10.406*mm"/>
+  <constant name="HcalSD_pad_separation" value="0.406*mm"/>
+  <constant name="HcalSD_radiator_thickness" value="15.0*mm"/>
+  <constant name="HcalSD_sensitive_gas_gap" value="1.2*mm"/>
+  <constant name="HcalSD_graphite_cathode_thickness" value="0.05*mm"/>
+  <constant name="HcalSD_graphite_anode_thickness" value="0.05*mm"/>
+  <constant name="HcalSD_glass_cathode_thickness" value="1.1*mm"/>
+  <constant name="HcalSD_glass_anode_thickness" value="0.7*mm"/>
+  <constant name="HcalSD_g10_thickness" value="1.4*mm"/>
+  <constant name="HcalSD_mylar_anode_thickness" value="0.05*mm"/>
+  <constant name="HcalSD_mylar_cathode_thickness" value="0.175*mm"/>
+  <constant name="HcalSD_mylar_thickness" value="0.2*mm"/>
+  <constant name="HcalSD_PCB_thickness" value="1.2*mm"/>
+  <constant name="HcalSD_electronics_mask_thickness" value="1.6*mm"/>
+  <constant name="HcalSD_steel_casette_thickness" value="2.5*mm"/>
+  <constant name="HcalSD_airgap_thickness" value="0.5*mm"/>
+  <constant name="HcalSD_back_plate_thickness" value="10*mm"/>
+  <constant name="HcalSD_barrel_end_module_type" value="1"/>
+  <constant name="HcalSD_stave_gaps" value="10*mm"/>
+  <constant name="HcalSD_lateral_structure_thickness" value="10*mm"/>
+  <constant name="HcalSD_layer_air_gap" value="2*mm"/>
+  <constant name="HcalSD_endcap_lateral_structure_thickness" value="5.0*mm"/>
+
+  <constant name="HcalSD_module_wall_thickness" value="10*mm"/>   
+
+  <constant name="HcalBarrelSD_nlayers" value="40"/>
+  <constant name="HcalSD_MinNumCellsInTransvPlane" value="1"/>
+  <constant name="HcalBarrelSD_number_modules" value="5"/>
+  <constant name="HcalEndcap_symmetry" value="Hcal_outer_symmetry"/>
+  <constant name="HcalEndcapRingSD_inner_symmetry"  value="Ecal_Hcal_symmetry"/>
+  <constant name="HcalEndcapRingSD_outer_symmetry"  value="HcalEndcap_symmetry"/>
+  <constant name="HcalEndcapRingSD_nlayers"         value="7"/>
+  <constant name="HcalEndcapSD_nlayers" value="40"/>
+
+  <constant name="HcalSD_gasInlet_length" value="3.0*mm"/>
+  <constant name="HcalSD_modules_gap" value="20*mm"/>
+  <constant name="HcalSD_spacer_separation" value="100*mm"/>
+  <constant name="HcalSD_spacer_thickness" value="8*mm"/>
+  <constant name="HcalSD_gasInlet_innerRadius" value="0.4*mm"/>
+  <constant name="HcalSD_gasInlet_outerRadius" value="0.5*mm"/>
+
+  
+
+  <!-- translations -->
+  <constant name="Hcal_endcap_zmin" value="HcalEndcap_min_z"/>
+
+  <!-- used for "hybrid" readout segmentation -->
+  <constant name="AHCal_cell_size" value="3.0*cm"/>
+  <constant name="SDHCal_cell_size" value="1.0*cm"/>
+  
+  <!-- TODO move these two element at the correct place -->
+  <!-- TODO create the additional detectors for the different options for l/s4 and l/s5 -->
+  <!-- TODO merge the two variables to only one for both barrel and endcap -->
+  <!-- barrel and endcvap constructors use the slices in reversed order ! -->
+  <!-- <constant name="Hcal_readout_segmentation_slice_barrel" value="3"/> -->
+  <!-- <constant name="Hcal_readout_segmentation_slice_endcap" value="3"/> -->
+
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/limits.xml b/Detector/DetCEPCv4/compact/limits.xml
new file mode 100644
index 0000000000000000000000000000000000000000..17023e1ba52968c0f20a2983e7cf134e54693d0c
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/limits.xml
@@ -0,0 +1,11 @@
+<define>
+  <constant name="cal_steplimit_val" value="5.0"/>
+  <constant name="cal_steplimit_unit" value="mm"/>
+
+  <constant name="tpc_steplimit_val" value="10.0"/>
+  <constant name="tpc_steplimit_unit" value="mm"/>
+
+  <constant name="tracker_steplimit_val" value="5.0"/>
+  <constant name="tracker_steplimit_unit" value="mm"/>
+</define>
+
diff --git a/Detector/DetCEPCv4/compact/materials.xml b/Detector/DetCEPCv4/compact/materials.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5e0ba2345541a067e10e04f76df2babf39331c6b
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/materials.xml
@@ -0,0 +1,552 @@
+  <materials>
+    <isotope N="1" Z="1" name="H1">
+      <atom unit="g/mole" value="1.00782503081372"/>
+    </isotope>
+    <isotope N="2" Z="1" name="H2">
+      <atom unit="g/mole" value="2.01410199966617"/>
+    </isotope>
+    <element name="H">
+      <fraction n="0.999885" ref="H1"/>
+      <fraction n="0.000115" ref="H2"/>
+    </element>
+    <isotope N="12" Z="6" name="C12">
+      <atom unit="g/mole" value="12"/>
+    </isotope>
+    <isotope N="13" Z="6" name="C13">
+      <atom unit="g/mole" value="13.0034"/>
+    </isotope>
+    <element name="C">
+      <fraction n="0.9893" ref="C12"/>
+      <fraction n="0.0107" ref="C13"/>
+    </element>
+    <isotope N="14" Z="7" name="N14">
+      <atom unit="g/mole" value="14.0031"/>
+    </isotope>
+    <isotope N="15" Z="7" name="N15">
+      <atom unit="g/mole" value="15.0001"/>
+    </isotope>
+    <element name="N">
+      <fraction n="0.99632" ref="N14"/>
+      <fraction n="0.00368" ref="N15"/>
+    </element>
+    <isotope N="16" Z="8" name="O16">
+      <atom unit="g/mole" value="15.9949"/>
+    </isotope>
+    <isotope N="17" Z="8" name="O17">
+      <atom unit="g/mole" value="16.9991"/>
+    </isotope>
+    <isotope N="18" Z="8" name="O18">
+      <atom unit="g/mole" value="17.9992"/>
+    </isotope>
+    <element name="O">
+      <fraction n="0.99757" ref="O16"/>
+      <fraction n="0.00038" ref="O17"/>
+      <fraction n="0.00205" ref="O18"/>
+    </element>
+    <material name="G4_KAPTON" state="solid">
+      <MEE unit="eV" value="79.6"/>
+      <D unit="g/cm3" value="1.42"/>
+      <fraction n="0.026362" ref="H"/>
+      <fraction n="0.691133" ref="C"/>
+      <fraction n="0.07327" ref="N"/>
+      <fraction n="0.209235" ref="O"/>
+    </material>
+    <isotope N="28" Z="14" name="Si28">
+      <atom unit="g/mole" value="27.9769"/>
+    </isotope>
+    <isotope N="29" Z="14" name="Si29">
+      <atom unit="g/mole" value="28.9765"/>
+    </isotope>
+    <isotope N="30" Z="14" name="Si30">
+      <atom unit="g/mole" value="29.9738"/>
+    </isotope>
+    <element name="Si">
+      <fraction n="0.922296077703922" ref="Si28"/>
+      <fraction n="0.0468319531680468" ref="Si29"/>
+      <fraction n="0.0308719691280309" ref="Si30"/>
+    </element>
+    <material name="SiC_foam" state="solid">
+      <MEE unit="eV" value="137.77733431141"/>
+      <D unit="g/cm3" value="0.19"/>
+      <fraction n="0.299548759813591" ref="C"/>
+      <fraction n="0.700451240186409" ref="Si"/>
+    </material>
+    <material Z="13" name="G4_Al" state="solid">
+      <MEE unit="eV" value="166"/>
+      <D unit="g/cm3" value="2.699"/>
+      <atom unit="g/mole" value="26.9815"/>
+      <fraction n="1" ref="Al"/>
+    </material>
+    <material name="G4_Si" state="solid">
+      <MEE unit="eV" value="173"/>
+      <D unit="g/cm3" value="2.33"/>
+      <fraction n="1" ref="Si"/>
+    </material>
+    <isotope N="63" Z="29" name="Cu63">
+      <atom unit="g/mole" value="62.9296"/>
+    </isotope>
+    <isotope N="65" Z="29" name="Cu65">
+      <atom unit="g/mole" value="64.9278"/>
+    </isotope>
+    <element name="Cu">
+      <fraction n="0.6917" ref="Cu63"/>
+      <fraction n="0.3083" ref="Cu65"/>
+    </element>
+    <material name="G4_Cu" state="solid">
+      <MEE unit="eV" value="322"/>
+      <D unit="g/cm3" value="8.96"/>
+      <fraction n="1" ref="Cu"/>
+    </material>
+    <material Z="4" name="G4_Be" state="solid">
+      <MEE unit="eV" value="63.7"/>
+      <D unit="g/cm3" value="1.848"/>
+      <atom unit="g/mole" value="9.01218"/>
+      <fraction n="1" ref="Be"/>
+    </material>
+    <isotope N="46" Z="22" name="Ti46">
+      <atom unit="g/mole" value="45.9526"/>
+    </isotope>
+    <isotope N="47" Z="22" name="Ti47">
+      <atom unit="g/mole" value="46.9518"/>
+    </isotope>
+    <isotope N="48" Z="22" name="Ti48">
+      <atom unit="g/mole" value="47.9479"/>
+    </isotope>
+    <isotope N="49" Z="22" name="Ti49">
+      <atom unit="g/mole" value="48.9479"/>
+    </isotope>
+    <isotope N="50" Z="22" name="Ti50">
+      <atom unit="g/mole" value="49.9448"/>
+    </isotope>
+    <element name="Ti">
+      <fraction n="0.0825" ref="Ti46"/>
+      <fraction n="0.0744" ref="Ti47"/>
+      <fraction n="0.7372" ref="Ti48"/>
+      <fraction n="0.0541" ref="Ti49"/>
+      <fraction n="0.0518" ref="Ti50"/>
+    </element>
+    <material name="G4_Ti" state="solid">
+      <MEE unit="eV" value="233"/>
+      <D unit="g/cm3" value="4.54"/>
+      <fraction n="1" ref="Ti"/>
+    </material>
+    <material name="styropor" state="solid">
+      <MEE unit="eV" value="65.9436601819466"/>
+      <D unit="g/cm3" value="0.025"/>
+      <fraction n="0.922577329294378" ref="C"/>
+      <fraction n="0.0774226707056217" ref="H"/>
+    </material>
+    <material name="GroundOrHVMix" state="solid">
+      <MEE unit="eV" value="259.806022507979"/>
+      <D unit="g/cm3" value="5.19"/>
+      <fraction n="0.00360636223506744" ref="H"/>
+      <fraction n="0.0945480597302505" ref="C"/>
+      <fraction n="0.0100234489402697" ref="N"/>
+      <fraction n="0.0286236705202312" ref="O"/>
+      <fraction n="0.863198458574181" ref="Cu"/>
+    </material>
+    <isotope N="35" Z="17" name="Cl35">
+      <atom unit="g/mole" value="34.9689"/>
+    </isotope>
+    <isotope N="37" Z="17" name="Cl37">
+      <atom unit="g/mole" value="36.9659"/>
+    </isotope>
+    <element name="Cl">
+      <fraction n="0.7578" ref="Cl35"/>
+      <fraction n="0.2422" ref="Cl37"/>
+    </element>
+    <material name="siPCBMix" state="solid">
+      <MEE unit="eV" value="262.475002085268"/>
+      <D unit="g/cm3" value="5.05076923076923"/>
+      <fraction n="0.014498933901919" ref="Cl"/>
+      <fraction n="0.083477099995865" ref="O"/>
+      <fraction n="0.0654857498400853" ref="Si"/>
+      <fraction n="0.00351122019083304" ref="H"/>
+      <fraction n="0.0142636698452849" ref="C"/>
+      <fraction n="0.818763326226013" ref="Cu"/>
+    </material>
+    <isotope N="36" Z="18" name="Ar36">
+      <atom unit="g/mole" value="35.9675"/>
+    </isotope>
+    <isotope N="38" Z="18" name="Ar38">
+      <atom unit="g/mole" value="37.9627"/>
+    </isotope>
+    <isotope N="40" Z="18" name="Ar40">
+      <atom unit="g/mole" value="39.9624"/>
+    </isotope>
+    <element name="Ar">
+      <fraction n="0.003365" ref="Ar36"/>
+      <fraction n="0.000632" ref="Ar38"/>
+      <fraction n="0.996003" ref="Ar40"/>
+    </element>
+    <material name="G4_AIR" state="gas">
+      <MEE unit="eV" value="85.7"/>
+      <D unit="g/cm3" value="0.00120479"/>
+      <fraction n="0.000124000124000124" ref="C"/>
+      <fraction n="0.755267755267755" ref="N"/>
+      <fraction n="0.231781231781232" ref="O"/>
+      <fraction n="0.0128270128270128" ref="Ar"/>
+    </material>
+    <material name="Vacuum" state="gas">
+      <D unit="g/cm3" value="0.00000000001"/>
+      <fraction n="1" ref="G4_AIR"/>
+    </material>
+    <material name="Air" state="gas">
+      <D unit="g/cm3" value="0.00120479"/>
+      <fraction n="1" ref="G4_AIR"/>
+    </material>
+    <material name="ThinAir" state="gas">
+      <D unit="g/cm3" value="0.00120479*1e-2"/>
+      <fraction n="1" ref="G4_AIR"/>
+    </material>
+    <isotope N="180" Z="74" name="W180">
+      <atom unit="g/mole" value="179.947"/>
+    </isotope>
+    <isotope N="182" Z="74" name="W182">
+      <atom unit="g/mole" value="181.948"/>
+    </isotope>
+    <isotope N="183" Z="74" name="W183">
+      <atom unit="g/mole" value="182.95"/>
+    </isotope>
+    <isotope N="184" Z="74" name="W184">
+      <atom unit="g/mole" value="183.951"/>
+    </isotope>
+    <isotope N="186" Z="74" name="W186">
+      <atom unit="g/mole" value="185.954"/>
+    </isotope>
+    <element name="W">
+      <fraction n="0.0012" ref="W180"/>
+      <fraction n="0.265" ref="W182"/>
+      <fraction n="0.1431" ref="W183"/>
+      <fraction n="0.3064" ref="W184"/>
+      <fraction n="0.2843" ref="W186"/>
+    </element>
+    <material name="G4_W" state="solid">
+      <MEE unit="eV" value="727"/>
+      <D unit="g/cm3" value="19.3"/>
+      <fraction n="1" ref="W"/>
+    </material>
+    <material name="g10" state="solid">
+      <MEE unit="eV" value="114.378463512112"/>
+      <D unit="g/cm3" value="1.7"/>
+      <fraction n="0.08" ref="Cl"/>
+      <fraction n="0.460597175271302" ref="O"/>
+      <fraction n="0.361327255" ref="Si"/>
+      <fraction n="0.0193736737588317" ref="H"/>
+      <fraction n="0.078701895969866" ref="C"/>
+    </material>
+    <isotope N="54" Z="26" name="Fe54">
+      <atom unit="g/mole" value="53.9396"/>
+    </isotope>
+    <isotope N="56" Z="26" name="Fe56">
+      <atom unit="g/mole" value="55.9349"/>
+    </isotope>
+    <isotope N="57" Z="26" name="Fe57">
+      <atom unit="g/mole" value="56.9354"/>
+    </isotope>
+    <isotope N="58" Z="26" name="Fe58">
+      <atom unit="g/mole" value="57.9333"/>
+    </isotope>
+    <element name="Fe">
+      <fraction n="0.05845" ref="Fe54"/>
+      <fraction n="0.91754" ref="Fe56"/>
+      <fraction n="0.02119" ref="Fe57"/>
+      <fraction n="0.00282" ref="Fe58"/>
+    </element>
+    <isotope N="50" Z="24" name="Cr50">
+      <atom unit="g/mole" value="49.946"/>
+    </isotope>
+    <isotope N="52" Z="24" name="Cr52">
+      <atom unit="g/mole" value="51.9405"/>
+    </isotope>
+    <isotope N="53" Z="24" name="Cr53">
+      <atom unit="g/mole" value="52.9407"/>
+    </isotope>
+    <isotope N="54" Z="24" name="Cr54">
+      <atom unit="g/mole" value="53.9389"/>
+    </isotope>
+    <element name="Cr">
+      <fraction n="0.04345" ref="Cr50"/>
+      <fraction n="0.83789" ref="Cr52"/>
+      <fraction n="0.09501" ref="Cr53"/>
+      <fraction n="0.02365" ref="Cr54"/>
+    </element>
+    <isotope N="58" Z="28" name="Ni58">
+      <atom unit="g/mole" value="57.9353"/>
+    </isotope>
+    <isotope N="60" Z="28" name="Ni60">
+      <atom unit="g/mole" value="59.9308"/>
+    </isotope>
+    <isotope N="61" Z="28" name="Ni61">
+      <atom unit="g/mole" value="60.9311"/>
+    </isotope>
+    <isotope N="62" Z="28" name="Ni62">
+      <atom unit="g/mole" value="61.9283"/>
+    </isotope>
+    <isotope N="64" Z="28" name="Ni64">
+      <atom unit="g/mole" value="63.928"/>
+    </isotope>
+    <element name="Ni">
+      <fraction n="0.680769" ref="Ni58"/>
+      <fraction n="0.262231" ref="Ni60"/>
+      <fraction n="0.011399" ref="Ni61"/>
+      <fraction n="0.036345" ref="Ni62"/>
+      <fraction n="0.009256" ref="Ni64"/>
+    </element>
+    <material name="stainless_steel" state="solid">
+      <MEE unit="eV" value="282.929693036223"/>
+      <D unit="g/cm3" value="7.87"/>
+      <fraction n="0.70611" ref="Fe"/>
+      <fraction n="0.18784" ref="Cr"/>
+      <fraction n="0.10605" ref="Ni"/>
+    </material>
+    <material name="fanele2" state="solid">
+      <MEE unit="eV" value="75.3984269235952"/>
+      <D unit="g/cm3" value="2.04"/>
+      <fraction n="0.0814736540216391" ref="H"/>
+      <fraction n="0.543350389498575" ref="C"/>
+      <fraction n="0.257623229207059" ref="O"/>
+      <fraction n="0.0266436363636364" ref="N"/>
+      <fraction n="0.0909090909090909" ref="Cu"/>
+    </material>
+    <material name="fanele1" state="solid">
+      <MEE unit="eV" value="83.6887639821308"/>
+      <D unit="g/cm3" value="2.61666666666667"/>
+      <fraction n="0.0746841828531692" ref="H"/>
+      <fraction n="0.498071190373694" ref="C"/>
+      <fraction n="0.236154626773137" ref="O"/>
+      <fraction n="0.0244233333333333" ref="N"/>
+      <fraction n="0.166666666666667" ref="Cu"/>
+    </material>
+    <material name="G4_POLYSTYRENE" state="solid">
+      <MEE unit="eV" value="68.7"/>
+      <D unit="g/cm3" value="1.06"/>
+      <fraction n="0.077418" ref="H"/>
+      <fraction n="0.922582" ref="C"/>
+    </material>
+    <isotope N="79" Z="35" name="Br79">
+      <atom unit="g/mole" value="78.9183"/>
+    </isotope>
+    <isotope N="81" Z="35" name="Br81">
+      <atom unit="g/mole" value="80.9163"/>
+    </isotope>
+    <element name="Br">
+      <fraction n="0.5069" ref="Br79"/>
+      <fraction n="0.4931" ref="Br81"/>
+    </element>
+    <material name="PCB" state="solid">
+      <MEE unit="eV" value="88.255598548367"/>
+      <D unit="g/cm3" value="1.7"/>
+      <fraction n="0.180774" ref="Si"/>
+      <fraction n="0.405633" ref="O"/>
+      <fraction n="0.278042" ref="C"/>
+      <fraction n="0.0684428" ref="H"/>
+      <fraction n="0.0671091" ref="Br"/>
+    </material>
+    <material name="G4_Fe" state="solid">
+      <MEE unit="eV" value="286"/>
+      <D unit="g/cm3" value="7.874"/>
+      <fraction n="1" ref="Fe"/>
+    </material>
+    <material name="beam" state="gas">
+      <P unit="pascal" value="6.25e-06"/>
+      <MEE unit="eV" value="38.5760755714278"/>
+      <D unit="g/cm3" value="1.7e-14"/>
+      <fraction n="0.36264" ref="H"/>
+      <fraction n="0.36276" ref="N"/>
+      <fraction n="0.117748421296248" ref="C"/>
+      <fraction n="0.156851578703752" ref="O"/>
+    </material>
+    <material name="TDR_gas" state="gas">
+      <MEE unit="eV" value="177.374841770826"/>
+      <D unit="g/cm3" value="0.001731"/>
+      <fraction n="0.95667" ref="Ar"/>
+      <fraction n="0.00519198196" ref="H"/>
+      <fraction n="0.02165502376" ref="C"/>
+      <fraction n="0.01648299428" ref="O"/>
+    </material>
+    <material name="epoxy" state="solid">
+      <MEE unit="eV" value="60.8292941662115"/>
+      <D unit="g/cm3" value="1.3"/>
+      <fraction n="0.131793699039672" ref="H"/>
+      <fraction n="0.535387047414054" ref="C"/>
+      <fraction n="0.332819253546274" ref="O"/>
+    </material>
+    <material name="G4_C" state="solid">
+      <MEE unit="eV" value="81"/>
+      <D unit="g/cm3" value="2"/>
+      <fraction n="1" ref="C"/>
+    </material>
+    <isotope N="27" Z="13" name="Al27">
+      <atom unit="g/mole" value="26.9815"/>
+    </isotope>
+    <element name="Al">
+      <fraction n="1" ref="Al27"/>
+    </element>
+
+<!-- 
+    <material name="TPC_endplate_mix">
+      <! D value="1.7" unit="g/cm3"/    >
+      <composite n="74" ref="G4_AIR"/>
+      <composite n="12" ref="g10"/>
+      <composite n="14" ref="G4_Al"/>
+    </material>
+-->
+ 
+    <material name="TPC_endplate_mix" state="solid">
+      <MEE unit="eV" value="97.0754229107761"/>
+      <D unit="g/cm3" value="0.5827515446"/>
+      <fraction n="0.00953598760814401" ref="C"/>
+      <fraction n="0.558898138898139" ref="N"/>
+      <fraction n="0.226789772550668" ref="O"/>
+      <fraction n="0.00949198949198949" ref="Ar"/>
+      <fraction n="0.14" ref="Al"/>
+      <fraction n="0.0096" ref="Cl"/>
+      <fraction n="0.0433592706" ref="Si"/>
+      <fraction n="0.00232484085105981" ref="H"/>
+    </material>
+    <material name="CarbonFiber" state="solid">
+      <MEE unit="eV" value="70.7270877537631"/>
+      <D unit="g/cm3" value="1.46666666666667"/>
+      <fraction n="0.794091986922138" ref="C"/>
+      <fraction n="0.058408571165309" ref="H"/>
+      <fraction n="0.147499441912553" ref="O"/>
+    </material>
+    <material name="CarbonFiber_25percent">
+      <D type="density" value="0.375" unit="g/cm3"/>
+      <fraction n="1.0" ref="CarbonFiber"/>
+    </material>
+    <material name="CarbonFiber_15percent">
+      <D type="density" value="0.225" unit="g/cm3"/>
+      <fraction n="1.0" ref="CarbonFiber"/>
+    </material>
+    <material name="G4_GRAPHITE" state="solid">
+      <MEE unit="eV" value="78"/>
+      <D unit="g/cm3" value="2.21"/>
+      <fraction n="1" ref="C"/>
+    </material>
+    <material name="diamond" state="solid">
+      <MEE unit="eV" value="81"/>
+      <D unit="g/cm3" value="3.51"/>
+      <fraction n="1" ref="C"/>
+    </material>
+    <material Z="79" name="G4_Au" state="solid">
+      <MEE unit="eV" value="790"/>
+      <D unit="g/cm3" value="19.32"/>
+      <atom unit="g/mole" value="196.967"/>
+    </material>
+    <material name="G4_POLYETHYLENE" state="solid">
+      <MEE unit="eV" value="57.4"/>
+      <D unit="g/cm3" value="0.94"/>
+      <fraction n="0.143711" ref="H"/>
+      <fraction n="0.856289" ref="C"/>
+    </material>
+    <isotope N="55" Z="25" name="Mn55">
+      <atom unit="g/mole" value="54.938"/>
+    </isotope>
+    <element name="Mn">
+      <fraction n="1" ref="Mn55"/>
+    </element>
+    <material name="Steel235" state="solid">
+      <MEE unit="eV" value="285.146562707739"/>
+      <D unit="g/cm3" value="7.87"/>
+      <fraction n="0.9843" ref="Fe"/>
+      <fraction n="0.0017" ref="C"/>
+      <fraction n="0.014" ref="Mn"/>
+    </material>
+
+    <comment> materials introduced for the BeamCal</comment>
+    <material name="TungstenDens24">
+      <D value="17.8" unit="g/cm3"/>
+      <fraction n="0.93" ref="W"/>
+      <fraction n="0.061" ref="Ni"/>
+      <fraction n="0.009" ref="Fe"/>
+    </material>
+
+    <material name="Kapton">
+      <D value="1.43" unit="g/cm3" />
+      <composite n="22" ref="C"/>
+      <composite n="10" ref="H" />
+      <composite n="2" ref="N" />
+      <composite n="5" ref="O" />
+    </material>
+
+    <comment> materials for the SemiDigital Hadronic calorimeter</comment>
+    <material name="RPCGAS2" >
+    <!-- C2H2F4 (TFE) 0.93% + IsoButane 0.05% + SF6 0.02% -->
+    <!--  <D value="0.00421" unit="g/cm3" /> -->
+      <D value="0.00449" unit="g/cm3" />
+      <fraction n="0.70828" ref="F"/>
+      <fraction n="0.26054" ref="C"/>
+      <fraction n="0.01928" ref="H"/>
+      <fraction n="0.00439" ref="S"/>
+    </material>
+
+    <material name="FloatGlass" >
+<!--      <D value="2.44" unit="g/cm3" /> -->
+      <D value="2.49" unit="g/cm3" />
+      <fraction n="0.46645" ref="O"/>
+      <fraction n="0.34125" ref="Si"/>
+      <fraction n="0.06432" ref="Ca"/>
+      <fraction n="0.02412" ref="Mg"/>
+      <fraction n="0.10386" ref="Na"/>
+    </material>
+
+    <material name="mylar">
+      <D value="1.4" unit="g/cm3" />
+      <fraction n="0.333025" ref="O"/>
+      <fraction n="0.041959" ref="H"/>
+      <fraction n="0.625016" ref="C"/>
+    </material>
+
+    <material name="Nylon" >
+    <!-- Nylon-6-6 -->
+<!--      <MEE unit="eV" value="63.9"/> -->
+      <D value="1.14" unit="g/cm3" />
+      <fraction n="0.097976" ref="H"/>
+      <fraction n="0.636856" ref="C"/>
+      <fraction n="0.123779" ref="N"/>
+      <fraction n="0.141389" ref="O"/>
+    </material>
+
+    <material name="PEEK-GF30" >
+      <D value="1.51" unit="g/cm3" />
+      <fraction n="0.554056" ref="C"/>
+      <fraction n="0.116535" ref="O"/>
+      <fraction n="0.029408" ref="H"/>
+      <fraction n="0.333333" ref="Si"/>
+    </material>
+
+    <material name="g10-RPC">
+<!--      <MEE unit="eV" value="114.378463512112"/> -->
+      <D value="1.80" unit="g/cm3" />
+      <fraction n="0.07868" ref="C"/>
+      <fraction n="0.46056" ref="O"/>
+      <fraction n="0.02045" ref="H"/>
+      <fraction n="0.46056" ref="Si"/>
+      <fraction n="0.080"   ref="Cl"/>
+    </material>
+
+    <material name="graphite">
+      <MEE unit="eV" value="78"/>
+      <D value="2.21" unit="g/cm3" />
+      <fraction n="1.00" ref="C"/>
+    </material>
+
+    <material name="Steel304L">
+      <D type="density" value="8.00" unit="g/cm3" />
+      <fraction n="0.695" ref="Fe" />
+      <fraction n="0.185" ref="Cr" />
+      <fraction n="0.100" ref="Ni" />
+      <fraction n="0.020" ref="Mn" />
+    </material>
+
+    <!-- to model beampipe with 2mm Be + 0.7mm Cu cables (calc by DJeans) -->
+    <material name="BeampipeBeCableMix">
+      <D type="density" value="3.69" unit="g/cm3" />
+       <fraction n="0.806" ref="Be" />
+       <fraction n="0.194" ref="Cu" />
+    </material>
+
+
+  </materials>
diff --git a/Detector/DetCEPCv4/compact/misc_defs.xml b/Detector/DetCEPCv4/compact/misc_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4ef1eec8f4afd0e0358bd377f276ba6784249069
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/misc_defs.xml
@@ -0,0 +1,10 @@
+<define>
+
+  <constant name="Ecal_endcap_zmax" value="EcalEndcap_max_z"/>
+  <constant name="Ecal_endcap_plug_rmin" value="EcalEndcapRing_inner_radius"/>
+
+  <constant name="TUBE_crossing_angle" value="CepC_Main_Crossing_Angle"/>
+
+</define>
+
+
diff --git a/Detector/DetCEPCv4/compact/services_defs.xml b/Detector/DetCEPCv4/compact/services_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..91e4ed58b436936f24818235a97d85022c8fbcf3
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/services_defs.xml
@@ -0,0 +1,45 @@
+<define>
+
+  <!-- services -->
+  <!-- constant name="EcalBarrelServices_RailDistanceToRight" value="166.5*mm"/ -->
+  <constant name="EcalBarrelServices_RailDistanceToRight" value="500*mm"/>
+  <constant name="EcalBarrelServices_RailHeight" value="30.0*mm"/>
+  <constant name="EcalBarrelServices_RailSeparation" value="880.0*mm"/>
+  <constant name="EcalBarrelServices_RailWidth" value="103.25*mm"/>
+
+  <constant name="EcalBarrelServices_ZMinus_FirstInterrail_Cu_Thickness" value="(1.8*mm+0.9*mm)/2."/>
+  <constant name="EcalBarrelServices_ZMinus_FirstInterrail_PE_Thickness" value="4.5*mm"/>
+  <constant name="EcalBarrelServices_ZPlus_FirstInterrail_Cu_Thickness" value="(1.09*mm+0.61*mm)/2."/>
+  <constant name="EcalBarrelServices_ZPlus_FirstInterrail_PE_Thickness" value="2.67*mm"/>
+
+  <constant name="EcalBarrel_EndCapServices_ZMinus_Cu_Thickness" value="5.2*mm"/>
+  <constant name="EcalBarrel_EndCapServices_ZMinus_PE_Thickness" value="12.4*mm"/>
+  <constant name="EcalBarrel_EndCapServices_ZPlus_Cu_Thickness" value="3.5*mm"/>
+  <constant name="EcalBarrel_EndCapServices_ZPlus_PE_Thickness" value="8.3*mm"/>
+
+  <constant name="HcalServicesModule_InnerServicesWidth" value="200.0*mm"/>
+  <constant name="BuildHcalElectronicsInterface" value="1"/>
+  <constant name="HcalServicesModule_ZMinus_StainlessSteel_Thickness" value="15.0*mm"/>
+  <constant name="HcalServicesModule_ZMinus_PE_Thickness" value="27.5*mm"/>
+  <constant name="HcalServicesModule_ZMinus_Cu_Thickness" value="8.2*mm"/>
+  <constant name="HcalServicesModule_ZPlus_StainlessSteel_Thickness" value="15.0*mm"/>
+  <constant name="HcalServicesModule_ZPlus_PE_Thickness" value="25.6*mm"/>
+  <constant name="HcalServicesModule_ZPlus_Cu_Thickness" value="7.4*mm"/>
+  <constant name="Hcal_steel_cassette_thickness" value="0.5*mm"/>
+  <constant name="HcalServices_outer_FR4_thickness" value="2.8*mm"/>
+  <constant name="HcalServices_outer_Cu_thickness" value="0.4*mm"/>
+  <constant name="Hcal_endcap_services_module_width" value="100.0*mm"/>
+
+  <constant name="SIT12_cable_thickness" value="0.063*mm"/>
+  <constant name="petal_cp_support_thickness" value="2.0*mm"/>
+  <constant name="disk_si_thickness" value="0.2*mm"/>
+  <constant name="petal_support_zoffset" value="1.5*mm"/>
+  <constant name="ftd2_sit1_radial_diff" value="0.0*mm"/>
+  <constant name="ftd3_sit2_radial_diff" value="-1.0*mm"/>
+  <constant name="SServices_FTD2_cone_thickness" value="0.040*mm"/>
+  <constant name="SServices_FTD3_cone_thickness" value="0.020*mm"/>
+  <constant name="SServices_FTD7_cables_thickness" value="0.85*mm"/>
+
+  <constant name="VXD_cable_cross_section_area" value="25.0*mm*mm"/>
+  <constant name="VXD_cable_inner1_radius" value="30.0*mm"/>
+</define>
diff --git a/Detector/DetCEPCv4/compact/set_simple_planar_sensors_01.xml b/Detector/DetCEPCv4/compact/set_simple_planar_sensors_01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ba8966c6ff5180595b237a4d958985f27b3ad3c7
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/set_simple_planar_sensors_01.xml
@@ -0,0 +1,47 @@
+<!--
+   SET parameters for ILD_o1_v5
+  -->
+
+<lccdd>
+
+  <detectors>
+
+    <detector name="SET" type="SET_Simple_Planar" vis="ILD_SETVis" id="ILDDetID_SET" readout="SETCollection" insideTrackingVolume="true">
+
+      <envelope vis="ILD_SETVis">
+        <shape type="Tube" rmin="SET_inner_radius" rmax="SET_outer_radius" dz="SET_half_length"  material = "Air" />
+      </envelope>
+
+      <type_flags type="DetType_TRACKER +  DetType_BARREL + DetType_STRIP "/>
+
+      <!-- database : set_simple_planar_sensors_01 -->
+
+      <!-- SQL command: "select * from extended_reconstruction_parameters;"  -->
+      <reconstruction strip_width="0.0125*mm" strip_length="92*mm" strip_pitch="0.05*mm" strip_angle="7*deg"  />
+
+      <!-- SQL command: "select * from global;"  -->
+      <global sensitive_thickness="0.2*mm" support_thickness="1*mm" sensor_length="92*mm" sensitive_mat="G4_Si"
+              support_mat="G4_C" sensitive_threshold_KeV="64*keV"  />
+
+      <!-- SQL command: "select * from set_layers;"  -->
+
+      <layer layer_id="0" sensitive_distance_from_tpc="3*mm" coverage_of_TPC_Ecal_Hcal_barrel="0.98"
+             n_ladders="24" ladder_clearance="0.1*mm" faces_IP="1"  />
+
+      <layer layer_id="1" sensitive_distance_from_tpc="5.5*mm" coverage_of_TPC_Ecal_Hcal_barrel="0.98"
+             n_ladders="24" ladder_clearance="0.1*mm" faces_IP="0"  />
+
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="SETCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+  </readouts>
+
+
+</lccdd>
+
diff --git a/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_01.xml b/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6e7d7d46d2d77bad304433a8e4e68c4dea6390f1
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_01.xml
@@ -0,0 +1,55 @@
+<!--
+   SIT parameters for ILD_o1_v5
+  -->
+
+<lccdd>
+
+  <detectors>
+
+    <detector name="SIT" type="SIT_Simple_Pixel" vis="ILD_SITVis" id="ILDDetID_SIT" readout="SITCollection" insideTrackingVolume="true">
+
+      <envelope vis="ILD_SITVis">
+
+        <shape type="BooleanShape" operation="Union" material="Air" >
+          <shape type="Tube" rmin="SIT_inner_radius"   rmax="SIT_outer_radius_1" dz="SIT_half_length_1" />
+          <shape type="Tube" rmin="SIT_outer_radius_1" rmax="SIT_outer_radius"   dz="SIT_half_length" />
+        </shape>
+
+      </envelope>
+
+      <type_flags type="DetType_TRACKER + DetType_BARREL + DetType_STRIP "/>
+
+      <!-- database : sit_simple_planar_sensors_03 -->
+
+      <!-- SQL command: "select * from extended_reconstruction_parameters;"  -->
+      <reconstruction strip_width="0." strip_length="92*mm" strip_pitch="0." strip_angle="0*deg"  />
+
+      <!-- SQL command: "select * from global;"  -->
+      <global sensitive_thickness="0.2*mm" support_thickness="1*mm" sensor_length="92*mm"
+              sensitive_mat="G4_Si" support_mat="G4_C" sensitive_threshold_KeV="64*keV"  />
+
+      <!-- SQL command: "select * from sit_layers;"  -->
+      <layer layer_id="0" sensitive_radius="153*mm" n_sensors_per_ladder="8" n_ladders="10"
+             ladder_clearance="0.1*mm" faces_IP="1" is_SIT1="1" is_SIT2="0"  />
+
+      <layer layer_id="1" sensitive_radius="155.5*mm" n_sensors_per_ladder="8" n_ladders="10"
+             ladder_clearance="0.1*mm" faces_IP="0" is_SIT1="0" is_SIT2="0"  />
+
+      <layer layer_id="2" sensitive_radius="300*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="1" is_SIT1="0" is_SIT2="1"  />
+
+      <layer layer_id="3" sensitive_radius="302.5*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="0" is_SIT1="0" is_SIT2="0"  />
+
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="SITCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_02.xml b/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_02.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bb95b043624ce8dc91057032ebf900d216d08120
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/sit_simple_pixel_sensors_02.xml
@@ -0,0 +1,61 @@
+<!--
+   SIT parameters for ILD_o1_v5
+  -->
+
+<lccdd>
+
+  <detectors>
+
+    <detector name="SIT" type="SIT_Simple_Pixel" vis="ILD_SITVis" id="ILDDetID_SIT" readout="SITCollection" insideTrackingVolume="true">
+
+      <envelope vis="ILD_SITVis">
+
+        <shape type="BooleanShape" operation="Union" material="Air" >
+          <shape type="Tube" rmin="SIT_inner_radius"   rmax="SIT_outer_radius_1" dz="SIT_half_length_1" />
+          <shape type="Tube" rmin="SIT_outer_radius_1" rmax="SIT_outer_radius"   dz="SIT_half_length" />
+        </shape>
+
+      </envelope>
+
+      <type_flags type="DetType_TRACKER + DetType_BARREL + DetType_STRIP "/>
+
+      <!-- database : sit_simple_planar_sensors_03 -->
+
+      <!-- SQL command: "select * from extended_reconstruction_parameters;"  -->
+      <reconstruction strip_width="0." strip_length="92*mm" strip_pitch="0." strip_angle="0*deg"  />
+
+      <!-- SQL command: "select * from global;"  -->
+      <global sensitive_thickness="0.2*mm" support_thickness="1*mm" sensor_length="92*mm"
+              sensitive_mat="G4_Si" support_mat="G4_C" sensitive_threshold_KeV="64*keV"  />
+
+      <!-- SQL command: "select * from sit_layers;"  -->
+      <layer layer_id="0" sensitive_radius="153*mm" n_sensors_per_ladder="8" n_ladders="10"
+             ladder_clearance="0.1*mm" faces_IP="1" is_SIT1="1" is_SIT2="0"  />
+
+      <layer layer_id="1" sensitive_radius="155.5*mm" n_sensors_per_ladder="8" n_ladders="10"
+             ladder_clearance="0.1*mm" faces_IP="0" is_SIT1="0" is_SIT2="0"  />
+
+      <layer layer_id="2" sensitive_radius="321*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="1" is_SIT1="0" is_SIT2="1"  />
+
+      <layer layer_id="3" sensitive_radius="323.5*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="0" is_SIT1="0" is_SIT2="0"  />
+
+      <layer layer_id="4" sensitive_radius="300*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="1" is_SIT1="0" is_SIT2="1"  />
+
+      <layer layer_id="5" sensitive_radius="302.5*mm" n_sensors_per_ladder="14" n_ladders="19"
+             ladder_clearance="0.1*mm" faces_IP="0" is_SIT1="0" is_SIT2="0"  />
+
+    </detector>
+
+  </detectors>
+
+  <readouts>
+    <readout name="SITCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+  </readouts>
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/top_defs.xml b/Detector/DetCEPCv4/compact/top_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c774b8c438307c4bbe4aeeea0bd412e1146adafe
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/top_defs.xml
@@ -0,0 +1,131 @@
+<define>
+
+  <comment>
+    all hardcoded overall dimensions needed to define envelopes are in this file
+    this file has the parts common to the different detector versions
+
+    subdetector-specific ones are in separate files
+  </comment>
+
+  <constant name="CepC_Main_Crossing_Angle" value="33*mrad"/>
+
+  <!-- the field inside and outside the solenoid -->
+  <constant name="outerField_nominal_value" value="-1.5*tesla"/>
+
+
+  <!-- VXD -->
+  <constant name="top_VXD_inner_radius"   value="15.95*mm "/>
+  <constant name="top_VXD_outer_radius"   value="101*mm "/>
+  <constant name="top_VXD_half_length"    value="200*mm "/>
+
+  <!-- FTD -->
+  <constant name="top_FTD1_vtx3_distance_z" value="95*mm"/>
+
+  <constant name="FTD_disk2_zPosRelToTpcLength" value="0.158004"/>
+  <constant name="FTD_disk3_zPosRelToTpcLength" value="0.273577"/>
+  <constant name="FTD_disk4_zPosRelToTpcLength" value="0.359149"/>
+  <constant name="FTD_disk5_zPosRelToTpcLength" value="0.3936"/>
+  <constant name="FTD_disk6_zPosRelToTpcLength" value="0.786611"/>
+
+  <constant name="top_FTD7_ecal_distance_z" value="200*mm"/>
+
+
+  <!-- SIT -->
+  <constant name="SIT1_Half_Length_Z" value="368.00*mm"/>
+  <constant name="SIT1_Radius"        value="153.00*mm"/>
+  <constant name="SIT2_Half_Length_Z" value="644.00*mm"/>
+  <constant name="SIT2_Radius"        value="299.90*mm"/>
+
+  <!-- TPC -->
+  <constant name="TPC_Ecal_Hcal_barrel_halfZ" value="2350*mm"/>
+  <constant name="top_TPC_inner_radius"    value="329*mm"/>
+
+  <!-- ECAL -->
+  <constant name="Ecal_Tpc_gap" value="35*mm"/>
+  <constant name="Ecal_Hcal_symmetry"   value="8"/>
+
+  <constant name="Ecal_barrel_thickness" value="196.96*mm"/>
+
+  <constant name="Hcal_Ecal_gap" value="30*mm"/>
+
+  <!-- constant name="Ecal_endcap_zmin" value="2450.0*mm"/ -->
+  <constant name="Ecal_endcap_zmin" value="TPC_Ecal_Hcal_barrel_halfZ + 100.0*mm"/>
+
+  <constant name="Ecal_endcap_center_box_size" value="800.0*mm"/>
+
+  <constant name="Ecal_Lcal_ring_gap" value="140*mm"/>
+  <constant name="Ecal_EC_Ring_gap" value="10*mm"/>
+
+  <!-- HCAL -->
+  <constant name="Hcal_barrel_thickness" value="1272.3*mm"/>
+  <constant name="Hcal_Coil_additional_gap" value="29.5*mm"/>
+  <!--constant name="Hcal_outer_symmetry" value="16"/-->
+  <constant name="Hcal_outer_symmetry" value="8"/>
+
+  <constant name="Hcal_endcap_center_box_size" value="700.0*mm"/>
+  <constant name="Hcal_endcap_zmin" value="2650*mm" />
+  <constant name="Hcal_endcap_thickness" value="1287.0*mm"/>
+  <constant name="Hcal_radial_ring_inner_gap" value="50*mm"/>
+  <constant name="Hcal_endcap_cryostat_gap" value="170*mm"/>
+
+  <!-- coil -->
+  <constant name="Coil_extra_size" value="1522*mm"/>
+  <constant name="Coil_thickness" value="750.0*mm"/>
+
+
+  <!-- Yoke -->
+  <constant name="top_Yoke_symmetry"        value="12"/>
+  <!-- define relative to HCAL
+       <constant name="top_Yoke_inner_radius"    value="4424.0*mm"/>
+       <constant name="top_Yoke_outer_radius"    value="7725.0*mm"/>
+       -->
+  <constant name="top_Hcal_Yoke_gap"       value="300*mm"/>
+  <constant name="top_Yoke_thickness"      value="2550*mm"/>
+
+  <constant name="top_Yoke_half_length"     value="4047.0*mm"/>
+  <constant name="Yoke_Z_start_endcaps"     value="4072.0*mm"/>
+  <constant name="Yoke_endcap_inner_radius" value="320*mm"/>
+
+  <!-- lumical -->
+  <constant name="top_Lcal_inner_radius" value="30.0*mm"/>
+  <constant name="Lcal_outer_radius"     value="100.0*mm"/>
+  <constant name="LumiCal_tubebulge_overshoot"   value="11.2*mm"/>
+  <constant name="top_Lcal_z_begin"      value="Ecal_endcap_zmin" />
+
+  <!-- lhcal -->
+  <constant name="top_LHCal_thickness"               value="480*mm"/>
+
+  <constant name="top_LHCal_inner_radius"            value="130*mm"/>
+  <constant name="top_LHCal_outer_radius"            value="315*mm"/>
+  <constant name="top_LHCal_min_z"                   value="2680*mm"/>
+  <constant name="LHcal_zend"           value="top_LHCal_min_z + top_LHCal_thickness"/>
+  <constant name="LHcal_BCal_clearance" value="35*mm"/>
+
+  <!-- beamcal -->
+  <constant name="top_BCal_nLayers"                  value="30"/>
+  <constant name="top_BeamCal_layerThickness"        value="4.0008*mm"/>
+  <constant name="top_BCal_dGraphite"                value="80*mm"/>
+  <constant name="top_BeamCal_thickness"             value="top_BCal_dGraphite + top_BCal_nLayers*top_BeamCal_layerThickness"/>
+  <constant name="top_BeamCal_tubeIncoming_radius"   value="15.0*mm"/>
+  <constant name="top_BeamCal_tubeIncoming_clearance"   value="1.0*mm"/> <!-- Allow some clearance -->
+  <constant name="BCal_rInner" value="17.8*mm"/>
+  <constant name="BCal_rOuter" value="140*mm"/>
+
+  <!-- the beam tube -->
+  <constant name="TUBE_IPInnerTube_end_z"         value="200*mm"/>
+  <constant name="TUBE_central_inner_radius" value="14*mm"/>
+  <constant name="TUBE_central_thickness" value="0.5*mm"/>
+
+  <constant name="TUBE_IPInnerBulge_end_z"        value="500*mm"/>
+  <constant name="TUBE_IPInnerBulge_end_innerradius" value="19.5*mm"/>
+
+  <constant name="TUBE_IPOuterTube_start_z"       value="500*mm"/>
+  <constant name="TUBE_IPOuterTube_end_z"         value="700*mm"/>
+
+  <constant name="TUBE_Lcal_clearance" value="20*mm"/>
+
+  <!-- space left for envelopes (counting from inner beampipe surface) -->
+  <constant name="TUBE_inner_maxthick" value="1.0*mm"/> 
+  <constant name="TUBE_outer_maxthick" value="3.0*mm"/> 
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/top_defs_CepC_v04.xml b/Detector/DetCEPCv4/compact/top_defs_CepC_v04.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9ad0a0233586cf356feb6692d423d11cd6fb8323
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/top_defs_CepC_v04.xml
@@ -0,0 +1,12 @@
+<define>
+
+<comment> 
+all hardcoded overall dimensions which differ between large and small models
+</comment>
+
+  <constant name="Field_nominal_value" value="3.0*tesla"/>
+  <constant name="top_TPC_outer_radius"    value="1808*mm"/>
+  <constant name="Ecal_endcap_extra_size" value="52.68*mm"/>
+  <constant name="Ecal_endcap_number_of_towers" type="string" value="4 5"/>
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/tpc10_01.xml b/Detector/DetCEPCv4/compact/tpc10_01.xml
new file mode 100644
index 0000000000000000000000000000000000000000..eb46b3b7335c717378890327c0c1d64eeab9ca47
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/tpc10_01.xml
@@ -0,0 +1,94 @@
+<!--
+   TPC parameters for ILD_o1_v5
+  -->
+
+<lccdd>
+
+  <detectors>
+
+    <detector name="TPC" type="TPC10" vis="TPCVis" id="ILDDetID_TPC" limits="Tracker_limits" readout="TPCCollection" insideTrackingVolume="true">
+
+
+      <envelope vis="ILD_TPCVis">
+        <shape type="Tube" rmin="TPC_inner_radius" rmax="TPC_outer_radius"
+               dz="TPC_half_length"  material = "Air" />
+      </envelope>
+
+      <type_flags type="DetType_TRACKER +  DetType_BARREL + DetType_GASEOUS "/>
+
+      <!-- database : tpc10_01 -->
+      <!-- SQL command: "SELECT * FROM `global`;"  -->
+
+      <!--	ORIGINAL :     dr_InnerServiceArea="30*mm" dr_OuterServiceArea="30*mm"  DANIEL REDUCED TO FIT THICK ECAL -->
+
+      <global TPC_pad_height="6*mm" TPC_pad_width="1*mm"  TPC_max_step_length="5*mm" dr_InnerWall="25*mm" 
+	      dr_InnerServiceArea="18.1*mm" dr_OuterServiceArea="18.1*mm"
+              dr_OuterWall="55*mm" dz_Cathode="0.06*mm" dz_Readout="25*mm" dz_Endplate="100*mm"
+              chamber_Gas="TDR_gas" sensitive_threshold_eV="32*eV"  />
+
+      <!-- updates from Dimitra 4/7/17 -->
+      <cathode dz_Cathode_Insulator="0.046*mm" dz_Cathode_Conductor="0.004*mm" material_Cathode_Insulator="G4_KAPTON"
+               material_Cathode_Conductor="G4_Cu" dr_Cathode_Grip="18*mm" dz_Cathode_Grip="15*mm" material_Cathode_Grip="SiC_foam"  />
+
+
+
+      <!-- SQL command: "SELECT * FROM `innerWall`;"  -->
+      <innerWall>
+	<!-- updates from Dimitra 4/7/17 -->
+	<row dr="0.07*mm" material="G4_Cu"  />
+	<row dr="0.05*mm" material="G4_KAPTON"  />
+	<row dr="0.3*mm" material="g10"  />
+	<row dr="24.22*mm" material="G4_AIR"  />
+	<row dr="0.3*mm" material="g10"  />
+	<row dr="0.05*mm" material="G4_KAPTON"  />
+	<row dr="0.01*mm" material="G4_Al"  />
+      </innerWall>
+      <!-- SQL command: "SELECT * FROM `outerWall`;"  -->
+      <outerWall>
+	<!-- updates from Dimitra 4/7/17 -->
+	<row dr="0.03*mm" material="G4_Al"  />
+	<row dr="0.15*mm" material="G4_KAPTON"  />
+	<row dr="0.9*mm" material="g10"  />
+	<!-- row dr="57.66*mm" material="G4_AIR"  / -->
+	<row dr="52.66*mm" material="G4_AIR"  /> <!-- removed 5 mm to accomadate fat ecal: to be finalised when numbers available -->
+	<row dr="0.9*mm" material="g10"  />
+	<row dr="0.15*mm" material="G4_KAPTON"  />
+	<row dr="0.21*mm" material="G4_Cu"  />
+      </outerWall>
+      <!-- SQL command: "SELECT * FROM `readout`;"  -->
+      <readout>
+        <row dz="0.003*mm" material="G4_Cu" comment="gating"  />
+        <row dz="0.03*mm" material="G4_KAPTON" comment="gating"  />
+        <row dz="0.003*mm" material="G4_Cu" comment="gating"  />
+        <row dz="4.447*mm" material="TDR_gas" comment="gating"  />
+        <row dz="0.003*mm" material="G4_Cu" comment="mpgd"  />
+        <row dz="0.03*mm" material="G4_KAPTON" comment="mpgd"  />
+        <row dz="0.003*mm" material="G4_Cu" comment="mpgd"  />
+        <row dz="4.447*mm" material="TDR_gas" comment="mpgd"  />
+        <row dz="0.003*mm" material="G4_Cu" comment="mpgd"  />
+        <row dz="0.03*mm" material="G4_KAPTON" comment="mpgd"  />
+        <row dz="0.003*mm" material="G4_Cu" comment="mpgd"  />
+        <row dz="4.447*mm" material="TDR_gas" comment="mpgd"  />
+        <row dz="0.05*mm" material="G4_Cu" comment="pads"  />
+        <row dz="2*mm" material="g10" comment="structural"  />
+        <row dz="0.5*mm" material="G4_Si" comment="electronics"  />
+        <row dz="2*mm" material="epoxy" comment="structural"  />
+        <row dz="1*mm" material="G4_KAPTON" comment="structural"  />
+        <row dz="2*mm" material="G4_Al" comment="Cooling"  />
+        <row dz="1*mm" material="G4_KAPTON" comment="structural"  />
+        <row dz="3*mm" material="CarbonFiber" comment="structural"  />
+      </readout>
+    </detector>
+
+  </detectors>
+
+ <readouts>
+    <readout name="TPCCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+ </readouts>
+
+
+</lccdd>
+
diff --git a/Detector/DetCEPCv4/compact/tracker_defs.xml b/Detector/DetCEPCv4/compact/tracker_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1ff9d486b544e22d9e57ff4b204f83fb6ea27b3e
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/tracker_defs.xml
@@ -0,0 +1,13 @@
+<define>
+
+  <constant name="VXD_radius_r1" value="16*mm"/>
+  <constant name="VXD_length_r1" value="62.5*mm"/>
+  <constant name="VXD_radius_r3" value="37*mm"/>
+  <constant name="VXD_length_r3" value="125*mm"/>
+  <constant name="VXD_radius_r5" value="58*mm"/>
+  <!--constant name="VXD_length_r5" value="125*mm"/-->
+
+  <constant name="tracker_region_rmax" value="TPC_outer_radius" />
+  <constant name="tracker_region_zmax" value="Ecal_endcap_zmin" />
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/tube_defs.xml b/Detector/DetCEPCv4/compact/tube_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b700986ac4f333b7b3333f4e0599605892de8018
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/tube_defs.xml
@@ -0,0 +1,106 @@
+<define>
+
+  <constant name="TUBE_innerCylinder_zEnd"      value="TUBE_IPInnerTube_end_z"/>
+  <constant name="TUBE_innerCylinder_rInner"    value="TUBE_central_inner_radius"/>
+  <constant name="TUBE_innerCylinder_thickness" value="TUBE_central_thickness"/>
+
+  <constant name="TUBE_firstCone_zStart" value="TUBE_innerCylinder_zEnd"/>
+  <constant name="TUBE_firstCone_zEnd" value="TUBE_IPInnerBulge_end_z"/>
+  <constant name="TUBE_firstCone_rInnerStart" value="TUBE_innerCylinder_rInner"/>
+  <constant name="TUBE_firstCone_rInnerEnd" value="TUBE_IPInnerBulge_end_innerradius"/>
+  <constant name="TUBE_firstCone_thickness" value="3*mm"/>
+  <!--
+     D. Jeans, update april 2017
+     in this driver, we have to define the what I call the radial thickness
+     this is the thickness in the radial direction, not that perpendicular to the surface.
+     in the cones, we increase the thickness by a factor 1/cos(theta), where theta is the cone angle (half opening angle)
+     (previously the nominal thickness was used as the radial thickness)
+    -->
+  <constant name="TUBE_firstCone_dz" value="TUBE_firstCone_zEnd-TUBE_firstCone_zStart"/>
+  <constant name="TUBE_firstCone_dr" value="TUBE_firstCone_rInnerEnd-TUBE_firstCone_rInnerStart"/>
+  <constant name="TUBE_firstCone_costh" value="TUBE_firstCone_dz/sqrt( TUBE_firstCone_dz**2. + TUBE_firstCone_dr**2. )"/>
+  <constant name="TUBE_firstCone_RadThickness" value="TUBE_firstCone_thickness/TUBE_firstCone_costh"/>
+
+
+  <constant name="TUBE_secondCylinder_zStart"    value="TUBE_firstCone_zEnd"/>
+  <constant name="TUBE_secondCylinder_zEnd"      value="TUBE_IPOuterTube_end_z"/>
+  <constant name="TUBE_secondCylinder_rInner"    value="TUBE_firstCone_rInnerEnd"/>
+  <constant name="TUBE_secondCylinder_thickness" value="3*mm"/>
+
+  <constant name="TUBE_IPOuterTube_end_radius" value="TUBE_secondCylinder_rInner+TUBE_secondCylinder_thickness"/>
+
+  <!-- max radius of beampipe (in case fillet radius=0: with a realsitic fillet, true maximum radius will be a little smaller) -->
+  <!-- this is actually the radius of the intersection of the second cone with the cupola -->
+
+  <constant name="TUBE_secondCone_rMax" value="Lcal_outer_radius-LumiCal_tubebulge_overshoot"/>
+  <constant name="TUBE_cupola_thickness" value="2*mm"/>
+  <constant name="TUBE_cupola_zEnd" value="TUBE_IPOuterBulge_end_z"/>
+
+  <constant name="TUBE_secondCone_tanOpeningAngle" value="(TUBE_secondCone_rMax-TUBE_secondCylinder_rInner)/(TUBE_cupola_zEnd-TUBE_secondCylinder_zEnd)"/>
+  <constant name="TUBE_secondCone_cosOpeningAngle" value="1./( 1. + TUBE_secondCone_tanOpeningAngle**2 )"/>
+
+  <constant name="TUBE_secondCone_part1_zStart" value="TUBE_secondCylinder_zEnd"/>
+  <constant name="TUBE_secondCone_part1_zEnd" value="FTD_disk3_zPosRelToTpcLength*TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="TUBE_secondCone_part1_rInnerStart" value="TUBE_secondCylinder_rInner"/>
+  <constant name="TUBE_secondCone_part1_rInnerEnd" value="TUBE_secondCone_part1_rInnerStart + TUBE_secondCone_tanOpeningAngle*(TUBE_secondCone_part1_zEnd-TUBE_secondCone_part1_zStart)"/>
+  <!-- include 0.7mm thickness for the cables -->
+  <constant name="TUBE_secondCone_part1_thickness" value="2.7*mm"/> 
+  <constant name="TUBE_secondCone_part1_RadThickness" value="TUBE_secondCone_part1_thickness/TUBE_secondCone_cosOpeningAngle"/>
+
+  <constant name="TUBE_secondCone_part2_zStart" value="TUBE_secondCone_part1_zEnd"/>
+  <constant name="TUBE_secondCone_part2_zEnd" value="FTD_disk4_zPosRelToTpcLength*TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="TUBE_secondCone_part2_rInnerStart" value="TUBE_secondCone_part1_rInnerEnd"/>
+  <constant name="TUBE_secondCone_part2_rInnerEnd" value="TUBE_secondCone_part2_rInnerStart + TUBE_secondCone_tanOpeningAngle*(TUBE_secondCone_part2_zEnd-TUBE_secondCone_part2_zStart)"/>
+  <constant name="TUBE_secondCone_part2_thickness" value="2.7*mm"/>
+  <constant name="TUBE_secondCone_part2_RadThickness" value="TUBE_secondCone_part2_thickness/TUBE_secondCone_cosOpeningAngle"/>
+
+  <constant name="TUBE_secondCone_part3_zStart" value="TUBE_secondCone_part2_zEnd"/>
+  <constant name="TUBE_secondCone_part3_zEnd" value="FTD_disk5_zPosRelToTpcLength*TPC_Ecal_Hcal_barrel_halfZ"/>
+  <constant name="TUBE_secondCone_part3_rInnerStart" value="TUBE_secondCone_part2_rInnerEnd"/>
+  <constant name="TUBE_secondCone_part3_rInnerEnd" value="TUBE_secondCone_part3_rInnerStart + TUBE_secondCone_tanOpeningAngle*(TUBE_secondCone_part3_zEnd-TUBE_secondCone_part3_zStart)"/>
+  <constant name="TUBE_secondCone_part3_thickness" value="2.7*mm"/>
+  <constant name="TUBE_secondCone_part3_RadThickness" value="TUBE_secondCone_part3_thickness/TUBE_secondCone_cosOpeningAngle"/>
+
+  <constant name="TUBE_secondCone_part4_zStart" value="TUBE_secondCone_part3_zEnd"/>
+  <constant name="TUBE_secondCone_part4_zEnd" value="TUBE_cupola_zEnd"/>
+  <constant name="TUBE_secondCone_part4_rInnerStart" value="TUBE_secondCone_part3_rInnerEnd"/>
+  <constant name="TUBE_secondCone_part4_rInnerEnd" value="TUBE_secondCone_part4_rInnerStart + TUBE_secondCone_tanOpeningAngle*(TUBE_secondCone_part4_zEnd-TUBE_secondCone_part4_zStart)"/>
+  <constant name="TUBE_secondCone_part4_thickness" value="2.7*mm"/>
+  <constant name="TUBE_secondCone_part4_RadThickness" value="TUBE_secondCone_part4_thickness/TUBE_secondCone_cosOpeningAngle"/>
+  
+  <!-- the tube going through lumical -->
+  <constant name="TUBE_lumiTube_zStart" value="TUBE_cupola_zEnd+TUBE_cupola_thickness"/>
+  <constant name="TUBE_lumiTube_zEnd" value="BeamCal_min_z-5*mm"/>
+  <constant name="TUBE_lumiTube_thickness" value="1*mm"/>
+  <constant name="TUBE_lumiTube_rInner" value="Lcal_inner_radius-TUBE_lumiTube_thickness-1*mm"/>
+
+  <!-- tubes in beamcal -->
+  <constant name="TUBE_incoming_inBeamcal_InnerRadius" value="14*mm"/>
+  <constant name="TUBE_incoming_inBeamcal_OuterRadius" value="15*mm"/>
+
+  <constant name="TUBE_outgoing_inBeamcal_InnerRadius" value="16*mm"/>
+  <constant name="TUBE_outgoing_inBeamcal_OuterRadius" value="17*mm"/>
+
+  <!-- beams beyond beamcal, into qd0 and extraction magnet-->
+  <constant name="TUBE_upstream_thickness" value="2*mm"/>
+  <constant name="TUBE_transition_length" value="20*mm"/> <!-- distance over which beampipe size changes between sections-->
+
+  <constant name="TUBE_incoming_beamcalToQD0_InnerRadius" value="9.5*mm"/>
+  <constant name="TUBE_outgoing_beamcalToQD0_InnerRadius" value="12*mm"/>
+
+  <constant name="TUBE_incoming_QD0andBeyond_InnerRadius" value="8*mm"/>
+  <constant name="TUBE_outgoing_QD0andBeyond_InnerRadius" value="12*mm"/>
+
+  <constant name="TUBE_QD0_Lstar" value="4100*mm"/>
+  <constant name="TUBE_QD0_length" value="2200*mm"/>
+
+  <constant name="TUBE_QD0_gap_SD0" value="150*mm"/>
+  <constant name="TUBE_SD0_length" value="600*mm"/>
+
+  <constant name="TUBE_QD0_cryostat_length" value="TUBE_QD0_length+TUBE_QD0_gap_SD0+TUBE_SD0_length"/>
+
+  <!-- extraction magnets: guestimates by DJeans, no recent official design available -->
+  <constant name="TUBE_QDEX1A_Lstar" value="5500*mm"/>
+  <constant name="TUBE_QDEX1A_length" value="TUBE_QD0_Lstar+TUBE_QD0_cryostat_length-TUBE_QDEX1A_Lstar"/>
+
+</define>
diff --git a/Detector/DetCEPCv4/compact/vxd07.xml b/Detector/DetCEPCv4/compact/vxd07.xml
new file mode 100644
index 0000000000000000000000000000000000000000..48490eec2744a7963e2458b50bb5d6ea29f84283
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/vxd07.xml
@@ -0,0 +1,102 @@
+<!-- 
+     VXD parameters for ILD_o1_v5  
+-->
+
+<lccdd>
+<detectors>
+
+<detector name="VXD" type="VXD04" vis="VXDVis" id="ILDDetID_VXD" limits="Tracker_limits" readout="VXDCollection" insideTrackingVolume="true">
+  
+  <envelope vis="ILD_VXDVis">
+    <shape type="BooleanShape" operation="Subtraction" material="Air" >
+      <shape type="BooleanShape" operation="Subtraction" material="Air" >
+	<shape type="BooleanShape" operation="Subtraction" material="Air" >
+	  <shape type="BooleanShape" operation="Subtraction" material="Air" >
+	    <shape type="Tube" rmin="VXD_inner_radius" rmax="VXD_outer_radius" dz="VXD_half_length" />
+	    <shape type="Tube" rmin="0." rmax="VXD_inner_radius_1" dz="(VXD_half_length - VXD_cone_max_z)/2. + env_safety " />
+	    <position x="0" y="0" z="VXD_half_length-(VXD_half_length - VXD_cone_max_z)/2.+ env_safety"/> 
+	  </shape>
+	  <shape type="Tube" rmin="0." rmax="VXD_inner_radius_1" dz="(VXD_half_length - VXD_cone_max_z)/2. + env_safety " />
+	  <position x="0" y="0" z="- ( VXD_half_length-(VXD_half_length - VXD_cone_max_z)/2.+ env_safety ) "/> 
+	  <rotation x="0" y="180.*deg" z="0" />
+	</shape>
+	<shape type="Cone" rmin1="0" rmax1="VXD_inner_radius" rmin2="0" rmax2="VXD_inner_radius_1" 
+	       z="(VXD_cone_max_z-VXD_cone_min_z)/2. + env_safety "/>
+	<position x="0" y="0" z="VXD_cone_min_z+(VXD_cone_max_z-VXD_cone_min_z)/2."/> 
+      </shape>
+      <shape type="Cone" rmin1="0" rmax1="VXD_inner_radius" rmin2="0" rmax2="VXD_inner_radius_1" 
+	     z="(VXD_cone_max_z-VXD_cone_min_z)/2. + env_safety "/>
+      <position x="0" y="0" z="-(VXD_cone_min_z+(VXD_cone_max_z-VXD_cone_min_z)/2.)"/> 
+      <rotation x="0" y="180.*deg" z="0" />
+    </shape>
+  </envelope>
+
+  <!-- set the detecor type flag - note: using the '+' operator here as the evaluator does not understand '|' 
+       -> be carefull not to add any flags twice !!!     -->
+  <type_flags type=" DetType_TRACKER + DetType_PIXEL + DetType_VERTEX "/>
+  
+  <!-- database : TMP_DB10 -->
+  <!-- SQL command: "select * from layers_common_parameters;"  -->
+  <layers_common_parameters id="1"
+			    electronics_structure_thickness="0.1*mm"
+			    active_silicon_thickness="0.05*mm"
+			    support_structure_radial_thickness="0.49392*mm"
+			    end_electronics_half_z="5*mm" 
+			    strip_final_beampipe_radious="VXD_inner_radius_1"	
+			    side_band_electronics_option="1"
+			    end_ladd_electronics_option="1"
+			    side_band_electronics_width="0.5*mm" 
+			    side_band_electronics_thickness="0.05*mm"
+			    active_side_band_electronics_option="0"
+			    layer_gap="2*mm"
+			    flex_cable_material="G4_KAPTON"
+			    flex_cable_thickness="0.05*mm"
+			    foam_spacer_material="SiC_foam"
+			    foam_spacer_thickness="0.94*mm"
+			    metal_traces_material="G4_Al"
+			    metal_traces_thickness="0.01*mm"
+			    cool_pipe_material="titanium" 
+			    cool_pipe_inner_radius="0.75*mm"
+			    cool_pipe_outer_radius="1*mm"
+			    external_kapton_thickness="0.05*mm"
+			    external_metal_thickness="0.009*mm"  />
+  <!-- SQL command: "SELECT * FROM cryostat;"  -->
+  <cryostat id="1" alu_skin_inner_radious="100*mm" alu_skin_tickness="0.5*mm" foam_inner_radious="90*mm" foam_tickness="10*mm" foam_half_z="166.6*mm" 
+	    endplate_inner_radious="VXD_inner_radius_1" 
+	    cryostat_option="1" cryostat_apperture="30*mm" cryostat_apperture_radius="1.5*mm"  />
+  <!-- SQL command: "select * from support_shell;"  -->
+  <support_shell id="0" inner_radious="65*mm" half_z="145*mm" thickess="0.49392*mm" endplate_inner_radious="30*mm" endplate_inner_radius_L1="15.7*mm" endplate_outer_radius_L1="20*mm" 
+		 offset_ladder_block="0.28224*mm" beryllium_ladder_block_length="5*mm" beryllium_ladder_block_thickness="0.25*mm" shell_endplate_thickness="2*mm" forward_shell_half_z="6.5*mm"  />
+  <!-- SQL command: "select * from layer;"  -->
+  <layer id="0" layer_radius="VXD_radius_r1" ladder_length="VXD_length_r1" ladder_width="5.5*mm" nb_ladder="10" ladder_gap="0" strip_line_final_z="150*mm" end_electronics_width="5.5*mm" 
+	 initial_kapton_striplines_thickness="0.04566*mm" final_kapton_striplines_thickness="0.02435*mm" initial_metal_striplines_thickness="0.00806*mm" 
+	 final_metal_striplines_thickness="0.0043*mm" support_width="4.5*mm"  />
+  <layer id="1" layer_radius="VXD_radius_r1" ladder_length="VXD_length_r1" ladder_width="5.5*mm" nb_ladder="10" ladder_gap="0" strip_line_final_z="150*mm" end_electronics_width="5.5*mm" 
+	 initial_kapton_striplines_thickness="0.04566*mm" final_kapton_striplines_thickness="0.02435*mm" initial_metal_striplines_thickness="0.00806*mm" 
+	 final_metal_striplines_thickness="0.0043*mm" support_width="4.5*mm"  />
+  <layer id="2" layer_radius="VXD_radius_r3" ladder_length="VXD_length_r3" ladder_width="11*mm" nb_ladder="11" ladder_gap="0*mm" strip_line_final_z="150*mm" end_electronics_width="11*mm" 
+	 initial_kapton_striplines_thickness="0.04102*mm" final_kapton_striplines_thickness="0.05059*mm" initial_metal_striplines_thickness="0.00724*mm" 
+	 final_metal_striplines_thickness="0.00893*mm" support_width="10*mm"  />
+  <layer id="3" layer_radius="VXD_radius_r3" ladder_length="VXD_length_r3" ladder_width="11*mm" nb_ladder="11" ladder_gap="0*mm" strip_line_final_z="150*mm" end_electronics_width="11*mm" 
+	 initial_kapton_striplines_thickness="0.04102*mm" final_kapton_striplines_thickness="0.05059*mm" initial_metal_striplines_thickness="0.00724*mm" 
+	 final_metal_striplines_thickness="0.00893*mm" support_width="10*mm"  />
+  <layer id="4" layer_radius="VXD_radius_r5" ladder_length="VXD_length_r3" ladder_width="11*mm" nb_ladder="17" ladder_gap="0*mm" strip_line_final_z="150*mm" end_electronics_width="11*mm" 
+	 initial_kapton_striplines_thickness="0.04044*mm" final_kapton_striplines_thickness="0.07819*mm" initial_metal_striplines_thickness="0.00714*mm" 
+	 final_metal_striplines_thickness="0.0138*mm" support_width="10*mm"  />
+  <layer id="5" layer_radius="VXD_radius_r5" ladder_length="VXD_length_r3" ladder_width="11*mm" nb_ladder="17" ladder_gap="0*mm" strip_line_final_z="150*mm" end_electronics_width="11*mm" 
+	 initial_kapton_striplines_thickness="0.04044*mm" final_kapton_striplines_thickness="0.07819*mm" initial_metal_striplines_thickness="0.00714*mm" 
+	 final_metal_striplines_thickness="0.0138*mm" support_width="10*mm"  />
+</detector> <!--vxd-->
+
+</detectors>
+
+  <readouts>
+    <readout name="VXDCollection">
+      <!-- fixme: for now DD4hep cannot handle signed values - side should actually be "-2" -->
+      <id>system:5,side:2,layer:9,module:8,sensor:8</id>
+    </readout>
+  </readouts>
+
+
+
+</lccdd>
diff --git a/Detector/DetCEPCv4/compact/yoke_defs.xml b/Detector/DetCEPCv4/compact/yoke_defs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..59672a5a558a68871b9693ab6504643de54342a4
--- /dev/null
+++ b/Detector/DetCEPCv4/compact/yoke_defs.xml
@@ -0,0 +1,7 @@
+<define>
+  <constant name="Yoke_cells_size" value="30*mm"/>
+  <constant name="Yoke_barrel_inner_radius" value="Yoke_inner_radius"/>
+</define>
+
+
+
diff --git a/Detector/DetCEPCv4/src/include/FieldMapBrBz.h b/Detector/DetCEPCv4/src/include/FieldMapBrBz.h
new file mode 100644
index 0000000000000000000000000000000000000000..899b2c4a3865c662d7df72c1ba75d4d8b3f6cd12
--- /dev/null
+++ b/Detector/DetCEPCv4/src/include/FieldMapBrBz.h
@@ -0,0 +1,48 @@
+#ifndef FieldMap_rzBrBz_h
+#define FieldMap_rzBrBz_h 1
+
+#include <DD4hep/FieldTypes.h>
+
+#include <string>
+#include <vector>
+
+class FieldMapBrBz: public dd4hep::CartesianField::Object {
+public:
+
+  struct FieldValues_t {
+    double Br;
+    double Bz;
+    FieldValues_t(double _Br, double _Bz):
+      Br(_Br), Bz(_Bz) {}
+  };
+
+  int coorsOrder;             // integer with the order with which variables are scanned in the fieldmap, 1(2) for RZ(ZR) order
+  std::string  strCoorsOrder; // string  with the order with which variables are scanned in the fieldmap, RZ or ZR order
+  std::string  ntupleName;    // tree name
+  std::string  rhoVar;        // rho  coordinate name in tree
+  std::string  zVar;          // z    coordinate name in tree
+  std::string  BrhoVar;       // Brho component  name in tree
+  std::string  BzVar;         // Bz   component  name in tree
+
+  int nRho, nZ;                            // bins in rho and z coordinates in fieldmap
+  int rhoOrdering;                         // rho coordinate ordering, 1(-1) if from low-to-high (high-to-low)
+  double rhoMin, rhoMax, rhoStep, rScale;  // min, max, step-size and scale factor of rho coordinate in fieldmap
+  int zOrdering;                           // z   coordinate ordering, 1(-1) if from low-to-high (high-to-low)
+  double zMin,   zMax,   zStep,   zScale;  // min, max, step-size and scale factor of z   coordinate in fieldmap
+
+  double bScale;                           //Bfield scale factor
+  std::vector< FieldValues_t > fieldMap;   //List with the field map points
+
+public:
+  /// Initializing constructor
+  FieldMapBrBz();
+  /// Call to access the field components at a given location
+  virtual void fieldComponents(const double* pos, double* field);
+  /// Field the FieldMap from the the tree specified in the XML
+  void fillFieldMapFromTree(const std::string& filename, double coorUnits, double BfieldUnits);
+  /// Get global index in the Field map
+  int getGlobalIndex(const int rBin, const int zBin);
+};
+
+
+#endif // FieldMap_rzBrBz_h
diff --git a/Detector/DetCEPCv4/src/include/FieldMapXYZ.h b/Detector/DetCEPCv4/src/include/FieldMapXYZ.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce8e06d15ac1d863ad375871e8c7e182ed0e1460
--- /dev/null
+++ b/Detector/DetCEPCv4/src/include/FieldMapXYZ.h
@@ -0,0 +1,55 @@
+#ifndef FieldMap_XYZ_h
+#define FieldMap_XYZ_h 1
+
+#include <DD4hep/FieldTypes.h>
+
+#include <string>
+#include <vector>
+
+class FieldMapXYZ: public dd4hep::CartesianField::Object {
+public:
+
+  struct FieldValues_t {
+    double Bx;
+    double By;
+    double Bz;
+    FieldValues_t(double _Bx, double _By, double _Bz):
+      Bx(_Bx), By(_By), Bz(_Bz) {}
+  };
+
+  int coorsOrder;             // integer with the order with which variables are scanned in the fieldmap, 1(2) for RZ(ZR) order
+  std::string  strCoorsOrder; // string  with the order with which variables are scanned in the fieldmap, RZ or ZR order
+  std::string  ntupleName;    // tree name
+  std::string  xVar;          // x  coordinate name in tree
+  std::string  yVar;          // y  coordinate name in tree
+  std::string  zVar;          // z  coordinate name in tree
+  std::string  BxVar;         // Bx component  name in tree
+  std::string  ByVar;         // By component  name in tree
+  std::string  BzVar;         // Bz component  name in tree
+
+  int nX, nY, nZ;                // bins in x, y and z coordinates in fieldmap
+  int xOrdering;                 // x coordinate ordering, 1(-1) if from low-to-high (high-to-low)
+  double xMin,xMax,xStep,xScale; // min, max, step-size and scale factor of x coordinate in fieldmap
+  int yOrdering;                 // y coordinate ordering, 1(-1) if from low-to-high (high-to-low)
+  double yMin,yMax,yStep,yScale; // min, max, step-size and scale factor of y coordinate in fieldmap
+  int zOrdering;                 // z coordinate ordering, 1(-1) if from low-to-high (high-to-low)
+  double zMin,zMax,zStep,zScale; // min, max, step-size and scale factor of z coordinate in fieldmap
+  
+  double bScale;                         //Bfield scale factor 
+  std::vector< FieldValues_t > fieldMap; //List with the field map points
+
+public:
+  /// Initializing constructor
+  FieldMapXYZ();
+  
+  /// Call to access the field components at a given location
+  virtual void fieldComponents(const double* pos, double* field);
+  /// Field the FieldMap from the the tree specified in the XML
+  void fillFieldMapFromTree(const std::string& filename, double coorUnits, double BfieldUnits);
+  /// Get global index in the Field map 
+  int  getGlobalIndex(const int xBin, const int yBin, const int zBin);
+  
+};
+
+
+#endif // FieldMap_XYZ_h
diff --git a/Detector/DetCEPCv4/src/include/LcgeoExceptions.h b/Detector/DetCEPCv4/src/include/LcgeoExceptions.h
new file mode 100644
index 0000000000000000000000000000000000000000..69166a0f240075bb8679bad32a3db37a8c690be6
--- /dev/null
+++ b/Detector/DetCEPCv4/src/include/LcgeoExceptions.h
@@ -0,0 +1,27 @@
+//====================================================================
+//  DDSim - LC simulation based on DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//====================================================================
+#ifndef Exceptions_h
+#define Exceptions_h
+
+#include <exception> 
+
+namespace lcgeo {
+  
+  //define some exception to throw
+  class GeometryException : public std::exception{
+    
+  protected:
+    std::string message;
+    GeometryException() {  /*no_op*/ ; } 
+    
+  public: 
+    GeometryException( std::string text ){
+      message = "GeometryException: " + text ;
+    }
+    virtual const char* what() const noexcept { return  message.c_str() ; }
+  }; 
+}
+#endif
diff --git a/Detector/DetCEPCv4/src/include/XMLHandlerDB.h b/Detector/DetCEPCv4/src/include/XMLHandlerDB.h
new file mode 100644
index 0000000000000000000000000000000000000000..7285d2bc0178b38af0a65d74247c67aa5c6c7269
--- /dev/null
+++ b/Detector/DetCEPCv4/src/include/XMLHandlerDB.h
@@ -0,0 +1,23 @@
+#include "XML/XMLDetector.h"
+#include <string>
+
+namespace {
+  /** Wrapper class to replace the Database class used in Mokka to read the parameters.
+   *  Assumes parameters are stored as attributes of the corresponding xml element.
+   */
+  struct XMLHandlerDB{
+    xml_comp_t x_det ;
+    /** C'tor initializes the handle */
+  XMLHandlerDB(xml_comp_t det) : x_det(det) {}
+  
+    double fetchDouble( const char* _name){ return  x_det.attr<double>( dd4hep::xml::Strng_t(_name) )  ; }
+
+    int    fetchInt( const char* _name){ return  x_det.attr<int>( dd4hep::xml::Strng_t(_name) ) ; }
+
+    std::string fetchString( const char* _name){ return  x_det.attr<std::string>( dd4hep::xml::Strng_t(_name) ) ;}
+
+    /** allow this to be used as a 'pointer' ( as was used for Mokka Database object)*/
+    XMLHandlerDB* operator->() { return this ; }
+  };
+
+}
diff --git a/Detector/DetCEPCv4/src/include/lcgeo.h b/Detector/DetCEPCv4/src/include/lcgeo.h
new file mode 100644
index 0000000000000000000000000000000000000000..b5a233eee6078de0aca95c3d1966c55238713209
--- /dev/null
+++ b/Detector/DetCEPCv4/src/include/lcgeo.h
@@ -0,0 +1,26 @@
+#ifndef lcgeo_h
+#define lcgeo_h
+
+// file for some global configuration of lcgeo 
+// so far only version number:
+
+// define version macros for Lcgeo
+#define LCGEO_MAJOR_VERSION 0
+#define LCGEO_MINOR_VERSION 5
+
+#define LCGEO_VERSION_GE( MAJV , MINV )  ( (  LCGEO_MAJOR_VERSION  > MAJV ) || ( (LCGEO_MAJOR_VERSION==MAJV) && ( LCGEO_MINOR_VERSION >= MINV ) ) )
+
+#define LCGEO_VERSION_GT( MAJV , MINV )  ( (  LCGEO_MAJOR_VERSION  > MAJV ) || ( (LCGEO_MAJOR_VERSION==MAJV) && ( LCGEO_MINOR_VERSION >  MINV ) ) )
+
+namespace lcgeo {
+
+  /// return a string with the current lcgeo version in the form vXX-YY.
+  inline std::string versionString(){
+    std::string vs("vXX-YY") ;
+    std::sprintf( &vs[0] , "v%2.2d-%2.2d", LCGEO_MAJOR_VERSION, LCGEO_MINOR_VERSION  ) ;
+    return vs ;
+  }
+  
+}
+
+#endif
diff --git a/Detector/DetCEPCv4/src/other/BoxSupport_o1_v01_geo.cpp b/Detector/DetCEPCv4/src/other/BoxSupport_o1_v01_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1c3ec3e54c82c2cc1ce3ea3fe2eba4063b16fbad
--- /dev/null
+++ b/Detector/DetCEPCv4/src/other/BoxSupport_o1_v01_geo.cpp
@@ -0,0 +1,86 @@
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DDRec/DetectorData.h"
+#include "DDRec/Surface.h"
+#include "XML/Utilities.h"
+#include "XMLHandlerDB.h"
+#include <cmath>
+#include <map>
+#include <string>
+
+using namespace std;
+
+using dd4hep::Assembly;
+using dd4hep::ConeSegment;
+using dd4hep::DetElement;
+using dd4hep::Detector;
+using dd4hep::Material;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::Ref_t;
+using dd4hep::RotateY;
+using dd4hep::RotationY;
+using dd4hep::SensitiveDetector;
+using dd4hep::Solid;
+using dd4hep::SubtractionSolid;
+using dd4hep::Transform3D;
+//using dd4hep::Tube;
+using dd4hep::Box;
+using dd4hep::Volume;
+using dd4hep::BUILD_ENVELOPE;
+
+using dd4hep::rec::Vector3D;
+using dd4hep::rec::VolCylinder;
+using dd4hep::rec::SurfaceType;
+using dd4hep::rec::volSurfaceList;
+
+static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector /*sens*/)
+{
+
+  xml_det_t     x_det     = e;
+  int           det_id    = x_det.id();
+  string        det_name  = x_det.nameStr();
+  DetElement    sdet(det_name, det_id);
+  bool          reflect   = x_det.reflect();
+
+  Volume envelope = dd4hep::xml::createPlacedEnvelope(theDetector,  e , sdet) ;
+
+  if (theDetector.buildType() == BUILD_ENVELOPE) return sdet ;
+
+  for (xml_coll_t c(x_det, Unicode("section")); c; ++c) {
+
+    xml_comp_t xmlSection(c);
+
+    const double zStart       = xmlSection.attr< double > (_Unicode(start));
+    const double zEnd         = xmlSection.attr< double > (_Unicode(end));
+    const double rInner       = xmlSection.attr< double > (_Unicode(rMin));
+    const double rOuter       = xmlSection.attr< double > (_Unicode(rMax));
+    Material sectionMat       = theDetector.material(xmlSection.materialStr());
+    const std::string volName      = "section_" + xmlSection.nameStr();
+
+    const double zHalf       = fabs(zEnd - zStart) * 0.5; // half z length of the cone
+    const double zPosition   = fabs(zEnd + zStart) * 0.5; // middle z position
+
+    // solid for the tube: the difference between two boxes
+    Box outerBox(rOuter, rOuter, zHalf);
+    Box innerBox(rInner, rInner, zHalf);
+    SubtractionSolid squareTubeSolid( outerBox, innerBox, Position(0, 0, 0) );
+
+    Volume tubeVol(volName + "_pos", squareTubeSolid, sectionMat);
+    tubeVol.setAttributes(theDetector, xmlSection.regionStr(), xmlSection.limitsStr(), xmlSection.visStr());
+    envelope.placeVolume(tubeVol, Position(0, 0, zPosition));
+
+    if (reflect) {
+      Volume tubeVol2(volName + "_neg", squareTubeSolid, sectionMat);
+      tubeVol2.setAttributes(theDetector, xmlSection.regionStr(), xmlSection.limitsStr(), xmlSection.visStr());
+      Transform3D Vol2Place(RotationY(-180.0 * dd4hep::degree), Position(0, 0, -1.*zPosition));
+      envelope.placeVolume(tubeVol2, Vol2Place);
+    }
+
+  }
+
+  return sdet;
+
+}
+
+DECLARE_DETELEMENT(BoxSupport_o1_v01, create_detector)
diff --git a/Detector/DetCEPCv4/src/other/TubeSupport_o1_v01_geo.cpp b/Detector/DetCEPCv4/src/other/TubeSupport_o1_v01_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cd463688bb84c953b2ccf4f31fca8ca2da8c82ab
--- /dev/null
+++ b/Detector/DetCEPCv4/src/other/TubeSupport_o1_v01_geo.cpp
@@ -0,0 +1,97 @@
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DDRec/DetectorData.h"
+#include "DDRec/Surface.h"
+#include "XML/Utilities.h"
+#include "XMLHandlerDB.h"
+#include <cmath>
+#include <map>
+#include <string>
+
+using namespace std;
+
+using dd4hep::Assembly;
+using dd4hep::ConeSegment;
+using dd4hep::DetElement;
+using dd4hep::Detector;
+using dd4hep::Material;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::Ref_t;
+using dd4hep::RotateY;
+using dd4hep::RotationY;
+using dd4hep::SensitiveDetector;
+using dd4hep::Solid;
+using dd4hep::SubtractionSolid;
+using dd4hep::Transform3D;
+using dd4hep::Tube;
+using dd4hep::Volume;
+using dd4hep::BUILD_ENVELOPE;
+
+using dd4hep::rec::Vector3D;
+using dd4hep::rec::VolCylinder;
+using dd4hep::rec::SurfaceType;
+using dd4hep::rec::volSurfaceList;
+
+static Ref_t create_detector(Detector& theDetector, xml_h e, SensitiveDetector /*sens*/)
+{
+
+  xml_det_t     x_det     = e;
+  int           det_id    = x_det.id();
+  string        det_name  = x_det.nameStr();
+  DetElement    sdet(det_name, det_id);
+  bool          reflect   = x_det.reflect();
+
+  Volume envelope = dd4hep::xml::createPlacedEnvelope(theDetector,  e , sdet) ;
+
+  if (theDetector.buildType() == BUILD_ENVELOPE) return sdet ;
+
+  for (xml_coll_t c(x_det, Unicode("section")); c; ++c) {
+
+    xml_comp_t xmlSection(c);
+
+    const double zStart       = xmlSection.attr< double > (_Unicode(start));
+    const double zEnd         = xmlSection.attr< double > (_Unicode(end));
+    const double rInner       = xmlSection.attr< double > (_Unicode(rMin));
+    const double rOuter       = xmlSection.attr< double > (_Unicode(rMax));
+    const double thickness    = rOuter - rInner;
+    Material sectionMat       = theDetector.material(xmlSection.materialStr());
+    const std::string volName      = "section_" + xmlSection.nameStr();
+
+    const double zHalf       = fabs(zEnd - zStart) * 0.5; // half z length of the cone
+    const double zPosition   = fabs(zEnd + zStart) * 0.5; // middle z position
+
+    // solid for the tube (including vacuum and wall): a solid cone
+    Tube tubeSolid(rInner, rOuter, zHalf);
+
+    Volume tubeVol(volName + "_pos", tubeSolid, sectionMat);
+    tubeVol.setAttributes(theDetector, xmlSection.regionStr(), xmlSection.limitsStr(), xmlSection.visStr());
+    envelope.placeVolume(tubeVol, Position(0, 0, zPosition));
+
+    //Add surface to the support
+    Vector3D ocyl(  rInner + thickness/2.  , 0. , 0. );
+    VolCylinder cylSurf1( tubeVol , SurfaceType( SurfaceType::Helper ) , 0.5*thickness  , 0.5*thickness , ocyl );
+    volSurfaceList( sdet )->push_back( cylSurf1 );
+
+
+    if (reflect) {
+
+      Volume tubeVol2(volName + "_neg", tubeSolid, sectionMat);
+      tubeVol2.setAttributes(theDetector, xmlSection.regionStr(), xmlSection.limitsStr(), xmlSection.visStr());
+      Transform3D Vol2Place(RotationY(-180.0 * dd4hep::degree), Position(0, 0, -1.*zPosition));
+      envelope.placeVolume(tubeVol2, Vol2Place);
+
+      VolCylinder cylSurf2( tubeVol2 , SurfaceType( SurfaceType::Helper ) , 0.5*thickness  , 0.5*thickness , ocyl );
+      volSurfaceList( sdet )->push_back( cylSurf2 );
+
+
+    }
+
+
+  }
+
+  return sdet;
+
+}
+
+DECLARE_DETELEMENT(TubeSupport_o1_v01, create_detector)
diff --git a/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered.h b/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered.h
new file mode 100644
index 0000000000000000000000000000000000000000..2424ad2ab6defa7762156c9d1fb2bf3e947b4860
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered.h
@@ -0,0 +1,215 @@
+/*
+ * Helper classes for FTD Self-Scaling Driver from Mokka
+ * copied from original FTD_Simple_Staggered.hh. 
+ * 
+ * @author F.Gaede, DESY 
+ * @date  May 2014
+ * @version $Id$
+ */
+#ifndef FTD_Simple_Staggered_h
+#define FTD_Simple_Staggered_h 1
+
+// class LogicalVolume;
+// class Database;
+// class TRKSD_FTD01;
+// class VisAttributes;
+
+// #include "VSubDetectorDriver.hh"
+// #include "Material.hh"
+// #include "Trap.hh"
+// #include "VisAttributes.hh"
+// #include "ReflectionFactory.hh"
+
+#include <map>
+
+class gearpar {
+
+public:
+  static const short NPETALS             = 1; 
+  static const short ZOFFSET             = 2;
+  static const short ALPHA               = 3;
+  static const short PHI0                = 4;
+  static const short PETAL0SIGNOFFSET    = 5;
+  static const short HALFANGLEPETAL      = 6;
+  static const short ZPOSITION           = 7;
+  static const short SUPPORTRINNER       = 8;
+  static const short SUPPORTLENGTHMIN    = 9;
+  static const short SUPPORTLENGTHMAX    =10; 
+  static const short SUPPORTWIDTH        =11; 
+  static const short SUPPORTTHICKNESS    =12;
+  static const short SUPPORTRANDLENGTH   =13; 
+  static const short SENSITIVERINNER     =14; 
+  static const short SENSITIVELENGTHMIN  =15; 
+  static const short SENSITIVELENGTHMAX  =16;
+  static const short SENSITIVEWIDTH      =17; 
+  static const short SENSIVIVERANLENGHT  =18;
+  static const short SENSITIVETHICKNESS  =19; 
+  static const short SENSORTYPE          =20; 
+  static const short NSENSORS            =21;
+  static const short ISDOUBLESIDED       =22;
+    
+};
+
+/** Structures to store common parameters (database, etc.. )
+ * Possible improvement: map<string,double>, then no need
+ * of struct, string = parameter name in database
+ */
+struct glEnviron
+{
+  double TPC_Ecal_Hcal_barrel_halfZ;
+  double Ecal_endcap_zmin;
+  double TPC_inner_radius;
+	
+  double SIT1_Half_Length_Z;
+  double SIT2_Half_Length_Z;
+  double SIT1_Radius;
+  double SIT2_Radius;
+  double VXD_layer3_maxZ;
+	
+  double zEnd_IPOuterTube;
+  double rEnd_IPOuterTube;
+  double zEnd_IPOuterBulge;
+  double rEnd_IPOuterBulge;
+	
+  double beamTubeTangent;
+};
+
+/// Helper struct
+struct dbInfoCommon
+{
+  double ftd1_vtx3_distance_z;
+  double ftd7_ecal_distance_z;
+  double ftd1_sit1_radial_diff;
+  double ftd2_sit1_radial_diff;
+  double ftd3_sit2_radial_diff;
+  double ftd4to7_tpc_radial_gap;
+    
+  double beamTubeClearance;
+  double cables_thickness;
+  double cable_shield_thickness;
+    
+  double outer_cylinder_total_thickness;
+  double inner_cylinder_total_thickness;
+    
+  // Petal specific
+  double petal_half_angle_support;  // theta
+  double petal_y_ratio;
+
+  //fg: additional parameter:
+  double support_spaceframe_width ;
+};
+
+/// helper struct
+struct dbExtended_reconstruction_parameters
+{
+
+  double strip_width;    
+  double strip_length;   
+  double strip_pitch;    
+  double strip_angle;   
+  
+};
+
+struct dbInfoDisk
+{
+  int disk_number;
+  
+  int sensor_is_pixel;
+  int double_sided;
+  
+  double disks_Si_thickness;  
+  // Support Cylinders
+  double ZStartOuterCylinder;
+  double ZStopOuterCylinder;
+  double ZStartInnerCylinder;
+  double ZStopInnerCylinder;
+  // Petal	
+  double petal_cp_support_thickness;
+  double petal_cp_support_dxMax;
+  double petal_support_zoffset;
+  
+};
+
+
+// class FTD_Simple_Staggered : public VSubDetectorDriver
+// {
+// public:
+//     FTD_Simple_Staggered(void) : VSubDetectorDriver("FTD_Simple_Staggered","ftd")  {} 
+//     ~FTD_Simple_Staggered(void) {};
+    
+//     bool ContextualConstruct(const CGAGeometryEnvironment &env, LogicalVolume *worldLog);
+    
+// #ifdef MOKKA_GEAR    
+//     void GearSetup();
+//     double GetdEdx( const Material* material );
+// #endif
+    
+// private:
+// 		// register PV
+//     void registerPV( const PhysicalVolumesPair & pvPair );
+    
+// 		// Setters for parameters -----
+//     void SetEnvironPar( const CGAGeometryEnvironment & env );
+//     void SetdbParCommon( Database * db );
+//     void SetParDisk( Database * db );
+//     // ----------------------------
+//     void RegisterSDs( Database * db ); // registers two sensitive detectors one for pixel disks and one for strips
+    
+// 		// Construction of parametrized values for the petals (dy, dxMin,..)
+//     double Getdy( const double & the_inner_radius );
+//     double Getdx( const double & the_inner_radius );
+// 		// -----------------------------------------------------------------
+    
+// 		// Petal support construction ------------------------------------
+//     void DoAndPlaceDisk( std::map<std::string,double> valuesDict, LogicalVolume * mother );
+    
+//     void petalSupport( std::map<std::string,double>  valuesDict, LogicalVolume * mother ); 
+//     void petalSensor( std::map<std::string,double>  valuesDict, LogicalVolume * mother ); 
+    
+
+//     std::vector<double> * GetPetalDimensions( const double& petal_cp_support_dy, 
+//                                                const String& whereItgoes, const bool isSilicon );
+
+//     Trap * SemiPetalSolid(const double& petal_cp_support_dy, const String& whereItgoes,
+//                             const bool isSilicon ); 
+// 		// -----------------------------------------------------------------
+    
+// 		// DB Parameters
+//     dbInfoCommon _dbParCommon;
+//     dbInfoDisk _dbParDisk;
+// 	  dbExtended_reconstruction_parameters _dbParExReco;
+
+//     // Global environment variables
+//     glEnviron _glEnv;
+  
+  
+//     Material* _SiMat;
+//     Material* _KaptonMat;
+//     Material* _CuMat;
+//     Material* _AirMat;
+//     Material* _CarbonFiberMat;
+    
+//     VisAttributes * _VisAttSupport;
+//     VisAttributes * _VisAttSensitive;
+//     VisAttributes * _VisAttHolePetal;
+    
+// 		// Disk positioning parameters
+//     double _z_position;
+//     double _zEnd;
+//     double _inner_radius;
+//     double _outer_radius;
+//     double _beamTubeRadius;
+    
+//     TRKSD_FTD01* _theFTDSD_pixel;
+//     TRKSD_FTD01* _theFTDSD_strip;
+    
+// 		// Storing all the gear parameters
+//     std::map<int,std::vector<double> > _ftdparameters;
+    
+// 		// Registring the Physical Volumes to be deleted
+//     std::vector<VPhysicalVolume*> _registerPV;
+// };
+
+#endif
+
+
diff --git a/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered_geo.cpp b/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..52049c85e44281d4b77e0cd64c6c88f8980ff6db
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/FTD_Simple_Staggered_geo.cpp
@@ -0,0 +1,2048 @@
+//====================================================================
+//  lcgeo - LC detector models in DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DetType.h"
+#include "XMLHandlerDB.h"
+#include "XML/Utilities.h"
+
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "FTD_Simple_Staggered.h"
+
+// #define DEBUG_VALUES
+// #define DEBUG_PETAL 4
+
+//#include "DDRec/DDGear.h"
+//#define MOKKA_GEAR
+
+#include <cmath>
+#include <string>
+#include <map>
+#include <assert.h>
+
+using namespace std;
+using namespace dd4hep;
+using namespace rec;
+
+/// helper to wrap access to global constants
+struct EnvDetector{
+  Detector* _theDetector;
+  EnvDetector() : _theDetector(0) {} ;
+  EnvDetector(Detector& theDetector) : _theDetector( &theDetector) {} ;
+  inline double GetParameterAsDouble(const std::string& name) const {  return _theDetector->constant<double>( name ) ; } 
+} ;
+
+
+/// Helper vector for creation of DetElements holding Volumes and their placement 
+typedef std::vector< std::pair< Volume, PlacedVolume > > VolVec ;
+
+///Helper vector for DetElements (e.g. petals in disk)
+typedef std::vector< DetElement > DEVec ;
+
+
+/// Storing all the gear parameters
+std::map<int,std::vector<double> > _ftdparameters;
+
+
+/// Global environment variables
+glEnviron _glEnv;
+/// common DB Parameters
+dbInfoCommon _dbParCommon;
+/// disk DB Parameters
+dbInfoDisk _dbParDisk;
+/// reco DB Parameters
+dbExtended_reconstruction_parameters _dbParExReco;
+double _inner_radius = 0.0;
+double _outer_radius = 0.0;
+double _z_position = 0.0;
+double _beamTubeRadius = 0.0;
+double _zEnd = 0.0;
+Material _SiMat ;
+Material _KaptonMat ;
+Material _CuMat ;
+Material _AirMat ;
+Material _CarbonFiberMat ;
+
+
+// function prototpyes
+double Getdy(const double & innerRadius );
+double Getdx( const double & innerRadius );
+//void DoAndPlaceDisk( Detector& theDetector,DetElement det,SensitiveDetector sens, std::map<std::string,double> valuesDict, Volume  mother ) ;
+void petalSupport( Detector& theDetector,DetElement det,  std::map<std::string,double> valuesDict, Volume  FTDPetalAirLogical ) ;
+VolVec  petalSensor(  Detector& theDetector, DetElement ftd, SensitiveDetector sens, std::map<std::string,double> valuesDict, Volume  FTDPetalAirLogical ) ;
+Trap SemiPetalSolid(const double& petal_cp_support_dy, const std::string& whereItgoes, const bool isSilicon ) ;
+
+
+//debug print function
+void printVolume( Volume v ){
+  std::cout << " ++++ create Volume " << v.name() << std::endl ;
+}
+//=========================== PARAMETERS SETTERS FUNCTIONS ====================================/
+//*********************************************************************************************
+// Set Environment variables (dependent of other subdetectors)
+void SetEnvironPar(const EnvDetector& env)
+{
+
+  _glEnv.TPC_Ecal_Hcal_barrel_halfZ = env.GetParameterAsDouble("TPC_Ecal_Hcal_barrel_halfZ") ;
+  _glEnv.Ecal_endcap_zmin = env.GetParameterAsDouble("Ecal_endcap_zmin")  ;
+  _glEnv.TPC_inner_radius = env.GetParameterAsDouble("TPC_inner_radius")  ;
+  
+  _glEnv.SIT1_Half_Length_Z = env.GetParameterAsDouble("SIT1_Half_Length_Z") ;
+  _glEnv.SIT2_Half_Length_Z = env.GetParameterAsDouble("SIT2_Half_Length_Z") ;
+  _glEnv.SIT1_Radius = env.GetParameterAsDouble("SIT1_Radius") ;
+  _glEnv.SIT2_Radius = env.GetParameterAsDouble("SIT2_Radius") ;
+  _glEnv.VXD_layer3_maxZ = env.GetParameterAsDouble("VXD_length_r3") ;
+  
+  _glEnv.zEnd_IPOuterTube = (env.GetParameterAsDouble("TUBE_IPOuterTube_end_z"))  ;  // ---> A lo mejor no hacen falta
+  _glEnv.rEnd_IPOuterTube = (env.GetParameterAsDouble("TUBE_IPOuterTube_end_radius")) ;
+  _glEnv.zEnd_IPOuterBulge = (env.GetParameterAsDouble("TUBE_IPOuterBulge_end_z")) ;
+  _glEnv.rEnd_IPOuterBulge = (env.GetParameterAsDouble("TUBE_IPOuterBulge_end_radius")) ;
+  
+  _glEnv.beamTubeTangent = ( _glEnv.rEnd_IPOuterBulge - _glEnv.rEnd_IPOuterTube ) / (_glEnv.zEnd_IPOuterBulge - _glEnv.zEnd_IPOuterTube);
+}
+
+
+//*********************************************************************************************
+// Set variables common to all disk, dumping 'common_parameters' table from 'ftd08' database
+void SetdbParCommon(xml_comp_t x_det)
+{
+  // Getting common_parameters table
+  //db->exec("select * from common_parameters;");
+  { 
+    XMLHandlerDB db(  x_det.child( _Unicode( common_parameters ) ) );
+    
+    //  db->getTuple();
+    
+    _dbParCommon.beamTubeClearance = db->fetchDouble("beamtube_clearance") ; 
+    _dbParCommon.outer_cylinder_total_thickness = db->fetchDouble("outer_cylinder_total_thickness") ;
+    _dbParCommon.inner_cylinder_total_thickness = _dbParCommon.outer_cylinder_total_thickness;
+    _dbParCommon.cable_shield_thickness = db->fetchDouble("cable_shield_thickness") ;
+    _dbParCommon.cables_thickness = db->fetchDouble("cables_thickness") ;
+    
+    // check that there is enough space for the cables and support
+    if( _dbParCommon.beamTubeClearance < (_dbParCommon.cables_thickness + (2.0*_dbParCommon.cable_shield_thickness) + 0.5 *mm) )  
+      {
+	cout << "FTD_Simple_Staggered:Stop: Not enough space for inner support structure and cables: increase beamTubeClearance" << endl;
+	exit(1);
+      }
+    
+    _dbParCommon.ftd1_vtx3_distance_z =  db->fetchDouble("ftd1_vtx3_distance_z") ; 
+    _dbParCommon.ftd7_ecal_distance_z =  db->fetchDouble("ftd7_ecal_distance_z") ; 
+    _dbParCommon.ftd1_sit1_radial_diff =  db->fetchDouble("ftd1_sit1_radial_diff") ; 
+    _dbParCommon.ftd2_sit1_radial_diff =  db->fetchDouble("ftd2_sit1_radial_diff") ; 
+    _dbParCommon.ftd3_sit2_radial_diff =  db->fetchDouble("ftd3_sit2_radial_diff") ; 
+    _dbParCommon.ftd4to7_tpc_radial_gap =  db->fetchDouble("ftd4to7_tpc_radial_gap") ; 
+    // Petal Central Part Support: X-Y dimensions, thickness and angles. Same constant values
+    // for all the micro-strips disks
+    _dbParCommon.petal_half_angle_support = db->fetchDouble("petal_half_angle_support") ;
+    _dbParCommon.petal_y_ratio = db->fetchDouble("petal_y_ratio") ;
+    //fg: add additional parameter:
+    _dbParCommon.support_spaceframe_width= db->fetchDouble("support_spaceframe_width") ;
+
+  } 
+
+  // db->exec("select * from extended_reconstruction_parameters;");
+  // db->getTuple();
+  {
+    XMLHandlerDB db(  x_det.child( _Unicode( extended_reconstruction_parameters ) ) );
+    
+    _dbParExReco.strip_width  = db->fetchDouble("strip_width")   ;
+    _dbParExReco.strip_length = db->fetchDouble("strip_length")  ;
+    _dbParExReco.strip_pitch  = db->fetchDouble("strip_pitch")   ;
+    _dbParExReco.strip_angle  = db->fetchDouble("strip_angle")   ;
+  }
+
+#ifdef DEBUG_VALUES
+  cout << "FTD_Simple_Staggered:SetdbParCommon:\n" 
+       << "beamTubeClearance = " << _dbParCommon.beamTubeClearance << " \n"   
+       << "outer_cylinder_total_thickness = " << _dbParCommon.outer_cylinder_total_thickness << " \n"   
+       << "inner_cylinder_total_thickness = " << _dbParCommon.inner_cylinder_total_thickness << " \n"   
+       << "cable_shield_thickness = " << _dbParCommon.cable_shield_thickness << " \n"   
+       << "cables_thickness = " << _dbParCommon.cables_thickness << " \n"   
+       << "ftd1_vtx3_distance_z = " << _dbParCommon.ftd1_vtx3_distance_z << " \n"   
+       << "ftd7_ecal_distance_z = " << _dbParCommon.ftd7_ecal_distance_z << " \n"   
+       << "ftd1_sit1_radial_diff = " << _dbParCommon.ftd1_sit1_radial_diff << " \n"   
+       << "ftd2_sit1_radial_diff = " << _dbParCommon.ftd2_sit1_radial_diff << " \n"   
+       << "ftd3_sit2_radial_diff = " << _dbParCommon.ftd3_sit2_radial_diff << " \n"   
+       << "ftd4to7_tpc_radial_gap = " << _dbParCommon.ftd4to7_tpc_radial_gap << " \n"   
+       << "petal_half_angle_support = " << _dbParCommon.petal_half_angle_support << " \n"   
+       << "petal_y_ratio = " << _dbParCommon.petal_y_ratio << " \n"   
+       << "strip_width = " << _dbParExReco.strip_width << " \n"   
+       << "strip_length = " << _dbParExReco.strip_length << " \n"   
+       << "strip_pitch = " << _dbParExReco.strip_pitch << " \n"   
+       << "strip_angle = " << _dbParExReco.strip_angle << " \n"   
+       << endl;
+
+#endif
+  
+}
+
+//*********************************************************************************************
+// Set variables disk number specific, dumping 'disk' table from 'ftd08' database
+void SetParDisk( XMLHandlerDB db)
+{
+
+  _dbParDisk.disk_number = db->fetchInt( "disk_number" );
+  _dbParDisk.disks_Si_thickness = db->fetchDouble("disk_si_thickness")  ;
+  _dbParDisk.petal_cp_support_thickness = db->fetchDouble("petal_cp_support_thickness")  ;
+  _dbParDisk.petal_cp_support_dxMax = db->fetchDouble("petal_cp_support_dxMax") ; 
+  _dbParDisk.petal_support_zoffset = db->fetchDouble("petal_support_zoffset") ; //NEW
+  _dbParDisk.sensor_is_pixel = db->fetchInt("sensor_is_pixel"); //NEW
+  _dbParDisk.double_sided = db->fetchInt("double_sided"); //NEW
+  
+#ifdef DEBUG_VALUES
+  cout << "FTD_Simple_Staggered:SetParDisk:\n" 
+       << "disk_number = " << _dbParDisk.disk_number << " \n"   
+       << "sensor_is_pixel = " << _dbParDisk.sensor_is_pixel << " \n"   
+       << "double_sided = " << _dbParDisk.double_sided << " \n"   
+       << "petal_support_zoffset = " << _dbParDisk.petal_support_zoffset << " \n"   
+       << "disks_Si_thickness = " << _dbParDisk.disks_Si_thickness << " \n"   
+       << "petal_cp_support_thickness = " << _dbParDisk.petal_cp_support_thickness << " \n"   
+       << "petal_cp_support_dxMax = " << _dbParDisk.petal_cp_support_dxMax << " \n"   
+       << "petal_support_zoffset = " << _dbParDisk.petal_support_zoffset << " \n"   
+       << endl;
+#endif
+  
+}
+//=END======================= PARAMETERS SETTERS FUNCTIONS ================================END=/
+
+
+
+/** Construction of FTD detector, ported from Mokka driver FTD_simple_Staggered.cc
+ *
+ * FTD_Simple_Staggered.cc
+ *
+ * Simplified Implementation of a self scaling 7 disk FTD
+ * Based on SFtd06 but using simple trapezoid sensitive and support structures
+ * All disks have the same structure
+ * Sensitive material Silicon 
+ * Support material Carbon Fiber, Foam 
+ *
+ * All disks' envelop:
+ * Dimensions and coordinates are specified for the sensitive layer, support disks are built on to these
+ * _inner_radius = (  _beamTubeRadius + beamTubeClearance)
+ *
+ * First Disk:
+ * z defined by distance from end of VTX layer 3
+ * outer r defined by radial difference to SIT layer 1
+ *
+ * Second Disk:
+ * z defined relative to TPC half-length: to ensure positioning with SIT set these numbers to the same value in DB
+ * outer r defined by radial difference to SIT layer 1
+ *
+ * Third Disk:
+ * z defined relative to TPC half-length: to ensure positioning with SIT set these numbers to the same value in DB
+ * outer r defined by radial difference to SIT layer 1
+ *
+ * Fourth, Fifth and Sixth Disk:
+ * z defined relative to TPC half-length
+ * outer r defined by gap between TPC inner radius and FTD disks
+ *
+ * Last Disk:
+ * z defined by distance from front of ECal endcap
+ * outer r defined by gap between TPC inner radius and FTD disks
+ *
+ * Parameters Set in Model Parameter DB Table:
+ * TPC_Ecal_Hcal_barrel_halfZ
+ * _glEnv.Ecal_endcap_zmin
+ * _glEnv.TPC_inner_radius
+ * VXD_length_r3
+ *
+ * Parameters shared with other drivers:
+ * SSit03:_glEnv.SIT1_Half_Length_Z
+ * SSit03:_glEnv.SIT2_Half_Length_Z 
+ * SSit03:_glEnv.SIT1_Radius 
+ * SSit03:_glEnv.SIT2_Radius 
+ * TubeX01:TUBE_IPOuterTube_end_z
+ * TubeX01:TUBE_IPOuterTube_end_radius
+ * TubeX01:TUBE_IPOuterBulge_end_z
+ * TubeX01:TUBE_IPOuterBulge_end_radius
+ *
+ *
+ * History:
+ *  May 2014: FG: original port from Mokka
+ *  Oct 2014  FG: - added class ZDiskPetalsData as interface to reconstruction (initially to 
+ *                  instantiate gear::FTDParameters )  
+ *                - changed rotations and translations to a more natural one (positive sense of rotation, etc.)
+ *                - 'replaced' usage of reflection in original code with individual placements
+ *                  in distinct disks on either side of the origin (see comments in code for placements
+                    of 
+ * 
+ * Mokka History:  
+ * - first implementation P. Mora de Freitas (sept 02)
+ * - fixed geometry overlap -- Adrian Vogel, 2005-12-05
+ * - implemented new GEAR interface -- K. Harder, T. Pinto Jayawardena  2007-07-31
+ * - SFtd03: Modified version of SFtd02: Rewritten as a self scaling driver which does not
+ *   make use of a seperate super driver. Steve Aplin (May 2008)
+ *   October 15th 2008, Steve Aplin using description from SiLC Collaboration
+ * - Fixes a bug in SFtd04.cc which meant that the copper cables on thin 
+ *   inside of the cylinder were far to thick (SJA 28/05/09)
+ *   September 7th 2010, Jordi Duarte using mechanical design from IFCA group
+ * - SFtd06: Modified version of SFtd05 implementing realistic details of the disks 
+ *           4,5,6,7 structure. -- J. Duarte Campderros (Sept. 2010)
+ *           Added realistic description to disks 1,2,3. Changed disk 3 to micro-strips 
+ *           technology --- J. Duarte Campderros (Oct. 2010)
+ *           Included the alternative z-offset between petals --|
+ *           Included the use of the GEAR class FTDParameter  --| J. Duarte Campderros (July, 2011)
+ *           Modified the placement of the Volumes using the 
+ *           G4ReflectionFactory Place methods. Now the volumes in Z
+ *           negatives are specular images from the positives -- J. Duarte Campderros (Sept, 2011)
+ * - FTD_Simple_Staggered: created to enable development of tracking code while SFtd06 is finalised.
+ *   S.J. Aplin (Nov 2011)
+ *
+ *  @author: F.Gaede, DESY, May 2014
+ *  @version $Id$
+ */
+static Ref_t create_element(Detector& theDetector, xml_h e, SensitiveDetector sens)  {
+
+
+  //  std::cout << " FTD04 - Detector.BuildType = " << theDetector.buildType() << std::endl ;
+
+  //------------------------------------------
+  //  See comments starting with '//**' for
+  //     hints on porting issues
+  //------------------------------------------
+
+  
+  xml_det_t    x_det = e;
+  string       name  = x_det.nameStr();
+  
+  DetElement   ftd(  name, x_det.id()  ) ;
+
+ // --- create an envelope volume and position it into the world ---------------------
+  
+  Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  e , ftd ) ;
+  
+  dd4hep::xml::setDetectorTypeFlag( e, ftd ) ;
+
+  if( theDetector.buildType() == BUILD_ENVELOPE ) return ftd ;
+  
+  //-----------------------------------------------------------------------------------
+  
+  PlacedVolume pv;
+
+  sens.setType("tracker");
+
+  // --- create assembly and DetElement for support and service volumes 
+
+  Assembly supp_assembly( name + "_support_assembly"  ) ;
+
+  pv = envelope.placeVolume( supp_assembly ) ;
+
+  DetElement suppDE( ftd , name+"_support" , x_det.id() )  ;
+  suppDE.setPlacement( pv ) ;
+  //--------------------------------
+
+
+  dd4hep::rec::ZDiskPetalsData*  zDiskPetalsData = new ZDiskPetalsData ;
+
+ //######################################################################################################################################################################
+  //  code ported from FTD_Simple_Staggered::construct() :
+  //##################################
+  
+  double phi1 = 0 ;
+  double phi2 = 2*M_PI;
+  
+  //fg: vis attributes defined in xml now
+  //     // Globals and cosmetics definitions
+  // 	_VisAttSensitive = new G4VisAttributes(G4Colour(1.,1.,.45));
+  //   //G4VisAttributes *
+  // 	_VisAttSupport = new G4VisAttributes(G4Colour(1,.5,.5));
+  // 	_VisAttHolePetal = new G4VisAttributes(G4Color(1,.5,.5,1.0));
+  // 	G4VisAttributes *VisAttAirDisk = new G4VisAttributes(G4Colour(.5,.3,.8,0.98));
+  // 	VisAttAirDisk->SetVisibility(0);
+  // 	G4VisAttributes *VisAttAirPetal = new G4VisAttributes(G4Colour(.5,.3,.8,0.98));
+  // 	VisAttAirPetal->SetVisibility(0);
+  // 	G4VisAttributes *VisAttCyl = new G4VisAttributes(G4Colour(0.45,.2,0.9,.98));
+  //   G4VisAttributes *VisAttCables = new G4VisAttributes(G4Colour(0.,0.9,0.));
+  //   VisAttCables->SetForceWireframe(false);
+  
+  // 	PhysicalVolumesPair Phys;
+  
+  // Get and set the Globals from the surrounding environment TPC ECAL SIT VTX and Beam-Pipe
+  SetEnvironPar(   EnvDetector( theDetector ) );
+	
+  // Get and set the variables global to the FTD cables_thickness, ftd1_vtx3_distance_z, etc
+  //  Database * db = new Database(env.GetDBName());
+  SetdbParCommon( x_det );
+  
+  // Materials definitions
+  _SiMat     = theDetector.material("G4_Si") ; // silicon_2.33gccm");
+  _KaptonMat = theDetector.material("G4_KAPTON"); //kapton");
+  _CuMat     = theDetector.material("G4_Cu"); //copper"); 
+  _AirMat    = theDetector.material("G4_AIR" ); //air");
+  _CarbonFiberMat = theDetector.material("CarbonFiber");
+ 
+
+  //fg: replace with standard from materials file
+  // -- PROVISIONAL -- Carbon Fiber definition from database ?? 
+  // double density;
+  // std::string matname, symbol;
+  // int nel;
+  // double fractionmass, volumefraction;
+  // volumefraction = 0.5;
+  // density = (1.3 + volumefraction / 3 ) * g/cm3;
+  // fractionmass = 1 - 1.3 * (1 - volumefraction) / (density / (g/cm3));
+  // _CarbonFiberMat = new Material(matname = "CarbonFiber", density, nel=2);
+  // _CarbonFiberMat->AddElement(CGAGeometryManager::GetElement("C"), fractionmass);
+  // _CarbonFiberMat->AddMaterial(CGAGeometryManager::GetMaterial("epoxy"),1.0-fractionmass);
+  // cout << "CarbonFiber->GetRadlen() = " << _CarbonFiberMat->GetRadlen() / cm << " cm" << endl;
+  // <-------------------------------------------------------------------------------------------
+  
+  
+	
+  cout << "FTD_Simple_Staggered:"  
+       << "\t inner support thickness = " << _dbParCommon.inner_cylinder_total_thickness  
+       << "\t cables thickness = " << _dbParCommon.cables_thickness
+       << "\t 2 x cable shield thickness = " << 2 * _dbParCommon.cable_shield_thickness
+       << "\t beamTubeClearance = " << _dbParCommon.beamTubeClearance
+       << endl;
+  
+  // Now we can start to build the disks -------------------------------------------
+  const double theta = _dbParCommon.petal_half_angle_support;
+  
+  // Disk parameters
+  _dbParDisk.ZStartOuterCylinder=0;
+  _dbParDisk.ZStopOuterCylinder=0;
+  double OuterCylinderInnerRadius=0;
+  
+  _dbParDisk.ZStartInnerCylinder=0;
+  _dbParDisk.ZStopInnerCylinder=0;
+  double InnerCylinderOuterRadius1=0;
+  double InnerCylinderOuterRadius2=0;
+  
+  //   db->exec("select * from disks;");
+  //   db->getTuple();
+  //   //... assembling detector
+  //   do {
+
+  for(xml_coll_t c( x_det ,_U(disk)); c; ++c)  {
+    
+    xml_comp_t  x_disk( c );
+    XMLHandlerDB db( x_disk )  ;
+
+    //... 
+    int disk_number(-1);
+    // double _inner_radius = 0.0;
+    // double _outer_radius = 0.0;
+    // double _z_position = 0.0;
+    // double _beamTubeRadius = 0.0;
+    // double _zEnd = 0.0;
+
+    // Get and set the parameters disk specific
+    SetParDisk( db );
+    
+    disk_number = _dbParDisk.disk_number;
+#ifdef ONE_DISK
+    if (disk_number != ONE_DISK )
+      {
+	continue;
+      }
+#endif
+		
+    switch (disk_number) 
+      {
+      case 1:
+	// z defined by distance from end of VTX layer 3
+	_z_position = ( _glEnv.VXD_layer3_maxZ + _dbParCommon.ftd1_vtx3_distance_z );
+          
+	//          _z_position = disk_number * 100.0 * mm;
+          
+	// outer r defined by radial difference to SIT layer 1
+	_outer_radius = ( _glEnv.SIT1_Radius + _dbParCommon.ftd1_sit1_radial_diff ); 
+          
+          
+	// beam tube radius at backside of disk 
+	_zEnd = _z_position +  _dbParDisk.petal_support_zoffset + 0.5 * _dbParDisk.petal_cp_support_thickness + ( _dbParDisk.double_sided * _dbParDisk.disks_Si_thickness ) ;
+          
+	// check which part of the beam tube this disk lies above
+	_beamTubeRadius = (_zEnd < _glEnv.zEnd_IPOuterTube ) ? _glEnv.rEnd_IPOuterTube : _glEnv.rEnd_IPOuterTube + ( (_zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent );
+          
+	_inner_radius = (  _beamTubeRadius + _dbParCommon.beamTubeClearance);
+          
+	// check that there is no overlap with SIT1
+	if( _z_position <= _glEnv.SIT1_Half_Length_Z && _outer_radius>=_glEnv.SIT1_Radius) 
+	  {
+            cout << "FTD_Simple_Staggered:Stop: Overlap between FTD1 and SIT1" << endl;
+            cout << "FTD_Simple_Staggered:FTD1 Radius = " << _outer_radius << "SIT1 Radius = " << _glEnv.SIT1_Radius << endl;
+            exit(1);
+	  }
+	if( db->fetchDouble("z_position_ReltoTPCLength") != 0.0) 
+	  {
+            cout << "FTD_Simple_Staggered:Stop: The z position of FTD1 is not relative. The relative value will not be used. It should be set to 0.0 in the DB." << endl;
+            cout << "FTD_Simple_Staggered:Stop: The z position of FTD1 is set by the distance between the centre of the sensitive layer and the max z of VTX layer 3." << endl;
+            exit(1);
+	  }
+	break;
+          
+      case 2:
+	// z defined relative to TPC half-length: to ensure positioning with SIT set these numbers to the same value in DB
+	_z_position = (_glEnv.TPC_Ecal_Hcal_barrel_halfZ * db->fetchDouble("z_position_ReltoTPCLength")) ;
+          
+	//          _z_position = disk_number * 100.0 * mm;
+          
+	// outer r defined by radial difference to SIT layer 1
+	_outer_radius = _glEnv.SIT1_Radius + _dbParCommon.ftd2_sit1_radial_diff; 
+          
+	// beam tube radius at backside of disk 
+	_zEnd = _z_position +  _dbParDisk.petal_support_zoffset + 0.5 * _dbParDisk.petal_cp_support_thickness + ( _dbParDisk.double_sided * _dbParDisk.disks_Si_thickness ) ;
+          
+	// check which part of the beam tube this disk lies above
+	_beamTubeRadius = (_zEnd < _glEnv.zEnd_IPOuterTube ) ? _glEnv.rEnd_IPOuterTube : _glEnv.rEnd_IPOuterTube + ( (_zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent );
+          
+	_inner_radius = (  _beamTubeRadius + _dbParCommon.beamTubeClearance) ;
+          
+	//... keep information for inner support cylinder with 0.5mm saftey clearance from inner radius of disks
+	_dbParDisk.ZStartInnerCylinder = _glEnv.zEnd_IPOuterTube;
+          
+	InnerCylinderOuterRadius1 = _inner_radius - ( ( _zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent ) - 0.5 * mm; 
+          
+	// check that there is no overlap with SIT1
+	if( _z_position <= _glEnv.SIT1_Half_Length_Z && _outer_radius>=_glEnv.SIT1_Radius) 
+	  {
+            cout << "FTD_Simple_Staggered:Stop:Overlap between FTD2 and SIT1" << endl;
+            cout << "FTD_Simple_Staggered:FTD2 Radius = " << _outer_radius << "SIT1 Radius = " << _glEnv.SIT1_Radius << endl;
+            exit(1);
+	  }
+	break;
+	
+      case 3:
+	// z defined relative to TPC half-length: to ensure positioning with SIT set these numbers to the same value in DB
+	_z_position = (_glEnv.TPC_Ecal_Hcal_barrel_halfZ * db->fetchDouble("z_position_ReltoTPCLength")) ;
+          
+	//          _z_position = disk_number * 100.0 * mm;
+          
+	// outer r defined by radial difference to SIT layer 2
+	_outer_radius = _glEnv.SIT2_Radius + _dbParCommon.ftd3_sit2_radial_diff; 
+          
+	// beam tube radius at backside of disk 
+	_zEnd = _z_position +  _dbParDisk.petal_support_zoffset + 0.5 * _dbParDisk.petal_cp_support_thickness + ( _dbParDisk.double_sided * _dbParDisk.disks_Si_thickness ) ;
+          
+	// check which part of the beam tube this disk lies above
+	_beamTubeRadius = (_zEnd < _glEnv.zEnd_IPOuterTube ) ? _glEnv.rEnd_IPOuterTube : _glEnv.rEnd_IPOuterTube + ( (_zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent );
+          
+	_inner_radius = _beamTubeRadius + _dbParCommon.beamTubeClearance ;
+          
+	// check that there is no overlap with SIT1
+	if( _z_position <= _glEnv.SIT2_Half_Length_Z && _outer_radius>=_glEnv.SIT2_Radius) 
+	  {
+            cout << "FTD_Simple_Staggered:Stop:Overlap between FTD3 and SIT2" <<  endl;
+            cout << "FTD_Simple_Staggered:FTD3 Radius = " << _outer_radius << "SIT2 Radius = " << _glEnv.SIT2_Radius << endl;
+            exit(1);
+	  }
+	break;
+	
+      case 4:
+      case 5:
+      case 6:
+	// z defined relative to TPC half-length
+	_z_position = (_glEnv.TPC_Ecal_Hcal_barrel_halfZ * db->fetchDouble("z_position_ReltoTPCLength")) ;
+          
+	//          _z_position = disk_number * 100.0 * mm;
+          
+	// outer r defined by gap between TPC inner radius and FTD disks
+	_outer_radius = _glEnv.TPC_inner_radius - _dbParCommon.ftd4to7_tpc_radial_gap; 
+          
+	// beam tube radius at backside of disk 
+	_zEnd = _z_position +  _dbParDisk.petal_support_zoffset + 0.5 * _dbParDisk.petal_cp_support_thickness + ( _dbParDisk.double_sided * _dbParDisk.disks_Si_thickness ) ;
+
+          
+	// check which part of the beam tube this disk lies above
+	_beamTubeRadius = (_zEnd < _glEnv.zEnd_IPOuterTube ) ? _glEnv.rEnd_IPOuterTube : _glEnv.rEnd_IPOuterTube + ( (_zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent );
+          
+	_inner_radius = _beamTubeRadius + _dbParCommon.beamTubeClearance ;
+          
+	// keep the information for outer cylinder
+	if(disk_number==4)
+	  {
+            _dbParDisk.ZStartOuterCylinder = _z_position;
+	  }
+	break;
+          
+      case 7:
+	// z defined by distance from front of ECal endcap
+	_z_position = _glEnv.Ecal_endcap_zmin - _dbParCommon.ftd7_ecal_distance_z;
+          
+	//          _z_position = disk_number * 100.0 * mm;
+          
+	// outer r defined by gap between TPC inner radius and FTD disks
+	_outer_radius = _glEnv.TPC_inner_radius - _dbParCommon.ftd4to7_tpc_radial_gap; 
+          
+	// beam tube radius at backside of disk 
+	_zEnd = _z_position +  _dbParDisk.petal_support_zoffset + 0.5 * _dbParDisk.petal_cp_support_thickness + ( _dbParDisk.double_sided * _dbParDisk.disks_Si_thickness ) ;
+          
+	// check which part of the beam tube this disk lies above
+	_beamTubeRadius = (_zEnd < _glEnv.zEnd_IPOuterTube ) ? _glEnv.rEnd_IPOuterTube : _glEnv.rEnd_IPOuterTube + ( (_zEnd - _glEnv.zEnd_IPOuterTube ) * _glEnv.beamTubeTangent );
+          
+	_inner_radius = _beamTubeRadius + _dbParCommon.beamTubeClearance ;
+          
+	// End of Support Structure: 0.5mm clearance from disks
+	_dbParDisk.ZStopOuterCylinder = _zEnd;
+	_dbParDisk.ZStopInnerCylinder = _zEnd;
+          
+	OuterCylinderInnerRadius = _outer_radius + 0.5 * mm;
+	InnerCylinderOuterRadius2 = _inner_radius - 0.5 * mm; 
+          
+	if( db->fetchDouble("z_position_ReltoTPCLength") != 0.0) 
+	  {
+            cout << "FTD_Simple_Staggered:Stop: The z position of FTD7 is not relative. The relative value will not be used. It should be set to 0.0 in the DB." << endl;
+            cout << "FTD_Simple_Staggered:Stop: The z position of FTD7 is set by the distance between the centre of the sensitive layer and the min z of the ECal Endcap." << endl;
+            exit(1);
+	  }
+	break;
+          
+      default:
+	cout << "FTD_Simple_Staggered: Error disk number must be between 1-7: disk number = " << disk_number << endl;
+	exit(1);
+      }
+    
+    cout << "FTD_Simple_Staggered: Disk:" << disk_number
+	 << "\t z = " << _z_position
+	 << "\t inner rad = " << _inner_radius
+	 << "\t outer rad = " << _outer_radius
+	 << "\t beamtube rad = " << _beamTubeRadius
+	 << "\t free space = " << (_inner_radius - 0.5 * mm - _dbParCommon.inner_cylinder_total_thickness - (2*_dbParCommon.cable_shield_thickness) - _dbParCommon.cables_thickness) - _beamTubeRadius 
+	 << endl;
+		
+    
+    /**************************************************************************************
+     ** Begin construction of disks with appropiate parameters    **
+     **************************************************************************************/
+    
+    //================================== AIR DISK =======================================//
+    //  The air-disk is the container and mother volume of the petals. There will be
+    //  7x2 air disks copies placed in the world volume.
+    //  
+    //  Check the comments at the beginning of this file for the description of 
+    //  each # disk parameter.
+    //  
+    //  Input parameters:
+    //       _inner_radius: inner radius of the whole structure
+    //       _outer_radius: outer radius of the whole structure
+    //       max_half_thickness_disk: 
+    //           the maximum thickness of the disk = 2.0 * ( sensitive thickness + support thickness + Zoffset ) 
+    
+    //                                 Zoffset=the displacement of the disks in z-direction
+    
+    // 
+    //		// The thickness of the air petal (containing the support and sensors)
+    //		double petalairthickness_half = 0.5 * ( _dbParDisk.petal_cp_support_thickness +
+    //			_dbParDisk.disks_Si_thickness )  
+    
+    
+    
+    // need enough space for double sided 
+    double petalairthickness_half = 0.5 * ( _dbParDisk.petal_cp_support_thickness
+					    + 2.0*_dbParDisk.disks_Si_thickness ) ;
+    
+    double max_half_thickness_disk = _dbParDisk.petal_support_zoffset + petalairthickness_half ;
+
+		
+    // Tubs *FTDDiskSolid = new Tubs("FTDAirDiskSolid",
+    // 				  _inner_radius,
+    // 				  _outer_radius,
+    // 				  max_half_thickness_disk,
+    // 				  phi1,
+    // 				  phi2
+    // 				  );
+    
+    Tube FTDDiskSolid( _inner_radius, _outer_radius, max_half_thickness_disk, phi1, phi2 );
+
+    // LogicalVolume *FTDDiskLogical = new LogicalVolume(FTDDiskSolid,
+    // 						      _AirMat,
+    // 						      "FTDAirDiskLogical", 
+    // 						      0, 
+    // 						      0, 
+    // 						      0);
+
+    //fg: Volume FTDDiskLogical(  _toString(  _dbParDisk.disk_number, "FTDAirDiskLogical_%d" ), FTDDiskSolid, _AirMat ) ;
+    //fg: replace the logical volume for the disks with two individual ones for the pos. and neg. z axis respectively
+    //fg: this way we do not need a reflection and can position the petals with different transforms on either side...
+    Volume FTDDiskLogicalPZ(  _toString(  _dbParDisk.disk_number, "FTDAirDiskLogicalPZ_%d" ), FTDDiskSolid, _AirMat ) ;
+    Volume FTDDiskLogicalNZ(  _toString(  _dbParDisk.disk_number, "FTDAirDiskLogicalNZ_%d" ), FTDDiskSolid, _AirMat ) ;
+
+
+    //    FTDDiskLogical->SetVisAttributes(VisAttAirDisk);
+    //    ftd.setVisAttributes(theDetector,  "SeeThrough", FTDDiskLogical ) ;
+    ftd.setVisAttributes(theDetector,  "SeeThrough", FTDDiskLogicalPZ ) ;
+    ftd.setVisAttributes(theDetector,  "SeeThrough", FTDDiskLogicalNZ ) ;
+
+		
+    
+    // RotationMatrix *rotDiskPositive = new RotationMatrix();
+    // // Sensors facing the IP)
+    // rotDiskPositive->rotateY(pi);
+    // // Re-allocating the local disk frame to the global frame
+    // rotDiskPositive->rotateZ(-pi/2.0);
+    
+    // Transform3D transPositive( *rotDiskPositive, Position( 0.,0.,_z_position) );
+
+    // // Place the positive copy in the world
+    // Phys = ReflectionFactory::Instance()->Place( transPositive,
+    // 						 "FTDAirDisk",
+    // 						 FTDDiskLogical,
+    // 						 worldLog,
+    // 						 false,
+    // 						 disk_number);
+    // registerPV( Phys );
+
+    ///fg RotationZYX rotDiskPositive( -pi/2.0, pi , 0. ) ; 
+    //fg use unrotated air disks...
+    RotationZYX rotDiskPositive(0,0,0) ; 
+    Transform3D transPositive( rotDiskPositive,  Position( 0.,0.,_z_position) );      
+
+    pv = envelope.placeVolume( FTDDiskLogicalPZ, transPositive ) ;
+
+    DetElement   diskDEposZ( ftd ,   _toString(  _dbParDisk.disk_number, "FTDDisk_%d_posZ" ) , x_det.id() );
+    diskDEposZ.setPlacement( pv ) ;
+
+    pv.addPhysVolID("layer", disk_number - 1  ).addPhysVolID("side", 1 )   ;
+
+    
+#ifdef DEBUG_VALUES
+    cout << "===================================================================== " << "\n" <<
+      "FTDAirDisk:\n" << 
+      " Inner Radius= " << _inner_radius <<  "\n" <<
+      " Outer Radius= " << _outer_radius <<  "\n" <<
+      " thickness =   " << max_half_thickness_disk*2.0 << "\n" <<
+      " placed at \n" << 
+      " x =   " <<  transPositive.Translation().Vect().X() << "\n" <<
+      " y =   " <<  transPositive.Translation().Vect().Y() << "\n" <<
+      " z =   " <<  transPositive.Translation().Vect().Z() << "\n" <<
+      endl;
+#endif
+    
+    
+//     // Place negative copy
+#ifndef DEBUG_POSITIVE
+    // 		RotationMatrix *rotDiskNegative = new RotationMatrix();
+    // 		rotDiskNegative->rotateZ(-pi/2.0);
+    
+    // 		Transform3D transNegative( *rotDiskNegative, Position( 0.,0.,-_z_position ) );
+    //     //Specular image
+    // 		transNegative = transNegative*ReflectX3D();
+    
+    // 		Phys = ReflectionFactory::Instance()->Place( transNegative,
+    //                                                   "FTDAirDisk",
+    //                                                   FTDDiskLogical,
+    //                                                   worldLog,
+    //                                                   false,
+    //                                                   -disk_number);
+    // 		registerPV( Phys );
+    
+    
+    //fg RotationZYX rotDiskNegative( -pi/2.0, 0 , 0. ) ; 
+    //fg use unrotated air disks...
+    RotationZYX rotDiskNegative(0,0,0) ; 
+    Transform3D transNegative( rotDiskNegative,  Position( 0.,0., -_z_position) );      
+    pv = envelope.placeVolume( FTDDiskLogicalNZ, transNegative ) ;
+
+    DetElement   diskDEnegZ( ftd ,   _toString(  _dbParDisk.disk_number, "FTDDisk_%d_negZ" ) , x_det.id() );
+    diskDEnegZ.setPlacement( pv ) ;
+
+
+    pv.addPhysVolID("layer", disk_number -1  ).addPhysVolID("side", -1 )   ;
+
+    
+    
+    
+#ifdef DEBUG_VALUES
+    cout << "===================================================================== " << "\n" <<
+      "FTDAirDisk:\n" << 
+      " Inner Radius= " << _inner_radius <<  "\n" <<
+      " Outer Radius= " << _outer_radius <<  "\n" <<
+      " thickness =   " << max_half_thickness_disk*2.0 << "\n" <<
+      " placed at \n" << 
+      " x =   " <<  transNegative.Translation().Vect().X() << "\n" <<
+      " y =   " <<  transNegative.Translation().Vect().Y() << "\n" <<
+      " z =   " <<  transNegative.Translation().Vect().Z() << "\n" <<
+      endl;
+#endif
+    
+#endif
+    //=END=============================== AIR DISK  =================================END=/
+    
+    //=================================== AIR PETAL =====================================/
+    // Air container for the petal: the mother of the real support petal and the silicon 
+    // sensors. This air petal will be placed inside the Air Disk,
+    // generating N rotated copies along the z-axis.               
+    //  Input parameters:     dxMax                                _
+    //                      --------                              | |    
+    //                      \      /   |                          | |              
+    //       XY-Plane        \    /    | dy          YZ-Plane     | |    
+    //                        \__/     |                          |_|     
+    //                        dxMin                                dz
+    // 
+    //                     dxMax: given by the database
+    //                     dxMin: depends of the _inner_radius of each disk
+    //                     dy:    heigth, depends of each disk
+    //                     dz:    thickness of the supports + thickness of Si
+    //                     theta: given by the db, semi-angle which defines the trapezoid
+		
+    // Dimensions for the disk
+ 
+    const double petal_cp_supp_half_dxMin = Getdx( _inner_radius )/2.0;
+    const double petal_cp_support_dy = Getdy(_inner_radius);
+ 
+    // ------------------------------------------------------------------------
+ 
+#ifdef DEBUG_VALUES
+    std::cout << "*** Petal parameters : petal_cp_supp_half_dxMin=" << petal_cp_supp_half_dxMin
+	      << " _dbParDisk.petal_cp_support_dxMax/2.0 =" << _dbParDisk.petal_cp_support_dxMax/2.0
+	      << " petal_cp_support_dy/2.0 =" << petal_cp_support_dy/2.0
+	      << " petalairthickness_half =" << petalairthickness_half << std::endl ;
+#endif
+
+    Trap FTDPetalAirSolid( petalairthickness_half, //thickness (calculated in the disk zone)
+    			   0.0,
+    			   0.0,
+    			   petal_cp_support_dy/2.0,  // dy
+    			   petal_cp_supp_half_dxMin, //dxMin 
+    			   _dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+    			   0.0,
+    			   petal_cp_support_dy/2.0,  // dy
+    			   petal_cp_supp_half_dxMin,  // dxMin
+    			   _dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+    			   0.0);
+ 
+    Volume FTDPetalAirLogical( _toString(  _dbParDisk.disk_number, "FTDPetalAirLogical_%d" ) , FTDPetalAirSolid, _AirMat ) ;
+    //printVolume( FTDPetalAirLogical ) ; 
+
+    ftd.setVisAttributes(theDetector,  "SeeThrough" , FTDPetalAirLogical ) ;
+
+		
+    // Placing N-copies of the air petal inside the air disk. The copies are built using the z-axis as
+    // the axis of rotation
+    const int petal_max_number = (int)(360.0*deg/(2.0*theta)) ; 
+
+    DEVec petVecposZ(petal_max_number) ;
+    DEVec petVecnegZ(petal_max_number) ;
+
+    double zSignPetal0 = 1. ;
+
+    for (int i = 0; i < petal_max_number; i++){ 
+
+#ifdef DEBUG_PETAL
+      if(i != DEBUG_PETAL ) {
+	continue;
+      }
+#endif
+
+      // Put the petal in the position inside the disk
+      double petalCdtheta = i*2.0*theta;
+      //fg: changed this to positve rotation
+            
+      //fg: the petals at negative z are numbered in positive sense of rotation
+      //    for the ones at positve z, we have to flip around the petal (rotY(pi)) 
+      //    and then rotate in the negative direction around the new (inverted) z-axis
+      //    -> this really mimicks the reflection of the petal disk:
+      //       changed sense of rotation and flipped petals !!
+      RotationZ   rotPetalNZ(    petalCdtheta - pi/2.             );
+      RotationZYX rotPetalPZ( -( petalCdtheta - pi/2. ) , pi , 0. );
+
+      int zsign = pow((double)-1,i);
+     
+      // Petal i=0 parameters for gear
+      if( i == 0 ) {
+	_ftdparameters[gearpar::PHI0].push_back(petalCdtheta );
+	_ftdparameters[gearpar::PETAL0SIGNOFFSET].push_back(zsign);
+	zSignPetal0 = zsign ;
+      }
+#ifdef DEBUG_PETAL
+      _ftdparameters[gearpar::PHI0].push_back(0);
+      _ftdparameters[gearpar::PETAL0SIGNOFFSET].push_back(1);
+#endif
+      
+      //fg: exchanged sin() and cos() in order to have a normal positve sense 
+      //    of rotation around z-axis
+      double dx = (petal_cp_support_dy/2.0 + _inner_radius)*cos( petalCdtheta );
+      double dy = (petal_cp_support_dy/2.0 + _inner_radius)*sin( petalCdtheta ); 
+      double dz = zsign*( _dbParDisk.petal_support_zoffset) ;
+      
+      Transform3D transPetalPZ( rotPetalPZ, Position( dx, dy, -dz) );
+
+      //fg: at negative z we just exchange the sign of the z-offset
+      dx = (petal_cp_support_dy/2.0 + _inner_radius)*cos( petalCdtheta );
+      dy = (petal_cp_support_dy/2.0 + _inner_radius)*sin( petalCdtheta ); 
+      Transform3D transPetalNZ( rotPetalNZ, Position( dx, dy,  dz) );
+      
+      
+      // Phys = ReflectionFactory::Instance()->Place(
+      // 						  transPetal,
+      // 						  "FTDPetalAir",
+      // 						  FTDPetalAirLogical,
+      // 						  FTDDiskLogical,
+      // 						  false,
+      // 						  i+1);
+      // registerPV( Phys );
+
+      //      pv = FTDDiskLogical.placeVolume( FTDPetalAirLogical, transPetal ) ;
+
+      // create DetElements for every petal
+      std::stringstream sspz ;  sspz << "ftd_petal_posZ_" << disk_number << "_"  << i  ;
+      std::stringstream ssnz ;  ssnz << "ftd_petal_negZ_" << disk_number << "_"  << i  ;
+      DetElement petalDEposZ( diskDEposZ, sspz.str() ,  x_det.id() );
+      DetElement petalDEnegZ( diskDEnegZ, ssnz.str() ,  x_det.id() );
+
+      pv = FTDDiskLogicalPZ.placeVolume( FTDPetalAirLogical, transPetalPZ ) ;
+      pv.addPhysVolID("module", i ) ;
+      petalDEposZ.setPlacement( pv ) ;
+
+
+      pv = FTDDiskLogicalNZ.placeVolume( FTDPetalAirLogical, transPetalNZ ) ;
+      pv.addPhysVolID("module", i ) ;
+      petalDEnegZ.setPlacement( pv ) ;
+
+      petVecposZ[i] =  petalDEposZ ;
+      petVecnegZ[i] =  petalDEnegZ ;
+
+
+#ifdef DEBUG_VALUES
+      cout << "===================================================================== " << "\n" <<
+	"FTDPetalAir:\n" << 
+	" Petal Offset = " << zsign*_dbParDisk.petal_support_zoffset << 
+	" Inner Radius= " << _inner_radius <<  "\n" <<
+	" Outer Radius= " << _outer_radius <<  "\n" <<
+	" xMax = " << _dbParDisk.petal_cp_support_dxMax <<  "\n" <<
+	" xMin = " << 2.0*petal_cp_supp_half_dxMin << "\n" <<
+	" dy =   " << petal_cp_support_dy << "\n" <<
+	" thickness =   " << petalairthickness_half*2.0 << "\n" <<
+	" placed at (pos z)  \n" << 
+	" x =   " <<  transPetalPZ.Translation().Vect().X() << "\n" <<
+	" y =   " <<  transPetalPZ.Translation().Vect().Y() << "\n" <<
+	" z =   " <<  transPetalPZ.Translation().Vect().Z() << "\n" <<
+	endl;
+#endif
+      
+    } // end petal loop ...  
+    
+    
+    // -------- reconstruction parameters  ----------------
+    dd4hep::rec::ZDiskPetalsData::LayerLayout thisLayer ;
+    
+    int isDoubleSided = false;
+    int nSensors = 1;
+
+    if( _dbParDisk.sensor_is_pixel != 1 ) {
+      isDoubleSided = true;
+      nSensors = 2;
+    }
+
+    thisLayer.typeFlags[ dd4hep::rec::ZDiskPetalsData::SensorType::DoubleSided ] = isDoubleSided ;
+    thisLayer.typeFlags[ dd4hep::rec::ZDiskPetalsData::SensorType::Pixel ]	   = _dbParDisk.sensor_is_pixel ;
+
+    thisLayer.petalHalfAngle	  = _dbParCommon.petal_half_angle_support ;
+    thisLayer.alphaPetal	  = 0. ;	// petals are othogonal to z-axis
+    thisLayer.zPosition		  = _z_position ;
+    thisLayer.petalNumber	  = petal_max_number ;
+    thisLayer.sensorsPerPetal	  = nSensors ; 
+    thisLayer.phi0		  = 0.  ;
+    thisLayer.zOffsetSupport	  = - zSignPetal0 *  fabs( _dbParDisk.petal_support_zoffset ) ; // sign of offset is negative (!?)
+    thisLayer.distanceSupport	  = _inner_radius ;
+    thisLayer.thicknessSupport	  = _dbParDisk.petal_cp_support_thickness ;
+    thisLayer.widthInnerSupport	  = 2. * petal_cp_supp_half_dxMin ;
+    thisLayer.widthOuterSupport	  = _dbParDisk.petal_cp_support_dxMax ;
+    thisLayer.lengthSupport	  = petal_cp_support_dy ;
+    thisLayer.zOffsetSensitive	  = zSignPetal0 * ( fabs( _dbParDisk.petal_support_zoffset ) +  0.5 * (_dbParDisk.disks_Si_thickness+_dbParDisk.petal_cp_support_thickness)  )  ;
+    thisLayer.distanceSensitive	  = _inner_radius ; 
+    thisLayer.thicknessSensitive  = _dbParDisk.disks_Si_thickness ;
+    thisLayer.widthInnerSensitive =  2. * petal_cp_supp_half_dxMin ;
+    thisLayer.widthOuterSensitive = _dbParDisk.petal_cp_support_dxMax ;
+    thisLayer.lengthSensitive	  = petal_cp_support_dy ;
+    
+    zDiskPetalsData->layers.push_back( thisLayer ) ;
+
+    // -------- end reconstruction parameters  ----------------
+
+  
+#ifdef DD4HEP_WITH_GEAR // ------------------------ Gear disk parameters
+    int sensorType = gear::FTDParameters::PIXEL;  
+    int isDoubleSided = false;
+    int nSensors = 1;
+    if( _dbParDisk.sensor_is_pixel != 1 ) {
+      
+      sensorType = gear::FTDParameters::STRIP;
+      isDoubleSided = true;
+      nSensors = 2;
+    }
+#ifdef DEBUG_PETAL
+    _ftdparameters[gearpar::NPETALS].push_back(1);
+#else
+    _ftdparameters[gearpar::NPETALS].push_back(petal_max_number);
+#endif
+    _ftdparameters[gearpar::SENSORTYPE].push_back(sensorType);
+    _ftdparameters[gearpar::ISDOUBLESIDED].push_back(isDoubleSided);
+    _ftdparameters[gearpar::NSENSORS].push_back(nSensors);
+    _ftdparameters[gearpar::ZPOSITION].push_back(_z_position);
+    _ftdparameters[gearpar::ZOFFSET].push_back(_dbParDisk.petal_support_zoffset);		
+    _ftdparameters[gearpar::ALPHA].push_back(0.0); // staggered design has no tilt
+    _ftdparameters[gearpar::HALFANGLEPETAL].push_back(_dbParCommon.petal_half_angle_support);
+    
+#endif
+    //=END=============================== AIR PETAL =================================END=/
+    
+    //=========================== PETALS & SENSORS ==============================/ 
+    
+    /******************************************************
+     ** Support, sensors and electronics are built via   **
+     ** DoAnPlaceDisk, see the appropiate functions:     **
+     **                                                  **  
+     **   +---------------------++--------------------+  **
+     **   |    Petal Supports   ||       sensors      |  **
+     **   +---------------------++--------------------+  **
+     **   | petalSupportPixels  || pixelSensors       |  **
+     **   +---------------------++--------------------+  **
+     **                                                  **
+     **                                                  **
+     **                                                  **
+     ******************************************************/
+    
+    std::map<std::string,double> valuesDict;
+    
+    valuesDict["petal_cp_supp_half_dxMin"] = petal_cp_supp_half_dxMin;
+    valuesDict["petal_cp_support_dy"] = petal_cp_support_dy;
+    valuesDict["_inner_radius"] = _inner_radius;
+    
+
+      
+    //    DoAndPlaceDisk( theDetector, ftd, sens, valuesDict, FTDPetalAirLogical );		
+
+    petalSupport(theDetector, ftd, valuesDict, FTDPetalAirLogical ) ; 
+
+    VolVec volV = petalSensor( theDetector, ftd, sens, valuesDict, FTDPetalAirLogical );
+
+
+    //---- meassurement surface vectors 
+
+    Vector3D u0( -1. , 0. ,  0. ) ;
+    Vector3D v0(  0. , 1. ,  0. ) ;
+    Vector3D n0(  0. , 0. , -1. ) ;
+
+    Vector3D u1( -1. , 0. ,  0. ) ;
+    Vector3D v1(  0. , 1. ,  0. ) ;
+    Vector3D n1(  0. , 0. , -1. ) ;
+
+    
+    double supp_thick = _dbParDisk.petal_cp_support_thickness ;
+    double active_silicon_thickness =  _dbParDisk.disks_Si_thickness  ;
+
+    SurfaceType surfType(SurfaceType::Sensitive) ;
+
+
+    if( ! _dbParDisk.sensor_is_pixel ){  // strip sensor
+      
+      surfType.setProperty( SurfaceType::Measurement1D , true ) ;
+      
+      // implement stereo angle 
+      double strip_angle  = _dbParExReco.strip_angle  ;
+      
+      // choose the rotation here such that u x v = n
+      
+      u0.fill( -cos( strip_angle ) ,  sin( strip_angle  ) , 0. ) ;
+      v0.fill(  sin( strip_angle ) ,  cos( strip_angle  ) , 0. ) ;
+
+      u1.fill( -cos( strip_angle ) , -sin( strip_angle  ) , 0. ) ;
+      v1.fill( -sin( strip_angle ) ,  cos( strip_angle  ) , 0. ) ;
+
+    }
+
+    // surf0 is used for the first sensor and includes the complete support material - surf1 is used for the second sensor and has only the silicon
+    VolPlane surf0( volV[0].first , surfType , active_silicon_thickness/2 , active_silicon_thickness/2 + supp_thick,  u0,v0,n0 ) ;
+    VolPlane surf1( volV[1].first , surfType , active_silicon_thickness/2 , active_silicon_thickness/2             ,  u1,v1,n1 ) ; ;
+
+    //----
+
+
+    // create DetElements for every sensor and assign to the petal DEs
+    // one or two (for double layers ) for positve and negative z each 
+    for (int i = 0; i < petal_max_number; i++){ 
+
+#ifdef DEBUG_PETAL
+      if(i != DEBUG_PETAL ) {
+	continue;
+      }
+#endif
+      //create DetElements for sensors - one per sensitive petal
+      std::stringstream sspz ;  sspz << "ftd_sensor_posZ_" << disk_number << "_"  << i << "_0"  ;
+      std::stringstream ssnz ;  ssnz << "ftd_sensor_negZ_" << disk_number << "_"  << i << "_0"  ;
+      
+      DetElement sensorDEposZ( petVecposZ[i], sspz.str() ,  x_det.id() );
+      DetElement sensorDEnegZ( petVecnegZ[i], ssnz.str() ,  x_det.id() );
+
+      sensorDEposZ.setPlacement( volV[0].second ) ;
+      sensorDEnegZ.setPlacement( volV[0].second ) ;
+      
+      volSurfaceList( sensorDEposZ )->push_back( surf0 ) ;
+      volSurfaceList( sensorDEnegZ )->push_back( surf0 ) ;
+
+      if(_dbParDisk.double_sided == 1 ) { // first two disks are single sided pixel
+
+	std::stringstream sspz1 ;  sspz1 << "ftd_sensor_posZ_" << disk_number << "_"  << i << "_1"  ;
+	std::stringstream ssnz1 ;  ssnz1 << "ftd_sensor_negZ_" << disk_number << "_"  << i << "_1"  ;
+
+	DetElement sensorDEposZ_2( petVecposZ[i], sspz1.str() ,  x_det.id() );
+	DetElement sensorDEnegZ_2( petVecnegZ[i], ssnz1.str() ,  x_det.id() );
+
+	sensorDEposZ_2.setPlacement( volV[1].second ) ;
+	sensorDEnegZ_2.setPlacement( volV[1].second ) ;
+
+	volSurfaceList( sensorDEposZ_2 )->push_back( surf1 ) ;
+	volSurfaceList( sensorDEnegZ_2 )->push_back( surf1 ) ;
+      }
+    }
+
+    //=END======================= PETALS, SENSORS & ELECT. ==========================END=/ 
+    
+    
+  } //**************** LOOP over disks *******************************
+
+
+	
+  //================================ OUTER CYLINDER ==================================/
+
+#ifndef DEBUG_PETAL
+#ifndef ONE_DISK
+
+  assert(_dbParDisk.ZStartOuterCylinder>0);
+  assert(_dbParDisk.ZStopOuterCylinder>0);
+  
+  double OuterCylinder_half_z = (_dbParDisk.ZStopOuterCylinder-_dbParDisk.ZStartOuterCylinder)/2.;
+  assert(OuterCylinder_half_z>0);
+  
+  double OuterCylinder_position = _dbParDisk.ZStartOuterCylinder + OuterCylinder_half_z;
+  
+  Tube FTDOuterCylinderSolid(OuterCylinderInnerRadius,
+			     OuterCylinderInnerRadius+_dbParCommon.outer_cylinder_total_thickness,
+			     OuterCylinder_half_z,
+			     phi1, 
+			     phi2);
+  
+  Volume FTDOuterCylinderLogical("FTDOuterCylinder", FTDOuterCylinderSolid, _KaptonMat ) ;
+
+  ftd.setVisAttributes( theDetector, "FTDCylVis", FTDOuterCylinderLogical ) ;
+	
+  Transform3D transCylPlus(  RotationZYX() , Position(0.,0.,OuterCylinder_position));
+  Transform3D transCylMinus( RotationZYX(), Position(0.,0.,-OuterCylinder_position));
+
+  //fixme: do we need a special transform here ?
+  //       nothing is placed anyways - see below...
+  // transCylMinus = transCylMinus*ReflectZ3D();
+  
+  //	Phys= ReflectionFactory::Instance()->Place(
+  //                                               transCylPlus,
+  //                                               "FTDOuterCylinder",
+  //                                               FTDOuterCylinderLogical,
+  //                                               worldLog,
+  //                                               false,
+  //                                               0);      
+  //	registerPV( Phys );
+  //  
+  //	Phys= ReflectionFactory::Instance()->Place(
+  //                                               transCylMinus,
+  //                                               "FTDOuterCylinder",
+  //                                               FTDOuterCylinderLogical,
+  //                                               worldLog,
+  //                                               false,
+  //                                               0);      
+  //	registerPV( Phys );
+  //=END============================ OUTER CYLINDER =============================END==/
+	
+  //================================ INNER CYLINDER ==================================/
+  //... Inner cylinder (cone)
+  assert(_dbParDisk.ZStartInnerCylinder>0);
+  assert(_dbParDisk.ZStopInnerCylinder>0);
+  
+  double InnerCylinder_half_z =  (_dbParDisk.ZStopInnerCylinder-_dbParDisk.ZStartInnerCylinder)/2.;
+  assert(InnerCylinder_half_z>0);
+  
+  //double InnerCylinder_position = _dbParDisk.ZStartInnerCylinder + InnerCylinder_half_z; NOT USED
+  
+  double InnerCylinderRmin1 = InnerCylinderOuterRadius1 - _dbParCommon.inner_cylinder_total_thickness - (2.0*_dbParCommon.cable_shield_thickness) - _dbParCommon.cables_thickness ;
+  double InnerCylinderRmax1 = InnerCylinderOuterRadius1;
+  double InnerCylinderRmin2 = InnerCylinderOuterRadius2 - _dbParCommon.inner_cylinder_total_thickness - (2.0*_dbParCommon.cable_shield_thickness) - _dbParCommon.cables_thickness ;
+  double InnerCylinderRmax2 = InnerCylinderOuterRadius2;
+	
+  double cableShieldRmin1 = InnerCylinderRmin1;  double cableShieldRmax1 = cableShieldRmin1 + (2.0*_dbParCommon.cable_shield_thickness) + _dbParCommon.cables_thickness ;
+  double cableShieldRmin2 = InnerCylinderRmin2;
+  double cableShieldRmax2 = cableShieldRmin2 + (2.0*_dbParCommon.cable_shield_thickness) + _dbParCommon.cables_thickness;
+	
+  double cablesRmin1 = cableShieldRmin1 + _dbParCommon.cable_shield_thickness; 
+  double cablesRmax1 = cablesRmin1 + _dbParCommon.cables_thickness;
+  double cablesRmin2 = cableShieldRmin2 + _dbParCommon.cable_shield_thickness; 
+  double cablesRmax2 = cablesRmin2 + _dbParCommon.cables_thickness;
+  
+  ConeSegment FTDInnerCylinderSolid( InnerCylinder_half_z, 
+				     InnerCylinderRmin1,
+				     InnerCylinderRmax1,
+				     InnerCylinderRmin2,
+				     InnerCylinderRmax2,		 
+				     phi1, 
+				     phi2);
+  
+  Volume FTDInnerCylinderLogical("FTDInnerCylinder", FTDInnerCylinderSolid, _KaptonMat ) ;
+
+  ftd.setVisAttributes( theDetector, "FTDCylVis", FTDInnerCylinderLogical ) ;
+  
+  ConeSegment FTDCableShieldSolid( InnerCylinder_half_z,
+				   cableShieldRmin1,
+				   cableShieldRmax1,
+				   cableShieldRmin2,
+				   cableShieldRmax2,
+				   phi1, 
+				   phi2);
+  
+  Volume FTDCableShieldLogical( "FTDInnerCableShield", FTDCableShieldSolid, _KaptonMat ) ;
+			        
+  ftd.setVisAttributes( theDetector, "FTDCylVis",   FTDCableShieldLogical );
+  
+  ConeSegment FTDCablesSolid( InnerCylinder_half_z,
+			      cablesRmin1,
+			      cablesRmax1,
+			      cablesRmin2,
+			      cablesRmax2,
+			      phi1, 
+			      phi2);
+  
+  Volume FTDCablesLogical("FTDInnerCables", FTDCablesSolid, _CuMat ) ;
+			   
+  ftd.setVisAttributes( theDetector, "FTDCylVis",  FTDCablesLogical ) ;
+  
+  // fg: the placements are all commented out in the Mokka original
+  //     so no outer cylinder is created - do we need one ???
+
+  //  //... the cables are placed inside the cylinder
+  //	Phys = ReflectionFactory::Instance()->Place(
+  //                                                Transform3D(),
+  //                                                "FTDInnerCables",
+  //                                                FTDCablesLogical,
+  //                                                FTDCableShieldLogical,
+  //                                                false,
+  //                                                0);      
+  //	registerPV( Phys );
+  //	
+  //	Phys = ReflectionFactory::Instance()->Place(
+  //                                                Transform3D(),
+  //                                                "FTDInnerCableShield",
+  //                                                FTDCableShieldLogical,
+  //                                                FTDInnerCylinderLogical,
+  //                                                false,
+  //                                                0);      
+  //	registerPV( Phys );
+  //  
+  //	Phys = ReflectionFactory::Instance()->Place(
+  //                                                Transform3D(RotationMatrix(), 
+  //                                                              Position(0., 0., InnerCylinder_position) ),
+  //                                                "FTDInnerCylinder",
+  //                                                FTDInnerCylinderLogical,
+  //                                                worldLog,
+  //                                                false,
+  //                                                0);
+  //	registerPV( Phys );
+  //  
+  //  Transform3D Tcyl( RotationMatrix(), Position(0.,0.,-InnerCylinder_position) );
+  //	Tcyl = Tcyl*ReflectZ3D();
+  //	Phys = ReflectionFactory::Instance()->Place(
+  //                                                Tcyl,
+  //                                                "FTDInnerCylinder",
+  //                                                FTDInnerCylinderLogical,
+  //                                                worldLog,
+  //                                                false,
+  //                                                0);
+//fg  registerPV( Phys );
+  //=END============================ INNER CYLINDER =============================END==/
+#endif
+#endif
+	
+
+  
+  //######################################################################################################################################################################
+  
+
+  zDiskPetalsData->widthStrip  = _dbParExReco.strip_width  ;
+  zDiskPetalsData->lengthStrip = _dbParExReco.strip_length ;
+  zDiskPetalsData->pitchStrip  = _dbParExReco.strip_pitch  ;
+  zDiskPetalsData->angleStrip  = _dbParExReco.strip_angle  ;
+  
+
+
+  ftd.addExtension< ZDiskPetalsData >( zDiskPetalsData ) ;
+  
+  //--------------------------------------
+  
+
+  return ftd;
+}
+
+DECLARE_DETELEMENT(FTD_Simple_Staggered ,create_element)
+
+
+
+
+
+//===================================================================================================================================================================================
+
+//================================ PETAL BUILD FUNCTIONS ======================================/
+
+//fg: obsolete - call the two functions directly 
+// //***********************************************************************************************
+// // Build the support, sensors and electronics, choosing what technology have the current disk    
+// //
+// // Input Parameters: 
+// //                   valuesDict: map (name variable, its value)  containing some dimension-disk 
+// //                               parameters, to be passed to the real building functions
+// //                   mother:     Volume where will be placed the volumes are going to
+// //                               build.
+// //
+// void DoAndPlaceDisk( Detector& theDetector,DetElement det,  SensitiveDetector sens, std::map<std::string,double> valuesDict, Volume  mother )
+// {
+//   petalSupport(theDetector, det, valuesDict, mother ) ; // support is placed at 0,0,0 withing the petal
+//   petalSensor( theDetector, det, sens, valuesDict, mother );
+//}
+
+//***********************************************************************************************
+// Build the petal  support. The support is a trapezoid made of foam.
+//
+// Input Parameters: 
+//                   valuesDict: map (name variable, its value)  containing some dimension-disk 
+//                               parameters, to be passed to the real building functions
+//                   mother:     Volume the volumes built are to be placed.
+
+
+void petalSupport( Detector& theDetector, DetElement ftd,  std::map<std::string,double> valuesDict, Volume  FTDPetalAirLogical )
+{
+  double petal_cp_supp_half_dxMin = valuesDict["petal_cp_supp_half_dxMin"];
+  double petal_cp_support_dy = valuesDict["petal_cp_support_dy"];
+  double _inner_radius_petal = valuesDict["_inner_radius"];
+
+  if( _dbParDisk.sensor_is_pixel == 1) {
+
+    Trap FTDPetalSupportSolid( _dbParDisk.petal_cp_support_thickness/2.0, //thickness
+			       0.0,
+			       0.0,
+			       petal_cp_support_dy/2.0,  // dy
+			       petal_cp_supp_half_dxMin, //dxMin 
+			       _dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+			       0.0,
+			       petal_cp_support_dy/2.0,  // dy
+			       petal_cp_supp_half_dxMin,  // dxMin
+			       _dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+			       0.0);
+    
+    Volume FTDPetalSupportLogical( _toString(  _dbParDisk.disk_number, "FTDPetalSupportLogical_%d" ), FTDPetalSupportSolid, _CarbonFiberMat );
+    //printVolume( FTDPetalSupportLogical ) ;
+
+    ftd.setVisAttributes(theDetector,  "FTDSupportVis" , FTDPetalSupportLogical ) ; 
+
+    // Position Ta;
+    // Ta.setX(0.0); 
+    // Ta.setY(0.0); 
+    // Ta.setZ(0.0); 
+
+    // PhysicalVolumesPair Phys = ReflectionFactory::Instance()->Place(
+    // 								    Transform3D(RotationMatrix(),Ta),
+    // 								    "FTDPetalSupport",
+    // 								    FTDPetalSupportLogical,
+    // 								    FTDPetalAirLogical,
+    // 								    false,
+    // 								    0);
+    //   registerPV(Phys);
+
+    // PlacedVolume pv =
+    FTDPetalAirLogical.placeVolume( FTDPetalSupportLogical , Transform3D() ) ;
+
+
+
+  }  else {
+
+    Trap FTDPetalSupportCPSolid( _dbParDisk.petal_cp_support_thickness/2.0,//thickness
+				 0.0,
+				 0.0,
+				 petal_cp_support_dy/2.0,  // height
+				 petal_cp_supp_half_dxMin, 
+				 _dbParDisk.petal_cp_support_dxMax/2.0,
+				 0.0,
+				 petal_cp_support_dy/2.0,  // height
+				 petal_cp_supp_half_dxMin, 
+				 _dbParDisk.petal_cp_support_dxMax/2.0,
+				 0.0);
+    
+	      
+    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Holes  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%/
+    //fg   Trap FTDPetalSupportHoleDownSolid = SemiPetalSolid( petal_cp_support_dy, "DOWN", false );
+    //fg   Trap FTDPetalSupportHoleUpSolid   = SemiPetalSolid( petal_cp_support_dy, "UP", false );
+    //fg	      
+    //fg   // some transformation needed 
+    //fg   const double petal_cp_holes_separation = 10.0*mm; // WARNING! HARDCODED...
+    //fg   
+    //fg   // RotationMatrix * idRot = new RotationMatrix;
+    //fg   Position movDown( 0.0, -petal_cp_support_dy/4.0+petal_cp_holes_separation/4.0, 0.0 );
+    //fg   Position movUp( 0.0, petal_cp_support_dy/4.0-petal_cp_holes_separation/4.0, 0.0);
+    
+    //fg----- SemiPetalSolid does not seem to work - compute hole parameters here instead:
+
+    // the space frame width 
+    double spfw = _dbParCommon.support_spaceframe_width ; 
+
+    double dxmin = petal_cp_supp_half_dxMin*2. ;
+    double dxmax = _dbParDisk.petal_cp_support_dxMax  ;
+
+    double ybase = petal_cp_support_dy / ( dxmax / dxmin  - 1. )  ;
+
+    // compute y_base to use intercept theorem for computing
+    //  the x-widths of the wholes at various y-values
+    //                        dxMax                                  _
+    //                     -----------   |                          | |    
+    //                     \         /   |                          | |              
+    //       XY-Plane       \ dxMin /    | dy          YZ-Plane     | |    
+    //                       \_____/     |                          |_|     
+    //                        \   /    |                            dz
+    //                         \ /     | ybase
+    //                          v      |
+
+    double petal_hole_dy =  ( petal_cp_support_dy - 3 * spfw ) / 2. ;
+
+    double petal_hole_down_dxMin = ( ( ybase + spfw                        ) / ybase  ) * dxmin  - 2. * spfw ; 
+    double petal_hole_down_dxMax = ( ( ybase + spfw    + petal_hole_dy     ) / ybase  ) * dxmin  - 2. * spfw ; 
+    double petal_hole_up_dxMin   = ( ( ybase + spfw *2 + petal_hole_dy     ) / ybase  ) * dxmin  - 2. * spfw ; 
+    double petal_hole_up_dxMax   = ( ( ybase + spfw *2 + petal_hole_dy * 2 ) / ybase  ) * dxmin  - 2. * spfw ; 
+    
+    Trap FTDPetalSupportHoleDownSolid(  2.*_dbParDisk.petal_cp_support_thickness/2.0,//thickness
+    					0.0,
+    					0.0,
+    					petal_hole_dy/2.0,  // height
+    					petal_hole_down_dxMin/2., 
+    					petal_hole_down_dxMax/2., 
+    					0.0,
+    					petal_hole_dy/2.0,  // height
+    					petal_hole_down_dxMin/2., 
+    					petal_hole_down_dxMax/2., 
+    					0.0) ;
+    
+    Trap FTDPetalSupportHoleUpSolid(   2.*_dbParDisk.petal_cp_support_thickness/2.0,//thickness
+    				      0.0,
+    				      0.0,
+    				      petal_hole_dy/2.0,  // height
+    				      petal_hole_up_dxMin/2., 
+    				      petal_hole_up_dxMax/2., 
+    				      0.0,
+    				      petal_hole_dy/2.0,  // height
+    				      petal_hole_up_dxMin/2., 
+    				      petal_hole_up_dxMax/2.,
+    				      0.0 ) ;
+    
+    Position movDown( 0.0,  -( petal_hole_dy /2.  + spfw / 2. ) , 0.0 );
+    Position movUp(   0.0,   ( petal_hole_dy /2.  + spfw / 2. ) , 0.0 );
+
+
+#ifdef DEBUG_VALUES
+    std::cout << " *** support holes parameters : " 
+    	      << " petal_hole_dy "  <<   petal_hole_dy 
+    	      << " petal_hole_down_dxMin "  <<  petal_hole_down_dxMin 
+    	      << " petal_hole_down_dxMax "  <<   petal_hole_down_dxMax
+    	      << " petal_hole_up_dxMin "  <<   petal_hole_up_dxMin 
+    	      << " petal_hole_up_dxMax "  <<   petal_hole_up_dxMax 
+    	      << " y shift: " << ( petal_hole_dy /4.  + spfw / 2. )  ;
+#endif    
+    
+    
+    //fg----- END: SemiPetalSolid does not seem to work - compute hole parameters here instead:
+    
+    
+    SubtractionSolid FTDPetalSupportSolid_Prov( FTDPetalSupportCPSolid, FTDPetalSupportHoleDownSolid, movDown ) ;
+    SubtractionSolid FTDPetalSupportSolid( FTDPetalSupportSolid_Prov, FTDPetalSupportHoleUpSolid, movUp ) ;
+    
+    //fg: debug stuff - cutting out tubes and boxes...
+    //    Tube tubehole( 0, 20*mm , 2.*_dbParDisk.petal_cp_support_thickness ); 
+    //    Box tubehole( 20*mm , 20*mm , 2.*_dbParDisk.petal_cp_support_thickness ); 
+    // SubtractionSolid FTDPetalSupportSolid_Prov( FTDPetalSupportCPSolid, tubehole , movDown ) ;
+    // SubtractionSolid FTDPetalSupportSolid( FTDPetalSupportSolid_Prov, tubehole , movUp ) ;
+
+
+    //%END%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Holes  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%END%/
+    
+    // Petal support with two holes substracted
+    Volume FTDPetalSupportLogical (_toString(  _dbParDisk.disk_number, "FTDPetalSupportLogical_%d" ), FTDPetalSupportSolid,  _CarbonFiberMat ) ;
+    //printVolume( FTDPetalSupportLogical ) ;
+
+    ftd.setVisAttributes(theDetector,  "FTDSupportVis" , FTDPetalSupportLogical ) ; 
+    //ftd.setVisAttributes(theDetector,  "Green Vis" , FTDPetalSupportLogical ) ; 
+
+
+      // // Placing all together ( support petal boolean  ) inside the air petal container
+      // PhysicalVolumesPair Phys = ReflectionFactory::Instance()->Place(
+      // 								      Transform3D(),
+      // 								      "FTDPetalSupport",
+      // 								      FTDPetalSupportLogical,
+      // 								      FTDPetalAirLogical,
+      // 								      false,
+      // 								      0);
+      // registerPV(Phys);
+
+      // PlacedVolume pv =
+	   FTDPetalAirLogical.placeVolume( FTDPetalSupportLogical , Transform3D() ) ;
+
+    }
+  //-END--------------------------- Central Part ----------------------------------END-/
+	
+
+#ifdef DEBUG_VALUES
+  cout << "===================================================================== " << "\n" <<
+    "FTDPetalSupport:\n" << 
+    " Inner Radius= " << _inner_radius_petal <<  "\n" <<
+    " Outer Radius= " << _outer_radius <<  "\n" <<
+    " xMax = " << _dbParDisk.petal_cp_support_dxMax <<  "\n" <<
+    " xMin = " << 2.0*petal_cp_supp_half_dxMin << "\n" <<
+    " dy =   " << petal_cp_support_dy << "\n" <<
+    " thickness =   " << _dbParDisk.petal_cp_support_thickness << "\n" <<
+    // " placed at \n" << 
+    // " x =   " <<  Ta.getX() << "\n" <<
+    // " y =   " <<  Ta.getY() << "\n" <<
+    // " z =   " <<  Ta.getZ() << "\n" <<
+    endl;
+#endif
+
+
+
+
+  // Gear Ladder 
+  _ftdparameters[gearpar::SUPPORTRINNER].push_back(_inner_radius_petal);
+  _ftdparameters[gearpar::SUPPORTLENGTHMIN].push_back(2.0*petal_cp_supp_half_dxMin);
+  _ftdparameters[gearpar::SUPPORTLENGTHMAX].push_back(_dbParDisk.petal_cp_support_dxMax);
+  _ftdparameters[gearpar::SUPPORTWIDTH].push_back(petal_cp_support_dy);
+  _ftdparameters[gearpar::SUPPORTTHICKNESS].push_back(_dbParDisk.petal_cp_support_thickness);
+}
+
+//***********************************************************************************************
+// Build the petal sensitive. The sensitive volume is a trapezoid made of silicon.
+//
+// Input Parameters: 
+//                   valuesDict: map (name variable, its value)  containing some dimension-disk 
+//                               parameters, to be passed to the real building functions
+//                   mother:     Volume the volumes built are to be placed.
+
+VolVec petalSensor(  Detector& theDetector, DetElement ftd, SensitiveDetector sens, std::map<std::string,double> valuesDict, Volume  FTDPetalAirLogical ) {
+  
+  VolVec volV ;
+
+  double petal_half_dxMin = valuesDict["petal_cp_supp_half_dxMin"];
+  double petal_dy = valuesDict["petal_cp_support_dy"];
+  double _inner_radius_petalSensor = valuesDict["_inner_radius"];
+  
+  Trap FTDPetalSensitiveSolid( _dbParDisk.disks_Si_thickness/2.0, //thickness
+				0.0,
+				0.0,
+				petal_dy/2.0,  // dy
+				petal_half_dxMin, //dxMin 
+				_dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+				0.0,
+				petal_dy/2.0,  // dy
+				petal_half_dxMin,  // dxMin
+				_dbParDisk.petal_cp_support_dxMax/2.0, //dxMax
+				0.0);
+  
+  // Now check 
+  // FIXME: sensitive detectors
+  // TRKSD_FTD01* sensitive_det = 0 ;
+  // if ( _dbParDisk.sensor_is_pixel ) {
+  //   sensitive_det = _theFTDSD_pixel;
+  // } 
+  // else {
+  //   sensitive_det = _theFTDSD_strip;
+  // }
+  
+  Volume FTDPetalSensitiveLogical (_toString( _dbParDisk.disk_number , "FTDPetalSensitiveLogical_%d" ) , FTDPetalSensitiveSolid, _SiMat ) ; 
+  //printVolume( FTDPetalSensitiveLogical ) ;
+
+  FTDPetalSensitiveLogical.setSensitiveDetector( sens ) ;
+
+  //ftd.setVisAttributes(  theDetector, "SeeThrough" , FTDPetalSensitiveLogical );
+  ftd.setVisAttributes(  theDetector, "FTDSensitiveVis" , FTDPetalSensitiveLogical );
+
+  
+  // front sensor
+  Position Ta( 0. , 0. , (_dbParDisk.petal_cp_support_thickness + _dbParDisk.disks_Si_thickness)/2.0 ) ;    
+  
+  // PhysicalVolumesPair Phys_front = ReflectionFactory::Instance()->Place(
+  // 									Transform3D(RotationMatrix(),Ta),
+  // 									"FTDPetalSensitive",
+  // 									FTDPetalSensitiveLogical,
+  // 									FTDPetalAirLogical,
+  // 									false,
+  // 									1);
+  
+  PlacedVolume pv = FTDPetalAirLogical.placeVolume( FTDPetalSensitiveLogical, Ta)  ;
+  pv.addPhysVolID("sensor", 1 )   ;
+  
+
+  volV.push_back(  std::make_pair( FTDPetalSensitiveLogical , pv )  ) ;
+
+#ifdef DEBUG_VALUES
+  cout << "===================================================================== " << "\n" <<
+    "FTDPetalSensitive:\n" << 
+    " Inner Radius= " << _inner_radius_petalSensor <<  "\n" <<
+    " Outer Radius= " << _outer_radius <<  "\n" <<
+    " xMax = " <<  _dbParDisk.petal_cp_support_dxMax <<  "\n" <<
+    " xMin = " << 2.0*petal_half_dxMin << "\n" <<
+    " dy =   " << petal_dy << "\n" <<
+    " thickness =   " << _dbParDisk.disks_Si_thickness << "\n" <<
+    " placed at\n " << 
+    " x =   " <<  Ta.X() << "\n" <<
+    " y =   " <<  Ta.Y() << "\n" <<
+    " z =   " <<  Ta.Z() << "\n" <<
+    endl;
+#endif
+  
+  if(_dbParDisk.double_sided == 1 ) { // first two disks are single sided pixel
+    
+    // rear sensor
+    Ta.SetZ( -(_dbParDisk.petal_cp_support_thickness + _dbParDisk.disks_Si_thickness)/2.0 );    
+
+    // PhysicalVolumesPair Phys_rear = ReflectionFactory::Instance()->Place(
+    //                                                                          Transform3D(RotationMatrix(),Ta),
+    //                                                                          "FTDPetalSensitive",
+    //                                                                          FTDPetalSensitiveLogical,
+    //                                                                          FTDPetalAirLogical,
+    //                                                                          false,
+    //                                                                          2);
+    
+    pv = FTDPetalAirLogical.placeVolume( FTDPetalSensitiveLogical, Ta )  ;
+    pv.addPhysVolID("sensor", 2 )   ;
+
+    volV.push_back(  std::make_pair( FTDPetalSensitiveLogical , pv )  ) ;
+
+    // registerPV(Phys_front);
+    // registerPV(Phys_rear);
+    
+    
+#ifdef DEBUG_VALUES
+    cout << "===================================================================== " << "\n" <<
+    "FTDPetalSensitive:\n" << 
+    " Inner Radius= " << _inner_radius_petalSensor <<  "\n" <<
+    " Outer Radius= " << _outer_radius <<  "\n" <<
+    " xMax = " <<  _dbParDisk.petal_cp_support_dxMax <<  "\n" <<
+    " xMin = " << 2.0*petal_half_dxMin << "\n" <<
+    " dy =   " << petal_dy << "\n" <<
+    " thickness =   " << _dbParDisk.disks_Si_thickness << "\n" <<
+    " placed at\n " << 
+    " x =   " <<  Ta.X() << "\n" <<
+    " y =   " <<  Ta.Y() << "\n" <<
+    " z =   " <<  Ta.Z() << "\n" <<
+    endl;
+#endif
+  }
+  
+  //        //================================ SILICON SENSORS ==================================/
+  //        // Sensors build as boxes of silicon. Assemblyblblaa
+  //        // 
+  //        //
+  //	double pixel_si_width = 9.9 * mm; //FIXME: From DB 
+  //	double pixel_si_length = 7.0 * mm; //FIXME: From DB 
+  //	double pixel_si_interspace = 5.0 * um; //FIXME: From DB
+  //    
+  //	Box * FTDPixelSolid = new Box( "FTDPixelSensor",
+  //                                      pixel_si_length/2.0,
+  //                                      pixel_si_width/2.0,
+  //                                      _dbParDisk.disks_Si_thickness/2.0
+  //                                      );
+  //    
+  //	Volume  FTDPixelLogical ( FTDPixelSolid,
+  //                                                            _SiMat,
+  //                                                            "FTDPixelSensor",
+  //                                                            0,
+  //                                                            0,
+  //                                                            0);
+  //    
+  //	FTDPixelLogical->SetVisAttributes( _VisAttSensitive );
+  //	FTDPixelLogical->SetSensitiveDetector(_theFTDSD); //Sensitive
+  //    
+  //        // Defining two (one) rows of pixels per assembly
+  //	std::vector<AssemblyVolume*> pixelsAssemblyRows;
+  //	
+  //	int howManyTotalRows = (int)(petal_cp_support_dy/pixel_si_width);
+  //        // How many rows have in the first assembly (disk 1 = 2, disk 2 =2 );
+  //        // except the first assembly, all the others have two rows per assembly
+  //	int numberRows = 2;
+  //	if( howManyTotalRows % 2 != 0 )
+  //        {
+  //		numberRows = 1;
+  //        }
+  //	int howManyMinPixels = (int)(2.0*petal_cp_supp_half_dxMin/pixel_si_length);
+  //#ifdef DEBUG_VALUES
+  //	cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n" <<
+  //    "Total Pixel rows: " << howManyTotalRows << " ( really done " << howManyTotalRows/2.0 << " assemblies ) \n";
+  //#endif
+  //	
+  //	Position rowTrans( 0.0, 0.0, 0.0);
+  //	for(int row = 0; row < (howManyTotalRows/2 + howManyTotalRows%2); ++row)
+  //        {
+  //            //Instantiating the assembly
+  //		pixelsAssemblyRows.push_back( new AssemblyVolume() );
+  //            // Number of pixels (lowest row should have 4)
+  //		int nPixel = howManyMinPixels+row;
+  //            // Positioning: note that if there are a odd number of
+  //            // pixels, the center pixel is centered in x=0
+  //		double x_offset = 0.0;
+  //		if( nPixel % 2 == 1 )
+  //            {
+  //			x_offset = pixel_si_length/2.0;
+  //                // Placing the central pixel
+  //			rowTrans.setX( 0.0 );
+  //			for(int j = 0; j < numberRows; ++j)
+  //                {
+  //				rowTrans.setY( pixel_si_width*(1.0/2.0 + j) +pixel_si_interspace );
+  //				pixelsAssemblyRows.back()->AddPlacedVolume( FTDPixelLogical, 
+  //                                                           rowTrans, (RotationMatrix*)0 );
+  //                }
+  //            }
+  //            // The others pixels except the central one, if there is
+  //		for(int pixelId = 0 ; pixelId < nPixel/2; ++pixelId)
+  //            {
+  //			rowTrans.setX( x_offset + pixel_si_length/2.0 + pixel_si_interspace + pixelId*pixel_si_length); //pixel_si_offset
+  //			for(int j = 0; j < numberRows; ++j)
+  //                {
+  //				rowTrans.setY( pixel_si_width*(1.0/2.0 + j) + pixel_si_interspace );
+  //                    // Assembly built as two (or one) rows of pixels
+  //				pixelsAssemblyRows.back()->AddPlacedVolume( FTDPixelLogical, 
+  //                                                           rowTrans, (RotationMatrix*)0 );
+  //				rowTrans.setX( -rowTrans.getX() ) ;
+  //				pixelsAssemblyRows.back()->AddPlacedVolume( FTDPixelLogical, 
+  //                                                           rowTrans, (RotationMatrix*)0 );
+  //                }
+  //            }
+  //            // All the others assemblies have two rows
+  //		numberRows = 2;
+  //        }
+  //        //Placing the assemblies inside the air petal, begining from the bottom	
+  //        //	double dz = _dbParDisk.petal_cp_support_thickness/2.0 + _dbParDisk.kapton_petal_thickness + _dbParDisk.disks_Si_thickness/2.0; 
+  //	double dz = _dbParDisk.disks_Si_thickness /2.0; 
+  //    
+  //	double dx = 0.0;
+  //	double dy = -petal_cp_support_dy/2.0;
+  //	Position inMotherTrans(dx, dy, dz); 
+  //	if( howManyTotalRows % 2 != 0 )
+  //        {	
+  //            numberRows = 1;
+  //        }
+  //	for( std::vector<AssemblyVolume*>::iterator assemblyRow = pixelsAssemblyRows.begin();
+  //        assemblyRow != pixelsAssemblyRows.end(); ++assemblyRow )
+  //        {
+  //#ifdef DEBUG_VALUES
+  //		static int i = 0;
+  //        cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n" <<
+  //        " Placement pixels sensors: \n" 
+  //        << "   Row " << i << ": dx=" << dx << ", dy=" << dy << ", dz=" << dz 
+  //        << " -- # pixel: " << (*assemblyRow)->GetInstanceCount() << "\n";
+  //        cout << "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n" << endl;
+  //		i++;
+  //#endif
+  //        (*assemblyRow)->MakeImprint( FTDPetalSupportAirLogical, inMotherTrans, (RotationMatrix*)0 );
+  //            // Ready to put the next one
+  //		dy += 2.0*pixel_si_width;
+  //		inMotherTrans.setY( dy );
+  //		if( numberRows == 1 )
+  //            {
+  //			dy -= pixel_si_width;
+  //			inMotherTrans.setY( dy );
+  //			numberRows = 2;
+  //            }
+  //        }
+  //        // Gear
+  //	int howManyPixelsUp = (int)(_dbParDisk.petal_cp_support_dxMax/pixel_si_length);
+	
+  _ftdparameters[gearpar::SENSITIVERINNER].push_back(_inner_radius_petalSensor);
+  _ftdparameters[gearpar::SENSITIVELENGTHMIN].push_back(2.0*petal_half_dxMin);
+  _ftdparameters[gearpar::SENSITIVELENGTHMAX].push_back(_dbParDisk.petal_cp_support_dxMax);
+  _ftdparameters[gearpar::SENSITIVEWIDTH].push_back(petal_dy);
+  _ftdparameters[gearpar::SENSITIVETHICKNESS].push_back(_dbParDisk.disks_Si_thickness);
+  
+  
+  return volV ;
+}
+
+
+
+//=END============================ PETAL BUILD FUNCTIONS ==================================END=/
+
+
+//============================= PETAL DIMENSION FUNCTIONS =====================================/
+// Functions to extract relative dimensions of the petals. The mechanical design for the petals
+// is made taking as reference one disk (disk 1 for pixels, disk 4 for strips), so the petal
+// is parametrized using variables given for the database (or calculates from them). All the
+// dimensions of the petal are extracted having the inner radius and outer radius of the disk,
+// the top length of the petal and the angle defined by the petal using trigonometry.
+//
+//   (*)outer radius
+//                    dxMax/2                     dxMax
+//	           ============               =============
+//	          |          //               \           /
+//      dy        |  (*)<--/ /                 \  PETAL  /
+//	          |      /  /                   \       /
+//	          -====/===/--> dxMin/2          =======   dxMin
+//	          |  /    /   
+//  inner radius  |/     /
+//                -·····/
+//	          |    /             dy = _outer_radius*cos( arcsin(dxMax/(2*_outer_radius)) ) - _inner_radius
+//	          |   /              ( a = dxMax/(2*tag(theta)) - _inner_radius - dy )
+//	 a        |  /               dxMin = 2*tan(theta)*( _inner_radius + a )
+//	          |-/ theta
+//	          |/
+//    
+//
+// So, changing the inner radius it'll change the dy and dxMin as well, providing the diferents widths
+// of the petal, needed to build the sensors, holes, etc...
+
+//------------------------------------------------------------------------------------------
+// Get the dy of the petal which corresponds to a given radius
+//
+// Input Parameters:   inner radius
+// Output Parameters:  dy
+  double Getdy(const double & innerRadius ){
+    
+    return _outer_radius*cos( asin(_dbParDisk.petal_cp_support_dxMax/(2.0*_outer_radius)) ) - innerRadius;
+  }
+//------------------------------------------------------------------------------------------
+// Get the dxMin of the petal which corresponds to a given radius
+//
+// Input Parameters:   inner radius
+// Output Parameters:  dxMin
+ double Getdx( const double & innerRadius ) {
+   
+   double a = _dbParDisk.petal_cp_support_dxMax/(2.0*tan(_dbParCommon.petal_half_angle_support)) - innerRadius - 
+     Getdy( innerRadius );
+   
+   return 2.0*(innerRadius + a)*tan(_dbParCommon.petal_half_angle_support);
+ }
+ 
+//------------------------------------------------------------------------------------------
+// Get the dimensions of the up and down holes or the silicon up or down sensors:
+// 
+// Input parameters:      
+//                   petal_cp_support_dy: height of the air petal container
+//                   whereItgoes:         "UP" or "DOWN", where is placed
+//                   isSilicon:           True of False, define if is the sensor or the holes
+//
+// Output:         
+//                  std::vector<double>* =  [ xMin_half, xMax_half, dy_half, thickness_half ]
+std::vector<double> GetPetalDimensions( const double& petal_cp_support_dy, const std::string & whereItgoes, const bool isSilicon )
+{
+  const double theta = _dbParCommon.petal_half_angle_support;
+	
+  double central_separation_y = 10.0*mm/2.0; //HARDCODED _dbParDisk.petal_cp_holes_separation/2.0;
+  double x_dim = 6.0*mm/cos(theta);          //HARDCODED _dbParDisk.petal_cp_holes_width_support/cos(theta);
+  double y_dimension = 10.0*mm;        // HARDCODED _dbParDisk.petal_cp_holes_separation;
+  double half_thickness = _dbParDisk.petal_cp_support_thickness/2.0;
+    
+  //Silicon detector or Hole?
+  if(isSilicon)
+    {
+      central_separation_y = 0.0;
+      const double padUp_Si_dxMax = 118.46*mm; 
+      x_dim = (_dbParDisk.petal_cp_support_dxMax-padUp_Si_dxMax)/2.0; // HARDCODED
+      //x_dim = (_dbParDisk.petal_cp_support_dxMax-_dbParDisk.padUp_Si_dxMax)/2.0;
+      y_dimension = y_dimension/2.0;
+      half_thickness = _dbParDisk.disks_Si_thickness/2.0;
+    }
+	
+  double pseudo_radius_up;
+  double pseudo_radius_down;
+  // Up or down?
+  if( whereItgoes == "UP" )
+    {
+        
+      pseudo_radius_up   = _inner_radius+petal_cp_support_dy - y_dimension;
+      pseudo_radius_down = _inner_radius+petal_cp_support_dy*_dbParCommon.petal_y_ratio + central_separation_y ;
+    }
+  else if( whereItgoes == "DOWN" )
+    {
+      pseudo_radius_up = _inner_radius + petal_cp_support_dy*_dbParCommon.petal_y_ratio - central_separation_y;
+      pseudo_radius_down = _inner_radius + y_dimension;
+    }
+  else
+    {
+      cout << "FTD_Simple_Staggered: Internal Error: The function SemiPetalSolid is not well called, the " <<
+        "4th argument must be \"UP\" or \"DOWN\".\n Check the code!!" << endl;
+      exit(-1);
+    }
+  const double xMin_half = (Getdx( pseudo_radius_down ) - x_dim)/2.0;
+  const double xMax_half = (Getdx( pseudo_radius_up )- x_dim)/2.0;
+  const double dy = pseudo_radius_up - pseudo_radius_down;
+#ifdef DEBUG_VALUES
+  cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n" <<
+    "    IsSilicon?: " << isSilicon <<  
+    " " << whereItgoes <<
+    " xMin=" << 2.*xMin_half << 
+    " xMax=" << 2.0*xMax_half << 
+    " dy= " << dy << std::endl;
+  cout << "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \n" << endl;
+#endif
+  std::vector<double>  dimensions ;
+  dimensions.push_back( xMin_half );
+  dimensions.push_back( xMax_half );
+  dimensions.push_back( dy/2.0 );
+  dimensions.push_back( half_thickness );
+    
+  return dimensions;
+}
+
+//------------------------------------------------------------------------------------------
+// Construction of the up and down holes or the silicon up or down sensors
+// 
+// Input parameters:      
+//                   petal_cp_support_dy: height of the air petal container
+//                   whereItgoes:         "UP" or "DOWN", where is placed
+//                   isSilicon:           True of False, define if is the sensor or the holes
+
+//-------------------------------------------------------------------------------------------------------------------
+Trap SemiPetalSolid( const double& petal_cp_support_dy, const std::string& whereItgoes, const bool isSilicon ){
+  // Get dimensions
+  const std::vector<double>&  dimensions = GetPetalDimensions( petal_cp_support_dy, whereItgoes, isSilicon );
+  double xMin_half      = dimensions[0];
+  double xMax_half      = dimensions[1];
+  double dy_half        = dimensions[2];
+  double half_thickness = dimensions[3];
+  
+  return Trap( half_thickness,//thickness
+	       0.0,
+	       0.0,
+	       dy_half,  // height
+	       xMin_half, 
+	       xMax_half,
+	       0.0,
+	       dy_half,  // height
+	       xMin_half, 
+	       xMax_half,
+	       0.0 ) ;
+  
+  //  return FTDSemiPetalSolid ;
+ }
+ //=END========================= PETAL DIMENSION FUNCTIONS =================================END=/
+
+//fixme: registering sensitive ...
+// //*********************************************************************************************
+// // Register two ftd sensitive detectors, one for the pixel disks and one for the strip disks
+// void RegisterSDs( Database * db )
+// {
+//   // Getting parameters disk-specific
+//   db->exec("select * from disks;");
+//   db->getTuple();
+  
+//   double minDiskThickness (MAXFLOAT);
+//   do
+//     	{
+//     _dbParDisk.disks_Si_thickness = db->fetchDouble("disk_si_thickness")  ;
+//     if(minDiskThickness>_dbParDisk.disks_Si_thickness)
+//         {
+// 			minDiskThickness = _dbParDisk.disks_Si_thickness;
+//         }
+//      	} while(db->getTuple()!=NULL);
+  
+//   this->_theFTDSD_pixel =  new TRKSD_FTD01( "FTD_PIXEL", minDiskThickness * 340 * keV/mm * 0.2,true);
+//   RegisterSensitiveDetector(_theFTDSD_pixel);
+
+//   this->_theFTDSD_strip =  new TRKSD_FTD01( "FTD_STRIP", minDiskThickness * 340 * keV/mm * 0.2,true);
+//   RegisterSensitiveDetector(_theFTDSD_strip);
+
+// }
+
+
+// void registerPV(const PhysicalVolumesPair & pvPair )
+// {
+// 	if( pvPair.first != 0 )
+//       {
+// 		_registerPV.push_back( pvPair.first );
+//       }
+// 	if( pvPair.second != 0 )
+//       {
+// 		_registerPV.push_back( pvPair.second );
+//       }
+// }
+
+// //================================ GEAR STUFF FUNCTIONS ====================================/
+#ifdef DD4HEP_WITH_GEAR
+//fixme: seems to be never called in Mokka class (maybe outside ? )
+
+void GearSetup()
+{	
+  //--- Added carbon fiber.  
+  //    TODO: It is needed some other changes??  
+  //    October, 2010, J.Duarte
+  double Si_RadLen, Si_dEdx;
+  double Kapton_RadLen, Kapton_dEdx;
+  double CarbonFiber_RadLen, CarbonFiber_dEdx;
+  double Cu_RadLen, Cu_dEdx;
+	
+  Si_RadLen = _SiMat->GetRadlen();
+  Kapton_RadLen = _KaptonMat->GetRadlen();
+  Cu_RadLen = _CuMat->GetRadlen();
+  CarbonFiber_RadLen = _CarbonFiberMat->GetRadlen();
+	
+  //... Looping over bins in the DEDX table to obtain the mip DEDX 
+  //... From energy 0.0001MeV to 1000MeV in steps of 10 (See GetdEdx function)
+  Si_dEdx=GetdEdx( _SiMat );
+  Kapton_dEdx=GetdEdx(_KaptonMat);
+  CarbonFiber_dEdx = GetdEdx(_CarbonFiberMat);
+  Cu_dEdx=GetdEdx( _CuMat );
+  
+  // Parameters for FTD
+  gear::GearMgr* gearMgr = MokkaGear::getMgr() ;
+  
+  gear::FTDParametersImpl* ftdParam = new gear::FTDParametersImpl();
+  
+  
+  // Write gearParameters to GearMgr
+  for(unsigned int layer = 0; layer < _ftdparameters[gearpar::NPETALS].size(); layer++)
+    {
+      // Extract all the param
+      int	nPetals       =   (int)_ftdparameters[gearpar::NPETALS].at(layer);
+      int	nSensors      =   (int) _ftdparameters[gearpar::NSENSORS].at(layer);
+      bool	isDoubleSided =   (bool)_ftdparameters[gearpar::ISDOUBLESIDED].at(layer);
+      int	sensorType    =   (int)_ftdparameters[gearpar::SENSORTYPE].at(layer);
+      double	phalfangle    =   _ftdparameters[gearpar::HALFANGLEPETAL].at(layer);
+      double	phi0	      =   _ftdparameters[gearpar::PHI0].at(layer);
+      // Correct the sign: axis of the trapezoids built inside a ref. with Z --> -Z
+      double	signoffset    = - _ftdparameters[gearpar::PETAL0SIGNOFFSET].at(layer);
+      double	alpha	      =   _ftdparameters[gearpar::ALPHA].at(layer);
+      double	zposition     =   _ftdparameters[gearpar::ZPOSITION].at(layer);
+      double	zoffset	      =   _ftdparameters[gearpar::ZOFFSET].at(layer);
+      double	suprtRin      =   _ftdparameters[gearpar::SUPPORTRINNER].at(layer);
+      double	suprtThic     =   _ftdparameters[gearpar::SUPPORTTHICKNESS].at(layer);
+      double	suprtLMin     =   _ftdparameters[gearpar::SUPPORTLENGTHMIN].at(layer);
+      double	suprtLMax     =   _ftdparameters[gearpar::SUPPORTLENGTHMAX].at(layer);
+      double	suprtW	      =   _ftdparameters[gearpar::SUPPORTWIDTH].at(layer);
+      //double suprtRL	      =   _ftdparameters[gearpar::SUPPORTRADLENGTH].at(layer); FIXME
+      double	suprtRL	      =    Si_RadLen;
+      double	sensitRin     =   _ftdparameters[gearpar::SENSITIVERINNER].at(layer);
+      double	sensitThic    =   _ftdparameters[gearpar::SENSITIVETHICKNESS].at(layer);
+      double	sensitLMin    =   _ftdparameters[gearpar::SENSITIVELENGTHMIN].at(layer);
+      double	sensitLMax    =   _ftdparameters[gearpar::SENSITIVELENGTHMAX].at(layer);
+      double	sensitW	      =   _ftdparameters[gearpar::SENSITIVEWIDTH].at(layer);
+      //double sensitRL	      =   _ftdparameters[gearpar::SENSITIVERADLENGTH].at(layer); //FIXME
+      double	sensitRL      = Si_RadLen;
+    
+      ftdParam->addLayer( nPetals, nSensors, isDoubleSided, sensorType, phalfangle, phi0, alpha,zposition, zoffset, signoffset,
+			  suprtRin, suprtThic, 
+			  suprtLMin, suprtLMax,
+			  suprtW, suprtRL,
+			  sensitRin, sensitThic,
+			  sensitLMin, sensitLMax,
+			  sensitW, sensitRL ) ;
+    }
+  
+  
+  // Add the extended_reconstruction_parameters
+  
+  ftdParam->setDoubleVal("strip_width", _dbParExReco.strip_width );
+  ftdParam->setDoubleVal("strip_length",_dbParExReco.strip_length);
+  ftdParam->setDoubleVal("strip_pitch", _dbParExReco.strip_pitch );
+  ftdParam->setDoubleVal("strip_angle", _dbParExReco.strip_angle );
+  
+  
+  gearMgr->setFTDParameters(ftdParam);
+}
+#endif
diff --git a/Detector/DetCEPCv4/src/tracker/SET_Simple_Planar_geo.cpp b/Detector/DetCEPCv4/src/tracker/SET_Simple_Planar_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..91e906c81c82af1ec6e9c5c785562599c046b68f
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/SET_Simple_Planar_geo.cpp
@@ -0,0 +1,463 @@
+//====================================================================
+//  lcgeo - LC detector models in DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetType.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "XMLHandlerDB.h"
+#include "XML/Utilities.h"
+#include <cmath>
+
+//#include "GearWrapper.h"
+
+using namespace std;
+using namespace dd4hep::rec;
+
+/** helper struct */
+struct SET_Layer {
+  int     n_ladders;
+  int     n_sensors_per_ladder;
+  double  sensor_length;
+  double  half_z;
+  double  sensitive_inner_radius ;
+  double  support_inner_radius ;
+  double  ladder_width ;
+  double  ladder_dphi ;
+};    
+
+//std::vector<SET_Layer> _SET_Layers;
+  
+/** helper struct */
+struct extended_reconstruction_parameters {
+  double sensor_length_mm;
+  double strip_width_mm;
+  double strip_length_mm;
+  double strip_pitch_mm;
+  double strip_angle_deg;
+};
+
+//extended_reconstruction_parameters _e_r_p;
+
+
+/** Construction of the SET detector, ported from Mokka driver SET_Simple_Planar.cc
+ *
+ *  Mokka History:
+ *  Feb 7th 2011, Steve Aplin - original version
+ *
+ *  @author: F.Gaede, DESY, Jan 2014
+ */
+static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4hep::SensitiveDetector sens)  {
+
+  //------------------------------------------
+  //  See comments starting with '//**' for
+  //     hints on porting issues
+  //------------------------------------------
+
+  
+  xml_det_t    x_det = e;
+  string       name  = x_det.nameStr();
+
+  dd4hep::DetElement   set(  name, x_det.id()  ) ;
+  
+  // --- create an envelope volume and position it into the world ---------------------
+  
+  dd4hep::Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  e , set ) ;
+  
+  dd4hep::xml::setDetectorTypeFlag( e, set ) ;
+
+  if( theDetector.buildType() == dd4hep::BUILD_ENVELOPE ) return set ;
+  
+  //-----------------------------------------------------------------------------------
+
+  
+  //PlacedVolume pv;
+  
+  
+  sens.setType("tracker");
+
+  
+  dd4hep::rec::ZPlanarData*  zPlanarData = new ZPlanarData ;
+
+  //######################################################################################################################################################################
+  //  code ported from SET_Simple_Planar::construct() :
+  //##################################
+
+  // extended_reconstruction_parameters _e_r_p;
+  
+  // *********************
+  //  Read and Store the Extended Reconstruction Parameters which are passed directly through to gear. Note others may be added below
+  // db->exec("select * from extended_reconstruction_parameters;");
+  // db->getTuple();
+  XMLHandlerDB db = XMLHandlerDB(  x_det.child( _Unicode( reconstruction ) ) ) ;
+  
+  zPlanarData->widthStrip  = db->fetchDouble("strip_width")  ;
+  zPlanarData->lengthStrip = db->fetchDouble("strip_length") ;
+  zPlanarData->pitchStrip  = db->fetchDouble("strip_pitch")  ;
+  zPlanarData->angleStrip  = db->fetchDouble("strip_angle") ;
+  double strip_angle = zPlanarData->angleStrip ;
+  // *********************
+  
+  
+  //... db common_parameters
+  // // db->exec("select * from global;");
+  // // db->getTuple();
+  db = XMLHandlerDB(  x_det.child( _Unicode( global ) ) ) ;
+
+  // Sensitive Thickness  
+  double sensitive_thickness = db->fetchDouble("sensitive_thickness") ;
+  // Support Thickness
+  double support_thickness = db->fetchDouble("support_thickness") ;
+  // Sensor Length
+  double sensor_length = db->fetchDouble("sensor_length") ;
+  
+  // _e_r_p.sensor_length_mm  =sensor_length;
+
+  dd4hep::Material air = theDetector.air()  ;
+  dd4hep::Material sensitiveMat = theDetector.material(db->fetchString("sensitive_mat"));  
+  dd4hep::Material supportMat   = theDetector.material(db->fetchString("support_mat"));  
+  
+  
+  // // // setup the encoder 
+  // // UTIL::BitField64 encoder( LCTrackerCellID::encoding_string() ) ; 
+  
+  // // encoder.reset() ;  // reset to 0
+  
+  // // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+  // // encoder[LCTrackerCellID::side()] = 0 ;
+  // // encoder[LCTrackerCellID::layer()]  = 0 ;
+  // // encoder[LCTrackerCellID::module()] = 0 ;
+  // // encoder[LCTrackerCellID::sensor()] = 0 ;
+  // // int cellID0 = encoder.lowWord() ;
+  
+  //... The SET Sensitive detector
+  //unused:  double sensitive_threshold_KeV = db->fetchDouble("sensitive_threshold_KeV")  ;
+  
+  //FIXME: the SD  ...
+  // // _theSETSD = 
+  // // new TRKSD02("SET",
+  // //             _sensitive_thickness * mm 
+  // //             * sensitive_threshold_KeV ,
+  // //             10.0 * MeV);
+  
+  // // RegisterSensitiveDetector(_theSETSD);
+  
+
+  const double TPC_outer_radius = theDetector.constant<double>("TPC_outer_radius");
+  const double TPC_Ecal_Hcal_barrel_halfZ = theDetector.constant<double>("TPC_Ecal_Hcal_barrel_halfZ");
+
+  for(xml_coll_t c( x_det ,_U(layer)); c; ++c)  {
+    
+    xml_comp_t  x_layer( c );
+    db = XMLHandlerDB( x_layer )  ;
+    
+    int layer_id = db->fetchInt("layer_id");
+    
+    double sensitive_distance_from_tpc = db->fetchDouble("sensitive_distance_from_tpc") ;
+    double coverage_of_TPC_Ecal_Hcal_barrel = db->fetchDouble("coverage_of_TPC_Ecal_Hcal_barrel") ;
+    
+    double max_half_z = coverage_of_TPC_Ecal_Hcal_barrel * TPC_Ecal_Hcal_barrel_halfZ;
+        
+    int number_of_sensors_per_half = floor(max_half_z/sensor_length);
+        
+    double half_z = sensor_length * number_of_sensors_per_half;
+        
+    double sensitive_radius = TPC_outer_radius + sensitive_distance_from_tpc;
+        
+    int n_ladders        = db->fetchInt("n_ladders") ;
+    int faces_IP         = db->fetchInt("faces_IP") ;
+    double ladder_clearance = db->fetchDouble("ladder_clearance") ;
+
+        
+    // create assembly and DetElement for the layer
+    std::string layerName = dd4hep::_toString( layer_id , "layer_%d" );
+    dd4hep::Assembly layer_assembly( layerName ) ;
+    dd4hep::PlacedVolume pv = envelope.placeVolume( layer_assembly ) ;
+    dd4hep::DetElement layerDE( set , layerName  , x_det.id() );
+    layerDE.setPlacement( pv ) ;
+
+
+    const double ladder_dphi = ( dd4hep::twopi / n_ladders ) ;
+
+    double sensitive_inner_radius = sensitive_radius - 0.5 * sensitive_thickness;
+    double ladder_width = 2*(tan(ladder_dphi*0.5)*sensitive_inner_radius - ladder_clearance) ;
+        
+    double support_radius(0) ;
+
+    if( faces_IP == 1 ){ // support is on the outside 
+      support_radius = sensitive_radius + (0.5 * sensitive_thickness) ;
+      ladder_width = 2*(tan(ladder_dphi*0.5)*sensitive_inner_radius - ladder_clearance) ;
+    }
+    else{ // support is on the inside
+      support_radius = sensitive_radius - (0.5 * sensitive_thickness) - support_thickness;
+      ladder_width = 2*(tan(ladder_dphi*0.5)*support_radius - ladder_clearance) ;
+    }
+
+
+    //FIXME: GEAR....
+    // std::ostringstream ossradius;
+    // std::ostringstream osshalfz;
+    // ossradius << inner_most_radius / mm;
+    // osshalfz << half_z / mm;
+
+    // if(is_SET1 == 1){
+    //   (*Control::globalModelParameters)["SET1_Radius"] = ossradius.str();
+    //   (*Control::globalModelParameters)["SET1_Half_Length_Z"] = osshalfz.str();
+    // }
+    // if(is_SET2 == 1){
+    //   (*Control::globalModelParameters)["SET2_Radius"] = ossradius.str();
+    //   (*Control::globalModelParameters)["SET2_Half_Length_Z"] = osshalfz.str();
+    // }
+    
+    dd4hep::rec::ZPlanarData::LayerLayout thisLayer ;
+    thisLayer.sensorsPerLadder = number_of_sensors_per_half * 2.0 ;
+    thisLayer.lengthSensor     = sensor_length ;
+    
+    thisLayer.distanceSupport  = support_radius;
+    thisLayer.offsetSupport    = 0. ;
+    thisLayer.thicknessSupport = support_thickness ;
+    thisLayer.zHalfSupport     = half_z ;
+    thisLayer.widthSupport     = ladder_width ;
+    
+    thisLayer.distanceSensitive  = sensitive_radius - 0.5 *sensitive_thickness;
+    thisLayer.offsetSensitive    = 0. ;
+    thisLayer.thicknessSensitive = sensitive_thickness ;
+    thisLayer.zHalfSensitive     = half_z ;
+    thisLayer.widthSensitive     = ladder_width ;
+    
+    thisLayer.ladderNumber =  n_ladders;
+    thisLayer.phi0         =  0. ;
+    
+    zPlanarData->layers.push_back( thisLayer ) ;
+    
+    SET_Layer layer_geom ;
+    std::vector<SET_Layer> SET_Layers;
+    
+    layer_geom.n_ladders = n_ladders;
+    layer_geom.half_z = half_z ;
+    layer_geom.sensor_length = sensor_length;
+    layer_geom.n_sensors_per_ladder = number_of_sensors_per_half * 2.0;
+    layer_geom.sensitive_inner_radius = sensitive_radius - 0.5 * sensitive_thickness;
+    layer_geom.support_inner_radius = support_radius;
+    layer_geom.ladder_width = ladder_width ;
+    layer_geom.ladder_dphi = ladder_dphi;
+    
+    SET_Layers.push_back(layer_geom) ;
+    
+    
+    std::cout << "SET_Simple_Planar: Layer:" << layer_id
+	      << "\t half length = " << layer_geom.half_z
+	      << "\t sensor length = " << layer_geom.sensor_length
+	      << "\t n sensors per ladder = " << layer_geom.n_sensors_per_ladder
+	      << "\t min r sensitive = " << layer_geom.sensitive_inner_radius
+	      << "\t min r support = " << layer_geom.support_inner_radius
+	      << "\t n ladders = " << layer_geom.n_ladders
+	      << "\t ladder width = " << layer_geom.ladder_width
+	      << "\t ladder clearance = " << ladder_clearance
+	      << "\t ladder dphi = " << ladder_dphi
+	      << "\t sensitive mat = " <<sensitiveMat->GetName()
+	      << "\t support mat = " <<supportMat->GetName()
+	      << "\t faces_IP = " << faces_IP
+	      << std::endl;
+    
+        
+    
+    //************************************************************************************************
+    // Geometric Values Established. Start Creating Volumes.
+        
+
+    // create an enclosing ladder volume that will be placed in the world volume for every ladder
+        
+    dd4hep::Box setLadderSolid( (sensitive_thickness +support_thickness ) / 2.0 ,
+                                layer_geom.ladder_width / 2.0,
+                                layer_geom.half_z);
+
+    dd4hep::Volume setLadderLogical (dd4hep::_toString( layer_id,"SET_LadderLogical_%02d"), setLadderSolid, air ) ; 
+        
+    // now create an envelope volume to represent the sensitive area, which will be divided up into individual sensors         
+        
+    dd4hep::Box setSenEnvelopeSolid( (sensitive_thickness ) / 2.0 ,
+                                     layer_geom.ladder_width  / 2.0,
+                                     layer_geom.half_z);
+    
+    //fixme: material ???    Volume setSenEnvelopeLogical( _toString( layer_id,"SET_SenEnvelopeLogical_%02d"), setSenEnvelopeSolid, sensitiveMat )  ;
+    dd4hep::Volume setSenEnvelopeLogical( dd4hep::_toString( layer_id,"SET_SenEnvelopeLogical_%02d"),
+                                          setSenEnvelopeSolid, air )  ;
+    
+    // create the sensor volumes and place them in the senstive envelope volume 
+    
+    dd4hep::Box setSenSolid( (sensitive_thickness ) / 2.0 ,
+                             layer_geom.ladder_width  / 2.0,
+                             (layer_geom.sensor_length / 2.0 ) - 1.e-06*dd4hep::mm ); // added tolerance to avoid false overlap detection
+    
+    dd4hep::Volume setSenLogical( dd4hep:: _toString( layer_id,"SET_SenLogical_%02d"), setSenSolid,sensitiveMat ) ; 
+    
+    setSenLogical.setSensitiveDetector(sens);
+    
+    
+    
+    //====== create the meassurement surface ===================
+    Vector3D u,v,n ;
+    
+    if( faces_IP == 0 ){
+
+      n.fill( -1. ,   0. , 0. ) ;
+
+      // implement stereo angle 
+      u.fill( 0. , -cos( strip_angle  ) , -sin( strip_angle  ) ) ;
+      v.fill( 0. , -sin( strip_angle  ) ,  cos( strip_angle  ) ) ;
+
+    } else {
+
+      n.fill( 1. , 0. , 0. ) ;
+
+      // implement stereo angle 
+      u.fill( 0. ,  cos( strip_angle  ) ,  sin( strip_angle  ) ) ;
+      v.fill( 0. , -sin( strip_angle  ) ,  cos( strip_angle  ) ) ;
+    }
+
+    double inner_thick =  sensitive_thickness / 2.0 ;
+    double outer_thick =  sensitive_thickness / 2.0 + support_thickness ;  // support is on top
+   
+    VolPlane surf( setSenLogical , SurfaceType(SurfaceType::Sensitive,SurfaceType::Measurement1D) ,inner_thick, outer_thick , u,v,n ) ; //,o ) ;
+ 
+    // vector of sensor placements - needed for DetElements in ladder loop below
+    std::vector<dd4hep::PlacedVolume> pvV(  layer_geom.n_sensors_per_ladder ) ;
+
+  //============================================================
+
+    for (int isensor=0; isensor < layer_geom.n_sensors_per_ladder ; ++isensor) {
+      
+      // encoder.reset() ;  // reset to 0
+      // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+      // encoder[LCTrackerCellID::sensor()] =  isensor+1;
+      // cellID0 = encoder.lowWord() ;
+      
+      double xpos = 0.0;
+      double ypos = 0.0;
+      double zpos = -layer_geom.half_z + (0.5*layer_geom.sensor_length) + (isensor*layer_geom.sensor_length) ;
+      
+      pv = setSenEnvelopeLogical.placeVolume( setSenLogical,
+                                              dd4hep::Transform3D( dd4hep::RotationY(0.) ,
+                                                                   dd4hep::Position( xpos, ypos, zpos)  ) );
+      
+      pv.addPhysVolID("sensor",  isensor ) ; 
+      //fixme: what is the correct numbering convention ?
+      // pv.addPhysVolID("sensor",  isensor + 1 ) ; 
+      pvV[isensor] = pv ;
+   }					      
+    
+    set.setVisAttributes(theDetector, "SeeThrough",  setLadderLogical ) ;
+    set.setVisAttributes(theDetector, "SeeThrough",  setSenEnvelopeLogical ) ;
+
+    set.setVisAttributes(theDetector, "BlueVis",       setSenLogical ) ;
+    
+    
+    // encoder.reset() ;  // reset to 0
+    // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+    // encoder[LCTrackerCellID::layer()]  = layer_id ;
+    // cellID0 = encoder.lowWord() ;
+        
+
+    pv = setLadderLogical.placeVolume( setSenEnvelopeLogical ,
+                                       dd4hep::Transform3D( dd4hep::RotationY( 0.), 
+                                                            dd4hep::Position( (-(sensitive_thickness +support_thickness ) / 2.0
+                                                                               + ( sensitive_thickness / 2.0) ), 0.,0.) ) );
+    // pv = setSenEnvelopeLogical.placeVolume( setLadderLogical, Transform3D( RotationY( 0.), 
+    // 									   Position( (-(sensitive_thickness +support_thickness ) / 2.0 + ( sensitive_thickness / 2.0) ), 0.,0.) ) );
+
+    //fixme: needed ??    pv.addPhysVolID("layer", layer_id ) ; 
+    
+    
+
+    // create support volume which will be placed in the enclosing ladder volume together with the senstive envelope volume
+    
+    dd4hep::Box setSupSolid( (support_thickness ) / 2.0 ,
+                             layer_geom.ladder_width / 2.0,
+                             layer_geom.half_z);
+    
+    dd4hep::Volume setSupLogical( dd4hep::_toString( layer_id,"SET_SupLogical_%02d"),  setSupSolid, supportMat ) ;
+    
+    
+    set.setVisAttributes(theDetector, "RedVis",  setSupLogical ) ;
+    
+    
+    pv = setLadderLogical.placeVolume( setSupLogical,
+                                       dd4hep::Transform3D( dd4hep::RotationY( 0.), 
+                                                            dd4hep::Position( (-(sensitive_thickness +support_thickness ) / 2.0
+                                                                               +sensitive_thickness + ( support_thickness / 2.0)   ), 0.,0.) ) );
+    
+    for( int i = 0 ; i < n_ladders ; ++i ){
+      
+      std::stringstream ladder_enum; ladder_enum << "set_ladder_" << layer_id << "_" << i;
+      
+      dd4hep::DetElement ladderDE( layerDE ,  ladder_enum.str() , x_det.id() );
+
+      for (int isensor=0; isensor < layer_geom.n_sensors_per_ladder ; ++isensor) {
+
+	std::stringstream sensor_ss ;  sensor_ss << ladder_enum.str() << "_" << isensor ;
+	
+	dd4hep::DetElement sensorDE( ladderDE, sensor_ss.str() ,  x_det.id() );
+	sensorDE.setPlacement( pvV[isensor] ) ;
+
+	volSurfaceList( sensorDE )->push_back(  surf ) ;
+      }					      
+    
+
+     // RotationMatrix *rot = new RotationMatrix();
+      // rot->rotateZ( i * -ladder_dphi );
+      
+      // // rotate by 180 degrees around z if facing away from the IP
+      // if( faces_IP == 0 ) rot->rotateZ( 180 * deg );
+      
+      // encoder[LCTrackerCellID::subdet()] = ILDDetID::SET ;
+      // encoder[LCTrackerCellID::layer()]  = layer_id ;
+      // encoder[LCTrackerCellID::module()] = i + 1 ;
+      // cellID0 = encoder.lowWord() ;  
+      
+      float dr = ( (sensitive_thickness +support_thickness ) / 2.0 ) - (sensitive_thickness / 2.0 ) ;
+      
+      //      double phi_rot =  i * -ladder_dphi ;
+      double phi_rot =  i * ladder_dphi ;
+
+      if( faces_IP == 0 ) { 
+
+	dr = -dr;
+
+	phi_rot += M_PI ;
+      }
+
+      pv = layer_assembly.placeVolume( setLadderLogical,
+                                       dd4hep::Transform3D( dd4hep::RotationZYX(  phi_rot, 0. , 0. ), 
+                                                            dd4hep::Position( (sensitive_radius+dr) * cos(i * ladder_dphi), 
+                                                                              (sensitive_radius+dr) * sin(i * ladder_dphi), 
+                                                                              0. ) ) ) ;
+      
+      pv.addPhysVolID("layer", layer_id ).addPhysVolID("module", i ) ; 
+      //fixme: what is the correct numbering convention ?
+      //pv.addPhysVolID("layer", layer_id ).addPhysVolID("module", i+1 ) ; 
+      
+      ladderDE.setPlacement( pv ) ;
+    }
+    
+    
+  }
+
+  cout << "SET_Simple_Planar done.\n" << endl;
+  //######################################################################################################################################################################
+  
+  set.addExtension< ZPlanarData >( zPlanarData ) ;
+
+  //--------------------------------------
+  
+  
+  set.setVisAttributes( theDetector, x_det.visStr(), envelope );
+  
+  return set;
+}
+DECLARE_DETELEMENT(SET_Simple_Planar,create_element)
+
diff --git a/Detector/DetCEPCv4/src/tracker/SIT_Simple_Pixel_geo.cpp b/Detector/DetCEPCv4/src/tracker/SIT_Simple_Pixel_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..01bd3572b8d3fdf99fd4068d8f14999ea8fa31ea
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/SIT_Simple_Pixel_geo.cpp
@@ -0,0 +1,478 @@
+//====================================================================
+//  lcgeo - LC detector models in DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetType.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "XML/Utilities.h"
+#include "XMLHandlerDB.h"
+#include <cmath>
+
+using namespace std;
+
+using dd4hep::Box;
+using dd4hep::DetElement;
+using dd4hep::Position;
+using dd4hep::RotationY;
+using dd4hep::RotationZYX;
+using dd4hep::Transform3D;
+using dd4hep::Volume;
+using dd4hep::_toString;
+using dd4hep::rec::volSurfaceList;
+using dd4hep::rec::ZPlanarData;
+
+/** helper struct */
+struct SIT_Layer {
+  int     n_ladders;
+  int     n_sensors_per_ladder;
+  double  sensor_length;
+  double  half_z;
+  double  sensitive_inner_radius ;
+  double  support_inner_radius ;
+  double  ladder_width ;
+  double  ladder_dphi ;
+};    
+
+//std::vector<SIT_Layer> _SIT_Layers;
+  
+// /** helper struct */
+// struct extended_reconstruction_parameters {
+//   double sensor_length_mm;
+//   double strip_width_mm;
+//   double strip_length_mm;
+//   double strip_pitch_mm;
+//   double strip_angle_deg;
+// };
+
+//extended_reconstruction_parameters _e_r_p;
+
+
+/** Construction of the SIT detector, ported from Mokka driver SIT_Simple_Pixel.cc
+ *
+ *  Mokka History:
+ *  Feb 7th 2011, Steve Aplin - original version
+ *
+ *  @author: F.Gaede, DESY, Jan 2014
+ */
+static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4hep::SensitiveDetector sens)  {
+
+  //------------------------------------------
+  //  See comments starting with '//**' for
+  //     hints on porting issues
+  //------------------------------------------
+
+  
+  xml_det_t    x_det = e;
+  string       name  = x_det.nameStr();
+  
+  dd4hep::DetElement   sit(  name, x_det.id()  ) ;
+  
+  // --- create an envelope volume and position it into the world ---------------------
+  
+  dd4hep::Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  e , sit ) ;
+  
+  dd4hep::xml::setDetectorTypeFlag( e, sit ) ;
+
+  if( theDetector.buildType() == dd4hep::BUILD_ENVELOPE ) return sit ;
+  
+  //-----------------------------------------------------------------------------------
+  
+  dd4hep::PlacedVolume pv;
+  
+  
+  sens.setType("tracker");
+
+
+  dd4hep::rec::ZPlanarData*  zPlanarData = new dd4hep::rec::ZPlanarData ;
+
+  //######################################################################################################################################################################
+  //  code ported from SIT_Simple_Pixel::construct() :
+  //##################################
+
+  //  extended_reconstruction_parameters _e_r_p;
+
+  // *********************
+  //  Read and Store the Extended Reconstruction Parameters which are passed directly through to gear. Note others may be added below
+  // db->exec("select * from extended_reconstruction_parameters;");
+  // db->getTuple();
+  XMLHandlerDB db = XMLHandlerDB(  x_det.child( _Unicode( reconstruction ) ) ) ;
+  
+  zPlanarData->widthStrip  = db->fetchDouble("strip_width")  ;
+  zPlanarData->lengthStrip = db->fetchDouble("strip_length") ;
+  zPlanarData->pitchStrip  = db->fetchDouble("strip_pitch")  ;
+  zPlanarData->angleStrip  = db->fetchDouble("strip_angle") ;
+  double strip_angle = zPlanarData->angleStrip ;
+  // *********************
+  
+  
+  //... db common_parameters
+  // // db->exec("select * from global;");
+  // // db->getTuple();
+  db = XMLHandlerDB(  x_det.child( _Unicode( global ) ) ) ;
+
+  // Sensitive Thickness  
+  double sensitive_thickness = db->fetchDouble("sensitive_thickness") ;
+  // Support Thickness
+  double support_thickness = db->fetchDouble("support_thickness") ;
+  // Sensor Length
+  double sensor_length = db->fetchDouble("sensor_length") ;
+  
+  dd4hep::Material air = theDetector.air()  ;
+  dd4hep::Material sensitiveMat = theDetector.material(db->fetchString("sensitive_mat"));  
+  dd4hep::Material supportMat   = theDetector.material(db->fetchString("support_mat"));  
+  
+  
+  // // // setup the encoder 
+  // // UTIL::BitField64 encoder( LCTrackerCellID::encoding_string() ) ; 
+  
+  // // encoder.reset() ;  // reset to 0
+  
+  // // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+  // // encoder[LCTrackerCellID::side()] = 0 ;
+  // // encoder[LCTrackerCellID::layer()]  = 0 ;
+  // // encoder[LCTrackerCellID::module()] = 0 ;
+  // // encoder[LCTrackerCellID::sensor()] = 0 ;
+  // // int cellID0 = encoder.lowWord() ;
+  
+  //... The SIT Sensitive detector
+  //unused:  double sensitive_threshold_KeV = db->fetchDouble("sensitive_threshold_KeV")  ;
+  
+  //FIXME: the SD  ...
+  // // _theSITSD = 
+  // // new TRKSD02("SIT",
+  // //             _sensitive_thickness * mm 
+  // //             * sensitive_threshold_KeV ,
+  // //             10.0 * MeV);
+  
+  // // RegisterSensitiveDetector(_theSITSD);
+  
+
+  for(xml_coll_t c( x_det ,_U(layer)); c; ++c)  {
+    
+    xml_comp_t  x_layer( c );
+    db = XMLHandlerDB( x_layer )  ;
+    
+    int layer_id = db->fetchInt("layer_id");
+    
+    double half_z(0);
+    double sensitive_radius(0);
+    double sensitive_inner_radius(0);
+    double support_radius(0);
+    int    n_sensors_per_ladder(0) ;
+    int    n_ladders(0) ;
+    double ladder_width(0) ;
+    double ladder_clearance(0) ;
+    int    faces_IP(0) ;
+    int    is_SIT1(0) ;
+    int    is_SIT2(0) ;
+
+      
+    sensitive_radius     = db->fetchDouble("sensitive_radius") ;
+    n_sensors_per_ladder = db->fetchInt("n_sensors_per_ladder") ;
+    half_z               = (n_sensors_per_ladder *sensor_length) / 2.0 ;
+    n_ladders            = db->fetchInt("n_ladders") ;
+    faces_IP             = db->fetchInt("faces_IP") ;
+    is_SIT1              = db->fetchInt("is_SIT1") ;
+    is_SIT2              = db->fetchInt("is_SIT2") ;
+    ladder_clearance     = db->fetchDouble("ladder_clearance") ;
+
+
+    // create assembly and DetElement for the layer
+    std::string layerName = dd4hep::_toString( layer_id , "layer_%d"  );
+    dd4hep::Assembly layer_assembly( layerName ) ;
+    pv = envelope.placeVolume( layer_assembly ) ;
+    dd4hep::DetElement layerDE( sit , layerName  , x_det.id() );
+    layerDE.setPlacement( pv ) ;
+
+
+    const double ladder_dphi = ( dd4hep::twopi / n_ladders ) ;
+
+    sensitive_inner_radius = sensitive_radius - 0.5 *sensitive_thickness;
+    ladder_width = 2*(tan(ladder_dphi*0.5)*sensitive_inner_radius - ladder_clearance) ;
+                    
+    // double inner_most_radius = 0.0;
+    
+    if( faces_IP == 1 ){ // support is on the outside 
+      support_radius = sensitive_radius + (0.5 *sensitive_thickness) ;
+      ladder_width = 2*(tan(ladder_dphi*0.5)*sensitive_inner_radius - ladder_clearance) ;
+      // inner_most_radius = sensitive_inner_radius;
+    }
+    else{ // support is on the inside
+      support_radius = sensitive_radius - (0.5 *sensitive_thickness) -support_thickness;
+      ladder_width = 2*(tan(ladder_dphi*0.5)*support_radius - ladder_clearance) ;
+      // inner_most_radius = support_radius;
+    }
+    
+    //FIXME: GEAR....
+    // std::ostringstream ossradius;
+    // std::ostringstream osshalfz;
+    // ossradius << inner_most_radius / mm;
+    // osshalfz << half_z / mm;
+
+    // if(is_SIT1 == 1){
+    //   (*Control::globalModelParameters)["SIT1_Radius"] = ossradius.str();
+    //   (*Control::globalModelParameters)["SIT1_Half_Length_Z"] = osshalfz.str();
+    // }
+    // if(is_SIT2 == 1){
+    //   (*Control::globalModelParameters)["SIT2_Radius"] = ossradius.str();
+    //   (*Control::globalModelParameters)["SIT2_Half_Length_Z"] = osshalfz.str();
+    // }
+    
+    dd4hep::rec::ZPlanarData::LayerLayout thisLayer ;
+    thisLayer.sensorsPerLadder = n_sensors_per_ladder ;
+    thisLayer.lengthSensor     = sensor_length ;
+
+    thisLayer.distanceSupport  = support_radius;
+    thisLayer.offsetSupport    = 0. ;
+    thisLayer.thicknessSupport = support_thickness ;
+    thisLayer.zHalfSupport     = half_z ;
+    thisLayer.widthSupport     = ladder_width ;
+
+    thisLayer.distanceSensitive  = sensitive_radius - 0.5 *sensitive_thickness;
+    thisLayer.offsetSensitive    = 0. ;
+    thisLayer.thicknessSensitive = sensitive_thickness ;
+    thisLayer.zHalfSensitive     = half_z ;
+    thisLayer.widthSensitive     = ladder_width ;
+
+    thisLayer.ladderNumber =  n_ladders;
+    thisLayer.phi0         =  0. ;
+
+    zPlanarData->layers.push_back( thisLayer ) ;
+
+    SIT_Layer layer_geom ;
+    layer_geom.n_ladders = n_ladders;
+    layer_geom.sensor_length =sensor_length;
+    layer_geom.n_sensors_per_ladder = n_sensors_per_ladder;
+    layer_geom.half_z = half_z ;
+    layer_geom.sensitive_inner_radius = sensitive_radius - 0.5 *sensitive_thickness;
+    layer_geom.support_inner_radius = support_radius;
+    layer_geom.ladder_width = ladder_width ;
+    layer_geom.ladder_dphi = ladder_dphi;
+    std::vector<SIT_Layer>SIT_Layers;
+    SIT_Layers.push_back(layer_geom) ;
+    
+    
+    std::cout << "SIT_Simple_Pixel: Layer:" << layer_id
+    	      << "\t half length = " << layer_geom.half_z
+    	      << "\t sensor length = " << layer_geom.sensor_length
+    	      << "\t n sensors per ladder = " << layer_geom.n_sensors_per_ladder
+    	      << "\t min r sensitive = " << layer_geom.sensitive_inner_radius
+    	      << "\t min r support = " << layer_geom.support_inner_radius
+    	      << "\t n ladders = " << layer_geom.n_ladders
+    	      << "\t ladder width = " << layer_geom.ladder_width
+    	      << "\t ladder clearance = " << ladder_clearance
+    	      << "\t ladder dphi = " << ladder_dphi
+    	      << "\t sensitive mat = " <<sensitiveMat->GetName()
+    	      << "\t support mat = " <<supportMat->GetName()
+    	      << "\t faces_IP = " << faces_IP
+    	      << "\t is_SIT1 = " << is_SIT1
+    	      << "\t is_SIT2 = " << is_SIT2
+    	      << std::endl;
+    
+        
+    // std::stringstream name_base;
+    // name_base << "SIT";
+    // std::stringstream name_enum;
+    // name_enum << layer_id;
+        
+    // create an enclosing ladder volume that will be placed in the world volume for every ladder
+        
+    dd4hep::Box sitLadderSolid( (sensitive_thickness +support_thickness ) / 2.0 ,
+                                layer_geom.ladder_width / 2.0,
+                                layer_geom.half_z);
+
+    dd4hep::Volume sitLadderLogical( dd4hep::_toString( layer_id,"SIT_LadderLogical_%02d"), sitLadderSolid, air ) ; 
+        
+    // now create an envelope volume to represent the sensitive area, which will be divided up into individual sensors         
+        
+    dd4hep::Box sitSenEnvelopeSolid( (sensitive_thickness ) / 2.0 ,
+                                     layer_geom.ladder_width  / 2.0,
+                                     layer_geom.half_z);
+    
+    //fixme: material ???    Volume sitSenEnvelopeLogical( _toString( layer_id,"SIT_SenEnvelopeLogical_%02d"), sitSenEnvelopeSolid, sensitiveMat )  ;
+    dd4hep::Volume sitSenEnvelopeLogical( dd4hep::_toString( layer_id,"SIT_SenEnvelopeLogical_%02d"),
+                                          sitSenEnvelopeSolid, air )  ;
+    
+    // create the sensor volumes and place them in the senstive envelope volume 
+    
+    dd4hep::Box sitSenSolid( (sensitive_thickness ) / 2.0 ,
+                             layer_geom.ladder_width  / 2.0,
+                             (layer_geom.sensor_length / 2.0 ) - 1.e-06 * dd4hep::mm ); // added tolerance to avoid false overlap detection
+    
+    dd4hep::Volume sitSenLogical( dd4hep::_toString( layer_id,"SIT_SenLogical_%02d"), sitSenSolid,sensitiveMat ) ; 
+    
+    sitSenLogical.setSensitiveDetector(sens);
+
+
+    //====== create the meassurement surface ===================
+    dd4hep::rec::Vector3D u,v,n ;
+
+    if( faces_IP == 0 ){
+
+      n.fill( -1. ,   0. , 0. ) ;
+
+      // implement stereo angle 
+      u.fill( 0. ,  -cos( strip_angle ) , -sin( strip_angle  ) ) ;
+      v.fill( 0. ,  -sin( strip_angle ) ,  cos( strip_angle  ) ) ;
+
+    } else {
+
+      n.fill( 1. , 0. , 0. ) ;
+
+      // implement stereo angle 
+      u.fill( 0. ,  cos( strip_angle  ) ,  sin( strip_angle  ) ) ;
+      v.fill( 0. , -sin( strip_angle  ) ,  cos( strip_angle  ) ) ;
+    }
+
+
+    double inner_thick =  sensitive_thickness / 2.0 ;
+    double outer_thick =  sensitive_thickness / 2.0 ;
+   
+    if( faces_IP ){
+      outer_thick += support_thickness ;
+    } else { 
+      inner_thick += support_thickness ;
+    }
+
+
+    dd4hep::rec::VolPlane surf( sitSenLogical ,
+                                dd4hep::rec::SurfaceType(dd4hep::rec::SurfaceType::Sensitive),
+                                inner_thick, outer_thick , u,v,n ) ; //,o ) ;
+
+    // vector of sensor placements - needed for DetElements in ladder loop below
+    std::vector<dd4hep::PlacedVolume> pvV(  layer_geom.n_sensors_per_ladder ) ;
+
+    //============================================================
+
+
+    for (int isensor=0; isensor < layer_geom.n_sensors_per_ladder ; ++isensor) {
+      
+      // encoder.reset() ;  // reset to 0
+      // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+      // encoder[LCTrackerCellID::sensor()] =  isensor+1;
+      // cellID0 = encoder.lowWord() ;
+      
+      double xpos = 0.0;
+      double ypos = 0.0;
+      double zpos = -layer_geom.half_z + (0.5*layer_geom.sensor_length) + (isensor*layer_geom.sensor_length) ;
+      
+      pv = sitSenEnvelopeLogical.placeVolume( sitSenLogical,
+                                              Transform3D( RotationY(0.) ,
+                                                           Position( xpos, ypos, zpos)  ) );
+      
+      pv.addPhysVolID("sensor",  isensor ) ; 
+      //fixme: what is the correct numbering convention ?
+      // pv.addPhysVolID("sensor",  isensor + 1 ) ; 
+      pvV[isensor] = pv ;
+    }					      
+    
+    sit.setVisAttributes(theDetector, "SeeThrough",  sitLadderLogical ) ;
+    sit.setVisAttributes(theDetector, "SeeThrough",  sitSenEnvelopeLogical ) ;
+
+    sit.setVisAttributes(theDetector, "BlueVis",       sitSenLogical ) ;
+    
+    
+    // encoder.reset() ;  // reset to 0
+    // encoder[LCTrackerCellID::subdet()] = ILDDetID::NOTUSED ;
+    // encoder[LCTrackerCellID::layer()]  = layer_id ;
+    // cellID0 = encoder.lowWord() ;
+        
+
+    pv = sitLadderLogical.placeVolume( sitSenEnvelopeLogical , Transform3D( RotationY( 0.), 
+									   Position( (-(sensitive_thickness +support_thickness ) / 2.0 + ( sensitive_thickness / 2.0) ), 0.,0.) ) );
+    // pv = sitSenEnvelopeLogical.placeVolume( sitLadderLogical, Transform3D( RotationY( 0.), 
+    // 									   Position( (-(sensitive_thickness +support_thickness ) / 2.0 + ( sensitive_thickness / 2.0) ), 0.,0.) ) );
+
+    //fixme: needed ??    pv.addPhysVolID("layer", layer_id ) ; 
+    
+    
+
+    // create support volume which will be placed in the enclosing ladder volume together with the senstive envelope volume
+    
+    Box sitSupSolid( (support_thickness ) / 2.0 ,
+		     layer_geom.ladder_width / 2.0,
+		     layer_geom.half_z);
+    
+    Volume sitSupLogical(   _toString( layer_id,"SIT_SupLogical_%02d"),  sitSupSolid, supportMat ) ;
+    
+    
+    sit.setVisAttributes(theDetector, "RedVis",  sitSupLogical ) ;
+    
+    
+    pv = sitLadderLogical.placeVolume( sitSupLogical, Transform3D( RotationY( 0.), 
+								   Position( (-(sensitive_thickness +support_thickness ) / 2.0 +sensitive_thickness + ( support_thickness / 2.0)   ), 0.,0.) ) );
+    
+    for( int i = 0 ; i < n_ladders ; ++i ){
+      
+      std::stringstream ladder_enum; ladder_enum << "sit_ladder_" << layer_id << "_" << i;
+      
+
+      DetElement   ladderDE( layerDE ,  ladder_enum.str() , x_det.id() );
+
+      for (int isensor=0; isensor < layer_geom.n_sensors_per_ladder ; ++isensor) {
+
+	std::stringstream sensor_ss ;  sensor_ss << ladder_enum.str() << "_" << isensor ;
+	
+	DetElement sensorDE( ladderDE, sensor_ss.str() ,  x_det.id() );
+	sensorDE.setPlacement( pvV[isensor] ) ;
+
+	volSurfaceList( sensorDE )->push_back(  surf ) ;
+      }					      
+    
+
+      // RotationMatrix *rot = new RotationMatrix();
+      // rot->rotateZ( i * -ladder_dphi );
+      
+      // // rotate by 180 degrees around z if facing away from the IP
+      // if( faces_IP == 0 ) rot->rotateZ( 180 * deg );
+      
+      // encoder[LCTrackerCellID::subdet()] = ILDDetID::SIT ;
+      // encoder[LCTrackerCellID::layer()]  = layer_id ;
+      // encoder[LCTrackerCellID::module()] = i + 1 ;
+      // cellID0 = encoder.lowWord() ;  
+      
+      float dr = ( (sensitive_thickness +support_thickness ) / 2.0 ) - (sensitive_thickness / 2.0 ) ;
+      
+      //      double phi_rot =  i * -ladder_dphi ;
+      double phi_rot =  i * ladder_dphi ;
+
+      if( faces_IP == 0 ) { 
+
+	dr = -dr;
+
+	phi_rot += M_PI ;
+      }
+
+      pv = layer_assembly.placeVolume( sitLadderLogical, Transform3D( RotationZYX(  phi_rot, 0. , 0. ), 
+								      Position( (sensitive_radius+dr) * cos(i * ladder_dphi), 
+										(sensitive_radius+dr) * sin(i * ladder_dphi), 
+										0. ) ) ) ;
+      
+      pv.addPhysVolID("layer", layer_id ).addPhysVolID("module", i ) ; 
+      //fixme: what is the correct numbering convention ?
+      //pv.addPhysVolID("layer", layer_id ).addPhysVolID("module", i+1 ) ; 
+ 
+
+      ladderDE.setPlacement( pv ) ;
+    }
+    
+    
+  }
+
+  cout << "SIT_Simple_Pixel done.\n" << endl;
+  //######################################################################################################################################################################
+  
+  sit.addExtension< ZPlanarData >( zPlanarData ) ;
+  
+  //--------------------------------------
+  
+  sit.setVisAttributes( theDetector, x_det.visStr(), envelope );
+  
+  return sit;
+}
+DECLARE_DETELEMENT(SIT_Simple_Pixel,create_element)
diff --git a/Detector/DetCEPCv4/src/tracker/TPC10_geo.cpp b/Detector/DetCEPCv4/src/tracker/TPC10_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..888aff300fa10286f78085884436f70a8da6a029
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/TPC10_geo.cpp
@@ -0,0 +1,641 @@
+//====================================================================
+//  lcgeo - LC detector models in DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetType.h"
+#include "LcgeoExceptions.h"
+#include "lcgeo.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "XML/Utilities.h"
+#include "XMLHandlerDB.h"
+
+#include <math.h>
+
+using namespace std;
+using namespace dd4hep;
+using namespace lcgeo;
+
+using dd4hep::rec::Vector3D;
+using dd4hep::rec::VolCylinder;
+using dd4hep::rec::SurfaceType;
+using dd4hep::rec::volSurfaceList;
+using dd4hep::rec::VolPlane;
+using dd4hep::rec::FixedPadSizeTPCData;
+
+/** Construction of TPC detector, ported from Mokka driver TPC10.cc
+ * Mokka History:
+ * - modified version of TPC driver by Ties Behnke
+ * - modified version of TPC02 as TPC03 with selectable chamber gas -- Adrian Vogel, 2005-06-09
+ * - modified version of TPC03 as TPC04 with limit of step length   -- Adrian Vogel, 2006-02-01
+ * - introduced self-scalability, no superdriver needed anymore     -- Adrian Vogel, 2006-03-11
+ * - modified version of TPC04 as TPC05 in order to have full MC
+ *   information both at entry and exit hits in the TPC ,
+ *   more realistic central electrode and endplate             -- Predrag Krstonosic, 2006-07-12
+ * - implemented new GEAR interface -- K. Harder, T. Pinto Jayawardena                2007-07-31
+ * - TPC10 implemented readout within the Gas volume and layered inner and outer wall -- SJA -- 2010-11-19
+ *
+ *  @author: F.Gaede, DESY, Nov 2013
+ *
+ */
+static Ref_t create_element(Detector& theDetector, xml_h e, SensitiveDetector sens)  {
+
+  //------------------------------------------
+  //  See comments starting with '//**' for
+  //     hints on porting issues
+  //------------------------------------------
+
+  
+  xml_det_t    x_det = e;
+  string       name  = x_det.nameStr();
+
+  DetElement   tpc(  name, x_det.id()  ) ;
+  
+
+ // --- create an envelope volume and position it into the world ---------------------
+
+  Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  e , tpc ) ;
+
+  dd4hep::xml::setDetectorTypeFlag( e, tpc ) ;
+
+  if( theDetector.buildType() == BUILD_ENVELOPE ) return tpc ;
+
+  //-----------------------------------------------------------------------------------
+
+  PlacedVolume pv;  
+
+  sens.setType("tracker");
+
+  std::cout << " ** building TPC10_geo in lcgeo " << lcgeo::versionString() << std::endl ;
+
+  //   //######################################################################################################################################################################
+  //   //  code ported from TPC10::construct() :
+  //   //##################################
+  
+  // const double phi1 =   0.0 * deg ;
+  // const double phi2 = 360.0 * deg;
+  const double phi1 =   0.0 ;
+  const double phi2 =  2*M_PI ;
+  //  
+  const double dzTotal           = theDetector.constant<double>("TPC_Ecal_Hcal_barrel_halfZ") * 2. ; 
+  const double rInner            = theDetector.constant<double>("TPC_inner_radius") ;
+  const double rOuter            = theDetector.constant<double>("TPC_outer_radius") ;
+    
+    
+  // Geometry parameters from the geometry environment and from the database
+  // Database *db = new Database(env.GetDBName());
+    
+  XMLHandlerDB db(  x_det.child( _Unicode( global ) ) );
+    
+  const double TPCMaxStepLength    = db->fetchDouble("TPC_max_step_length") ;
+  const double padHeight           = db->fetchDouble("TPC_pad_height") ;
+  const double padWidth            = db->fetchDouble("TPC_pad_width") ;
+  const double dr_InnerWall        = db->fetchDouble("dr_InnerWall") ;
+  const double dr_InnerServiceArea = db->fetchDouble("dr_InnerServiceArea") ;
+  const double dr_OuterServiceArea = db->fetchDouble("dr_OuterServiceArea") ;
+  const double dr_OuterWall        = db->fetchDouble("dr_OuterWall") ;
+  const double dz_Readout          = db->fetchDouble("dz_Readout") ;
+  const double dz_Endplate         = db->fetchDouble("dz_Endplate") ;
+
+  //    Material* const material_TPC_Gas = CGAGeometryManager::GetMaterial(db->fetchString("chamber_Gas"));
+  Material material_TPC_Gas =  theDetector.material(db->fetchString("chamber_Gas") ) ;
+
+  // #ifdef MOKKA_GEAR
+  //   _gear_gas_material = material_TPC_Gas; 
+  // #endif
+    
+  //unused:  const double sensitive_threshold_eV  = db->fetchDouble("sensitive_threshold_eV") ;
+    
+
+  //   db->exec("SELECT * FROM `cathode`;");
+  //   db->getTuple();
+  db = XMLHandlerDB(  x_det.child( _Unicode( cathode ) ) );
+    
+  const double dz_Cathode_Insulator   = db->fetchDouble("dz_Cathode_Insulator") ;
+  const double dz_Cathode_Conductor   = db->fetchDouble("dz_Cathode_Conductor") ;
+  Material material_Cathode_Insulator = theDetector.material(db->fetchString("material_Cathode_Insulator"));
+  Material material_Cathode_Conductor = theDetector.material(db->fetchString("material_Cathode_Conductor"));
+    
+  const double dr_Cathode_Grip = db->fetchDouble("dr_Cathode_Grip") ;
+  const double dz_Cathode_Grip = db->fetchDouble("dz_Cathode_Grip") ;
+  Material material_Cathode_Grip = theDetector.material(db->fetchString("material_Cathode_Grip"));
+    
+  cout << " Cathode Grip Ring Material: " << material_Cathode_Grip->GetName() << " : Rad length = " << material_Cathode_Grip->GetMaterial()->GetRadLen() / mm << " mm." << std::endl;
+    
+  const double dz_Cathode = 2*(dz_Cathode_Insulator+dz_Cathode_Conductor);
+    
+  double tracking_tpc_ecal_gap = theDetector.constant<double>("Ecal_Tpc_gap") ;;
+  double tracking_region_rmax = rOuter + tracking_tpc_ecal_gap - 0.1*mm;  // give 100 micron clearance 
+    
+  std::stringstream tracking_region_rmax_as_string;
+  tracking_region_rmax_as_string <<  tracking_region_rmax;
+    
+  //fg needed ???
+  // (*Control::globalModelParameters)["tracker_region_rmax"] = tracking_region_rmax_as_string.str();
+  // (*Control::globalModelParameters)["tracker_region_zmax"] = env.GetParameterAsString("TPC_Ecal_Hcal_barrel_halfZ");
+    
+    
+  // Calculate Dimentions needed for later. Note gas volume and endplate will be mirror placed ...
+  const double rMin_GasVolume      = rInner + dr_InnerWall;
+  const double rMax_GasVolume      = rOuter - dr_OuterWall;
+    
+  // note the will be two gas volumes one in each z-half. The cathode and readout are considered to be placed inside the Gas volume
+  const double dz_GasVolume        = ( dzTotal/2.0 ) - dz_Endplate; 
+    
+  const double rMin_Sensitive      = rMin_GasVolume + dr_InnerServiceArea;
+  const double rMax_Sensitive      = rMax_GasVolume - dr_OuterServiceArea;
+  const double dz_Sensitive        = dz_GasVolume - ( dz_Cathode/2.0 + dz_Readout ); // the d_Cathode spans both halfs of the TPC 
+  const double dz_Wall             = dzTotal - 2.0 * dz_Endplate ; // note field cage spans the complete length of the TPC Gas volume
+    
+    
+  const int numberPadRows = (int)((rMax_Sensitive-rMin_Sensitive)/padHeight) ;
+
+
+  // Materials to be used
+  Material materialAir     = theDetector.material("G4_AIR");
+
+  // Material mixture for end of endplate zone 
+  //  db->exec("SELECT * FROM `endplate_mixture`;");
+
+  //unused:  double endplate_mixture_total = 0.0;
+  //unused:  double densityTotal = 0.0 ;
+
+  //fg: don't create the material on the fly but define it in the xml file
+  // // std::map<Material* const, double> material_fractions;
+  // // //  while (db->getTuple()) 
+  // // for(xml_coll_t c( x_det ,_U(endplate_mixture)); c; ++c)  {
+  // //   xml_comp_t  x_row( c );
+  // //   db = XMLHandlerDB( x_row )  ;
+  // //   Material material = theDetector.material(db->fetchString("material"));
+  // //   material_fractions[material]    = db->fetchDouble("percentage") * perCent; // fraction of material mix
+  // //   endplate_mixture_total         += material_fractions[material];
+  // //   densityTotal                   += material->GetDensity() * material_fractions[material]; 
+  // // }
+  // // if (fabs( endplate_mixture_total - 1) > 1E-06 || (fabs( 1 - endplate_mixture_total) > 1E-06 )) 
+  // //   {
+  // //     cout << "endplate_mixture_total = " << endplate_mixture_total << endl;
+  // //     Control::Abort("TPC endplate material fractions do not add up to 100%",MOKKA_ERROR_BAD_DATABASE_PARAMETERS);
+  // //   }
+  // // Material *endplate_MaterialMix = new Material("TPC_endplate_mix", densityTotal, material_fractions.size());
+  // // for(  std::map<Material* const, double>::iterator it=material_fractions.begin(); it!=material_fractions.end();++it )
+  // //   {
+  // //     endplate_MaterialMix->AddMaterial(it->first, it->second);
+  // //   }
+  
+Material endplate_MaterialMix = theDetector.material( "TPC_endplate_mix" ) ;
+  
+  cout << "Endplate material mix Density   = " << endplate_MaterialMix->GetMaterial()->GetDensity() / g * cm3 << " g/cm3" << endl;
+  cout << "Endplate material mix Radlength = " << endplate_MaterialMix->GetMaterial()->GetRadLen() / mm << " mm" << endl;
+  
+  
+  //   // Visualisation attributes
+  
+  //   VisAttributes *wallVisAttributes = new VisAttributes(Colour(0.0, 0.5, 0.5)); // dull cyan
+  //   wallVisAttributes->SetForceWireframe(false);
+  //   wallVisAttributes->SetDaughtersInvisible(true);
+  
+  //   VisAttributes *cathodeVisAttributes = new VisAttributes(Colour(0.9, 0.3, 0.1)); // coppery brown
+  //   cathodeVisAttributes->SetForceWireframe(false);
+  
+  
+  // Some verbose output
+  cout << "TPC10: Inner radius of the gas volume is " << std::setw(4) << rMin_GasVolume / mm << " mm." << endl;
+  cout << "TPC10: Outer radius of the gas volume is " << std::setw(4) << rMax_GasVolume / mm << " mm." << endl;
+  cout << "TPC10: Inner wall thickness is " << std::setw(4) << dr_InnerWall / mm << " mm." << endl;
+  cout << "TPC10: Outer wall thickness is " << std::setw(4) << dr_OuterWall / mm << " mm." << endl;
+  cout << "TPC10: Outer wall thickness is " << std::setw(4) << dr_OuterWall / mm << " mm." << endl;
+  
+  cout << "TPC10: Inner radius of the sensitive volume is " << std::setw(4) << rMin_Sensitive / mm << " mm." << endl;
+  cout << "TPC10: Outer radius of the sensitive volume is " << std::setw(4) << rMax_Sensitive / mm << " mm." << endl;
+  cout << "TPC10: Number of Pad Rows in the TPC  " << std::setw(4) << numberPadRows << endl;
+  cout << "TPC10: Limiting the step length in the TPC to  " << std::setw(4) << TPCMaxStepLength / mm << " mm." << endl;
+  
+  //-------------------------------------------------------------------------------------------------------//
+  
+  //-------------------------------- TPC mother volume ----------------------------------------------------//
+  //------------ Volume for the whole TPC, Field Cage, Cathode, and Endplate and Sensitive ----------------//
+  
+  Tube tpc_motherSolid(rInner ,rOuter ,dzTotal/2.0 , phi1 , phi1+phi2 ); 
+  Volume tpc_motherLog(  "TPCLog", tpc_motherSolid, material_TPC_Gas );
+  pv = envelope.placeVolume( tpc_motherLog ) ;
+  tpc.setVisAttributes(theDetector,  "TPCMotherVis" ,  tpc_motherLog ) ;
+
+  // VisAttributes* motherVisAttributes = new VisAttributes(Colour(0.0, 0.5, 0.5)); // dull cyan
+  // motherVisAttributes->SetVisibility(false);
+  // motherVisAttributes->SetDaughtersInvisible(true);
+  // motherLog->SetVisAttributes(motherVisAttributes);
+  
+  
+  cout << "TPC10: Total Gas material corresponds to " << ( ( (rOuter-dr_OuterWall) - (rInner + dr_InnerWall) ) / (material_TPC_Gas->GetMaterial()->GetRadLen() / mm ) * 100.0 ) 
+       << "% of a radiation length." << endl;
+
+  //-------------------------------------------------------------------------------------------------------//
+
+  //-------------------------------- inner wall construction ----------------------------------------//
+
+  Tube innerWallSolid(rInner ,rInner + dr_InnerWall ,dz_Wall / 2.0 , phi1 ,phi1+phi2 ); 
+  Volume innerWallLog( "TPCInnerWallLog", innerWallSolid, materialAir ) ; 
+  pv = tpc_motherLog.placeVolume( innerWallLog ) ;
+  tpc.setVisAttributes(theDetector,  "CyanVis" ,  innerWallLog ) ;
+
+
+  Vector3D ocyl(  rInner + 0.5*dr_InnerWall , 0. , 0. ) ;
+  VolCylinder surfI( innerWallLog , SurfaceType( SurfaceType::Helper ) ,0.5*dr_InnerWall  , 0.5*dr_InnerWall , ocyl ) ;
+  volSurfaceList( tpc )->push_back(  surfI ) ;
+
+  int layerCounter = 0;
+  double fracRadLengthInnerWall = 0;
+  double rCursor = rInner ;
+  //  double gear_inner_wall_material_total_density = 0.0;
+
+//   db->exec("SELECT * FROM `innerWall`;");
+//   while (db->getTuple()) {
+
+  xml_comp_t  x_iWall=  x_det.child( _Unicode( innerWall) );
+  for(xml_coll_t c( x_iWall , _Unicode( row) ); c; ++c)  {
+
+    xml_comp_t  x_row( c );
+    db = XMLHandlerDB( x_row )  ;
+
+    const double dr = db->fetchDouble("dr") ;
+    Material layerMaterial = theDetector.material(db->fetchString("material"));    
+    Tube  layerSolid( rCursor, rCursor + dr , dz_Wall / 2.0, phi1, phi1+phi2);
+    Volume layerLog( _toString( layerCounter ,"TPCInnerWallLayerLog_%02d") , layerSolid, layerMaterial );
+    
+
+    //    layerLog->SetVisAttributes(VisAttributes::Invisible);
+    pv = innerWallLog.placeVolume( layerLog ) ;
+    ++layerCounter;
+    rCursor += dr ;
+    fracRadLengthInnerWall += dr / layerMaterial->GetMaterial()->GetRadLen();
+    
+    cout << "TPC10: Add Material to Inner Wall: dr =  " << std::setw(4) << dr / mm << " mm. Material = " 
+	 << layerMaterial->GetName() << " X0 = " << layerMaterial->GetMaterial()->GetRadLen() << "  " <<  dr / layerMaterial->GetMaterial()->GetRadLen() << "% X0" << endl;
+    
+// #ifdef MOKKA_GEAR
+//     gear_inner_wall_material_total_density += layerMaterial->GetDensity() * (dr / dr_InnerWall);    
+//     std::string material_name = db->fetchString("material");
+//     cout << "TPC10: gear_inner_wall_material_total_density = " << std::setw(4) << gear_inner_wall_material_total_density << endl;   
+//     if( gear_inner_wall_material_thicknesses.find( material_name ) ==  gear_inner_wall_material_thicknesses.end() ) {
+//       gear_inner_wall_material_thicknesses[ material_name ] = dr;
+//     }
+//     else {
+//       gear_inner_wall_material_thicknesses[ material_name ] += dr;
+//     }
+// #endif
+    
+  }
+  
+  cout << "TPC10: Inner wall material corresponds to " << int( fracRadLengthInnerWall * 1000) / 10. << "% of a radiation length." << endl;
+  cout << "TPC10: Inner wall effective X0 = " << std::setw(4) << dr_InnerWall / fracRadLengthInnerWall<< endl;  
+
+
+  //-------------------------------------------------------------------------------------------------------//
+
+  //-------------------------------- outer wall construction ---------------------------------------------//
+
+  Tube outerWallSolid( rOuter - dr_OuterWall ,rOuter ,dz_Wall / 2.0 ,phi1 , phi1+phi2) ;
+  Volume outerWallLog( "TPCOuterWallLog" , outerWallSolid, materialAir);
+  pv = tpc_motherLog.placeVolume( outerWallLog ) ;
+  tpc.setVisAttributes(theDetector,  "CyanVis" ,  outerWallLog );
+
+  ocyl.fill(   rOuter - 0.5*dr_OuterWall  , 0., 0. ) ;
+  VolCylinder surfO( outerWallLog , SurfaceType( SurfaceType::Helper ) ,0.5*dr_OuterWall  , 0.5*dr_OuterWall , ocyl ) ;
+  volSurfaceList( tpc )->push_back(  surfO ) ;
+
+  layerCounter = 0;
+  double fracRadLengthOuterWall = 0;
+  rCursor = rOuter - dr_OuterWall ;
+  //unused:  double gear_outer_wall_material_total_density = 0.0;
+ 
+  // db->exec("SELECT * FROM `outerWall`;");
+  // while (db->getTuple()) {
+  xml_comp_t  x_oWall=  x_det.child( _Unicode( outerWall) );
+  for(xml_coll_t c( x_oWall , _Unicode( row) ); c; ++c)  {
+    xml_comp_t  x_row( c );
+    db = XMLHandlerDB( x_row )  ;
+    
+    const double dr = db->fetchDouble("dr") ;
+    Material layerMaterial = theDetector.material(db->fetchString("material"));    
+    Tube  layerSolid( rCursor, rCursor + dr , dz_Wall / 2.0, phi1, phi1+phi2 );
+    Volume layerLog(  _toString( layerCounter ,"TPCOuterWallLayerLog_%02d") , layerSolid, layerMaterial );
+    //    layerLog->SetVisAttributes(VisAttributes::Invisible);
+    pv = outerWallLog.placeVolume( layerLog ) ;
+    ++layerCounter;
+    rCursor += dr ;
+    fracRadLengthOuterWall += dr / layerMaterial->GetMaterial()->GetRadLen();
+    
+    cout << "TPC10: Add Material to Outer Wall: dr =  " << std::setw(4) << dr / mm << " mm. Material = " << layerMaterial->GetName() << " X0 = "
+	 << layerMaterial->GetMaterial()->GetRadLen() << "  " <<  dr / layerMaterial->GetMaterial()->GetRadLen() << "% X0" << endl;
+    
+// #ifdef MOKKA_GEAR
+//     gear_outer_wall_material_total_density += layerMaterial->GetDensity() * (dr / dr_OuterWall);    
+//     std::string material_name = db->fetchString("material");
+//     cout << "TPC10: gear_outer_wall_material_total_density = " << std::setw(4) << gear_outer_wall_material_total_density << endl;   
+//     if( gear_outer_wall_material_thicknesses.find( material_name ) ==  gear_outer_wall_material_thicknesses.end() )
+//       {
+// 	gear_outer_wall_material_thicknesses[ material_name ] = dr;
+//       }
+//     else
+//       {
+//       	gear_outer_wall_material_thicknesses[ material_name ] += dr;
+//       }
+//#endif  
+    
+  }
+  cout << "TPC10: Outer wall material corresponds to " << int( fracRadLengthOuterWall * 1000) / 10.0 << "% of a radiation length." << endl;
+  cout << "TPC10: Outer wall effective X0 = " << std::setw(4) << dr_OuterWall / fracRadLengthOuterWall   << endl;  
+  //-----------------------------------------------------------------------------------------------//  
+
+
+  //-------------------------------- cathode grip ring construction ----------------------------------------//
+  // inner grip ring
+  Tube cathodeInnerGripSolid( rMin_GasVolume , rMin_GasVolume + dr_Cathode_Grip, dz_Cathode_Grip / 2.0 , phi1, phi2);
+  Volume cathodeInnerGripLog( "TPCCathodeInnerGripLog", cathodeInnerGripSolid, material_Cathode_Grip );
+  pv = tpc_motherLog.placeVolume( cathodeInnerGripLog ) ;
+  tpc.setVisAttributes(theDetector,  "GrayVis" ,  cathodeInnerGripLog );
+  
+  // outer grip ring
+  Tube cathodeOuterGripSolid( rMax_GasVolume - dr_Cathode_Grip, rMax_GasVolume, dz_Cathode_Grip / 2.0 , phi1, phi2);
+  Volume cathodeOuterGripLog("TPCCathodeOuterGripLog", cathodeOuterGripSolid, material_Cathode_Grip );
+  pv = tpc_motherLog.placeVolume(cathodeOuterGripLog ) ;
+  tpc.setVisAttributes(theDetector,  "GrayVis" ,  cathodeOuterGripLog );
+
+  //-----------------------------------------------------------------------------------------------//  
+
+  //-------------------------------- cathode construction ----------------------------------------//
+  Tube cathodeSolid(  rMin_Sensitive, rMax_Sensitive, dz_Cathode / 2.0, phi1, phi2);
+  Volume cathodeLog( "TPCCathodeLog", cathodeSolid, materialAir ) ;
+  pv = tpc_motherLog.placeVolume( cathodeLog );
+  tpc.setVisAttributes(theDetector,  "GrayVis" ,  cathodeLog );
+
+  // insulator 
+  Tube cathodeInsulatorSolid( rMin_Sensitive, rMax_Sensitive, (dz_Cathode_Insulator / 2.0)-0.00000001*mm, phi1, phi2);
+  Volume cathodeInsulatorLog( "TPCcathodeInsulatorLog",cathodeInsulatorSolid, material_Cathode_Insulator);
+  
+  // place plus and minus z 
+  pv = cathodeLog.placeVolume( cathodeInsulatorLog , Position( 0.0, 0.0, + dz_Cathode_Insulator / 2.0) );
+  pv = cathodeLog.placeVolume( cathodeInsulatorLog , Position( 0.0, 0.0, - dz_Cathode_Insulator / 2.0) );
+
+  tpc.setVisAttributes(theDetector,  "GrayVis" ,  outerWallLog );
+
+  cout << "Cathode dz = " <<  dz_Cathode_Insulator << endl; 
+  cout << "Place cathode +z at " <<  dz_Cathode_Insulator / 2.0 << endl; 
+  cout << "Place cathode -z at " << -dz_Cathode_Insulator / 2.0 << endl;
+  
+  // conductor 
+  Tube cathodeConductorSolid( rMin_Sensitive, rMax_Sensitive, dz_Cathode_Conductor / 2.0, phi1, phi2);
+  Volume cathodeConductorLog("TPCCathodeConductorLog",cathodeConductorSolid, material_Cathode_Conductor );
+  
+  // place plus and minus z 
+  pv = cathodeLog.placeVolume( cathodeConductorLog , Position( 0.0, 0.0, +(dz_Cathode_Insulator + (dz_Cathode_Conductor / 2.0) ) ) );
+  pv = cathodeLog.placeVolume( cathodeConductorLog , Position( 0.0, 0.0, -(dz_Cathode_Insulator + (dz_Cathode_Conductor / 2.0) ) ) );
+  //-----------------------------------------------------------------------------------------------//
+
+
+  //----------------------------------------------- TPC Sensitive Detector (Pad Rings) ---------------------------------------------------------------//
+  //fg: fixme: put this to SD and corresponding xml
+  //  TPCSD04 *sensitiveDetector = new TPCSD04("TPC", sensitive_threshold_eV);
+  //  RegisterSensitiveDetector(sensitiveDetector);
+  //  UserLimits *userLimits = new UserLimits(TPCMaxStepLength);
+
+  Tube senstiveGasSolid( rMin_Sensitive, rMax_Sensitive, dz_Sensitive / 2.0, phi1, phi2);
+
+  // ThreeVector translation(0,0,0);
+  // RotationMatrix rot;
+  // Transform3D transform(rot,translation);
+
+  Volume sensitiveGasLog( "TPCSensitiveLog", senstiveGasSolid, material_TPC_Gas );
+
+  //  sensitiveGasLog->SetVisAttributes(VisAttributes::Invisible);
+
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY(   0 * deg), ThreeVector(0, 0, +( dz_Cathode/2.0 + dz_Sensitive/2.0 ) )), sensitiveGasLog, "TPCSensitiveLog_+z", motherLog, false, 0);
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY( 180 * deg), ThreeVector(0, 0, -( dz_Cathode/2.0 + dz_Sensitive/2.0 ) )), sensitiveGasLog, "TPCSensitiveLog_-z", motherLog, false, 1);
+
+  DetElement   sensGasDEfwd( tpc ,  "tpc_sensGas_fwd", x_det.id() );
+  DetElement   sensGasDEbwd( tpc ,  "tpc_sensGas_bwd", x_det.id() );
+
+  pv = tpc_motherLog.placeVolume( sensitiveGasLog , Transform3D( RotationY( 0.) , Position(0, 0, +( dz_Cathode/2.0 + dz_Sensitive/2.0 ) ) ) ) ;
+  pv.addPhysVolID("side", +1 ) ; 
+  sensGasDEfwd.setPlacement( pv ) ;
+ 
+  pv = tpc_motherLog.placeVolume( sensitiveGasLog , Transform3D( RotationY( pi ) , Position(0, 0, -( dz_Cathode/2.0 + dz_Sensitive/2.0 ) ) ) ) ;
+  pv.addPhysVolID("side", -1 ) ; 
+  sensGasDEbwd.setPlacement( pv ) ;
+  
+
+  //debug:  tpc.setVisAttributes(theDetector,  "RedVis" ,  sensitiveGasLog) ;
+  tpc.setVisAttributes(theDetector,  "Invisible" ,  sensitiveGasLog) ;
+
+  //---------------------------------------------------- Pad row doublets -------------------------------------------------------------------------------//
+
+  for (int layer = 0; layer < numberPadRows; layer++) {
+    
+#if 1
+    // create twice the number of rings as there are pads, producing an lower and upper part of the pad with the boundry between them the pad-ring centre
+    
+    const double inner_lowerlayer_radius = rMin_Sensitive + (layer * (padHeight));
+    const double outer_lowerlayer_radius = inner_lowerlayer_radius + (padHeight/2.0);
+    
+    const double inner_upperlayer_radius = outer_lowerlayer_radius ;
+    const double outer_upperlayer_radius = inner_upperlayer_radius + (padHeight/2.0);
+    
+    Tube lowerlayerSolid( inner_lowerlayer_radius, outer_lowerlayer_radius, dz_Sensitive / 2.0, phi1, phi2);
+    Tube upperlayerSolid( inner_upperlayer_radius, outer_upperlayer_radius, dz_Sensitive / 2.0, phi1, phi2);
+
+    //fixme: layerstring
+    Volume lowerlayerLog( _toString( layer ,"TPC_lowerlayer_log_%02d") ,lowerlayerSolid, material_TPC_Gas );
+    Volume upperlayerLog( _toString( layer ,"TPC_upperlayer_log_%02d") ,upperlayerSolid, material_TPC_Gas );
+
+    tpc.setVisAttributes(theDetector,  "Invisible" ,  lowerlayerLog) ;
+    tpc.setVisAttributes(theDetector,  "Invisible" ,  upperlayerLog) ;
+    
+
+    DetElement   layerDEfwd( sensGasDEfwd ,   _toString( layer, "tpc_row_fwd_%03d") , x_det.id() );
+    DetElement   layerDEbwd( sensGasDEbwd ,   _toString( layer, "tpc_row_bwd_%03d") , x_det.id() );
+ 
+    Vector3D o(  inner_upperlayer_radius + 1e-10  , 0. , 0. ) ;
+    // create an unbounded surface (i.e. an infinite cylinder) and assign it to the forward gaseous volume only
+    VolCylinder surf( upperlayerLog , SurfaceType(SurfaceType::Sensitive, SurfaceType::Invisible, SurfaceType::Unbounded ) ,  (padHeight/2.0) ,  (padHeight/2.0) ,o ) ;
+
+    volSurfaceList( layerDEfwd )->push_back( surf ) ;
+//    volSurfaceList( layerDEbwd )->push_back( surf ) ;
+
+
+    pv = sensitiveGasLog.placeVolume( lowerlayerLog ) ;
+    pv.addPhysVolID("layer", layer ).addPhysVolID( "module", 0 ).addPhysVolID("sensor", 1 ) ;
+
+    pv = sensitiveGasLog.placeVolume( upperlayerLog ) ;
+    pv.addPhysVolID("layer", layer ).addPhysVolID( "module", 0 ).addPhysVolID("sensor", 0 ) ;
+    layerDEfwd.setPlacement( pv ) ;
+    layerDEbwd.setPlacement( pv ) ;
+
+    lowerlayerLog.setSensitiveDetector(sens);
+    upperlayerLog.setSensitiveDetector(sens);
+
+#else
+    // create just one volume per pad ring
+    
+    const double inner_radius = rMin_Sensitive + (layer * (padHeight) );
+    const double outer_radius = inner_radius +  padHeight ;
+    
+    Tube layerSolid( inner_radius, outer_radius, dz_Sensitive / 2.0, phi1, phi2);
+
+    Volume layerLog( _toString( layer ,"TPC_layer_log_%02d") , layerSolid, material_TPC_Gas );
+
+    tpc.setVisAttributes(theDetector,  "Invisible" ,  layerLog) ;
+    
+    DetElement   layerDEfwd( sensGasDEfwd ,   _toString( layer, "tpc_row_fwd_%03d") , x_det.id() );
+    DetElement   layerDEbwd( sensGasDEbwd ,   _toString( layer, "tpc_row_bwd_%03d") , x_det.id() );
+ 
+    Vector3D o(  inner_radius + (padHeight/2.0)  , 0. , 0. ) ;
+
+    VolCylinder surf( layerLog , SurfaceType(SurfaceType::Sensitive, SurfaceType::Invisible ) ,  (padHeight/2.0) ,  (padHeight/2.0) ,o ) ;
+
+    volSurfaceList( layerDEfwd )->push_back( surf ) ;
+    volSurfaceList( layerDEbwd )->push_back( surf ) ;
+
+    pv = sensitiveGasLog.placeVolume( layerLog ) ;
+    pv.addPhysVolID("layer", layer  ).addPhysVolID( "module", 0 ) ;
+
+    layerDEfwd.setPlacement( pv ) ;
+    layerDEbwd.setPlacement( pv ) ;
+
+    layerLog.setSensitiveDetector(sens);
+
+#endif
+  }
+
+  // Assembly of the TPC Readout
+  Tube readoutSolid( rMin_GasVolume, rMax_GasVolume, dz_Readout / 2.0, phi1, phi2);
+  Volume readoutLog( "TPCReadoutLog", readoutSolid, material_TPC_Gas );
+  tpc.setVisAttributes(theDetector,  "CyanVis" ,  readoutLog );
+
+
+  pv = tpc_motherLog.placeVolume( readoutLog , Transform3D( RotationY( 0.) , Position(0, 0, +( (dz_GasVolume - (dz_Readout/2.0) ) ))) ) ;
+  pv = tpc_motherLog.placeVolume( readoutLog , Transform3D( RotationY( pi ) , Position(0, 0, -( (dz_GasVolume - (dz_Readout/2.0) ) ))) ) ;
+ 
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY(  0 * deg), ThreeVector( 0, 0, +(dz_GasVolume - (dz_Readout / 2.0) ))), readoutLog, "TPCReadout_+z", motherLog, false, 0);
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY(180 * deg), ThreeVector( 0, 0, -(dz_GasVolume - (dz_Readout / 2.0) ))), readoutLog, "TPCReadout_-z", motherLog, false, 1);
+
+  int pieceCounter = 0;
+  double fracRadLengthReadout = 0;
+  double zCursor = -dz_Readout / 2;
+  
+  xml_comp_t  x_ro=  x_det.child( _Unicode( readout ) );
+  for(xml_coll_t c( x_ro , _Unicode( row) ); c; ++c)  {
+    
+    xml_comp_t  x_row( c );
+    db = XMLHandlerDB( x_row )  ;
+
+    const double dzPiece = db->fetchDouble("dz") ;
+    Material pieceMaterial = theDetector.material( db->fetchString("material") );
+    
+    Tube pieceSolid(  rMin_GasVolume, rMax_GasVolume, dzPiece / 2, phi1, phi2);
+    //fixme namestring
+    Volume pieceLog (  _toString( pieceCounter ,"TPCReadoutPieceLog_%02d"), pieceSolid, pieceMaterial ) ;
+
+    //    pieceLog->SetVisAttributes(VisAttributes::Invisible);
+    pv = readoutLog.placeVolume( pieceLog  , Position(0, 0,  zCursor + dzPiece/2. ) ) ;
+    
+    ++pieceCounter;
+    fracRadLengthReadout += dzPiece / pieceMaterial->GetMaterial()->GetRadLen();
+    zCursor += dzPiece;
+
+    if (zCursor > +dz_Readout / 2) {
+      throw GeometryException(  "TPC10: Overfull TPC readout - check your xml file - section <readout>."   ) ;
+    }
+  }
+
+  // Some verbose output
+  cout << "TPC10: Readout material corresponds to " << int(fracRadLengthReadout * 1000) / 10.0 << "% of a radiation length." << endl;
+
+  
+  Tube endplateSolid( rInner, rOuter, dz_Endplate / 2.0, phi1, phi2);
+  Volume endplateLog( "TPCEndplateLog",endplateSolid, endplate_MaterialMix );
+  tpc.setVisAttributes(theDetector,  "CyanVis" ,  endplateLog );
+ 
+  // add a plane to the endcap volume 
+  // note: u and v are exchanged: normal is along z ...      
+  DetElement   endcapDEfwd( tpc ,  "tpc_endcap_fwd", x_det.id() );
+  DetElement   endcapDEbwd( tpc ,  "tpc_endcap_bwd", x_det.id() );
+
+  // vectors for endplate plane
+  Vector3D u( 0. , 1. , 0. ) ;
+  Vector3D v( 1. , 0. , 0. ) ;
+  Vector3D n( 0. , 0. , 1. ) ;
+
+  // need to set the origin of this helper plane to be inside the material ( otherwise it would pick up the vacuum at the origin)
+  double mid_r = 0.5 * ( rOuter + rInner ) ;
+  Vector3D o( 0. , mid_r , 0. ) ;
+  
+  VolPlane surf( endplateLog , SurfaceType( SurfaceType::Helper ) ,  dz_Endplate / 2.0 + dz_Readout / 2 ,  dz_Endplate / 2.0 , u , v, n , o ) ;
+  volSurfaceList( endcapDEfwd )->push_back( surf ) ;
+  volSurfaceList( endcapDEbwd )->push_back( surf ) ;
+
+  // note: as opposed to the readout, the endpate is not placed inside the gas volume
+  pv = tpc_motherLog.placeVolume( endplateLog , Transform3D( RotationY( 0. ) , Position(0, 0, +(dz_GasVolume + (dz_Endplate / 2.0))) ) );
+  endcapDEfwd.setPlacement( pv ) ;
+  pv = tpc_motherLog.placeVolume( endplateLog , Transform3D( RotationY( pi ) , Position(0, 0, -(dz_GasVolume + (dz_Endplate / 2.0))) ) );
+  endcapDEbwd.setPlacement( pv ) ;
+  
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY(  0 * deg), ThreeVector( 0, 0, +(dz_GasVolume + (dz_Endplate / 2.0) ))), endplateLog, "TPCEndplate_+z", motherLog, false, 0);
+  // new PVPlacement(Transform3D(RotationMatrix().rotateY(180 * deg), ThreeVector( 0, 0, -(dz_GasVolume + (dz_Endplate / 2.0) ))), endplateLog, "TPCEndplate_-z", motherLog, false, 1);
+
+  cout << "TPC10: Total Endplate material corresponds to " << (fracRadLengthReadout * 100.0) + (dz_Endplate / (endplate_MaterialMix->GetMaterial()->GetRadLen() / mm) * 100.0 ) << "% of a radiation length." << endl;
+  
+
+// #ifdef MOKKA_GEAR
+//   // save the parameters needed to write the gear file ...
+//   _gear_r_min = rInner;
+//   _gear_r_max = rOuter;
+//   _gear_inner_wall_thickness = dr_InnerWall;
+//   _gear_outer_wall_thickness = dr_OuterWall;
+//   _gear_r_min_readout = rMin_Sensitive;
+//   _gear_r_max_readout = rMin_Sensitive + numberPadRows*padHeight;
+//   _gear_n_rows_readout = numberPadRows;
+//   _gear_pad_height = padHeight;
+//   _gear_pad_width = padWidth;
+//   _gear_max_drift_length = dz_Sensitive + dz_Cathode/2.0; // SJA: cathode has to be added as the sensitive region does not start at 0.00    
+//   _gear_z_anode = dzTotal - dz_Endplate; // the edge of the readout terminating the drift volume
+// #endif
+  
+
+  FixedPadSizeTPCData* tpcData = new FixedPadSizeTPCData ;
+
+  tpcData->zHalf = dzTotal/2.0 ; 
+  tpcData->rMin = rInner;
+  tpcData->rMax = rOuter;
+  tpcData->innerWallThickness = dr_InnerWall;
+  tpcData->outerWallThickness = dr_OuterWall;
+  tpcData->rMinReadout = rMin_Sensitive;
+  tpcData->rMaxReadout = rMin_Sensitive + numberPadRows*padHeight;
+  tpcData->maxRow = numberPadRows;
+  tpcData->padHeight = padHeight;
+  tpcData->padWidth = padWidth;
+  tpcData->driftLength = dz_Sensitive + dz_Cathode/2.0; // SJA: cathode has to be added as the sensitive region does not start at 0.00    
+  tpcData->zMinReadout = dz_Cathode/2.0; 
+  //  tpcData.z_anode = dzTotal - dz_Endplate; // the edge of the readout terminating the drift volume
+  
+  tpc.addExtension< FixedPadSizeTPCData >( tpcData )   ; 
+
+  //######################################################################################################################################################################
+  
+  
+  //--------------------------------------
+  
+  // Volume mother =  theDetector.pickMotherVolume( tpc ) ;
+  // pv = mother.placeVolume(envelope);
+  // pv.addPhysVolID( "system", x_det.id() ) ; //.addPhysVolID("side", 0 ) ;
+  
+  tpc.setVisAttributes( theDetector, x_det.visStr(), envelope );
+  //  if( tpc.isValid() ) 
+  // tpc.setPlacement(pv);
+  
+  return tpc;
+}
+DECLARE_DETELEMENT(TPC10,create_element)
diff --git a/Detector/DetCEPCv4/src/tracker/VXD04_geo.cpp b/Detector/DetCEPCv4/src/tracker/VXD04_geo.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9b13b09a490026901fabc8d868c3109f849afb4d
--- /dev/null
+++ b/Detector/DetCEPCv4/src/tracker/VXD04_geo.cpp
@@ -0,0 +1,1584 @@
+//====================================================================
+//  lcgeo - LC detector models in DD4hep 
+//--------------------------------------------------------------------
+//  F.Gaede, DESY
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetType.h"
+
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "XML/Utilities.h"
+#include "XMLHandlerDB.h"
+
+//#include "DDRec/DDGear.h"
+//#define MOKKA_GEAR
+
+#include <cmath>
+
+using namespace std;
+
+using dd4hep::Assembly;
+using dd4hep::BUILD_ENVELOPE;
+using dd4hep::Box;
+using dd4hep::ConeSegment;
+using dd4hep::DetElement;
+using dd4hep::Detector;
+using dd4hep::Material;
+using dd4hep::PlacedVolume;
+using dd4hep::Position;
+using dd4hep::Ref_t;
+using dd4hep::RotationZYX;
+using dd4hep::SensitiveDetector;
+using dd4hep::Torus;
+using dd4hep::Transform3D;
+using dd4hep::Tube;
+using dd4hep::Volume;
+using dd4hep::_toString;
+using dd4hep::rec::SurfaceType;
+using dd4hep::rec::Vector3D;
+using dd4hep::rec::VolCone;
+using dd4hep::rec::VolPlane;
+using dd4hep::rec::VolCylinder;
+using dd4hep::rec::ZPlanarData;
+using dd4hep::rec::volSurfaceList;
+
+/** Construction of VTX detector, ported from Mokka driver VXD04.cc
+ *
+ *  Mokka History:
+ * - first implementation -- Damien Grandjean, April 2003
+ * - fixed geometry overlap -- Adrian Vogel, 2005-12-12
+ * - added optional GEAR output -- R. Lippe, DESY, 2006-09-04
+ * -modification for double layer geometry -- Damien Grandjean, February 2008
+ * -increased realism in the description of the ladders, the Be support and the cabling, added cooling tubes Y. Voutsinas, September 2011
+ *
+ *  @author: F.Gaede, DESY, Nov 2013
+ *
+ */
+static Ref_t create_element(Detector& theDetector, xml_h e, SensitiveDetector sens)  {
+  
+  xml_det_t    x_det = e;
+  string       name  = x_det.nameStr();
+  
+  DetElement   vxd(  name, x_det.id()  ) ;
+  
+  // --- create an envelope volume and position it into the world ---------------------
+  
+  Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector,  e , vxd ) ;
+  
+  dd4hep::xml::setDetectorTypeFlag( e, vxd ) ;
+
+  if( theDetector.buildType() == BUILD_ENVELOPE ) return vxd ;
+
+  //-----------------------------------------------------------------------------------
+
+  sens.setType("tracker");
+
+  // --- create assembly and DetElement for support and service volumes 
+
+  Assembly supp_assembly( name + "_support_assembly"  ) ;
+
+  PlacedVolume pv_env = envelope.placeVolume( supp_assembly ) ;
+
+  DetElement suppDE( vxd , name+"_support" , x_det.id() )  ;
+  suppDE.setPlacement( pv_env ) ;
+  //--------------------------------
+
+
+  //######################################################################################################################################################################
+  //  code ported from VXD04::construct() :
+  //##################################
+  //------------------------------------------
+  //  See comments starting with '//**' for
+  //     hints on porting issues
+  //------------------------------------------
+  
+  // double sPhi = 0 * deg;
+  // double dPhi = 360 * deg;
+  //** DD4hep/TGeo seems to need rad (as opposed to the manual)
+  double sPhi = 0 ;
+  double dPhi = 2*M_PI;
+  
+  
+  //****************************************
+  // Layers
+  //****************************************
+  //
+  // Common layer thickness parameters
+  // db->exec("select * from layers_common_parameters;");
+  XMLHandlerDB db(  x_det.child( _Unicode( layers_common_parameters ) ) );
+			  
+  double foam_spacer_thickness = db->fetchDouble("foam_spacer_thickness");
+  double flex_cable_thickness = db->fetchDouble("flex_cable_thickness");
+  double metal_traces_thickness = db->fetchDouble("metal_traces_thickness");
+  double electronics_structure_thickness = db->fetchDouble("electronics_structure_thickness");
+  double active_silicon_thickness =   db->fetchDouble("active_silicon_thickness");
+  //unused:  double support_structure_radial_thickness =    db->fetchDouble("support_structure_radial_thickness");
+  double end_electronics_half_z=    db->fetchDouble("end_electronics_half_z");
+  //unused: double strip_final_beampipe_radious =    db->fetchDouble("strip_final_beampipe_radious");
+  int    side_band_electronics_option=    db->fetchInt("side_band_electronics_option");
+  std::string  flex_cable_material=    db->fetchString("flex_cable_material");
+  std::string  metal_traces_material=    db->fetchString("metal_traces_material");
+  std::string  foam_spacer_material=    db->fetchString("foam_spacer_material");
+  std::string  cool_pipe_material=    db->fetchString("cool_pipe_material");
+  int  end_ladd_electronics_option=    db->fetchInt("end_ladd_electronics_option"); 
+  double  side_band_electronics_width=    db->fetchDouble("side_band_electronics_width");
+  double  side_band_electronics_thickness=    db->fetchDouble("side_band_electronics_thickness");
+  int  active_side_band_electronics_option=  db->fetchInt("active_side_band_electronics_option");
+  double  layer_gap= db->fetchDouble("layer_gap");
+  double  cool_pipe_outer_radius = db->fetchDouble("cool_pipe_outer_radius");
+  double  cool_pipe_inner_radius =    db->fetchDouble("cool_pipe_inner_radius");
+  double  external_kapton_thickness = db->fetchDouble("external_kapton_thickness");
+  double  external_metal_thickness =  db->fetchDouble("external_metal_thickness");
+
+  //Cryostat parameters
+  // db->exec("SELECT * FROM cryostat;");
+  db = XMLHandlerDB(  x_det.child( _Unicode( cryostat ) ) ) ;
+
+  double rAlu   = db->fetchDouble("alu_skin_inner_radious") ;
+  double drAlu  = db->fetchDouble("alu_skin_tickness") ;
+  const double rSty   = db->fetchDouble("foam_inner_radious") ;
+  const double drSty  = db->fetchDouble("foam_tickness") ;
+  const double dzSty  = db->fetchDouble("foam_half_z") ;
+  const double cryostat_apperture  = db->fetchDouble("cryostat_apperture") ;
+  const double cryostat_apperture_radius  = db->fetchDouble("cryostat_apperture_radius") ;
+  double rInner = db->fetchDouble("endplate_inner_radious") ;
+  // double rAlu   = db->fetchDouble("alu_skin_inner_radious") * mm;
+  // double drAlu  = db->fetchDouble("alu_skin_tickness") * mm;
+  // const double rSty   = db->fetchDouble("foam_inner_radious") * mm;
+  // const double drSty  = db->fetchDouble("foam_tickness") * mm;
+  // const double dzSty  = db->fetchDouble("foam_half_z") * mm;
+  // const double cryostat_apperture  = db->fetchDouble("cryostat_apperture") * mm;
+  // const double cryostat_apperture_radius  = db->fetchDouble("cryostat_apperture_radius") * mm;
+  // double rInner = db->fetchDouble("endplate_inner_radious") * mm;
+
+  bool useCryo  = bool(db->fetchInt("cryostat_option"));
+
+  // support shell parameters
+  // db->exec("select * from support_shell;");
+  db = XMLHandlerDB(  x_det.child( _Unicode( support_shell ) ) ) ;
+  
+  double shell_inner_radious = db->fetchDouble("inner_radious");
+  double shell_half_z = db->fetchDouble("half_z");
+  double shell_thickess = db->fetchDouble("thickess");
+  double support_endplate_inner_radious = db->fetchDouble("endplate_inner_radious");
+  double support_endplate_inner_radious_L1 = db->fetchDouble("endplate_inner_radius_L1");
+  double support_endplate_outer_radious_L1 = db->fetchDouble("endplate_outer_radius_L1");
+  //unused:  double offset_ladder_block = db->fetchDouble("offset_ladder_block");
+  double beryllium_ladder_block_length = db->fetchDouble("beryllium_ladder_block_length");
+  double beryllium_ladder_block_thickness = db->fetchDouble("beryllium_ladder_block_thickness");
+  double beryllium_ladder_block_length2=0.;
+  double shell_endplate_thickness = db->fetchDouble("shell_endplate_thickness");
+  double forward_shell_half_z = db->fetchDouble("forward_shell_half_z");
+  
+
+  // ### fixme: SD ##############
+  //   // The VXD Sensitive detector
+  //   // Threshold is 20% of a MIP. For Si we have
+  //   // 340 KeV/mm as MIP.
+  //   theVXDSD =
+  //     new TRKSiSD00("VXD",
+  // 		  active_silicon_thickness * mm
+  // 		  * 340 * keV
+  // 		  * 0.2);
+  //   RegisterSensitiveDetector(theVXDSD);
+  
+
+  //**fg: the encoder is no longer needed - replaced by physVolID() calls
+  //   // setup the encoder 
+  //   UTIL::BitField64 encoder( LCTrackerCellID::encoding_string() ) ; 
+  //   encoder.reset() ;  // reset to 0
+  //   encoder[LCTrackerCellID::subdet()] = ILDDetID::VXD ;
+  //   encoder[LCTrackerCellID::side()] = 0 ;
+  //   encoder[LCTrackerCellID::layer()]  = 0 ;
+  //   encoder[LCTrackerCellID::module()] = 0 ;
+  //   encoder[LCTrackerCellID::sensor()] = 0 ;
+  //   int cellID0 = encoder.lowWord() ;
+
+  Material activeMaterial =  theDetector.material("G4_Si"); //silicon_2.33gccm"); 
+  
+
+  ZPlanarData*  zPlanarData = new ZPlanarData ;
+
+// #ifdef MOKKA_GEAR
+//   // some variables for storing information for MOKKA_GEAR
+//   // during the loop
+//   std::vector<helpLayer> gearHelpLadders ;
+//   std::vector<helpLayer> gearHelpSensitives ;
+//   std::vector<int> gearHelpNumberLadders ;
+//   std::vector<double> gearHelpPhi0 ;
+//   double gearHelpGap = 0. ;
+//   int gearHelpCount = 0 ;
+//   int gearHelpType = 0 ;
+// #endif
+  
+
+  // db->exec("select * from layer;");
+  //   do{
+  //**fg: get parameters for first layer - needed below
+  double ladder_0_length = 0 ;
+
+  for(xml_coll_t c( x_det ,_U(layer)); c; ++c)  {
+    
+    xml_comp_t  x_layer( c );
+    db = XMLHandlerDB( x_layer )  ;
+
+    int LayerId = db->fetchInt("id");
+    double layer_radius = db->fetchDouble("layer_radius");
+    double ladder_length  = db->fetchDouble("ladder_length");
+    if( LayerId == 0 ) {
+      ladder_0_length = ladder_length ; 
+    }
+    double ladder_width = db->fetchDouble("ladder_width");
+    double support_width = db->fetchDouble("support_width");
+    double ladder_gap = db->fetchDouble("ladder_gap");
+    //unused:    double strip_line_final_z = db->fetchDouble("strip_line_final_z");
+    double initial_kapton_striplines_thickness = db->fetchDouble("initial_kapton_striplines_thickness");
+    double final_kapton_striplines_thickness = db->fetchDouble("final_kapton_striplines_thickness");
+    double initial_metal_striplines_thickness = db->fetchDouble("initial_metal_striplines_thickness");
+    double final_metal_striplines_thickness = db->fetchDouble("final_metal_striplines_thickness");
+
+#ifdef LCIO_MODE
+    ladder_gapVec.push_back(ladder_gap);
+    StripLineFinalZ_Vec.push_back(strip_line_final_z);
+#endif
+    double nb_ladder = db->fetchDouble("nb_ladder");
+    
+    double phirot = 0.;
+    
+    std::cout << " ############## layer : " << LayerId << " number of ladders : " << nb_ladder << std::endl ; 
+
+
+    Assembly layer_assembly( _toString( LayerId , "layer_assembly_%d"  ) ) ;
+    envelope.placeVolume( layer_assembly ) ;
+
+
+    //replacing support ladder with flex cable (kapton+metal) & adding a foam spacer
+    // ****************************************************************************************
+    // **********************   flex  cable *****************************************
+    // ****************************************************************************************
+    
+    Material flexCableMaterial =  theDetector.material( flex_cable_material ); 
+    
+    Box FlexCableSolid( ladder_width+(side_band_electronics_option*side_band_electronics_width/2.),
+			ladder_length+(end_ladd_electronics_option*(2*end_electronics_half_z)) + beryllium_ladder_block_length*2.,
+			flex_cable_thickness/2.);
+
+    //** ----- Original Mokke/Geant4 code: -----
+    // Box *FlexCableSolid
+    //  = new Box("FlexCable",
+    // 		ladder_width+(side_band_electronics_option*side_band_electronics_width/2.),
+    // 		ladder_length+(end_ladd_electronics_option*(2*end_electronics_half_z)) + beryllium_ladder_block_length*2.,
+    // 		flex_cable_thickness/2.);
+    
+    //    VisAttributes* flex_cableVisAtt = new VisAttributes(Colour(1.,0.,0.,1.0));   //red
+    
+    //**fg: we need distinct names for every instance of a Volume - so we append _(layer#) to the volume name
+    Volume FlexCableLogical( _toString(LayerId,"FlexCable_%02d"), FlexCableSolid, flexCableMaterial ) ;
+    
+    // ----- Original Mokke/Geant4 code: -----
+    // LogicalVolume *FlexCableLogical=
+    //   new LogicalVolume(FlexCableSolid,
+    //  			flexCableMaterial,
+    //  			"FlexCable",
+    //  			0,
+    //  			0,
+    //  			0);
+    
+    vxd.setVisAttributes(theDetector,  "RedVis" , FlexCableLogical);
+    //** ----- Original Mokke/Geant4 code: -----
+    //    FlexCableLogical->SetVisAttributes(flex_cableVisAtt);
+    
+    // ****************************************************************************************
+    // **********************   metal traces  *****************************************
+    // ****************************************************************************************
+    
+    Material metalTracesMaterial = theDetector.material( metal_traces_material); 
+    
+    Box MetalTracesSolid( ladder_width+(side_band_electronics_option*side_band_electronics_width/2.),
+			  ladder_length+(end_ladd_electronics_option*(2*end_electronics_half_z)) + beryllium_ladder_block_length*2.,
+			  metal_traces_thickness/2.);
+    
+    Volume MetalTracesLogical( _toString(LayerId,"MetalTraces_%02d") , MetalTracesSolid,metalTracesMaterial ) ;
+    
+    vxd.setVisAttributes(theDetector,  "GrayVis" , MetalTracesLogical) ;
+    
+    // ****************************************************************************************
+    // **********************   foam spacer n support  *****************************************
+    // ****************************************************************************************
+    
+    Material foamSpacerMaterial = theDetector.material( foam_spacer_material);
+    
+    Box FoamSpacerSolid( support_width+(side_band_electronics_option*side_band_electronics_width/2.),
+			 ladder_length+(end_ladd_electronics_option*(2*end_electronics_half_z)) + beryllium_ladder_block_length*2. ,
+			 foam_spacer_thickness/2.);
+    
+    Volume FoamSpacerLogical( _toString(LayerId,"FoamSpacer_%02d"), FoamSpacerSolid, foamSpacerMaterial) ;
+      
+    vxd.setVisAttributes(theDetector, "YellowVis", FoamSpacerLogical ) ;
+
+    //here we place the physical volumes of both the flex cable (kapton & metal traces) and the foam spacer
+    
+    phirot = (2*M_PI)/nb_ladder;
+    
+    double ladder_clothest_approch = beryllium_ladder_block_thickness*2 +0.1;
+
+    // calculate optimal offset, such that there is 0.1mm space between to the edge and the surface of two adjacent ladders.
+    // in the case of ladders overlapped per superlayer
+    /*    
+      double offset_phi=(1-cos(phirot))/sin(phirot)*layer_radius  
+      -((ladder_width+(side_band_electronics_option*side_band_electronics_width/2.))
+      +(ladder_clothest_approch+cos(phirot)*2*(foam_spacer_thickness+active_silicon_thickness+flex_cable_thickness+metal_traces_thickness))/sin(phirot));
+    */
+    // in the case of ladders overlapped per layer
+      
+    double offset_phi=(1-cos(phirot))/sin(phirot)*layer_radius  
+      -((ladder_width+(side_band_electronics_option*side_band_electronics_width/2.))
+	+(ladder_clothest_approch+cos(phirot)*2*(active_silicon_thickness+flex_cable_thickness+metal_traces_thickness-foam_spacer_thickness/2.0))/sin(phirot));
+      
+    if (LayerId==0||LayerId==2||LayerId==4)  {  //------------------------------------------------------------------------
+       
+      for (double ladder_loop=0;ladder_loop<nb_ladder;ladder_loop++) {
+	
+	double phirot2 = ladder_loop*phirot;
+
+	// RotationMatrix *rot = new RotationMatrix();
+	// rot->rotateX(M_PI*0.5);
+	// rot->rotateY(phirot2);
+	RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;
+	
+	supp_assembly.placeVolume( FlexCableLogical,
+				   Transform3D( rot, Position(( layer_radius + metal_traces_thickness + (flex_cable_thickness/2.))*sin(phirot2)+offset_phi*cos(phirot2),
+							      -(layer_radius + metal_traces_thickness + (flex_cable_thickness/2.))*cos(phirot2)+offset_phi*sin(phirot2),
+							      0.))  );
+	// Phys=
+	//   new PVPlacement(rot,
+	// 			ThreeVector((layer_radius + metal_traces_thickness + (flex_cable_thickness/2.))*sin(phirot2)+offset_phi*cos(phirot2),
+	// 				      -(layer_radius + metal_traces_thickness + (flex_cable_thickness/2.))*cos(phirot2)+offset_phi*sin(phirot2),
+	// 				      0.),
+	// 			FlexCableLogical,
+	// 			"FlexCable",
+	// 			worldLog,
+	// 			false,
+	// 			0);
+	       
+	supp_assembly.placeVolume( FoamSpacerLogical,
+				   Transform3D(  rot, Position((layer_radius + flex_cable_thickness + metal_traces_thickness + foam_spacer_thickness/2.)*sin(phirot2)+offset_phi*cos(phirot2),
+							       -(layer_radius + flex_cable_thickness + metal_traces_thickness +  foam_spacer_thickness/2.)*cos(phirot2)+offset_phi*sin(phirot2),
+							       0.))  );
+
+	supp_assembly.placeVolume( MetalTracesLogical,  Transform3D( rot,Position((layer_radius + (metal_traces_thickness/2))*sin(phirot2)+offset_phi*cos(phirot2),
+										  -(layer_radius + (metal_traces_thickness/2.))*cos(phirot2)+offset_phi*sin(phirot2),
+ 										  0.))  );
+      }
+      
+    } else if (LayerId==1||LayerId==3||LayerId==5) { //------------------------------------------------------------------------
+      
+      for (double ladder_loop=0;ladder_loop<nb_ladder;ladder_loop++) {
+	
+	double phirot2 = ladder_loop*phirot;
+	
+	RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;
+	
+	supp_assembly.placeVolume( FlexCableLogical,
+				   Transform3D( rot, Position((layer_radius-(metal_traces_thickness + flex_cable_thickness/2.)+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+							      -(layer_radius-(metal_traces_thickness + flex_cable_thickness/2.)+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+							      0.))  ) ;
+
+	supp_assembly.placeVolume( FoamSpacerLogical,
+				   Transform3D( rot, Position((layer_radius + layer_gap - flex_cable_thickness -  metal_traces_thickness - foam_spacer_thickness/2.)*sin(phirot2)+offset_phi*cos(phirot2),
+							      -(layer_radius + layer_gap - flex_cable_thickness - metal_traces_thickness - foam_spacer_thickness/2.)*cos(phirot2)+offset_phi*sin(phirot2),
+							      0.))  );
+	
+	supp_assembly.placeVolume( MetalTracesLogical,  Transform3D( rot,Position((layer_radius-(metal_traces_thickness/2)+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+										  -(layer_radius-(metal_traces_thickness/2.)+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+										  0.))  );
+      }
+    }
+
+// #ifdef MOKKA_GEAR
+    
+//     //Definition of the VXDSupport composite material. It is going to be used only during the reconstruction stage, for tracking purposes. It consists by three layers: metal traces, flex cable and the foam spacer support with user defined materials and thicknesses. Here we define the element and calculate its effective radiation length, atomic number and atomic mass. For the simulation, the more realistic 3 different layers structure is being used.   
+
+//     double MetalDensity = metalTracesMaterial->GetMaterial()->GetDensity()/(g/mm3);
+//     double KaptonDensity = flexCableMaterial->GetMaterial()->GetDensity()/(g/mm3);
+//     double FoamDensity = foamSpacerMaterial->GetMaterial()->GetDensity()/(g/mm3);
+
+//     double VXDSupportThickness = metal_traces_thickness + flex_cable_thickness + foam_spacer_thickness;
+
+//     //calculations of thickness fractions of each layer of the support
+//     double metalTF = metal_traces_thickness / VXDSupportThickness;
+//     double foamTF = foam_spacer_thickness / VXDSupportThickness;
+//     double flexTF = flex_cable_thickness / VXDSupportThickness;
+
+//     double elemVol = 1/(mm2);
+
+//     double VXDSupportMass = foam_spacer_thickness*(elemVol)*FoamDensity + flex_cable_thickness*(elemVol)*KaptonDensity + metal_traces_thickness*(elemVol)*MetalDensity;
+
+//     double VXDSupportDensity = VXDSupportMass/1/(mm3) ;
+
+//     double foamFM = 100. * ((foam_spacer_thickness*(elemVol)*FoamDensity) / VXDSupportMass) ;
+//     double kaptonFM = 100. * ((flex_cable_thickness*(elemVol)*KaptonDensity) / VXDSupportMass) ;
+//     double metalFM = 100. * ((metal_traces_thickness*(elemVol)*MetalDensity) / VXDSupportMass) ;
+
+//     //Calculation of an effective radiation length for the support based on the mass fraction of each material
+
+//     double VXDSupportRadLen = 1. / ((metalTF/metalTracesMaterial->GetMaterial()->GetRadLen()) + (flexTF/flexCableMaterial->GetMaterial()->GetRadLen()) + (foamTF/foamSpacerMaterial->GetMaterial()->GetRadLen()));
+
+//     //Calculation of the effective atomic number of the VXD support. The Z effectives are obtained from the formula: Zeff = Sum(Wi*Zi) where Wi are the mass fractions of the elements that consist the material 
+
+//     Material *carbon = CGAGeometryManager::GetMaterial("carbon");
+//     Material *silicon = CGAGeometryManager::GetMaterial("silicon");
+//     Material *hydrogen = CGAGeometryManager::GetMaterial("H2");
+//     Material *nitro = CGAGeometryManager::GetMaterial("N2");
+//     Material *oxygen = CGAGeometryManager::GetMaterial("oxygen");
+
+//     double C_Z = carbon->GetZ();
+//     double Si_Z = silicon->GetZ();
+//     double C_A = carbon->GetA()/g;
+//     double Si_A = silicon->GetA()/g;
+//     double H_Z = hydrogen->GetZ();
+//     double H_A = hydrogen->GetA()/g;
+//     double N_Z = nitro->GetZ();
+//     double N_A = nitro->GetA()/g;
+//     double O_Z = oxygen->GetZ();
+//     double O_A = oxygen->GetA()/g;
+
+
+//     double foamZeff = C_Z*(C_A/(C_A+Si_A)) + Si_Z*(Si_A/(C_A+Si_A));
+
+
+//     double metalZ = metalTracesMaterial->GetZ();
+//     double metalA = metalTracesMaterial->GetA()/g;
+      
+//     //Calculation of kapton effective Z - weight fractions for each element taken from NIST dB
+
+//     double flexZeff = H_Z*0.026362 + C_Z*0.691133 + N_Z*0.073270 + O_Z*0.209235;
+
+//     double VXDSupportZeff = (metalFM/100.)*metalZ + (kaptonFM/100.)*flexZeff + (foamFM/100.)*foamZeff;
+
+
+//     //Calculation of the effective atomic mass of the VXD support. The Z effectives are obtained from the formula: Aeff = Zeff / (Z/A)eff where (Z/A)eff = Sum Wi*Zi/Ai
+
+//     double metalZA = metalZ/metalA;
+//     double foamZAeff = (C_A/(C_A+Si_A))*(C_Z/C_A) + (Si_A/(C_A+Si_A))*(Si_Z/Si_A);
+//     double flexZAeff = (H_Z/H_A)*0.026362 + (C_Z/C_A)*0.691133 + (N_Z/N_A)*0.073270 + (O_Z/O_A)*0.209235;
+
+//     double VXDSupportZAeff = (metalFM/100.)*metalZA + (kaptonFM/100.)*flexZAeff + (foamFM/100.)*foamZAeff;
+
+//     double VXDSupportAeff = VXDSupportZeff / VXDSupportZAeff;
+
+//     //Calculation of the effective nuclear interaction length of the VXD support
+
+//     double VXDSupportIntLength = 1. / ((metalTF/metalTracesMaterial->GetNuclearInterLength()) + (flexTF/flexCableMaterial->GetNuclearInterLength()) + (foamTF/foamSpacerMaterial->GetNuclearInterLength()));
+
+//     //Here we call the SimpleMaterial class of gear. The density should be converted to kg/m3
+//     VXDSupportDensity = 1000000*VXDSupportDensity;
+
+//     VXDSupportMaterial = new gear::SimpleMaterialImpl("VXDSupportMaterial", VXDSupportAeff, VXDSupportZeff, VXDSupportDensity, VXDSupportRadLen, VXDSupportIntLength );
+
+//     //_________________________________________________________________________________________________________
+//     //
+
+//     helpLayer thisLadder ;
+//     if (LayerId==2||LayerId==4||LayerId==6) 
+//       { 
+// 	thisLadder.distance  = layer_radius + layer_gap * 0.5 ;
+//       }
+//     if (LayerId==1||LayerId==3||LayerId==5) 
+//       { 
+// 	thisLadder.distance  = layer_radius  ;
+//       }      
+//     //      thisLadder.distance  = layer_radius ;
+//     thisLadder.offset    = offset_phi ;
+//     thisLadder.thickness = VXDSupportThickness ;
+//     thisLadder.length    = ladder_length ;
+//     thisLadder.width     = (ladder_width*2.)+(side_band_electronics_option*side_band_electronics_width) ;
+//     thisLadder.radLength = VXDSupportMaterial->GetMaterial()->getRadLength()/mm ;
+
+ 
+//     // find out type
+//     if( side_band_electronics_option == 0 &&  end_ladd_electronics_option == 1) gearHelpType = gear::ZPlanarParametersImpl::CCD  ;
+//     if( side_band_electronics_option == 1 &&  end_ladd_electronics_option == 0 ) gearHelpType = gear::ZPlanarParametersImpl::CMOS ;
+//     if( side_band_electronics_option == 1 &&  end_ladd_electronics_option == 1) gearHelpType = gear::ZPlanarParametersImpl::HYBRID ;
+
+// #endif
+
+    ZPlanarData::LayerLayout thisLayer ;
+    
+    if (LayerId==1||LayerId==3||LayerId==5) { 
+      
+      thisLayer.distanceSupport  = layer_radius + layer_gap * 0.5 ;
+      
+    }else if (LayerId==0||LayerId==2||LayerId==4) {
+      
+      thisLayer.distanceSupport  = layer_radius  ;
+    }      
+    
+    thisLayer.offsetSupport    = offset_phi ;
+    thisLayer.thicknessSupport = metal_traces_thickness + flex_cable_thickness + foam_spacer_thickness ;
+    thisLayer.zHalfSupport    = ladder_length ;
+    thisLayer.widthSupport     = (ladder_width*2.)+(side_band_electronics_option*side_band_electronics_width) ;
+    //     thisLayer.radLength = VXDSupportMaterial->GetMaterial()->getRadLength()/mm ;
+    
+    
+
+
+    // ****************************************************************************************
+    // **********************   Berylium annulus block *****************************************
+    // ****************************************************************************************
+    
+    //only one block per superlayer
+
+    if (LayerId==1) {
+      
+      Box BerylliumAnnulusBlockSolid( ladder_width, beryllium_ladder_block_length, beryllium_ladder_block_thickness);
+      
+      Volume BerylliumAnnulusBlockLogical( _toString(LayerId,"BerylliumAnnulusBlock_%02d"), BerylliumAnnulusBlockSolid, theDetector.material("G4_Be")) ; //"beryllium") ) ;
+      
+      vxd.setVisAttributes(theDetector,  "CyanVis" , BerylliumAnnulusBlockLogical) ;
+
+
+      //====== create the meassurement surface for Be annulus block ===================
+      Vector3D u( 1. , 0. , 0. ) ;
+      Vector3D v( 0. , 1. , 0. ) ;
+      Vector3D n( 0. , 0. , 1. ) ;
+      
+      VolPlane surfAnnBlock( BerylliumAnnulusBlockLogical , SurfaceType(SurfaceType::Helper) , beryllium_ladder_block_thickness/2. ,  beryllium_ladder_block_thickness/2. , u,v,n ) ; //,o ) ;
+      //============================================================
+
+      
+      for (double AnnulusBlock_loop=0;AnnulusBlock_loop<nb_ladder;AnnulusBlock_loop++) {
+
+	std::string annBlockNameP =  _toString( LayerId , "BerylliumAnnulusBlock_%02d_posZ") + _toString( (int)AnnulusBlock_loop, "_%02d" ) ;
+	std::string annBlockNameN =  _toString( LayerId , "BerylliumAnnulusBlock_%02d_negZ") + _toString( (int)AnnulusBlock_loop, "_%02d" ) ;
+	
+	double phirot2 = phirot*AnnulusBlock_loop;
+
+	RotationZYX rot( 0, phirot2 ,  M_PI*0.5 ) ;
+	
+	double ZAnnulusBlock = ladder_length + end_electronics_half_z + (beryllium_ladder_block_length*2.);
+	    
+	PlacedVolume pv_ann_pos = supp_assembly.placeVolume( BerylliumAnnulusBlockLogical,  Transform3D( rot, Position((layer_radius+beryllium_ladder_block_thickness+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+											     -(layer_radius+beryllium_ladder_block_thickness+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+											     ZAnnulusBlock))  ) ;
+	DetElement  annBlockPosZ( vxd , annBlockNameP  , x_det.id() );
+	annBlockPosZ.setPlacement( pv_ann_pos ) ;
+	volSurfaceList( annBlockPosZ )->push_back( surfAnnBlock ) ;
+	
+	PlacedVolume pv_ann_neg = supp_assembly.placeVolume( BerylliumAnnulusBlockLogical,  Transform3D( rot, Position((layer_radius+beryllium_ladder_block_thickness+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+											     -(layer_radius+beryllium_ladder_block_thickness+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+											     -ZAnnulusBlock))  );
+	DetElement  annBlockNegZ( vxd , annBlockNameN  , x_det.id() );
+	annBlockNegZ.setPlacement( pv_ann_neg ) ;
+	volSurfaceList( annBlockNegZ )->push_back( surfAnnBlock ) ;
+      }	
+
+    } else if (LayerId==3||LayerId==5)  { 
+      
+      beryllium_ladder_block_length2 = beryllium_ladder_block_length + (shell_half_z - (end_electronics_half_z *3.* end_ladd_electronics_option)-ladder_length);
+      
+      for (double AnnulusBlock_loop=0;AnnulusBlock_loop<nb_ladder;AnnulusBlock_loop++) {
+	
+	Box BerylliumAnnulusBlockSolid( ladder_width, beryllium_ladder_block_length2/2., beryllium_ladder_block_thickness);
+	
+	//**fg: need to create unique string name per Volume object
+	std::string volName = _toString(LayerId,"BerylliumAnnulusBlock_%02d") ;
+	volName +=  _toString( int(AnnulusBlock_loop), "_%02d");
+
+	Volume BerylliumAnnulusBlockLogical( volName , BerylliumAnnulusBlockSolid, theDetector.material("G4_Be")) ; //"beryllium") ) ;
+
+	//====== create the meassurement surface for Be annulus block ===================
+	Vector3D u( 1. , 0. , 0. ) ;
+	Vector3D v( 0. , 1. , 0. ) ;
+	Vector3D n( 0. , 0. , 1. ) ;
+	
+	VolPlane surfAnnBlock( BerylliumAnnulusBlockLogical , SurfaceType(SurfaceType::Helper) , beryllium_ladder_block_thickness/2. ,  beryllium_ladder_block_thickness/2. , u,v,n ) ; //,o ) ;
+	//============================================================
+
+	std::string annBlockNameP =  _toString( LayerId , "BerylliumAnnulusBlock_%02d_posZ") + _toString( (int)AnnulusBlock_loop, "_%02d" ) ;
+	std::string annBlockNameN =  _toString( LayerId , "BerylliumAnnulusBlock_%02d_negZ") + _toString( (int)AnnulusBlock_loop, "_%02d" ) ;
+	
+	vxd.setVisAttributes(theDetector,  "CyanVis" , BerylliumAnnulusBlockLogical) ;
+	
+	double phirot2 = phirot*AnnulusBlock_loop;
+	
+	RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;
+	
+	double ZAnnulusBlock2=shell_half_z -(beryllium_ladder_block_length2/2.);// - (shell_thickess/2.); 
+	
+	PlacedVolume pv_ann_pos = supp_assembly.placeVolume( BerylliumAnnulusBlockLogical,  Transform3D( rot, Position((layer_radius+beryllium_ladder_block_thickness+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+											     -(layer_radius+beryllium_ladder_block_thickness+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+											     ZAnnulusBlock2))  );
+	DetElement  annBlockPosZ( vxd , annBlockNameP  , x_det.id() );
+	annBlockPosZ.setPlacement( pv_ann_pos ) ;
+	volSurfaceList( annBlockPosZ )->push_back( surfAnnBlock ) ;
+
+	PlacedVolume pv_ann_neg = supp_assembly.placeVolume( BerylliumAnnulusBlockLogical,  Transform3D( rot, Position((layer_radius+beryllium_ladder_block_thickness+layer_gap)*sin(phirot2)+offset_phi*cos(phirot2),
+											     -(layer_radius+beryllium_ladder_block_thickness+layer_gap)*cos(phirot2)+offset_phi*sin(phirot2),
+											     -ZAnnulusBlock2)) ) ;
+	DetElement  annBlockNegZ( vxd , annBlockNameN  , x_det.id() );
+	annBlockNegZ.setPlacement( pv_ann_neg ) ;
+	volSurfaceList( annBlockNegZ )->push_back( surfAnnBlock ) ;
+      }
+    }
+    
+    
+    //****************************************************************************************
+    // *********************************  Electronics   **********************************
+    // ******************************  (dead Si layer ends)   ********************************
+    //****************************************************************************************
+    
+    // *********************************  Electronics at the end of the ladder  **********************************
+    
+    if(end_ladd_electronics_option==1){
+      
+      Box ElectronicsEndSolid( ladder_width, end_electronics_half_z, electronics_structure_thickness/2. );
+      
+      Volume ElectronicsEndLogical(_toString(LayerId,"ElectronicsEnd_%02d"),ElectronicsEndSolid, activeMaterial ); //("silicon_2.33gccm")
+      
+      vxd.setVisAttributes(theDetector,  "GreenVis" , ElectronicsEndLogical );
+      
+      double end_ladd_electronic_offset_phi = offset_phi +(side_band_electronics_option * side_band_electronics_width/2.);
+      
+    //====== create the meassurement surface ===================
+    Vector3D u( 1. , 0. , 0. ) ;
+    Vector3D v( 0. , 1. , 0. ) ;
+    Vector3D n( 0. , 0. , 1. ) ;
+
+    double end_ladd_elec_thick = metal_traces_thickness + flex_cable_thickness + foam_spacer_thickness + electronics_structure_thickness;
+
+    VolPlane surfEndElec( ElectronicsEndLogical , SurfaceType(SurfaceType::Helper) , end_ladd_elec_thick/2. ,  end_ladd_elec_thick/2. , u,v,n ) ; //,o ) ;
+    //============================================================
+
+      if (LayerId==1||LayerId==3||LayerId==5) {       
+	
+	for (double elec_loop=0; elec_loop<nb_ladder;elec_loop++) {
+
+	  std::string elecEndLadNameP =  _toString( LayerId , "ElectronicsEnd_%02d_posZ") + _toString( (int)elec_loop, "_%02d" ) ;
+	  std::string elecEndLadNameN =  _toString( LayerId , "ElectronicsEnd_%02d_negZ") + _toString( (int)elec_loop, "_%02d" ) ;
+	  
+	  double phirot2 = phirot*elec_loop;
+	  RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;    
+	  
+	  double Z = ladder_length +end_electronics_half_z + (ladder_gap/2.);
+	  
+	  PlacedVolume pv_el_end_pos = layer_assembly.placeVolume( ElectronicsEndLogical,
+				     Transform3D( rot, Position((layer_radius+(electronics_structure_thickness/2.)+layer_gap)*sin(phirot2)+ end_ladd_electronic_offset_phi*cos(phirot2),
+								-(layer_radius+(electronics_structure_thickness/2.)+layer_gap)*cos(phirot2)+ end_ladd_electronic_offset_phi*sin(phirot2),
+								Z))  );
+
+	  DetElement  elecEndLadDEposZ( vxd ,  elecEndLadNameP , x_det.id() );
+	  elecEndLadDEposZ.setPlacement( pv_el_end_pos ) ;
+	  volSurfaceList( elecEndLadDEposZ )->push_back( surfEndElec ) ;
+	  
+	  PlacedVolume pv_el_end_neg = layer_assembly.placeVolume( ElectronicsEndLogical,
+				     Transform3D( rot, Position((layer_radius+(electronics_structure_thickness/2.)+layer_gap)*sin(phirot2)+ end_ladd_electronic_offset_phi*cos(phirot2),
+								-(layer_radius+(electronics_structure_thickness/2.)+layer_gap)*cos(phirot2)+ end_ladd_electronic_offset_phi*sin(phirot2),
+								-Z))  );
+
+	  DetElement  elecEndLadDEnegZ( vxd ,  elecEndLadNameN , x_det.id() );
+	  elecEndLadDEnegZ.setPlacement( pv_el_end_neg ) ;
+	  volSurfaceList( elecEndLadDEnegZ )->push_back( surfEndElec ) ;
+	}
+	
+      } else if (LayerId==0||LayerId==2||LayerId==4)  {       
+	
+	for (double elec_loop=0; elec_loop<nb_ladder;elec_loop++) {
+
+	  std::string elecEndLadNameP =  _toString( LayerId , "ElectronicsEnd_%02d_posZ") + _toString( (int)elec_loop, "_%02d" ) ;
+	  std::string elecEndLadNameN =  _toString( LayerId , "ElectronicsEnd_%02d_negZ") + _toString( (int)elec_loop, "_%02d" ) ;
+	  
+	  double phirot2 = phirot*elec_loop;
+	  RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;    
+	  
+	  double Z = ladder_length +end_electronics_half_z + (ladder_gap/2.);
+	  
+	  PlacedVolume pv_el_end_pos = layer_assembly.placeVolume( ElectronicsEndLogical,
+				     Transform3D( rot, Position((layer_radius-(electronics_structure_thickness/2.))*sin(phirot2)+ end_ladd_electronic_offset_phi*cos(phirot2),
+								-(layer_radius-(electronics_structure_thickness/2.))*cos(phirot2)+ end_ladd_electronic_offset_phi*sin(phirot2),
+								Z))  );
+
+	  DetElement  elecEndLadDEposZ( vxd ,  elecEndLadNameP , x_det.id() );
+	  elecEndLadDEposZ.setPlacement( pv_el_end_pos ) ;
+	  volSurfaceList( elecEndLadDEposZ )->push_back( surfEndElec ) ;
+	  
+	  PlacedVolume pv_el_end_neg = layer_assembly.placeVolume( ElectronicsEndLogical,
+				     Transform3D( rot, Position((layer_radius-(electronics_structure_thickness/2.))*sin(phirot2)+ end_ladd_electronic_offset_phi*cos(phirot2),
+								-(layer_radius-(electronics_structure_thickness/2.))*cos(phirot2)+ end_ladd_electronic_offset_phi*sin(phirot2),
+								-Z))  );
+
+	  DetElement  elecEndLadDEnegZ( vxd ,  elecEndLadNameN , x_det.id() );
+	  elecEndLadDEnegZ.setPlacement( pv_el_end_neg ) ;
+	  volSurfaceList( elecEndLadDEnegZ )->push_back( surfEndElec ) ;
+
+	}
+      }
+    }
+    // *********************************  Electronics a long  the ladder  **********************************
+    
+    if(side_band_electronics_option==1){
+      
+      Box ElectronicsBandSolid( side_band_electronics_width/2., ladder_length/2., side_band_electronics_thickness/2. );
+      
+      Volume ElectronicsBandLogical(_toString(LayerId,"ElectronicsBand_%02d"), ElectronicsBandSolid, activeMaterial ) ;
+      
+      vxd.setVisAttributes(theDetector,  "GreenVis" , ElectronicsBandLogical ) ;
+      
+      //fixme: turn off sensitive sidebands for now - not sure they cause problems in the volume manager ....
+      // active_side_band_electronics_option = 0 ;
+      if(active_side_band_electronics_option==1)
+	ElectronicsBandLogical.setSensitiveDetector(sens);
+      
+      
+      double side_band_electronic_offset_phi = offset_phi - (side_band_electronics_option * ladder_width);
+      
+      if (LayerId==1||LayerId==3||LayerId==5) {       
+	
+	for (double elec_loop=0; elec_loop<nb_ladder;elec_loop++) {   
+	  
+	  double phirot2 = phirot*elec_loop;
+	  RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;   
+	  
+	  double Z = (ladder_length* (1-side_band_electronics_option/2.)) + ladder_gap/2.;
+	  
+	  // encoder[LCTrackerCellID::layer()]  =  LayerId -1;
+	  // encoder[LCTrackerCellID::module()] = elec_loop ;
+	  // cellID0 = encoder.lowWord() ;  
+	  
+	  PlacedVolume pv_el_band_pos = layer_assembly.placeVolume( ElectronicsBandLogical,
+				     Transform3D( rot, Position((layer_radius+(side_band_electronics_thickness/2.)+layer_gap)*sin(phirot2)+side_band_electronic_offset_phi*cos(phirot2),
+								-(layer_radius+(side_band_electronics_thickness/2.)+layer_gap)*cos(phirot2)+side_band_electronic_offset_phi*sin(phirot2),
+								Z))  ) ;
+	  
+	  //**fg: choose sensor 1 for sensitive electronics side band
+	  if(active_side_band_electronics_option==1)
+	    pv_el_band_pos.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(elec_loop)  ).addPhysVolID("sensor", 1 ).addPhysVolID("side", 1 )   ;
+
+	  PlacedVolume pv_el_band_neg = layer_assembly.placeVolume( ElectronicsBandLogical,
+				     Transform3D( rot, Position((layer_radius+(side_band_electronics_thickness/2.)+layer_gap)*sin(phirot2)+side_band_electronic_offset_phi*cos(phirot2),
+								-(layer_radius+(side_band_electronics_thickness/2.)+layer_gap)*cos(phirot2)+side_band_electronic_offset_phi*sin(phirot2),
+								-Z))  );
+
+	  if(active_side_band_electronics_option==1)
+	    pv_el_band_neg.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(elec_loop)  ).addPhysVolID("sensor", 1 ).addPhysVolID("side", -1 )   ;
+	  
+	}
+
+      } else if (LayerId==1||LayerId==3||LayerId==5) {       
+	    
+	for (double elec_loop=0; elec_loop<nb_ladder;elec_loop++) { 
+	  
+	  double phirot2 = phirot*elec_loop;
+	  RotationZYX rot( 0, phirot2 , (M_PI*0.5) ) ;   
+
+	  double Z = (ladder_length* (1-side_band_electronics_option/2.)) + ladder_gap/2.;
+	      
+	  // encoder[LCTrackerCellID::layer()]  =  LayerId -1;
+	  // encoder[LCTrackerCellID::module()] = elec_loop ;
+	  // cellID0 = encoder.lowWord() ;  
+
+	  PlacedVolume pv_el_band_pos = layer_assembly.placeVolume( ElectronicsBandLogical,
+				     Transform3D( rot, Position((layer_radius-(side_band_electronics_thickness/2.))*sin(phirot2)+side_band_electronic_offset_phi*cos(phirot2),
+								-(layer_radius-(side_band_electronics_thickness/2.))*cos(phirot2)+side_band_electronic_offset_phi*sin(phirot2),
+								Z))  );
+
+	  if(active_side_band_electronics_option==1)
+	    pv_el_band_pos.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(elec_loop)  ).addPhysVolID("sensor", 1 ).addPhysVolID("side", 1 )   ;
+
+	  PlacedVolume pv_el_band_neg = layer_assembly.placeVolume( ElectronicsBandLogical,
+				     Transform3D( rot, Position((layer_radius-(side_band_electronics_thickness/2.))*sin(phirot2)+side_band_electronic_offset_phi*cos(phirot2),
+								-(layer_radius-(side_band_electronics_thickness/2.))*cos(phirot2)+side_band_electronic_offset_phi*sin(phirot2),
+								-Z))  );
+	  if(active_side_band_electronics_option==1)
+	    pv_el_band_neg.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(elec_loop)  ).addPhysVolID("sensor", 1 ).addPhysVolID("side", -1 )   ;
+	}
+      }      
+    }
+    
+    //****************************************************************************************
+    //*******************************  Strip lines (Kapton + metal)  *************************
+    //************ here the strip lines are still simulate by conical geometry ***************
+    //************ the thickness varies linearly with z **************************************
+    //****************************************************************************************
+    
+
+    double strip_line_start_z=0.;
+    
+    if (LayerId==0||LayerId==1) {
+      strip_line_start_z = ladder_length + ladder_gap/2. +( end_electronics_half_z * 2.)+ shell_thickess + beryllium_ladder_block_length*2 ; // to avoid overlaps
+    } else {
+      strip_line_start_z = shell_half_z + shell_endplate_thickness;//ladder_length + ladder_gap/2. - end_electronics_half_z * 2.+ shell_thickess  ; // to avoid overlaps
+    }
+    //double strip_line_half_z = (strip_line_final_z - strip_line_start_z) / 2.;
+
+    double strip_line_half_z = (dzSty - strip_line_start_z) / 2.;
+
+    // std::cout << " ############## dzSty : " << dzSty << " strip_line_start_z  : " << strip_line_start_z 
+    // 	      << "strip_line_half_z "  << strip_line_half_z << std::endl ; 
+    //    std::cout << " ############## sPhi : " << sPhi << "  endPhi : " << sPhi+dPhi << std::endl;
+
+    assert (strip_line_half_z>0);
+
+ 
+    if (LayerId==0||LayerId==2||LayerId==4) {
+ 
+      //Here we define the solid and logical volumes of the kapton strip lines
+      ConeSegment KaptonLinesSolid( strip_line_half_z, 
+				    layer_radius, // inside radius at  -fDz
+				    layer_radius + initial_kapton_striplines_thickness, // outside radius at -fDz
+				    cryostat_apperture + LayerId*final_kapton_striplines_thickness, // inside radius at  +fDz
+				    cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness,
+				    sPhi, sPhi+dPhi);
+      
+      //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
+      //**fg, NB:  TGeoConeSeg( dz,rmin0,rmax0,rmin1,rmax1, phi0, phi1 )  -  G4Cons( rmin0,rmin1,rmax0,rmax1, dz, phi0, delta_phi ) !!!!!!!!!!!!!!!!!!!!
+      //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
+      
+      
+      Volume KaptonLinesLogical( _toString(LayerId,"KaptonLines_%02d"), KaptonLinesSolid, flexCableMaterial ) ;
+      
+      vxd.setVisAttributes(theDetector,  "WhiteVis" , KaptonLinesLogical );
+      
+      //Here we define the solid and logical volumes of the metal traces of the strip lines
+      ConeSegment MetalLinesSolid( strip_line_half_z,
+				   layer_radius + initial_kapton_striplines_thickness, // inside radius at  -fDz
+				   layer_radius + initial_kapton_striplines_thickness + initial_metal_striplines_thickness, // outside radius at -fDz
+				   cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness, // inside radius at  +fDz
+				   cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness,
+				   sPhi,  sPhi+dPhi);
+      
+      Volume MetalLinesLogical( _toString(LayerId,"MetalLines_%02d"), MetalLinesSolid, metalTracesMaterial );
+      
+      vxd.setVisAttributes(theDetector,  "GrayVis" , MetalLinesLogical) ;
+      
+      //here we place both the kapton and copper part of the strip lines
+      double Z = strip_line_start_z + strip_line_half_z;
+
+      std::string striplineNameP =  _toString( LayerId , "KaptonLines_%02d_posZ") ;
+      std::string metallineNameP =  _toString( LayerId , "MetalLines_%02d_posZ") ;
+      std::string striplineNameN =  _toString( LayerId , "KaptonLines_%02d_negZ") ;
+      std::string metallineNameN =  _toString( LayerId , "MetalLines_%02d_negZ") ;
+
+     //****** YV ***************************************************************************
+      // add surface for tracking ....
+
+      std::cout << "  ***** place cabling for " << _toString( LayerId , "KaptonLines_%02d") << std::endl ;
+
+      if (LayerId==2 || LayerId==4){   
+	
+	//const double kapton_theta = atan2( -1.*(cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness) + layer_radius , 2.* strip_line_half_z ) ;
+	//const double metal_theta = atan2( -1.*(cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness) + (layer_radius + initial_kapton_striplines_thickness), 2.* strip_line_half_z ) ;
+
+	const double kapton_theta = atan2( -1.*(cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness) + layer_radius , 2.* strip_line_half_z ) ;
+	const double metal_theta = atan2( -1.*(cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness) + (layer_radius + initial_kapton_striplines_thickness), 2.* strip_line_half_z ) ;
+
+	double cabling_kapton_thickness =  (final_kapton_striplines_thickness + initial_kapton_striplines_thickness) / 2.;    
+	double cabling_metal_thickness =  (final_metal_striplines_thickness + initial_metal_striplines_thickness) / 2.;   
+
+	std::cout << " layer " << LayerId << " length of the cone " << 2.* strip_line_half_z << " opening angle " << kapton_theta << std::endl;
+	
+	Vector3D o_kaptoncon(0.5 * (layer_radius + cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness) , 0. , 0. );
+	Vector3D o_metalcon( 0.5 * (layer_radius + initial_kapton_striplines_thickness + cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness), 0. , 0. );
+	
+	Vector3D metal_angle( 1. , 0. , metal_theta, Vector3D::spherical ) ;
+	Vector3D kapton_angle( 1. , 0. , kapton_theta, Vector3D::spherical ) ;
+	
+	VolCone conSurf1( KaptonLinesLogical , SurfaceType( SurfaceType::Helper ) , 0.5*cabling_kapton_thickness  , 0.5*cabling_kapton_thickness , kapton_angle, o_kaptoncon );
+	VolCone conSurf2( MetalLinesLogical , SurfaceType( SurfaceType::Helper ) , 0.5*cabling_metal_thickness  , 0.5*cabling_metal_thickness , metal_angle, o_metalcon );	
+	
+	PlacedVolume pv_kap_pos = supp_assembly.placeVolume( KaptonLinesLogical,  Transform3D( RotationZYX() , Position(0., 0., Z) ) );
+
+	DetElement suppPosStriplinesDE ( suppDE , striplineNameP , x_det.id() )  ;
+	suppPosStriplinesDE.setPlacement( pv_kap_pos );
+	//volSurfaceList( suppPosStriplinesDE )->push_back( conSurf1 );
+
+	PlacedVolume pv_met_pos = supp_assembly.placeVolume( MetalLinesLogical,   Transform3D( RotationZYX() , Position(0., 0., Z) ) );
+
+	DetElement suppPosMetallinesDE ( suppDE , metallineNameP , x_det.id() )  ;
+	suppPosMetallinesDE.setPlacement( pv_met_pos );
+	//volSurfaceList( suppPosMetallinesDE )->push_back( conSurf2 );
+
+	
+	RotationZYX rot( 0, 0 , M_PI ) ;   // the same but other side
+
+	PlacedVolume pv_kap_neg = supp_assembly.placeVolume( KaptonLinesLogical,  Transform3D( rot , Position(0., 0., -Z) ) );
+
+	DetElement suppNegStriplinesDE ( suppDE , striplineNameN , x_det.id() )  ;
+	suppNegStriplinesDE.setPlacement( pv_kap_neg );
+	//volSurfaceList( suppNegStriplinesDE )->push_back( conSurf1 );
+
+	PlacedVolume pv_met_neg = supp_assembly.placeVolume( MetalLinesLogical,   Transform3D( rot , Position(0., 0., -Z) ) );
+	
+	DetElement suppNegMetallinesDE ( suppDE , metallineNameN , x_det.id() )  ;
+	suppNegMetallinesDE.setPlacement( pv_met_neg );
+	//volSurfaceList( suppNegMetallinesDE )->push_back( conSurf2 );
+
+      }
+
+
+      
+      else {
+	const double kapton_theta = atan2( (cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness) - layer_radius , 2.* strip_line_half_z ) ;
+	const double metal_theta = atan2( (cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness) - (layer_radius + initial_kapton_striplines_thickness), 2.* strip_line_half_z ) ;
+	
+	std::cout << " layer " << LayerId << " length of the cone " << 2.* strip_line_half_z << " opening angle " << kapton_theta << std::endl;
+	
+	double cabling_kapton_thickness =  (final_kapton_striplines_thickness + initial_kapton_striplines_thickness) / 2.;    
+	double cabling_metal_thickness =  (final_metal_striplines_thickness + initial_metal_striplines_thickness) / 2.;   
+	
+	Vector3D o_kaptoncon(0.5 * (layer_radius + cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness) , 0. , 0. );
+	Vector3D o_metalcon( 0.5 * (layer_radius + initial_kapton_striplines_thickness + cryostat_apperture + LayerId*final_kapton_striplines_thickness + final_kapton_striplines_thickness + final_metal_striplines_thickness), 0. , 0. );
+	
+	Vector3D metal_angle( 1. , 0. , metal_theta, Vector3D::spherical ) ;
+	Vector3D kapton_angle( 1. , 0. , kapton_theta, Vector3D::spherical ) ;
+
+	std::cout << " kapton:layer " << LayerId << " v phi " << kapton_angle.phi() << " o phi " << o_kaptoncon.phi() << std::endl ;
+	std::cout << " metal:layer " << LayerId << " v phi " << metal_angle.phi() << " o phi " << o_metalcon.phi() << std::endl ;
+	
+	VolCone conSurf1( KaptonLinesLogical , SurfaceType( SurfaceType::Helper ) , 0.5*cabling_kapton_thickness  , 0.5*cabling_kapton_thickness , kapton_angle, o_kaptoncon );
+	VolCone conSurf2( MetalLinesLogical , SurfaceType( SurfaceType::Helper ) , 0.5*cabling_metal_thickness  , 0.5*cabling_metal_thickness , metal_angle, o_metalcon );
+
+	PlacedVolume pv_kap_pos = supp_assembly.placeVolume( KaptonLinesLogical,  Transform3D( RotationZYX() , Position(0., 0., Z) ) );
+	
+	DetElement suppPosStriplinesDE ( suppDE , striplineNameP , x_det.id() )  ;
+	suppPosStriplinesDE.setPlacement( pv_kap_pos );
+	volSurfaceList( suppPosStriplinesDE )->push_back( conSurf1 );
+	
+	PlacedVolume pv_met_pos = supp_assembly.placeVolume( MetalLinesLogical,   Transform3D( RotationZYX() , Position(0., 0., Z) ) );
+	
+	DetElement suppPosMetallinesDE ( suppDE , metallineNameP , x_det.id() )  ;
+	suppPosMetallinesDE.setPlacement( pv_met_pos );
+	volSurfaceList( suppPosMetallinesDE )->push_back( conSurf2 );
+	
+      
+	RotationZYX rot( 0, 0 , M_PI ) ;   // the same but other side
+	
+	PlacedVolume pv_kap_neg = supp_assembly.placeVolume( KaptonLinesLogical,  Transform3D( rot , Position(0., 0., -Z) ) );
+
+	DetElement suppNegStriplinesDE ( suppDE , striplineNameN , x_det.id() )  ;
+	suppNegStriplinesDE.setPlacement( pv_kap_neg );
+	volSurfaceList( suppNegStriplinesDE )->push_back( conSurf1 );
+
+	PlacedVolume pv_met_neg = supp_assembly.placeVolume( MetalLinesLogical,   Transform3D( rot , Position(0., 0., -Z) ) );
+	
+	DetElement suppNegMetallinesDE ( suppDE , metallineNameN , x_det.id() )  ;
+	suppNegMetallinesDE.setPlacement( pv_met_neg );
+	volSurfaceList( suppNegMetallinesDE )->push_back( conSurf2 );
+	
+      }
+      
+      //*****************************************************************************************
+
+
+
+    }
+
+
+
+
+
+
+
+    //****************************************************************************************
+    //*******************************  Cooling Pipes (Titanium )  ********************************
+    //****************************************************************************************      
+    
+    //endplate cooling pipes
+    
+    double ZEndPlateCoolPipes = shell_half_z + shell_endplate_thickness;
+
+    double ZEndPlateCoolPipesL1  = ladder_length +  ((end_electronics_half_z*end_ladd_electronics_option) * 2) + shell_thickess + (beryllium_ladder_block_length*2) ;
+
+    //**TGeoTorus(double r, double rmin, double rmax, double phi, double delta_phi)    
+    //**G4Torus(const G4String &pName, G4double pRmin, G4double pRmax, G4double pRtor, G4double pSPhi, G4double pDPhi )
+
+    Torus CoolPipeSolid(layer_radius + layer_gap + cool_pipe_outer_radius/2., cool_pipe_inner_radius,
+			cool_pipe_outer_radius, sPhi, dPhi);
+    
+    Volume CoolPipeLogical(_toString(LayerId,"CoolPipe_%02d"), CoolPipeSolid, theDetector.material("G4_Ti")) ; //titanium") ) ;
+    
+    vxd.setVisAttributes(theDetector,  "MagentaVis" , CoolPipeLogical );
+
+    //one cooling pipe for each double layer
+ 
+    if (LayerId==3 || LayerId==5) {
+
+      supp_assembly.placeVolume( CoolPipeLogical, Transform3D( RotationZYX() , Position(0., 0.,   ZEndPlateCoolPipes+cool_pipe_outer_radius  )) );
+      supp_assembly.placeVolume( CoolPipeLogical, Transform3D( RotationZYX() , Position(0., 0., -(ZEndPlateCoolPipes+cool_pipe_outer_radius) )) );
+      
+    } else if (LayerId==1)  { 
+      
+      supp_assembly.placeVolume( CoolPipeLogical, Transform3D( RotationZYX() , Position(0., 0.,   ZEndPlateCoolPipesL1 + cool_pipe_outer_radius + shell_thickess) ));
+      supp_assembly.placeVolume( CoolPipeLogical, Transform3D( RotationZYX() , Position(0., 0., -(ZEndPlateCoolPipesL1 + cool_pipe_outer_radius + shell_thickess)) ));
+    }
+
+    //***************************************************************************************************************
+    // *** cooling pipe connecting the pipes at the central be support endplate to the layer 1 support endplate  ****
+    //***************************************************************************************************************
+
+    if (LayerId==1){
+
+      double thetaTube = atan((support_endplate_inner_radious - (layer_radius + layer_gap + 2*cool_pipe_outer_radius)) / (shell_half_z - ZEndPlateCoolPipesL1)) ;
+
+      std::cout << "############## thetaTube = " << thetaTube << std::endl ;
+
+      double CoolPipeLength = (shell_half_z - shell_thickess/2.) - ZEndPlateCoolPipesL1;
+      
+      Tube CoolPipeTubeSolid( cool_pipe_inner_radius, cool_pipe_outer_radius, CoolPipeLength/2., sPhi, sPhi+dPhi );
+      
+      Volume CoolPipeTubeLogical( _toString(LayerId,"CoolPipeTube_%02d"), CoolPipeTubeSolid, theDetector.material("G4_Ti")) ; //titanium") ) ; 
+      
+      vxd.setVisAttributes(theDetector,  "MagentaVis" , CoolPipeTubeLogical );
+      
+      //**fg: reversed sign compared to original VXD04.cc as this created obvious overlaps in TGeo (also in Mokka ???)
+      RotationZYX rm( 0., 0., -thetaTube);
+      RotationZYX rm2(0., 0.,  thetaTube);
+      
+      supp_assembly.placeVolume( CoolPipeTubeLogical, Transform3D( rm,  Position( 0.,
+										  (layer_radius + layer_gap + support_endplate_inner_radious)/2.,
+										  (ZEndPlateCoolPipesL1 + 3*cool_pipe_outer_radius + CoolPipeLength/2.)) )) ;
+      
+      supp_assembly.placeVolume( CoolPipeTubeLogical, Transform3D( rm2, Position( 0.,
+										  -(layer_radius + layer_gap + support_endplate_inner_radious)/2.,
+										  (ZEndPlateCoolPipesL1 + 3*cool_pipe_outer_radius + CoolPipeLength/2.)) )) ;
+      
+      supp_assembly.placeVolume( CoolPipeTubeLogical, Transform3D( rm2, Position( 0.,
+										  (layer_radius + layer_gap + support_endplate_inner_radious)/2.,
+										  -(ZEndPlateCoolPipesL1 + 3*cool_pipe_outer_radius + CoolPipeLength/2.)) )) ;
+      
+      supp_assembly.placeVolume( CoolPipeTubeLogical, Transform3D( rm,  Position( 0.,
+										  -(layer_radius + layer_gap + support_endplate_inner_radious)/2.,
+										  -(ZEndPlateCoolPipesL1 + 3*cool_pipe_outer_radius + CoolPipeLength/2.)) )) ;
+      
+    }
+      
+    //****************************************************************************************
+    // *******************************  Si Active layer  *************************************
+    //****************************************************************************************
+
+    Box SiActiveLayerSolid( ladder_width, ladder_length/2., active_silicon_thickness/2. );
+      
+    Volume SiActiveLayerLogical( _toString( LayerId , "SiActiveLayer_%02d"),SiActiveLayerSolid, activeMaterial ) ;
+
+    vxd.setVisAttributes(theDetector,  "BlueVis" , SiActiveLayerLogical ) ;
+
+    SiActiveLayerLogical.setSensitiveDetector(sens);
+   
+
+    //====== create the meassurement surface ===================
+    Vector3D u( 1. , 0. , 0. ) ;
+    Vector3D v( 0. , 1. , 0. ) ;
+    Vector3D n( 0. , 0. , 1. ) ;
+    //    Vector3D o( 0. , 0. , 0. ) ;
+
+    double supp_thick = metal_traces_thickness + flex_cable_thickness + foam_spacer_thickness;
+
+    //fg: set inner and outer thickness to sens/2+sup as  every other layer is flipped -> will just add a bit of air ...
+    VolPlane surf( SiActiveLayerLogical , SurfaceType(SurfaceType::Sensitive) , active_silicon_thickness/2 + supp_thick  , active_silicon_thickness/2 + supp_thick , u,v,n ) ; //,o ) ;
+    //============================================================
+
+
+    double active_offset_phi = offset_phi +(side_band_electronics_option * side_band_electronics_width/2.); 
+      
+    for (double active_loop=0;active_loop<nb_ladder;active_loop++){
+	
+      double phirot2 =  phirot*active_loop;
+      RotationZYX rot( 0. , phirot2, (M_PI*0.5) ) ;
+	
+      double Z = ladder_length/2.+ ladder_gap;
+	
+      // encoder[LCTrackerCellID::layer()]  =  LayerId -1;
+      // encoder[LCTrackerCellID::module()] = active_loop ;
+      // cellID0 = encoder.lowWord() ;  
+
+      std::string ladderNameP =  _toString( LayerId , "SiActiveLayer_%02d_posZ") + _toString( (int)active_loop, "_%02d" ) ;
+      std::string ladderNameN =  _toString( LayerId , "SiActiveLayer_%02d_negZ") + _toString( (int)active_loop, "_%02d" ) ;
+
+
+      if (LayerId==1 ) {
+
+	std::cout << "  ***** place ladder "  << int(active_loop) << " for " << _toString( LayerId , "SiActiveLayer_%02d") << std::endl ;
+      }
+
+      if (LayerId==1||LayerId==3||LayerId==5) {
+	
+	PlacedVolume pv_layer_pos = layer_assembly.placeVolume( SiActiveLayerLogical,  Transform3D( rot, Position((layer_radius+(active_silicon_thickness/2.)+layer_gap)*sin(phirot2)+active_offset_phi*cos(phirot2),
+										     -(layer_radius+(active_silicon_thickness/2.)+layer_gap)*cos(phirot2)+active_offset_phi*sin(phirot2),
+										     Z)) ) ;
+	
+	pv_layer_pos.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(active_loop)  ).addPhysVolID("sensor", 0 ).addPhysVolID("side", 1 )   ;
+
+	DetElement   ladderDEposZ( vxd ,  ladderNameP , x_det.id() );
+	ladderDEposZ.setPlacement( pv_layer_pos ) ;
+	volSurfaceList( ladderDEposZ )->push_back( surf ) ;
+
+
+	PlacedVolume pv_layer_neg = layer_assembly.placeVolume( SiActiveLayerLogical,  Transform3D( rot, Position((layer_radius+(active_silicon_thickness/2.)+layer_gap)*sin(phirot2)+active_offset_phi*cos(phirot2),
+										     -(layer_radius+(active_silicon_thickness/2.)+layer_gap)*cos(phirot2)+active_offset_phi*sin(phirot2),
+										     -Z)) );
+	
+	pv_layer_neg.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(active_loop)  ).addPhysVolID("sensor", 0 ).addPhysVolID("side", -1 )   ;
+
+	DetElement   ladderDEnegZ( vxd ,   ladderNameN , x_det.id() );
+	ladderDEnegZ.setPlacement( pv_layer_neg ) ;
+	volSurfaceList( ladderDEnegZ )->push_back( surf ) ;
+	
+
+      } else if (LayerId==0||LayerId==2||LayerId==4) { 
+
+	PlacedVolume pv_layer_pos = layer_assembly.placeVolume( SiActiveLayerLogical,  Transform3D( rot, Position((layer_radius-(active_silicon_thickness/2.))*sin(phirot2)+active_offset_phi*cos(phirot2),
+										     -(layer_radius-(active_silicon_thickness/2.))*cos(phirot2)+active_offset_phi*sin(phirot2),
+										     Z)) ) ;
+	
+	pv_layer_pos.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(active_loop)  ).addPhysVolID("sensor", 0 ).addPhysVolID("side", 1 )   ;
+	
+	DetElement   ladderDEposZ( vxd ,  ladderNameP , x_det.id() );
+	ladderDEposZ.setPlacement( pv_layer_pos ) ;
+	volSurfaceList( ladderDEposZ )->push_back( surf ) ;
+
+	
+	PlacedVolume pv_layer_neg = layer_assembly.placeVolume( SiActiveLayerLogical,  Transform3D( rot, Position((layer_radius-(active_silicon_thickness/2.))*sin(phirot2)+active_offset_phi*cos(phirot2),
+	 									     -(layer_radius-(active_silicon_thickness/2.))*cos(phirot2)+active_offset_phi*sin(phirot2),
+	 									     -Z)) );
+	DetElement   ladderDEnegZ( vxd ,  ladderNameN , x_det.id() );
+	ladderDEnegZ.setPlacement( pv_layer_neg ) ;
+	volSurfaceList( ladderDEnegZ )->push_back( surf ) ;
+	
+	pv_layer_neg.addPhysVolID("layer", LayerId ).addPhysVolID( "module" , int(active_loop)  ).addPhysVolID("sensor", 0 ).addPhysVolID("side", -1 )   ;
+	
+      }		  
+
+    }
+      
+    // #ifdef MOKKA_GEAR
+    //       // sensitive layer
+    //       helpLayer thisSens ;
+    //       if (LayerId==2||LayerId==4||LayerId==6) 
+    // 	{ 
+    // 	  thisSens.distance  = layer_gap + layer_radius;
+    // 	}
+    //       if (LayerId==1||LayerId==3||LayerId==5) 
+    // 	{ 
+    // 	  thisSens.distance  = layer_radius  - active_silicon_thickness ;
+    // 	}
+    //       thisSens.offset    = active_offset_phi ;
+    //       thisSens.thickness = active_silicon_thickness ;
+    //       thisSens.length    = ladder_length ;
+    //       if (active_side_band_electronics_option==1) {
+    // 	thisSens.width     = ladder_width*2.+side_band_electronics_width ;
+    //       }
+    //       else  {
+    // 	thisSens.width     = ladder_width*2.; 
+    //       }
+    //       thisSens.radLength = (SiActiveLayerLogical->GetMaterial())->GetRadLen()/mm ;
+      
+    //       // save information for gear
+    //       gearHelpLadders.push_back( thisLadder );
+    //       gearHelpSensitives.push_back( thisSens ) ;
+    //       gearHelpNumberLadders.push_back( (int) nb_ladder ) ;
+      
+    //       // fg: here we start with the first ladder at -pi/2 (i.e. the negative y-axis)
+    //       gearHelpPhi0.push_back( -pi/2. ) ;
+      
+    //       gearHelpGap = std::max( gearHelpGap , ladder_gap ) ;
+    //       gearHelpCount ++ ;
+    // #endif
+
+
+    //--- fill ZPlanarData
+
+    if (LayerId==1||LayerId==3||LayerId==5)  { 
+
+      thisLayer.distanceSensitive  = layer_gap + layer_radius;
+
+    } else if (LayerId==0||LayerId==2||LayerId==4) { 
+
+      thisLayer.distanceSensitive  = layer_radius  - active_silicon_thickness ;
+    }
+    //Adjusted by Thorben Quast to provide consistency with CLIC while drawing for CED
+    //Please check as the prefactor is simply chosen for the geometry to match the hits
+    thisLayer.offsetSensitive    = 0.5*active_offset_phi ;
+    thisLayer.thicknessSensitive = active_silicon_thickness ;
+    thisLayer.zHalfSensitive    = ladder_length ;
+
+    if (active_side_band_electronics_option==1) {
+
+      thisLayer.widthSensitive     = ladder_width*2.+side_band_electronics_width ;
+
+    } else  {
+
+      thisLayer.widthSensitive      = ladder_width*2.; 
+    }
+
+    thisLayer.ladderNumber = (int) nb_ladder  ;
+    thisLayer.phi0 =  -M_PI/2.  ;
+    
+    zPlanarData->layers.push_back( thisLayer ) ;
+
+    // gearHelpGap = std::max( gearHelpGap , ladder_gap ) ;
+    // gearHelpCount ++ ;
+
+
+
+  } // --- end loop over layers ----------------------------------------------------------------------------------------
+
+
+    //****************************************************************************************
+    //*** Here we place the cabling going outside the VXD ************************************
+    //****************************************************************************************
+
+    DetElement suppExtKaptonCablesPos ( suppDE , name+"_ExtKaptonCab_pos" , x_det.id() )  ;
+    DetElement suppExtKaptonCablesNeg ( suppDE , name+"_ExtKaptonCab_neg" , x_det.id() )  ;
+    DetElement suppExtMetalCablesPos ( suppDE , name+"_ExtMetalCab_pos" , x_det.id() )  ;
+    DetElement suppExtMetalCablesNeg ( suppDE , name+"_ExtMetalCab_neg" , x_det.id() )  ;
+    
+    double external_cable_length = (drAlu + drSty)/2.;
+    double ExternalCablesZ = dzSty + drSty/2. + drAlu/2. ;
+
+    //** G4Tubs( const G4String& pName, G4double pRMin, G4double pRMax, G4double pDz, G4double pSPhi,G4double pDPhi );
+    //** TGeoTubeSeg(Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
+
+    //kapton part
+    Tube ExternalKaptonCablesSolid(cryostat_apperture, cryostat_apperture + 3*external_kapton_thickness/2.,  external_cable_length, sPhi, sPhi+dPhi);
+    //The reason for the factor three is that the thickness refer to the thickness of each single cable, and we have three cables in total, one per layer
+
+    Volume ExternalKaptonCablesLogical("ExternalKaptonCables", ExternalKaptonCablesSolid, theDetector.material("G4_KAPTON") );
+ 
+    vxd.setVisAttributes(theDetector,  "WhiteVis" , ExternalKaptonCablesLogical );
+
+    //metal part
+    Tube ExternalMetalCablesSolid(cryostat_apperture - 3*external_metal_thickness/2., cryostat_apperture, external_cable_length,  sPhi, sPhi+dPhi);
+
+    Volume ExternalMetalCablesLogical("ExternalMetalCables", ExternalMetalCablesSolid ,  theDetector.material("G4_Cu") ) ;
+ 
+    vxd.setVisAttributes(theDetector,  "GrayVis" , ExternalMetalCablesLogical );
+
+    
+    //====== YV: create a material surface for the cabling outside the VXD  ===================
+    // ==================================== Kapton part ====================================
+    
+    Vector3D oextcable( cryostat_apperture + cryostat_apperture + 3*external_kapton_thickness/2. , 0. , 0.  ) ;    
+    VolCylinder surfKaptonExtCables( ExternalKaptonCablesLogical , SurfaceType(SurfaceType::Helper) , external_kapton_thickness/2. , external_kapton_thickness/2., oextcable ) ;
+    
+    //========================================== Metal part ==================================
+    
+    Vector3D oextmetalcable( cryostat_apperture - 3*external_metal_thickness/2. + cryostat_apperture , 0. , 0.  ) ;    
+    VolCylinder surfMetalExtCables( ExternalMetalCablesLogical , SurfaceType(SurfaceType::Helper) , external_metal_thickness/2. , external_metal_thickness/2., oextmetalcable ) ;
+
+    //==================================================================================
+
+    PlacedVolume pv_kap_pos = supp_assembly.placeVolume( ExternalKaptonCablesLogical,  Transform3D( RotationZYX() , Position(0., 0.,  ExternalCablesZ) ) );
+    suppExtKaptonCablesPos.setPlacement( pv_kap_pos );
+    volSurfaceList( suppExtKaptonCablesPos )->push_back( surfKaptonExtCables ) ;
+
+    PlacedVolume pv_kap_neg = supp_assembly.placeVolume( ExternalKaptonCablesLogical,  Transform3D( RotationZYX() , Position(0., 0., -ExternalCablesZ) ) );
+    suppExtKaptonCablesNeg.setPlacement( pv_kap_neg );
+    volSurfaceList( suppExtKaptonCablesNeg )->push_back( surfKaptonExtCables ) ;
+
+    PlacedVolume pv_met_pos = supp_assembly.placeVolume( ExternalMetalCablesLogical,   Transform3D( RotationZYX() , Position(0., 0.,  ExternalCablesZ) ) );
+    suppExtMetalCablesPos.setPlacement( pv_met_pos );
+    volSurfaceList( suppExtMetalCablesPos )->push_back( surfMetalExtCables ) ;
+
+    PlacedVolume pv_met_neg = supp_assembly.placeVolume( ExternalMetalCablesLogical,   Transform3D( RotationZYX() , Position(0., 0., -ExternalCablesZ) ) );
+    suppExtMetalCablesNeg.setPlacement( pv_met_neg );
+    volSurfaceList( suppExtMetalCablesNeg )->push_back( surfMetalExtCables ) ;
+
+
+
+
+  
+  //****************************************
+  // Outer support shell
+  //****************************************
+  
+  // ************central tube************
+  
+  Tube SupportShellSolid( shell_inner_radious, shell_inner_radious+shell_thickess, shell_half_z, sPhi, sPhi+dPhi );
+
+  Volume SupportShellLogical("SupportShell", SupportShellSolid,  theDetector.material("G4_Be")) ; //"beryllium") ) ;
+
+  vxd.setVisAttributes(theDetector,  "CyanVis" , SupportShellLogical ) ;
+  
+
+  //====== create a material surface for the support shell ===================
+  
+  Vector3D osupshell( shell_inner_radious+shell_thickess/2. , 0. , 0.  ) ;
+  
+  VolCylinder surfSupShell( SupportShellLogical , SurfaceType(SurfaceType::Helper) , shell_thickess/2. , shell_thickess/2., osupshell ) ;
+  
+  volSurfaceList( suppDE )->push_back( surfSupShell ) ;
+  //============================================================
+
+
+
+  supp_assembly.placeVolume( SupportShellLogical ) ;
+  //  pv = supp_assembly.placeVolume( SupportShellLogical, Transform3D( RotationZYX(), Position() ) ) ;
+  
+
+  // ************support endplates************
+
+  double support_endplate_half_z = shell_endplate_thickness/2;
+  
+  Tube EndPlateShellSolid( support_endplate_inner_radious,  shell_inner_radious+shell_thickess, support_endplate_half_z, sPhi, sPhi+dPhi ) ;
+
+  Volume EndPlateShellLogical("EndPlateShell_outer", EndPlateShellSolid,  theDetector.material("G4_Be")) ; //"beryllium") ) ;
+
+  vxd.setVisAttributes(theDetector,  "CyanVis" , EndPlateShellLogical ) ;
+  
+  double ZEndPlateShell = shell_half_z + shell_endplate_thickness/2.;// + (beryllium_ladder_block_length*2);
+
+
+  DetElement endplateFwdDE( suppDE , name+"_endplate_fwd" , x_det.id() )  ;
+  DetElement endplateBwdDE( suppDE , name+"_endplate_bwd" , x_det.id() )  ;
+
+  PlacedVolume pv_end_pos = supp_assembly.placeVolume( EndPlateShellLogical, Transform3D( RotationZYX(), Position(0., 0.,  ZEndPlateShell ) ) ) ;
+  endplateFwdDE.setPlacement( pv_end_pos ) ;
+  PlacedVolume pv_end_neg = supp_assembly.placeVolume( EndPlateShellLogical, Transform3D( RotationZYX(), Position(0., 0., -ZEndPlateShell ) ) ) ;
+  endplateBwdDE.setPlacement( pv_end_neg ) ;
+
+  // --- add a helper surface for the outer part of the endplate shell ---------------------------------
+
+  Vector3D up( 1. , 0. , 0. ) ;
+  Vector3D vp( 0. , 1. , 0. ) ;
+  Vector3D np( 0. , 0. , 1. ) ;
+
+  // need to set the origin of this helper plane to be inside the material ( otherwise it would pick up the vacuum at the origin)
+  Vector3D o_endplate( 0. ,   0.5 * (  support_endplate_inner_radious + shell_inner_radious+shell_thickess )    , 0. ) ;
+
+  VolPlane surfEndplate( EndPlateShellLogical , SurfaceType(SurfaceType::Helper) , support_endplate_half_z , support_endplate_half_z, up,vp,np, o_endplate ) ;
+  volSurfaceList( endplateFwdDE )->push_back( surfEndplate ) ;
+  volSurfaceList( endplateBwdDE )->push_back( surfEndplate ) ;
+
+  //-----------------------------------------------------------------------------------------------------
+    
+
+
+  
+  // ************support endplates for the layer 1************
+  
+  double support_endplate_half_z_L1 = shell_thickess/2;
+  double ladder_length = ladder_0_length ;
+  
+  Tube EndPlateShellSolidL1( support_endplate_inner_radious_L1, support_endplate_outer_radious_L1, support_endplate_half_z_L1, sPhi, sPhi+dPhi ) ;
+  
+  Volume EndPlateShellLogicalL1("EndPlateShell_inner", EndPlateShellSolidL1,  theDetector.material("G4_Be")) ; //"beryllium") ) ;
+  
+  vxd.setVisAttributes(theDetector,  "CyanVis" , EndPlateShellLogicalL1 ) ;
+  
+  double ZEndPlateShell2 = ladder_length +  ((end_electronics_half_z*end_ladd_electronics_option) * 2) + shell_thickess/2. + (beryllium_ladder_block_length*2) ;
+  
+  supp_assembly.placeVolume( EndPlateShellLogicalL1, Transform3D( RotationZYX(), Position(0., 0.,   ZEndPlateShell2 ) ) ) ;
+  supp_assembly.placeVolume( EndPlateShellLogicalL1, Transform3D( RotationZYX(), Position(0., 0.,  -ZEndPlateShell2 ) ) ) ;
+  
+  //**** beryllium support shell cone ************************************************
+
+  double support_cone_half_z = (shell_half_z - (ZEndPlateShell2 + shell_thickess/2.))/2.;
+  
+  ConeSegment SupportShellCone( support_cone_half_z, 
+				support_endplate_outer_radious_L1, support_endplate_outer_radious_L1 + shell_thickess, 
+				support_endplate_inner_radious,    support_endplate_inner_radious    + shell_thickess,
+				sPhi, sPhi+dPhi);
+  
+  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
+  //**fg, NB:  TGeoConeSeg( dz,rmin0,rmax0,rmin1,rmax1, phi0, phi1 )  -  G4Cons( rmin0,rmin1,rmax0,rmax1, dz, phi0, delta_phi ) !!!!!!!!!!!!!!!!!!!!
+  //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!      
+      
+  Volume SupportConeLogical("SupportCone", SupportShellCone,  theDetector.material("G4_Be")) ; //"beryllium") ) ;
+  
+  vxd.setVisAttributes(theDetector,  "CyanVis" , SupportConeLogical ) ;
+  
+  double ZCone = ladder_length +  ((end_electronics_half_z*end_ladd_electronics_option) * 2) + shell_thickess + (beryllium_ladder_block_length*2) + support_cone_half_z;
+
+  // ================================== adding tracking surfaces for beryllium support cone ====================================
+  const double shell_theta = atan2( -1.*support_endplate_outer_radious_L1 + support_endplate_inner_radious, 2.*support_cone_half_z);  
+
+  Vector3D o_shellcon(0.5 * (support_endplate_outer_radious_L1 + shell_thickess + support_endplate_inner_radious) , 0., 0. ) ;
+  Vector3D shellcone_angle (  1. , 0. , shell_theta, Vector3D::spherical ) ;
+
+  VolCone suppShellCone( SupportConeLogical, SurfaceType( SurfaceType::Helper ) , 0.5*shell_thickess  , 0.5*shell_thickess , shellcone_angle, o_shellcon );
+  // ==============================================================================================================================
+  
+  PlacedVolume pv_supp_pos = supp_assembly.placeVolume( SupportConeLogical, Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  ZCone ) ) ) ;
+  DetElement suppShellConePosDE ( suppDE , "posShellCone" , x_det.id() )  ;
+  suppShellConePosDE.setPlacement( pv_supp_pos );
+  volSurfaceList( suppShellConePosDE )->push_back( suppShellCone );
+
+  PlacedVolume pv_supp_neg = supp_assembly.placeVolume( SupportConeLogical, Transform3D( RotationZYX( 0, 0, M_PI ), Position(0., 0., -ZCone ) ) ) ;
+  DetElement suppShellConeNegDE ( suppDE , "negShellCone" , x_det.id() )  ;
+  suppShellConeNegDE.setPlacement( pv_supp_neg );
+  volSurfaceList( suppShellConeNegDE )->push_back( suppShellCone );
+
+  //*** beryllium support forward part **************************************************************************
+  
+  double supportForZ = shell_half_z + shell_endplate_thickness + forward_shell_half_z;
+  
+  Tube SupportForSolid( support_endplate_inner_radious, support_endplate_inner_radious + shell_endplate_thickness, forward_shell_half_z,  sPhi, sPhi+dPhi ) ;
+
+  Volume SupportForLogical("SupportFor", SupportForSolid,  theDetector.material("G4_Be")) ; //"beryllium") ) ;
+
+  vxd.setVisAttributes(theDetector,  "CyanVis" , SupportForLogical ) ;
+
+  supp_assembly.placeVolume( SupportForLogical, Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  supportForZ ) ) ) ;
+  supp_assembly.placeVolume( SupportForLogical, Transform3D( RotationZYX( 0, 0, M_PI ), Position(0., 0., -supportForZ ) ) ) ;
+
+  
+  //*** Cryostat ***************************************************************
+
+
+  double aluEndcapZ = dzSty + drSty + drAlu / 2;
+  double styEndcapZ = dzSty + drSty / 2;
+  
+  double aluHalfZ = dzSty + drSty;
+  
+  if (useCryo) {
+    Material aluMaterial = theDetector.material( "G4_Al" ) ;
+    //          VisAttributes *aluVisAttributes = new VisAttributes(Colour(0.5, 0.5, 0.5)); 
+    
+    Material styMaterial = theDetector.material("styropor");
+    
+
+
+    Tube aluBarrelSolid( rAlu, rAlu + drAlu, aluHalfZ, sPhi, sPhi+dPhi);
+    Volume aluBarrelLog( "CryostatAluSkinBarrel", aluBarrelSolid, aluMaterial );
+    vxd.setVisAttributes(theDetector,  "GrayVis" , aluBarrelLog ) ;
+    supp_assembly.placeVolume( aluBarrelLog ) ;
+    
+    Tube styBarrelSolid(  rSty, rSty + drSty, dzSty, sPhi, sPhi+dPhi);
+    Volume styBarrelLog( "CryostatFoamBarrel", styBarrelSolid, styMaterial );
+    vxd.setVisAttributes(theDetector,  "LightGrayVis", styBarrelLog ) ;
+    supp_assembly.placeVolume( styBarrelLog ) ;
+
+    //====== create a material surface for the cryostat barrel ===================
+
+    double rc =  ( rAlu + drAlu /2.) ;
+    Vector3D oc( rc , 0. , 0.  ) ;
+
+    double outer_thick = drAlu/2. ;
+    double inner_thick = drAlu/2. + drSty ;
+
+    VolCylinder surfC( aluBarrelLog , SurfaceType(SurfaceType::Helper) , inner_thick , outer_thick, oc ) ;
+
+    volSurfaceList( suppDE )->push_back( surfC ) ;
+    //============================================================
+
+
+    //Aluminium + styropor endplates for the cryostat
+    //Create an apperture at the cryostat endcap for the cabling and the cooling pipes
+    
+
+    // in order to assign material surfaces to the endcap of the cryostat
+    // we need four DetElements as the endcap consists of four distinct volumes ...
+    DetElement suppFwdInDE ( suppDE , name+"_support_fwd_inner" , x_det.id() )  ;
+    DetElement suppBwdInDE ( suppDE , name+"_support_bwd_inner" , x_det.id() )  ;
+    DetElement suppFwdOutDE( suppDE , name+"_support_fwd_outer" , x_det.id() )  ;
+    DetElement suppBwdOutDE( suppDE , name+"_support_bwd_outer" , x_det.id() )  ;
+
+    Tube aluEndcapSolidInner(  rInner, cryostat_apperture - cryostat_apperture_radius, drAlu / 2, sPhi, sPhi+dPhi);
+    Volume aluEndcapInnerLog( "CryostatAluSkinEndPlateInner", aluEndcapSolidInner, aluMaterial );
+    vxd.setVisAttributes(theDetector,  "GrayVis" , aluEndcapInnerLog ) ;
+    PlacedVolume pv_alu_end_pos = supp_assembly.placeVolume( aluEndcapInnerLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,   aluEndcapZ ) ) ) ;
+    suppFwdInDE.setPlacement( pv_alu_end_pos ) ;
+    PlacedVolume pv_alu_end_neg = supp_assembly.placeVolume( aluEndcapInnerLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  -aluEndcapZ ) ) ) ;
+    suppBwdInDE.setPlacement( pv_alu_end_neg ) ;
+
+    Tube aluEndcapSolidOuter(   cryostat_apperture + cryostat_apperture_radius, rAlu + drAlu, drAlu / 2, sPhi, sPhi+dPhi);
+    Volume aluEndcapOuterLog( "CryostatAluSkinEndPlateOuter", aluEndcapSolidOuter, aluMaterial );
+    vxd.setVisAttributes(theDetector,  "GrayVis" , aluEndcapOuterLog ) ;
+    PlacedVolume pv_alu_end_out_pos = supp_assembly.placeVolume( aluEndcapOuterLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,   aluEndcapZ ) ) ) ;
+    suppFwdOutDE.setPlacement( pv_alu_end_out_pos ) ;
+    PlacedVolume pv_alu_end_out_neg = supp_assembly.placeVolume( aluEndcapOuterLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  -aluEndcapZ ) ) ) ;
+    suppBwdOutDE.setPlacement( pv_alu_end_out_neg ) ;
+    
+    Tube styEndcapSolidInner(  rInner, cryostat_apperture - cryostat_apperture_radius, drSty / 2, sPhi, sPhi+dPhi);
+    Volume styEndcapInnerLog( "CryostatFoamEndPlateInner", styEndcapSolidInner, styMaterial );
+    vxd.setVisAttributes(theDetector,  "WhiteVis" , styEndcapInnerLog ) ;
+    supp_assembly.placeVolume( styEndcapInnerLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,   styEndcapZ ) ) ) ;
+    supp_assembly.placeVolume( styEndcapInnerLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  -styEndcapZ ) ) ) ;
+
+    Tube styEndcapSolidOuter(  cryostat_apperture + cryostat_apperture_radius, rSty + drSty, drSty / 2, sPhi, sPhi+dPhi);
+    Volume styEndcapOuterLog( "CryostatFoamEndPlateOuter", styEndcapSolidOuter, styMaterial );
+    vxd.setVisAttributes(theDetector,  "WhiteVis" , styEndcapOuterLog ) ;
+    supp_assembly.placeVolume( styEndcapOuterLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,   styEndcapZ ) ) ) ;
+    supp_assembly.placeVolume( styEndcapOuterLog , Transform3D( RotationZYX( 0, 0, 0  ), Position(0., 0.,  -styEndcapZ ) ) ) ;
+
+    //====== create a material surface for the cryostat endcap ===================
+    // Vector3D up( 1. , 0. , 0. ) ;
+    // Vector3D vp( 0. , 1. , 0. ) ;
+    // Vector3D np( 0. , 0. , 1. ) ;
+
+    // need to set the origin of this helper plane to be inside the material ( otherwise it would pick up the vacuum at the origin)
+    double mid_r = 0.5 * ( cryostat_apperture - cryostat_apperture_radius +  rInner  ) ;
+    Vector3D op_i( 0. , mid_r , 0. ) ;
+
+    VolPlane surfPi( aluEndcapInnerLog , SurfaceType(SurfaceType::Helper) , inner_thick , outer_thick, up,vp,np, op_i ) ;
+    volSurfaceList( suppFwdInDE )->push_back( surfPi ) ;
+    volSurfaceList( suppBwdInDE )->push_back( surfPi ) ;
+    
+    mid_r = 0.5 * ( cryostat_apperture + cryostat_apperture_radius + rSty + drSty ) ;
+    Vector3D op_o( 0. , mid_r , 0. ) ;
+
+    VolPlane surfPo( aluEndcapOuterLog , SurfaceType(SurfaceType::Helper) , inner_thick , outer_thick, up,vp,np, op_o) ;
+    volSurfaceList( suppFwdOutDE )->push_back( surfPo ) ;
+    volSurfaceList( suppBwdOutDE )->push_back( surfPo ) ;
+
+    //============================================================
+
+  }
+  
+  //     cout<<"rAlu "<< rAlu<<endl;
+  //     cout<<"drAlu "<< drAlu<<endl;
+  //     cout<<"aluHalfZ "<< aluHalfZ<<endl;
+  //     cout<<"drSty "<< drSty<<endl;
+  //     cout<<"rInner "<<rInner <<endl;
+  //     cout<<"+aluEndcapZ "<<+aluEndcapZ <<endl;
+  //     cout<<"shell_inner_radious "<<shell_inner_radious <<endl; 
+  //     cout<<"foam inner radius "<<rSty <<endl; 
+  //     cout << "database name =" << dbName << endl;
+  
+  // #ifdef MOKKA_GEAR
+  //     // -------write data to gear
+  
+  //     // get gear manager
+  //     MokkaGear* gearMgr = MokkaGear::getMgr() ;
+  
+  //     // construct VXDParameters
+  //     gear::ZPlanarParametersImpl* vxdParams = 
+  //       new gear::ZPlanarParametersImpl(gearHelpType ,                                        // vxd type 
+  // 				      shell_inner_radious ,                                 // inner radius
+  // 				      shell_inner_radious+shell_thickess ,                  // outer radius
+  // 				      shell_half_z ,                                        // half length
+  // 				      gearHelpGap ,                                         // shell gap
+  // 				      (SupportShellLogical->GetMaterial())->GetRadLen()/mm ) ; // shell rad length
+  
+  //     // add all layers
+  //     for( int i = 0 ; i < gearHelpCount ; i++ ) {
+  //       vxdParams->addLayer( gearHelpNumberLadders[i] , gearHelpPhi0[i] ,
+  // 			   gearHelpLadders[i].distance , gearHelpLadders[i].offset,gearHelpLadders[i].thickness ,
+  // 			   gearHelpLadders[i].length , gearHelpLadders[i].width , gearHelpLadders[i].radLength ,
+  // 			   gearHelpSensitives[i].distance, gearHelpSensitives[i].offset , gearHelpSensitives[i]. thickness , 
+  // 			   gearHelpSensitives[i].length , gearHelpSensitives[i].width , gearHelpSensitives[i].radLength ) ;
+  //       gearMgr->setVXDParameters( vxdParams ) ;
+  //     }
+  
+  // #endif
+  
+  zPlanarData->rInnerShell = shell_inner_radious  ;
+  zPlanarData->rOuterShell = shell_inner_radious+shell_thickess ;
+  zPlanarData->zHalfShell  = shell_half_z ;
+  zPlanarData->gapShell    = 0. ;
+  //######################################################################################################################################################################
+  
+  vxd.addExtension< ZPlanarData >( zPlanarData ) ;
+
+  
+  //--------------------------------------
+  
+  
+  vxd.setVisAttributes( theDetector, x_det.visStr(), envelope );
+
+  return vxd;
+}
+DECLARE_DETELEMENT(VXD04,create_element)