From 2b52b7d051d1e510ff7d2aed307f573dce17f5e6 Mon Sep 17 00:00:00 2001
From: FU Chengdong <fucd@ihep.ac.cn>
Date: Mon, 2 Dec 2024 07:25:14 +0000
Subject: [PATCH] SIM: update vertex detector design and spatial resolution as
 designed

---
 Detector/DetCRD/CMakeLists.txt                |   1 +
 .../CRD_common_v02/Beampipe_v01_06.xml        | 348 +++++++++++
 .../CRD_common_v02/VXD_Composite_v01_02.xml   | 164 +++++
 Detector/DetCRD/compact/README.md             |   2 +-
 .../TDR_o1_v01/TDR_o1_v01-onlyTracker.xml     |   4 +-
 .../DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml  |   4 +-
 .../DetCRD/scripts/TDR_o1_v01/tracking.py     |   8 +-
 .../Tracker/SiTrackerComposite_v02_geo.cpp    | 558 ++++++++++++++++++
 8 files changed, 1080 insertions(+), 9 deletions(-)
 create mode 100644 Detector/DetCRD/compact/CRD_common_v02/Beampipe_v01_06.xml
 create mode 100644 Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml
 create mode 100644 Detector/DetCRD/src/Tracker/SiTrackerComposite_v02_geo.cpp

diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt
index 6f874165..e4bd5b46 100644
--- a/Detector/DetCRD/CMakeLists.txt
+++ b/Detector/DetCRD/CMakeLists.txt
@@ -21,6 +21,7 @@ gaudi_add_module(DetCRD
                          src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp
                          src/Tracker/SiTrackerStaggeredLadder_v02_geo.cpp
                          src/Tracker/SiTrackerComposite_v01_geo.cpp
+                         src/Tracker/SiTrackerComposite_v02_geo.cpp
                          src/Tracker/TPC_Simple_o1_v01.cpp
                          src/Tracker/TPC_ModularEndcap_o1_v01.cpp
 			 src/Tracker/SiTracker_itkbarrel_v01_geo.cpp
diff --git a/Detector/DetCRD/compact/CRD_common_v02/Beampipe_v01_06.xml b/Detector/DetCRD/compact/CRD_common_v02/Beampipe_v01_06.xml
new file mode 100644
index 00000000..465890f4
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v02/Beampipe_v01_06.xml
@@ -0,0 +1,348 @@
+<lccdd>
+  <info name="CRD" title="CRD Beam pipe" author="Chengdong Fu" url="no" status="development" version="1.0">
+    <comment>A beampipe for CRD</comment>
+  </info>
+
+  <display>
+    <vis name="TubeVis"   alpha="0.1" r="1.0" g="0.7"  b="0.5"   showDaughters="true"  visible="true"/>
+    <vis name="VacVis"   alpha="1.0" r="0.0" g="0.0"  b="0.0"   showDaughters="true"  visible="false"/>
+  </display>
+
+  <define>
+    <constant name="BeamPipe_Iron_thickness"        value="2.5*mm"/>
+    <constant name="BeamPipe_BeAl_zmin"             value="BeamPipe_CentralBe_zmax-2.5*mm"/>
+    <constant name="BeamPipe_BeAl_thickness1"       value="0.3*mm"/>
+    <constant name="BeamPipe_BeAl_thickness2"       value="0.5*mm"/>
+    <constant name="BeamPipe_Al_thickness3"         value="1.3*mm"/>
+    <constant name="BeamPipe_Cooling_zpos1"         value="96.0*mm"/>
+    <constant name="BeamPipe_Cooling_outer_radius1" value="11.2*mm"/>
+    <constant name="BeamPipe_Cooling_zpos2"         value="118.25*mm"/>
+    <constant name="BeamPipe_Cooling_zpos3"         value="162.8*mm"/>
+    <constant name="BeamPipe_Cooling_outer_radius3" value="13.5*mm"/>
+    <constant name="BeamPipe_Cooling_zpos4"         value="168.4*mm"/>
+    <constant name="BeamPipe_Al_thickness4"         value="1.5*mm"/>
+    <constant name="BeamPipe_Cooling_zpos5"         value="177.35*mm"/>
+    <constant name="BeamPipe_Cooling_outer_radius5" value="19.0*mm"/>
+    <constant name="BeamPipe_Cooling_zpos6"         value="BeamPipe_CentralAl_zmax"/>
+    <constant name="BeamPipe_CablePipe_thickness1"  value="1.5*mm"/>
+    <constant name="BeamPipe_CablePipe_thickness2"  value="1.6*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos0"          value="219.8*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos1"          value="222.8*mm"/>
+    <constant name="BeamPipe_CablePipe_inner_radius1"  value="12.8*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius1"  value="17.4*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos2"          value="240.0*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius2"  value="27.0*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos3"          value="250.0*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos4"          value="259.8*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius4"  value="27.4*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos5"          value="262.0*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos6"          value="372.5*mm"/>
+    <constant name="BeamPipe_CablePipe_inner_radius6"  value="27.9*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius6"  value="43.4*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos7"          value="386.5*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius7"  value="44.4*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos8"          value="388.5*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos9"          value="465.0*mm"/>
+    <constant name="BeamPipe_CablePipe_outer_radius9"  value="65.0*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos10"         value="470.0*mm"/>
+    <constant name="BeamPipe_CablePipe_inner_radius9"  value="45.5*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos11"         value="495.0*mm"/>
+    <constant name="BeamPipe_CablePipe_zpos12"         value="500.0*mm"/>
+  </define>
+
+  <detectors>        
+    <detector name="BeamPipe" type="CRDBeamPipe_v01" vis="VacVis" printLevel="ERROR">
+      <parameter crossingangle="CrossingAngle" />
+      <envelope>
+	<shape type="Assembly"/>
+      </envelope>
+
+      <type_flags type="DetType_BEAMPIPE"/>
+
+      <section type ="Center" name="IPInnerTube" zStart="0" zEnd="BeamPipe_BeAl_zmin" rStart="0">
+	<layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+	<layer material="G4_Be" thickness="BeamPipe_Be_inner_thickness" vis="TubeVis"/>
+	<layer material="G4_WATER" thickness="BeamPipe_Cooling_thickness" vis="GrayVis"/>
+	<layer material="G4_Be" thickness="BeamPipe_Be_outer_thickness" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeAlLinker" zStart="BeamPipe_BeAl_zmin" zEnd="BeamPipe_CentralBe_zmax" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Be" thickness="BeamPipe_Be_inner_thickness/2" vis="TubeVis"/>
+	<layer material="G4_Al" thickness="BeamPipe_Be_inner_thickness/2" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_thickness" vis="GrayVis"/>
+        <layer material="G4_Be" thickness="BeamPipe_Be_outer_thickness" vis="TubeVis"/>
+	<layer material="G4_Al" thickness="BeamPipe_BeAl_thickness1" thicknessEnd="BeamPipe_BeAl_thickness2" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling1" zStart="BeamPipe_CentralBe_zmax" zEnd="BeamPipe_Cooling_zpos1" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Be_inner_thickness" thicknessEnd="BeamPipe_BeAl_thickness2" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_thickness" thicknessEnd="BeamPipe_Be_inner_thickness+BeamPipe_Cooling_thickness+BeamPipe_Be_outer_thickness-BeamPipe_BeAl_thickness2" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Be_outer_thickness+BeamPipe_BeAl_thickness2" thicknessEnd="BeamPipe_BeAl_thickness2" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling2" zStart="BeamPipe_Cooling_zpos1" zEnd="BeamPipe_Cooling_zpos2" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_BeAl_thickness2" thicknessEnd="BeamPipe_Al_thickness3" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Be_inner_thickness+BeamPipe_Cooling_thickness+BeamPipe_Be_outer_thickness-BeamPipe_BeAl_thickness2"
+	       thicknessEnd="BeamPipe_Cooling_outer_radius3-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness3" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" thicknessEnd="BeamPipe_Al_thickness3" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling3" zStart="BeamPipe_Cooling_zpos2" zEnd="BeamPipe_Cooling_zpos3" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" vis="TubeVis"/>
+	<layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_outer_radius3-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness3" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling4" zStart="BeamPipe_Cooling_zpos3" zEnd="BeamPipe_Cooling_zpos4" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_outer_radius3-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness3"
+	       thicknessEnd="BeamPipe_Cooling_outer_radius5-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness4" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" thicknessEnd="BeamPipe_Al_thickness4" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling5" zStart="BeamPipe_Cooling_zpos4" zEnd="BeamPipe_Cooling_zpos5" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_outer_radius5-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness4" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness4" vis="TubeVis"/>
+      </section>
+      <section type ="Center" name="IPBeCooling6" zStart="BeamPipe_Cooling_zpos5" zEnd="BeamPipe_Cooling_zpos6" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Central_inner_radius" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness3" vis="TubeVis"/>
+        <layer material="G4_PARAFFIN" thickness="BeamPipe_Cooling_outer_radius5-BeamPipe_Central_inner_radius-BeamPipe_Al_thickness3-BeamPipe_Al_thickness4" thicknessEnd="0" vis="GrayVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness4" thicknessEnd="BeamPipe_Al_thickness-BeamPipe_Al_thickness3" vis="TubeVis"/>
+      </section>
+      <section type="Waist" name="Waist1st" zStart="BeamPipe_CentralAl_zmax" zEnd="BeamPipe_ExpandAl_zmax" rStart="BeamPipe_Central_inner_radius" size="BeamPipe_FirstExpand_width">
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness" vis="TubeVis"/>
+      </section>
+      <!-- cable pipe-->
+      <section type="CenterSide" name="IPCablePipeFront" zStart="BeamPipe_CablePipe_zpos0" zEnd="BeamPipe_CablePipe_zpos1" rStart="BeamPipe_CablePipe_inner_radius1">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_inner_radius1" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe1" zStart="BeamPipe_CablePipe_zpos1" zEnd="BeamPipe_CablePipe_zpos2" rStart="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness1">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe2" zStart="BeamPipe_CablePipe_zpos2" zEnd="BeamPipe_CablePipe_zpos3" rStart="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness1">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_outer_radius2-BeamPipe_CablePipe_outer_radius1+BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe3" zStart="BeamPipe_CablePipe_zpos3" zEnd="BeamPipe_CablePipe_zpos4" rStart="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness1">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+	<layer material="Air" thickness="BeamPipe_CablePipe_outer_radius2-BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe4" zStart="BeamPipe_CablePipe_zpos4" zEnd="BeamPipe_CablePipe_zpos5" rStart="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness1">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius2-BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness2"
+	       thicknessEnd="BeamPipe_CablePipe_outer_radius4-BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2+BeamPipe_CablePipe_outer_radius4-BeamPipe_CablePipe_outer_radius2"
+	       thicknessEnd="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe5" zStart="BeamPipe_CablePipe_zpos5" zEnd="BeamPipe_CablePipe_zpos6"
+	       rStart="BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness1" rEnd="BeamPipe_CablePipe_inner_radius6">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius4-BeamPipe_CablePipe_outer_radius1-BeamPipe_CablePipe_thickness2"
+	       thicknessEnd="BeamPipe_CablePipe_outer_radius6-BeamPipe_CablePipe_inner_radius6-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe6" zStart="BeamPipe_CablePipe_zpos6" zEnd="BeamPipe_CablePipe_zpos7" rStart="BeamPipe_CablePipe_inner_radius6">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius6-BeamPipe_CablePipe_inner_radius6-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe7" zStart="BeamPipe_CablePipe_zpos7" zEnd="BeamPipe_CablePipe_zpos8" rStart="BeamPipe_CablePipe_inner_radius6">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius6-BeamPipe_CablePipe_inner_radius6-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2"
+	       thicknessEnd="BeamPipe_CablePipe_outer_radius7-BeamPipe_CablePipe_inner_radius6-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2+BeamPipe_CablePipe_outer_radius7-BeamPipe_CablePipe_outer_radius6"
+	       thicknessEnd="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe8" zStart="BeamPipe_CablePipe_zpos8" zEnd="BeamPipe_CablePipe_zpos9"
+	       rStart="BeamPipe_CablePipe_inner_radius6" rEnd="BeamPipe_CablePipe_inner_radius9">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius7-BeamPipe_CablePipe_inner_radius6-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2"
+               thicknessEnd="BeamPipe_CablePipe_outer_radius9-BeamPipe_CablePipe_inner_radius9-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe9" zStart="BeamPipe_CablePipe_zpos9" zEnd="BeamPipe_CablePipe_zpos10" rStart="BeamPipe_CablePipe_inner_radius9">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness1" vis="TubeVis"/>
+        <layer material="Air" thickness="BeamPipe_CablePipe_outer_radius9-BeamPipe_CablePipe_inner_radius9-BeamPipe_CablePipe_thickness1-BeamPipe_CablePipe_thickness2" vis="VacVis"/>
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_thickness2" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe10" zStart="BeamPipe_CablePipe_zpos10" zEnd="BeamPipe_CablePipe_zpos11" rStart="BeamPipe_CablePipe_inner_radius9">
+        <layer material="G4_Al" thickness="BeamPipe_CablePipe_outer_radius9-BeamPipe_CablePipe_inner_radius9" vis="TubeVis"/>
+      </section>
+      <section type="CenterSide" name="IPCablePipe11" zStart="BeamPipe_CablePipe_zpos11" zEnd="BeamPipe_CablePipe_zpos12" rStart="BeamPipe_CablePipe_inner_radius9">
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness" vis="TubeVis"/>
+      </section>
+      <!-- end -->
+      <section type="Runway" name="Waist2nd" zStart="BeamPipe_ExpandAl_zmax" zEnd="BeamPipe_Linker_zmin" rStart="BeamPipe_Central_inner_radius" size="BeamPipe_FirstExpand_width">
+        <layer material="G4_Al" thickness="BeamPipe_Al_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Runway" name="Waist3rd" zStart="BeamPipe_Linker_zmin" zEnd="BeamPipe_Linker_zmax" rStart="BeamPipe_Central_inner_radius" size="BeamPipe_FirstExpand_width">
+        <layer material="G4_Cu" thickness="BeamPipe_ThinCu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Runway" name="Waist4th" zStart="BeamPipe_Linker_zmax" zEnd="BeamPipe_Waist_zmax" rStart="BeamPipe_Central_inner_radius" size="BeamPipe_FirstExpand_width"
+	       shift="BeamPipe_SecondExpand_width-BeamPipe_FirstExpand_width">
+        <layer material="G4_Cu" thickness="BeamPipe_ThinCu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Crotch" name="Fork" zStart="BeamPipe_Waist_zmax" zEnd="BeamPipe_Crotch_zmax"
+	       rStart="BeamPipe_Central_inner_radius" rEnd="BeamPipe_Central_inner_radius" size="BeamPipe_SecondExpand_width">
+        <layer material="G4_Cu" thickness="BeamPipe_ThinCu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="FirstDoublePipe" zStart="BeamPipe_Crotch_zmax" zEnd="BeamPipe_FirstSeparated_zmax" rStart="0">
+	<layer material="beam" thickness="BeamPipe_Fork_inner_radius" vis="VacVis"/>
+	<layer material="G4_Cu" thickness="BeamPipe_ThinCu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="BeforeMask" zStart="BeamPipe_FirstSeparated_zmax" zEnd="BeamPipe_Mask_zmin" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Fork_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="Mask" zStart="BeamPipe_Mask_zmin" zEnd="BeamPipe_Mask_zmax" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Mask_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness+BeamPipe_Fork_inner_radius-BeamPipe_Mask_inner_radius" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="SecondDoublePipe" zStart="BeamPipe_Mask_zmax" zEnd="BeamPipe_Q1a_zmin" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Fork_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="Q1a" zStart="BeamPipe_Q1a_zmin" zEnd="BeamPipe_Q1a_zmax" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Q1a_inner_radius" vis="VacVis"/>
+	<layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+        <layer material="stainless_steel" thickness="BeamPipe_Iron_thickness" vis="TubeVis"/>
+        <layer material="CrZrCu18150" thickness="6.0*mm" vis="MagentaVis"/>
+        <layer material="stainless_steel" thickness="8.0*mm" vis="ShellVis"/>
+      </section>
+      <section type="Legs" name="Q1Linker" zStart="BeamPipe_Q1a_zmax" zEnd="BeamPipe_Q1b_zmin" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Q1a_inner_radius" thicknessEnd="BeamPipe_Q1b_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="Q1b" zStart="BeamPipe_Q1b_zmin" zEnd="BeamPipe_Q1b_zmax" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Q1b_inner_radius" vis="VacVis"/>
+	<layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+        <layer material="stainless_steel" thickness="BeamPipe_Iron_thickness" vis="TubeVis"/>
+        <layer material="CrZrCu18150" thickness="6.0*mm" vis="MagentaVis"/>
+        <layer material="stainless_steel" thickness="8.0*mm" vis="ShellVis"/>
+      </section>
+      <section type="Legs" name="QF1Linker" zStart="BeamPipe_Q1b_zmax" zEnd="BeamPipe_QF1_zmin" rStart="0">
+        <layer material="beam" thickness="BeamPipe_Q1b_inner_radius" thicknessEnd="BeamPipe_QF1_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+      </section>
+      <section type="Legs" name="QF1" zStart="BeamPipe_QF1_zmin" zEnd="BeamPipe_QF1_zmax" rStart="0">
+        <layer material="beam" thickness="BeamPipe_QF1_inner_radius" vis="VacVis"/>
+	<layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+        <layer material="stainless_steel" thickness="BeamPipe_Iron_thickness" vis="TubeVis"/>
+        <layer material="CrZrCu18150" thickness="6.0*mm" vis="MagentaVis"/>
+        <layer material="stainless_steel" thickness="8.0*mm" vis="ShellVis"/>
+      </section>
+      <section type="Legs" name="Farest" zStart="BeamPipe_QF1_zmax" zEnd="BeamPipe_end_z" rStart="0">
+        <layer material="beam" thickness="BeamPipe_QF1_inner_radius" vis="VacVis"/>
+        <layer material="G4_Cu" thickness="BeamPipe_Cu_thickness" vis="TubeVis"/>
+      </section>
+
+      <!-- Magnets and their cooling, support -->
+      <section type="CenterSide" name="AntiSolenoid1" zStart="1160*mm" zEnd="1900*mm" rStart="90*mm">
+        <layer material="CrZrCu18150" thickness="20*mm" vis="MagentaVis"/>
+      </section>
+      <section type="CenterSide" name="AntiSolenoid2" zStart="1930*mm" zEnd="3964*mm" rStart="120*mm">
+        <layer material="CrZrCu18150" thickness="10*mm" vis="MagentaVis"/>
+      </section>
+      <section type="CenterSide" name="AntiSolenoid3" zStart="3970*mm" zEnd="7000*mm" rStart="185*mm">
+        <layer material="CrZrCu18150" thickness="10*mm" vis="MagentaVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetShell_Front" zStart="1110*mm" zEnd="1115*mm" rStart="50.0*mm">
+        <layer material="stainless_steel" thickness="91.25*mm" vis="ShellVis"/>
+	<layer material="G4_W" thickness="10*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetShell_FrontSide" zStart="1115*mm" zEnd="1900*mm" rStart="130.75*mm" rEnd="175*mm">
+        <layer material="stainless_steel" thickness="10.5*mm" thicknessEnd="65*mm" vis="ShellVis"/>
+	<layer material="G4_W" thickness="10*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetShell_CenterSide" zStart="1900*mm" zEnd="3800*mm" rStart="175*mm">
+        <layer material="stainless_steel" thickness="65*mm" vis="ShellVis"/>
+	<layer material="G4_W" thickness="10*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetShell_Linker" zStart="3800*mm" zEnd="3910*mm" rStart="175*mm">
+        <layer material="stainless_steel" thickness="135*mm" vis="ShellVis"/>
+	<layer material="G4_W" thickness="10*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetShell_RearSide" zStart="3910*mm" zEnd="7160*mm" rStart="240*mm">
+        <layer material="stainless_steel" thickness="70*mm" vis="ShellVis"/>
+	<layer material="G4_W" thickness="10*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_1" zStart="1130*mm" zEnd="1135*mm" rStart="75*mm">
+        <layer material="stainless_steel" thickness="50*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_2i" zStart="1135*mm" zEnd="1925*mm" rStart="75*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_2o" zStart="1135*mm" zEnd="1900*mm" rStart="120*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_3l" zStart="1900*mm" zEnd="1905*mm" rStart="120*mm">
+        <layer material="stainless_steel" thickness="25*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_3r" zStart="1925*mm" zEnd="1930*mm" rStart="75*mm">
+        <layer material="stainless_steel" thickness="35*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_4i" zStart="1930*mm" zEnd="4000*mm" rStart="105*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_4o" zStart="1905*mm" zEnd="3940*mm" rStart="140*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_5l" zStart="3940*mm" zEnd="3945*mm" rStart="140*mm">
+        <layer material="stainless_steel" thickness="70*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_5r" zStart="4000*mm" zEnd="4005*mm" rStart="105*mm">
+        <layer material="stainless_steel" thickness="70*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_6i" zStart="4005*mm" zEnd="7050*mm" rStart="170*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_6o" zStart="3945*mm" zEnd="7050*mm" rStart="205*mm">
+        <layer material="stainless_steel" thickness="5*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetSupport_7" zStart="7050*mm" zEnd="7055*mm" rStart="170*mm">
+        <layer material="stainless_steel" thickness="40*mm" vis="ShellVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_1l" zStart="1135*mm" zEnd="1160*mm" rStart="80*mm">
+        <layer material="lHe" thickness="40*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_1i" zStart="1160*mm" zEnd="1900*mm" rStart="80*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_1o" zStart="1160*mm" zEnd="1900*mm" rStart="110*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_1r" zStart="1900*mm" zEnd="1925*mm" rStart="80*mm">
+        <layer material="lHe" thickness="40*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_2l" zStart="1905*mm" zEnd="1930*mm" rStart="120*mm">
+        <layer material="lHe" thickness="20*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_2i" zStart="1925*mm" zEnd="3964*mm" rStart="110*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_2o" zStart="1930*mm" zEnd="3945*mm" rStart="130*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_2r1" zStart="3964*mm" zEnd="4000*mm" rStart="110*mm">
+        <layer material="lHe" thickness="65*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_2r2" zStart="3945*mm" zEnd="3964*mm" rStart="130*mm">
+        <layer material="lHe" thickness="45*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_3l" zStart="3945*mm" zEnd="3970*mm" rStart="175*mm">
+        <layer material="lHe" thickness="30*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_3i" zStart="3970*mm" zEnd="7000*mm" rStart="175*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_3o" zStart="3970*mm" zEnd="7000*mm" rStart="195*mm">
+        <layer material="lHe" thickness="10*mm" vis="BlueVis"/>
+      </section>
+      <section type="CenterSide" name="MagnetCooling_3r" zStart="7000*mm" zEnd="7050*mm" rStart="175*mm">
+        <layer material="lHe" thickness="30*mm" vis="BlueVis"/>
+      </section>
+    </detector>
+  </detectors>        
+</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml b/Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml
new file mode 100644
index 00000000..1fea5860
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml
@@ -0,0 +1,164 @@
+<lccdd>
+  <info name="VXD_Stitching_v01_02"
+        title="CepC VXD with stitch module"
+        author=""
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <comment>CepC vertex detector</comment>
+  </info>
+  <define>
+    <constant name="VXD_inner_radius" value="Vertex_inner_radius"/>
+    <constant name="VXD_outer_radius" value="Vertex_outer_radius"/>
+    <constant name="VXD_half_length"  value="Vertex_half_length"/>
+    <constant name="VXDLayer3_length" value="749*mm" />
+    <constant name="VXD_sensor_backbone"   value="0.055*mm"/>
+    <constant name="VXD_sensor_switches"   value="0.019*mm"/>
+    <constant name="VXD_sensor_bias"   value="0.106*mm"/>
+    <constant name="VXD_sensor_periphery"   value="0.177*mm"/>
+  </define>
+
+  <detectors>
+    <detector id="DetID_VXD" name="VXD" type="SiTrackerComposite_v02" vis="VXDVis" readout="VXDCollection" insideTrackingVolume="true" printLevel="INFO">
+      <envelope>
+        <shape type="Assembly"/>
+      </envelope>
+
+      <type_flags type="DetType_TRACKER + DetType_BARREL + DetType_PIXEL "/>
+
+      <global sensitive_thickness="VXD_sensitive_thickness" support_thickness="VXD_support_thickness" sensor_length="VXD_sensor_length"
+              sensitive_mat="G4_Si" support_mat="G4_C" sensitive_threshold_KeV="64*keV"  />
+      <display ladder="SeeThrough" support="VXDSupportVis" flex="VXDFlexVis" sens_env="SeeThrough" sens="GrayVis" deadsensor="GreenVis" deadwire="RedVis"/>
+
+      <shell rmin="70*mm" rmax="72.5*mm" zhalf="510*mm" material="CFRP_CMS" vis="LightGrayVis"/>
+
+      <layer id="0" phi0="0" isBent="true">
+	<module offset="0" phi="0" radius="11.06254*mm" nx="48" ny="4" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="45*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+	  <driver thickness="50*um" width="1.385*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+
+	<module offset="0" phi="180*degree" radius="11.06254*mm" nx="48" ny="4" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="45*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="1.385*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+      </layer>
+
+      <layer id="1" phi0="11.4375*degree" isBent="true">
+	<module offset="0" phi="0" radius="16.56198*mm" nx="72" ny="6" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="32*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="1.385*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+
+        <module offset="0" phi="180*degree" radius="16.56198*mm" nx="72" ny="6" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="32*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="1.385*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+      </layer>
+
+      <layer id="2" phi0="-1.6875*degree" isBent="true">
+	<module offset="0" phi="0" radius="22.06142*mm" nx="96" ny="8" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+	  <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="31*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="4.155*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+
+        <module offset="0" phi="180*degree" radius="22.06142*mm" nx="96" ny="8" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="31*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="4.155*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+      </layer>
+
+      <layer id="3" phi0="-6.75*degree" isBent="true">
+	<module offset="0" phi="0" radius="27.56086*mm" nx="120" ny="10" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+            <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="29*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="4.155*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+
+        <module offset="0" phi="180*degree" radius="27.56086*mm" nx="120" ny="10" backbone="VXD_sensor_backbone" switches="VXD_sensor_switches" bias="VXD_sensor_bias" periphery="VXD_sensor_periphery" mechanical_gap="0.5*mm" material="G4_Si">
+          <sensor thickness="50*um" width="8.409*mm" length="3.296*mm" material="G4_Si" vis="VXDVis"/>
+          <flex vis="GrayVis">
+	    <slice thickness="0.4*um" material="G4_Al"/>
+            <slice thickness="29*um" material="CFRP_CMS"/>
+          </flex>
+          <readout thickness="50*um" width="4.155*mm" material="Kapton" vis="RedVis"/>
+          <driver thickness="50*um" width="4.155*mm" material="Kapton" vis="BlueVis"/>
+        </module>
+      </layer>
+
+      <layer id="4" ladder_radius="43.792*mm" ladder_offset="(8.7+11.7)*mm" n_ladders="25" n_sensors_per_side="0">
+        <ladder isDoubleSided="true">
+          <ladderSupport height="3.2*mm" length="VXDLayer3_length" thickness="370*um" width="17.4*mm" mat="CFRP_CMS"/>
+          <flex>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/> <!--glue between flex and sensor/support-->
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness=" 8.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="13.0*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness=" 8.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="13.0*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness="12.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="25.0*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness="12.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness="13.0*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness=" 8.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness="13.0*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness=" 8.0*um" width="17.4*mm" mat="G4_Al"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Kapton"/>
+            <slice length="VXDLayer3_length" thickness="12.5*um" width="17.4*mm" mat="Acrylicglue"/> <!--glue between flex and sensor/support-->
+          </flex>
+          <sensor n_sensors="29" gap="0.1*mm" thickness="50*um" active_length="25.6*mm" active_width="12.8*mm" dead_width="2*mm" sensor_mat="G4_Si"
+                  deadwire_length="(29*(25.6+0.1)-0.1)*mm" deadwire_width="2.6*mm" deadwire_thickness="(50/10)*um" deadwire_mat="G4_Al"/>
+        </ladder>
+      </layer>
+    </detector>
+  </detectors>
+  
+  <readouts>
+    <readout name="VXDCollection">
+      <!--segmentation type="CartesianGridYZ" grid_size_y="0.016*mm" grid_size_z="0.016*mm"/>
+      <id>system:5,side:-2,layer:9,module:8,sensor:32:8,y:-12,z:-12</id-->
+      <!-- old tracking not use senor id: 24-31 bit-->
+      <id>system:5,side:-2,layer:9,module:8,sensor:32:16</id>
+    </readout>
+  </readouts>
+</lccdd>
diff --git a/Detector/DetCRD/compact/README.md b/Detector/DetCRD/compact/README.md
index 7d876e62..2885e745 100644
--- a/Detector/DetCRD/compact/README.md
+++ b/Detector/DetCRD/compact/README.md
@@ -24,7 +24,7 @@ The following CRD detector models are available in CEPCSW
 | CRD_o1_v04    | smaller center beam pipe     | SIT+DC+SET  | crystal | RPC  | developing     |
 | CRD_o1_v05    | Use Ref-Det ECAL and HCAL    | SIT+TPC+SET | crystal | Glass| developing     |
 | ------------- | -----------------------------|-------------|---------|------|----------------|
-| TDR_o1_v01    | long barrel vertex,  TPC     | SIT+TPC+SET | crystal | Glass| developing     |
+| TDR_o1_v01    | stitching and planar VXD, TPC| ITK+TPC+OTK | crystal | Glass| developing     |
 | TDR_o1_v02    | short barrel vertex, TPC     | SIT+TPC+SET | crystal | Glass| developing     |
 | TDR_o2_v01    | long barrel vertex,  DC      | SIT+DC +SET | crystal | Glass| developing     |
 | TDR_o2_v02    | short barrel vertex, DC      | SIT+DC +SET | crystal | Glass| developing     |
diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyTracker.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyTracker.xml
index 9dbc26d9..34a822bc 100644
--- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyTracker.xml
+++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01-onlyTracker.xml
@@ -26,10 +26,10 @@
 
   <include ref="./TDR_Dimensions_v01_01.xml"/>
 
-  <include ref="../CRD_common_v02/Beampipe_v01_05.xml"/>
+  <include ref="../CRD_common_v02/Beampipe_v01_06.xml"/>
   <!--preliminary vertex and tracker, to update/-->
   <!--include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/-->
-  <include ref="../CRD_common_v02/VXD_Composite_v01_01.xml"/>
+  <include ref="../CRD_common_v02/VXD_Composite_v01_02.xml"/>
   <include ref="../CRD_common_v02/FTD_SkewRing_v01_07.xml"/>
   <!--include ref="../CRD_common_v02/SIT_SimplePixel_v01_04.xml"/-->
   <include ref="../CRD_common_v02/SIT_StaggeredStave_v02.xml"/>
diff --git a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
index 881750ac..53eb9aa3 100644
--- a/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
+++ b/Detector/DetCRD/compact/TDR_o1_v01/TDR_o1_v01.xml
@@ -27,10 +27,10 @@
 
   <include ref="./TDR_Dimensions_v01_01.xml"/>
 
-  <include ref="../CRD_common_v02/Beampipe_v01_05.xml"/>
+  <include ref="../CRD_common_v02/Beampipe_v01_06.xml"/>
   <!--preliminary vertex and tracker, to update/-->
   <!--include ref="../CRD_common_v02/VXD_StaggeredLadder_v02_01.xml"/-->
-  <include ref="../CRD_common_v02/VXD_Composite_v01_01.xml"/>
+  <include ref="../CRD_common_v02/VXD_Composite_v01_02.xml"/>
   <include ref="../CRD_common_v02/FTD_SkewRing_v01_07.xml"/>
   <!--include ref="../CRD_common_v02/SIT_SimplePixel_v01_04.xml"/-->
   <include ref="../CRD_common_v02/SIT_StaggeredStave_v02.xml"/>
diff --git a/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py b/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
index 3f91a8f4..daacc154 100644
--- a/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
+++ b/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
@@ -73,8 +73,8 @@ ftdhitname  = "FTDTrackerHits"
 ftdspname   = "FTDSpacePoints"
 from Configurables import SmearDigiTool
 vxdtool = SmearDigiTool("VXD")
-vxdtool.ResolutionU = [0.004, 0.004, 0.004, 0.004, 0.004, 0.004]
-vxdtool.ResolutionV = [0.004, 0.004, 0.004, 0.004, 0.004, 0.004]
+vxdtool.ResolutionU = [0.005]
+vxdtool.ResolutionV = [0.005]
 vxdtool.UsePlanarTag = True
 vxdtool.ParameterizeResolution = False
 vxdtool.ParametersU = [5.60959e-03, 5.74913e-03, 7.03433e-03, 1.99516, -663.952, 3.752e-03, 0, -0.0704734, 0.0454867e-03, 1.07359]
@@ -114,8 +114,8 @@ digiSET.IsStrip = False
 digiSET.SimTrackHitCollection = "OTKBarrelCollection"
 digiSET.TrackerHitCollection = sethitname
 digiSET.TrackerHitAssociationCollection = "OTKBarrelTrackerHitAssociation"
-digiSET.ResolutionU = [0.005]
-digiSET.ResolutionV = [0.021]
+digiSET.ResolutionU = [0.010]
+digiSET.ResolutionV = [1.000]
 digiSET.UsePlanarTag = True
 digiSET.ParameterizeResolution = False
 digiSET.ParametersU = [2.29655e-03, 0.965899e-03, 0.584699e-03, 17.0856, 84.566, 12.4695e-03, -0.0643059, 0.168662, 1.87998e-03, 0.514452]
diff --git a/Detector/DetCRD/src/Tracker/SiTrackerComposite_v02_geo.cpp b/Detector/DetCRD/src/Tracker/SiTrackerComposite_v02_geo.cpp
new file mode 100644
index 00000000..35848cb3
--- /dev/null
+++ b/Detector/DetCRD/src/Tracker/SiTrackerComposite_v02_geo.cpp
@@ -0,0 +1,558 @@
+//====================================================================
+//  cepcgeo - CEPC silicon detector models in DD4hep 
+//--------------------------------------------------------------------
+//  Chengdong FU and Tianyuan ZHANG, IHEP
+//  email: fucd@ihep.ac.cn
+//  $Id$
+//====================================================================
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/DD4hepUnits.h"
+#include "DD4hep/DetType.h"
+#include "DD4hep/Printout.h"
+#include "DDRec/Surface.h"
+#include "DDRec/DetectorData.h"
+#include "XML/Utilities.h"
+#include <cmath>
+
+#include "DetIdentifier/CEPCDetectorData.h"
+
+using namespace std;
+
+using dd4hep::Box;
+using dd4hep::Tube;
+using dd4hep::DetElement;
+using dd4hep::Material;
+using dd4hep::Position;
+using dd4hep::RotationY;
+using dd4hep::RotationZ;
+using dd4hep::RotationZYX;
+using dd4hep::Transform3D;
+using dd4hep::Rotation3D;
+using dd4hep::Volume;
+using dd4hep::_toString;
+using dd4hep::rec::volSurfaceList;
+using dd4hep::rec::ZPlanarData;
+using dd4hep::mm;
+
+/** Construction of the VXD detector, ported from Mokka driver SIT_Simple_Pixel.cc
+ *
+ *  Mokka History:
+ *  Feb 7th 2011, Steve Aplin - original version
+ *  F.Gaede, DESY, Jan 2014   - dd4hep SIT pixel
+ *  Hao Zeng, IHEP, July 2021
+ *  Chengdong FU, IHEP, Sep 2024 - composite from SiTrackerStaggeredLadder_v02 and SiTrackerStitching_v01
+ *  Tianyuan ZHANG, IHEP, Dec 2024 - add sensor detail based on SiTrackerComposite_v01
+ */
+
+static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4hep::SensitiveDetector sens) {
+
+  xml_det_t  x_det    = e;
+  Material   air      = theDetector.air();
+  int        det_id   = x_det.id();
+  string     name     = x_det.nameStr();
+  DetElement det(name, det_id);
+
+  Volume envelope = dd4hep::xml::createPlacedEnvelope(theDetector, e, det);
+  dd4hep::xml::setDetectorTypeFlag(e, det) ;
+  if(theDetector.buildType()==dd4hep::BUILD_ENVELOPE) return det;
+  envelope.setVisAttributes(theDetector.visAttributes("SeeThrough"));
+
+  dd4hep::PrintLevel printLevel = dd4hep::ERROR;
+  if (x_det.hasAttr(_Unicode(printLevel))) {
+    printLevel = dd4hep::printLevel(x_det.attr<string>(_Unicode(printLevel)));
+  }
+  dd4hep::PrintLevel oldLevel = dd4hep::setPrintLevel(printLevel);
+
+  if (x_det.hasChild(_U(sensitive))) {
+    xml_dim_t sd_typ = x_det.child(_U(sensitive));
+    sens.setType(sd_typ.typeStr());
+  }
+  else {
+    sens.setType("tracker");
+  }
+
+  dd4hep::printout(dd4hep::INFO, "Construct", "** building SiTrackerComposite_v02 ...");
+
+  dd4hep::rec::CompositeData* compositeData = new dd4hep::rec::CompositeData;
+
+  //fetch the display parameters
+  xml_comp_t x_display(x_det.child(_Unicode(display)));
+  std::string ladderVis      = x_display.attr<string>(_Unicode(ladder));
+  std::string supportVis     = x_display.attr<string>(_Unicode(support));
+  std::string flexVis        = x_display.attr<string>(_Unicode(flex));
+  std::string sensEnvVis     = x_display.attr<string>(_Unicode(sens_env));
+  std::string sensVis        = x_display.attr<string>(_Unicode(sens));
+  std::string deadsensVis    = x_display.attr<string>(_Unicode(deadsensor));
+  std::string deadwireVis    = x_display.attr<string>(_Unicode(deadwire));
+
+  //fetch the shell parameters
+  if (x_det.hasChild(_Unicode(shell))) {
+    xml_comp_t x_shell(x_det.child(_Unicode(shell)));
+    double rmin_shell = x_shell.rmin();
+    double rmax_shell = x_shell.rmax();
+    double zhalf_shell = x_shell.zhalf();
+    Tube shellSolid(rmin_shell, rmax_shell, zhalf_shell);
+    Volume shellLogical(name + "_ShellLogical", shellSolid, theDetector.material(x_shell.materialStr()));
+    shellLogical.setVisAttributes(theDetector.visAttributes(x_shell.visStr()));
+    envelope.placeVolume(shellLogical);
+
+    compositeData->zHalfShell  = zhalf_shell;
+    compositeData->rInnerShell = rmin_shell;
+    compositeData->rOuterShell = rmax_shell;
+  }
+
+  for(xml_coll_t layer_i(x_det,_U(layer)); layer_i; ++layer_i){
+    xml_comp_t x_layer(layer_i);
+   
+    dd4hep::PlacedVolume pv;
+    int layer_id                 = x_layer.id();
+    bool isBent = false;
+    if (x_layer.hasAttr(_Unicode(isBent))) isBent = x_layer.attr<bool>(_Unicode(isBent));
+
+    dd4hep::printout(dd4hep::INFO, "Construct", "layer_id: %02d --- %s", layer_id, isBent ? "Stitching" : "Planar");
+
+    double z = x_layer.hasAttr(_U(z)) ? x_layer.z() : 0;
+
+    if (isBent) {
+      double phi0 = x_layer.phi0();
+
+      dd4hep::rec::CylindricalData::LayerLayout thisLayer;
+
+      int module_id = 0;
+      for (xml_coll_t module_i(x_layer, _U(module)); module_i; ++module_i) {
+	if (module_id>1) dd4hep::printout(dd4hep::ERROR, "Construct", "Not support more than two modules, possible wrong in reconstruction");
+
+	string name_module = name + dd4hep::_toString(layer_id, "_Layer%02d") + dd4hep::_toString(module_id, "_Stave%02d");
+	DetElement moduleDE(det, name_module, x_det.id());
+
+	xml_comp_t x_module(module_i);
+
+	double offset = x_module.offset();
+	double phi    = x_module.phi();
+
+	double radius = x_module.radius();
+	double backbone = x_module.attr<double>(_Unicode(backbone));
+	double switches = x_module.attr<double>(_Unicode(switches));
+	double bias = x_module.attr<double>(_Unicode(bias));
+	double periphery = x_module.attr<double>(_Unicode(periphery));
+	double mechanical_gap = x_module.attr<double>(_Unicode(mechanical_gap));
+	int nx = x_module.attr<int>(_Unicode(nx));
+	int ny = x_module.attr<int>(_Unicode(ny));
+	Material mat = theDetector.material(x_module.materialStr());
+
+	xml_comp_t x_sensor(x_module.child(_U(sensor)));
+	double sensor_thickness = x_sensor.thickness();
+	double sensor_width     = x_sensor.width();
+	double sensor_length    = x_sensor.length();
+	double sensor_dphi      = sensor_width/radius;
+	Material sensor_mat     = theDetector.material(x_sensor.materialStr());
+
+	Tube sensor_solid(radius, radius+sensor_thickness, sensor_length/2, -sensor_width/radius/2, sensor_width/radius/2);
+	Volume sensor_volume(name_module + "Sensor", sensor_solid, sensor_mat);
+	sensor_volume.setSensitiveDetector(sens);
+	if (x_det.hasAttr(_U(limits))) sensor_volume.setLimitSet(theDetector, x_det.limitsStr());
+	sensor_volume.setVisAttributes(theDetector.visAttributes(x_sensor.visStr()));
+
+	xml_comp_t x_flex(x_module.child(_Unicode(flex)));
+	std::vector<std::pair<double, Material> > flexs;
+	double flex_thickness = 0;
+	for (xml_coll_t slice_i(x_flex, _U(slice)); slice_i; ++slice_i) {
+	  xml_comp_t x_slice(slice_i);
+	  double thickness   = x_slice.thickness();
+	  Material mat_slice = theDetector.material(x_slice.materialStr());
+	  flexs.push_back(std::make_pair(thickness, mat_slice));
+	  flex_thickness += thickness;
+	  dd4hep::printout(dd4hep::DEBUG, "Construct", "flex %s: %f mm", mat_slice.name(), thickness/dd4hep::mm);
+	}
+	double flex_width  = (sensor_width+periphery)*ny + bias*ny/2;
+	double flex_length = (sensor_length+switches)*nx + backbone*nx/3 + mechanical_gap;
+	double flex_radius = radius+sensor_thickness;
+	double flex_dphi   = flex_width/radius;
+	Tube flex_solid(flex_radius, flex_radius+flex_thickness, flex_length/2, -flex_dphi/2, flex_dphi/2);
+	Volume flex_volume(name_module + "Flex", flex_solid, air);
+	flex_volume.setVisAttributes(theDetector.visAttributes(x_flex.visStr()));
+	double start_radius = flex_radius;
+	for (unsigned islice=0; islice<flexs.size(); islice++) {
+	  dd4hep::printout(dd4hep::DEBUG, "Construct", "flex start radius: %f mm", start_radius/dd4hep::mm);
+	  Tube slice_solid(start_radius, start_radius+flexs[islice].first, flex_length/2, -flex_dphi/2, flex_dphi/2);
+	  Volume slice_volume(name_module + dd4hep::_toString(int(islice), "Flex_%d"), slice_solid, flexs[islice].second);
+	  flex_volume.placeVolume(slice_volume);
+	  start_radius += flexs[islice].first;
+	}
+
+	double service_radius = radius + sensor_thickness;
+
+	// in fact driver, the left impact as name of readout
+	xml_comp_t x_readout(x_module.child(_Unicode(readout)));
+	double readout_thickness = x_readout.thickness();
+	double readout_length = x_readout.width();
+	double readout_width  = flex_width;
+	double readout_dphi  = readout_width/radius;
+	Material readout_mat = theDetector.material(x_readout.materialStr());
+	Tube readout_solid(service_radius, service_radius+readout_thickness, readout_length/2, -flex_dphi/2, flex_dphi/2);
+	Volume readout_volume(name_module + "DriverL", readout_solid, readout_mat);
+	readout_volume.setVisAttributes(theDetector.visAttributes(x_readout.visStr()));
+
+	xml_comp_t x_driver(x_module.child(_Unicode(driver)));
+        double driver_thickness = x_driver.thickness();
+        double driver_length = x_driver.width();
+        double driver_width  = flex_width;
+        double driver_dphi  = driver_width/radius;
+        Material driver_mat = theDetector.material(x_driver.materialStr());
+        Tube driver_solid(service_radius, service_radius+driver_thickness, driver_length/2, -flex_dphi/2, flex_dphi/2);
+        Volume driver_volume(name_module + "DriverR", driver_solid, driver_mat);
+        driver_volume.setVisAttributes(theDetector.visAttributes(x_driver.visStr()));
+
+	double module_length = flex_length + readout_length + driver_length;
+	double module_width  = flex_width;
+	double module_dphi   = module_width/radius;
+	double module_thickness = sensor_thickness + std::max(flex_thickness, std::max(readout_thickness,driver_thickness));
+	Tube module_solid(radius, radius+module_thickness, module_length/2, -flex_dphi/2, flex_dphi/2);
+	Volume module_volume(name_module, module_solid, air);
+	module_volume.setVisAttributes(theDetector.visAttributes("SeeThrough"));
+
+	Tube board_solid(radius, radius+sensor_thickness, module_length/2, -flex_dphi/2, flex_dphi/2);
+	Volume board_volume(name_module + "Board", board_solid, mat);
+	board_volume.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
+	module_volume.placeVolume(board_volume);
+
+	double z_bent = 0.0;
+	double delta = 0.0;
+	for (int ix = 0; ix < nx; ix++) {
+	    if (ix < nx / 2) {
+		z_bent = -flex_length/2 + sensor_length/2 + (static_cast<int>(ix/3) + 1)*backbone + ix*(sensor_length + switches);
+	    }
+	    else {
+		z_bent = -flex_length/2 + sensor_length/2 + (static_cast<int>(ix/3) + 1)*backbone + ix*(sensor_length + switches) + mechanical_gap;
+	    }
+	    for (int iy = 0; iy < ny; iy++) {
+	        if (iy % 2 != 0) {
+		    delta = -flex_dphi/2 + sensor_dphi/2 + iy*(sensor_dphi + periphery/radius) + ((iy + 1)/2)*bias/radius;
+	        }
+	        else {
+		    delta = -flex_dphi/2 + sensor_dphi/2 + iy*sensor_dphi + (iy + 1)*periphery / radius + iy/2*bias/radius;
+	        }
+		Transform3D tran(RotationZ(delta), Position(0, 0, z_bent));
+		dd4hep::PlacedVolume pv = board_volume.placeVolume(sensor_volume, tran);
+
+		int sensor_id = ix + nx*iy;
+		pv.addPhysVolID("sensor", sensor_id);
+		dd4hep::rec::Vector3D ocyl(radius + 0.5 * sensor_thickness, 0., 0.);
+		dd4hep::rec::VolCylinder surf(sensor_volume, dd4hep::rec::SurfaceType(dd4hep::rec::SurfaceType::Sensitive),
+		0.5 * sensor_thickness, module_thickness - 0.5 * sensor_thickness, ocyl);
+		DetElement sensorDE(moduleDE, name_module + dd4hep::_toString(sensor_id, "_Sensor%02d"), x_det.id());
+		sensorDE.setPlacement(pv);
+		volSurfaceList(sensorDE)->push_back(surf);
+	  }
+        }
+
+	module_volume.placeVolume(flex_volume, Position(0, 0, readout_length/2-driver_length/2));
+	module_volume.placeVolume(readout_volume, Position(0, 0, -flex_length/2-driver_length/2));
+	module_volume.placeVolume(driver_volume, Position(0, 0,  flex_length/2+readout_length/2));
+
+	if (module_id == 0) {
+	  thisLayer.zHalf              = flex_length/2.0;
+	  thisLayer.radiusSensitive    = radius;
+	  thisLayer.thicknessSensitive = sensor_thickness;
+	  thisLayer.radiusSupport      = flex_radius;
+	  thisLayer.thicknessSupport   = flex_thickness;
+	  //thisLayer.width              = flex_width;
+	  thisLayer.phi0 = phi0 + phi;
+	  thisLayer.rgap = radius;
+	}
+	else {
+	  thisLayer.rgap = radius - thisLayer.rgap;
+          thisLayer.dphi = phi0 + phi - thisLayer.phi0;
+        }
+
+	Transform3D tran(RotationZ(phi0+phi), Position(offset*cos(phi), offset*sin(phi), z));
+	pv = envelope.placeVolume(module_volume, tran);
+	pv.addPhysVolID("layer", layer_id).addPhysVolID("module", module_id);
+
+	moduleDE.setPlacement(pv);
+
+	module_id++;
+      }
+
+      compositeData->layersBent.push_back(thisLayer);
+    }
+    else {
+      double sensitive_radius      = x_layer.attr<double>(_Unicode(ladder_radius));
+      int n_sensors_per_ladder     = x_layer.attr<int>(_Unicode(n_sensors_per_side));
+      int n_ladders                = x_layer.attr<int>(_Unicode(n_ladders)) ;
+      double ladder_offset         = x_layer.attr<double>(_Unicode(ladder_offset));
+      double ladder_radius         = sqrt(ladder_offset*ladder_offset + sensitive_radius*sensitive_radius); 
+      double ladder_phi0           = -atan(ladder_offset/sensitive_radius);
+      dd4hep::printout(dd4hep::INFO, "Construct", "ladder_radius = %f mm, sensitive_radius = %f mm, n_sensors_per_ladder = %d", ladder_radius/mm, sensitive_radius/mm, n_sensors_per_ladder);
+
+      std::string layerName = dd4hep::_toString(layer_id , "layer_%02d");
+      dd4hep::Assembly layer_assembly(layerName);
+      pv = envelope.placeVolume(layer_assembly);
+      dd4hep::DetElement layerDE(det, layerName, x_det.id());
+      layerDE.setPlacement(pv);
+    
+      const double ladder_dphi = ( dd4hep::twopi / n_ladders ) ;
+      dd4hep::printout(dd4hep::DEBUG, "Construct", "ladder_dphi: %f (%f degree)", ladder_dphi, ladder_dphi/dd4hep::degree);
+    
+      //fetch the ladder parameters
+      xml_comp_t x_ladder(x_layer.child(_Unicode(ladder)));
+    
+      //fetch the ladder support parameters
+      xml_comp_t x_ladder_support(x_ladder.child(_Unicode(ladderSupport)));
+      double support_length        = x_ladder_support.attr<double>(_Unicode(length));
+      double support_thickness     = x_ladder_support.attr<double>(_Unicode(thickness));
+      double support_height        = x_ladder_support.attr<double>(_Unicode(height));
+      double support_width         = x_ladder_support.attr<double>(_Unicode(width));
+      Material support_mat;
+      if(x_ladder_support.hasAttr(_Unicode(mat))) {
+	support_mat = theDetector.material(x_ladder_support.attr<string>(_Unicode(mat)));
+      }
+      else {
+	support_mat = theDetector.material(x_ladder_support.materialStr());
+      }
+      dd4hep::printout(dd4hep::INFO, "Construct", "support_length = %f mm, support_thickness = %f mm, support_width = %f mm", support_length/mm, support_thickness/mm, support_width/mm);
+
+      //fetch the flex parameters
+      double flex_thickness(0);
+      double flex_width(0);
+      double flex_length(0);
+      xml_comp_t x_flex(x_ladder.child(_Unicode(flex)));
+      for(xml_coll_t flex_i(x_flex,_U(slice)); flex_i; ++flex_i) {
+	xml_comp_t x_flex_slice(flex_i);
+	double x_flex_slice_thickness = x_flex_slice.attr<double>(_Unicode(thickness));
+	double x_flex_slice_width = x_flex_slice.attr<double>(_Unicode(width));
+	double x_flex_slice_length = x_flex_slice.attr<double>(_Unicode(length));
+	flex_thickness += x_flex_slice_thickness;
+	if (x_flex_slice_width > flex_width) flex_width = x_flex_slice_width;
+	if (x_flex_slice_length > flex_length) flex_length = x_flex_slice_length;
+	dd4hep::printout(dd4hep::DEBUG, "Construct", "x_flex_slice_thickness: %f mm", x_flex_slice_thickness/mm);
+      }
+      dd4hep::printout(dd4hep::INFO, "Construct", "flex_length = %f mm, flex_thickness = %f mm, flex_width = %f mm", flex_length/mm, flex_thickness/mm, flex_width/mm);
+
+      //fetch the sensor parameters
+      xml_comp_t x_sensor(x_ladder.child(_Unicode(sensor)));
+      int n_sensors_per_side                  = x_sensor.attr<int>(_Unicode(n_sensors));
+      double dead_gap                         = x_sensor.attr<double>(_Unicode(gap));
+      double sensor_thickness                 = x_sensor.attr<double>(_Unicode(thickness));
+      double sensor_active_len                = x_sensor.attr<double>(_Unicode(active_length));
+      double sensor_active_width              = x_sensor.attr<double>(_Unicode(active_width));
+      double sensor_dead_width                = x_sensor.attr<double>(_Unicode(dead_width));
+      double sensor_deadwire_length           = x_sensor.attr<double>(_Unicode(deadwire_length));
+      double sensor_deadwire_width            = x_sensor.attr<double>(_Unicode(deadwire_width));
+      double sensor_deadwire_thickness        = x_sensor.attr<double>(_Unicode(deadwire_thickness));
+      Material sensor_mat                     = theDetector.material(x_sensor.attr<string>(_Unicode(sensor_mat)));
+      Material sensor_deadwire_mat            = theDetector.material(x_sensor.attr<string>(_Unicode(deadwire_mat)));
+
+      dd4hep::printout(dd4hep::INFO, "Construct", "sensor_active_length = %f mm, sensor_thickness = %f mm, sensor_active_width = %f mm", sensor_active_len/mm, sensor_thickness/mm, sensor_active_width/mm);
+      dd4hep::printout(dd4hep::INFO, "Construct", "sensor_dead_width = %f mm, dead_gap = %f mm, n_sensors_per_side = %d", sensor_dead_width/mm, dead_gap/mm, n_sensors_per_side);
+
+      //create ladder logical volume
+      Box LadderSolid((support_height+2*sensor_thickness+2*flex_thickness)/2.0, support_width/2.0, support_length/2.0);
+      Volume LadderLogical(name + dd4hep::_toString(layer_id, "_LadderLogical_%02d"), LadderSolid, air);
+      // create flex envelope logical volume
+      Box FlexEnvelopeSolid(flex_thickness/2.0, flex_width/2.0, flex_length/2.0);
+      Volume FlexEnvelopeLogical(name + dd4hep::_toString( layer_id, "_FlexEnvelopeLogical_%02d"), FlexEnvelopeSolid, air);
+      FlexEnvelopeLogical.setVisAttributes(theDetector.visAttributes("SeeThrough"));
+
+      //create the flex layers inside the flex envelope
+      double flex_start_height(-flex_thickness/2.); 
+      int index = 0;
+      for(xml_coll_t flex_i(x_flex,_U(slice)); flex_i; ++flex_i){
+	xml_comp_t x_flex_slice(flex_i);
+	double x_flex_slice_thickness = x_flex_slice.attr<double>(_Unicode(thickness));
+	double x_flex_slice_width = x_flex_slice.attr<double>(_Unicode(width));
+	double x_flex_slice_length = x_flex_slice.attr<double>(_Unicode(length));
+	Material x_flex_slice_mat;
+	if(x_flex_slice.hasAttr(_Unicode(mat))) {
+	  x_flex_slice_mat = theDetector.material(x_flex_slice.attr<string>(_Unicode(mat)));
+	}
+	else {
+	  x_flex_slice_mat = theDetector.material(x_flex_slice.materialStr());
+	}
+	// Material x_flex_slice_mat = theDetector.material(x_flex_slice.attr<string>(_Unicode(mat)));
+	Box FlexLayerSolid(x_flex_slice_thickness/2.0, x_flex_slice_width/2.0, x_flex_slice_length/2.0);
+	Volume FlexLayerLogical(name + dd4hep::_toString( layer_id, "_FlexLayerLogical_%02d") + dd4hep::_toString( index, "index_%02d"), FlexLayerSolid, x_flex_slice_mat);
+	FlexLayerLogical.setVisAttributes(theDetector.visAttributes(flexVis));
+	double flex_slice_height = flex_start_height + x_flex_slice_thickness/2.;
+	pv = FlexEnvelopeLogical.placeVolume(FlexLayerLogical, Position(flex_slice_height, 0., 0.));
+	flex_start_height += x_flex_slice_thickness;
+	index++;
+      }
+
+      //place the flex envelope inside the ladder envelope
+      pv = LadderLogical.placeVolume(FlexEnvelopeLogical, Position((support_height + flex_thickness)/2.0, 0., 0.)); //top side
+      //define the transformation3D(only need a combination of translation and rotation)
+      Transform3D tran_mirro(RotationZYX(0., dd4hep::twopi/2.0, 0.), Position(-(support_height + flex_thickness)/2.0, 0., 0.));
+      pv = LadderLogical.placeVolume(FlexEnvelopeLogical, tran_mirro); //bottom side
+
+      //create sensor envelope logical volume
+      Box SensorTopEnvelopeSolid(sensor_thickness/2.0, support_width/2.0, support_length/2.0);
+      Volume SensorTopEnvelopeLogical(name + dd4hep::_toString( layer_id, "_SensorEnvelopeLogical_%02d"), SensorTopEnvelopeSolid, air);
+      Box SensorBottomEnvelopeSolid(sensor_thickness/2.0, support_width/2.0, support_length/2.0);
+      Volume SensorBottomEnvelopeLogical(name + dd4hep::_toString(layer_id, "_SensorEnvelopeLogical_%02d"), SensorBottomEnvelopeSolid, air);
+      SensorTopEnvelopeLogical.setVisAttributes(theDetector.visAttributes(sensEnvVis));
+
+      //create sensor logical volume
+      Box SensorSolid(sensor_thickness/2.0, sensor_active_width/2.0, sensor_active_len/2.0);
+      Volume SensorTopLogical(name + dd4hep::_toString(layer_id+1, "_SensorLogical_%02d"), SensorSolid, sensor_mat);
+      Volume SensorBottomLogical(name + dd4hep::_toString(layer_id, "_SensorLogical_%02d"), SensorSolid, sensor_mat);
+      SensorTopLogical.setSensitiveDetector(sens);
+      SensorBottomLogical.setSensitiveDetector(sens);
+      if (x_det.hasAttr(_U(limits))) {
+	SensorTopLogical.setLimitSet(theDetector, x_det.limitsStr());
+	SensorBottomLogical.setLimitSet(theDetector, x_det.limitsStr());
+      }
+      SensorTopLogical.setVisAttributes(theDetector.visAttributes(sensVis));
+      SensorBottomLogical.setVisAttributes(theDetector.visAttributes(sensVis));
+
+      //create dead sensor logical volume
+      Box SensorDeadSolid(sensor_thickness / 2.0, sensor_dead_width / 2.0, sensor_active_len / 2.0);
+      Volume SensorDeadLogical(name + dd4hep::_toString( layer_id, "_SensorDeadLogical_%02d"), SensorDeadSolid, sensor_mat);
+      SensorDeadLogical.setVisAttributes(theDetector.visAttributes(deadsensVis));
+
+      //create dead wire logical volume
+      Box SensorDeadWireSolid(sensor_deadwire_thickness / 2.0, sensor_deadwire_width / 2.0, sensor_deadwire_length / 2.0);
+      Volume SensorDeadWireLogical(name + dd4hep::_toString( layer_id, "_SensorDeadWireLogical_%02d"), SensorDeadWireSolid, sensor_deadwire_mat);
+      SensorDeadWireLogical.setVisAttributes(theDetector.visAttributes(deadwireVis));
+
+      //place the dead wire in the sensor envelope
+      // pv = SensorTopEnvelopeLogical.placeVolume(SensorDeadWireLogical, Position(0.0, (sensor_active_width-support_width/2.0) + sensor_dead_width/2.0 + sensor_deadwire_width/2.0, 0.0));
+      // pv = SensorBottomEnvelopeLogical.placeVolume(SensorDeadWireLogical, Position(0.0, (sensor_active_width-support_width/2.0) + sensor_dead_width/2.0 + sensor_deadwire_width/2.0, 0.0));
+      pv = SensorTopEnvelopeLogical.placeVolume(SensorDeadWireLogical, Position(0.0, (-support_width/2.0) + (sensor_deadwire_width/2.0), 0.0));
+      pv = SensorBottomEnvelopeLogical.placeVolume(SensorDeadWireLogical, Position(0.0, (-support_width/2.0) + (sensor_deadwire_width/2.0), 0.0));
+
+      // place the active sensor and dead sensor inside the sensor envelope
+      std::vector<dd4hep::PlacedVolume> TopSensor_pv;
+      std::vector<dd4hep::PlacedVolume> BottomSensor_pv;
+      for(int isensor=0; isensor < n_sensors_per_side; ++isensor){
+	double sensor_total_z = n_sensors_per_side*sensor_active_len + dead_gap*(n_sensors_per_side-1);
+	double xpos = 0.0;
+	double ypos_active = (support_width/2.0) - (sensor_active_width/2.0);
+	double ypos_dead = (-support_width/2.0) + sensor_deadwire_width + (sensor_dead_width/2.0);
+	double zpos = -sensor_total_z/2.0 + sensor_active_len/2.0 + isensor*(sensor_active_len + dead_gap);
+	pv = SensorTopEnvelopeLogical.placeVolume(SensorTopLogical, Position(xpos,ypos_active,zpos));
+	//pv.addPhysVolID("topsensor",  isensor ) ;
+	pv.addPhysVolID("layer", layer_id+1).addPhysVolID("sensor", isensor);
+	TopSensor_pv.push_back(pv);
+	pv = SensorBottomEnvelopeLogical.placeVolume(SensorBottomLogical, Position(xpos,ypos_active,zpos));
+	//pv.addPhysVolID("bottomsensor",  isensor ) ;
+	pv.addPhysVolID("layer", layer_id  ).addPhysVolID("sensor", isensor);
+	BottomSensor_pv.push_back(pv);
+	pv = SensorTopEnvelopeLogical.placeVolume(SensorDeadLogical, Position(xpos,ypos_dead,zpos));
+	pv = SensorBottomEnvelopeLogical.placeVolume(SensorDeadLogical, Position(xpos,ypos_dead,zpos));
+      }
+      //place the sensor envelope inside the ladder envelope
+      pv = LadderLogical.placeVolume(SensorTopEnvelopeLogical,
+				     Position(support_height/2.0 + flex_thickness + sensor_thickness/2.0, 0., 0.));//top-side sensors
+      Position pos(-(support_height/2.0 + flex_thickness + sensor_thickness/2.0), 0., 0.);
+      pv = LadderLogical.placeVolume(SensorBottomEnvelopeLogical, pos);//bottom-side sensors
+    
+      //create the ladder support
+      Box LadderSupportSolid(support_height/2.0, support_width/2.0, support_length/2.0);
+      Volume LadderSupportLogical(name + _toString( layer_id,"_SupLogical_%02d"), LadderSupportSolid, support_mat);
+      LadderSupportLogical.setVisAttributes(theDetector.visAttributes(supportVis));
+
+      //create ladder support cavity
+      Box LadderSupportCavitySolid(support_height/2.0-support_thickness/2.0, support_width/2.0-support_thickness/2.0, support_length/2.0);
+      Volume LadderSupportCavityLogical(name + _toString( layer_id,"_SupCavityLogical_%02d"), LadderSupportCavitySolid, air);
+      LadderSupportCavityLogical.setVisAttributes(theDetector.visAttributes("SeeThrough"));
+
+      pv = LadderSupportLogical.placeVolume(LadderSupportCavityLogical);
+      pv = LadderLogical.placeVolume(LadderSupportLogical);
+
+      for(int i = 0; i < n_ladders; i++){
+	std::stringstream ladder_enum; 
+	ladder_enum << "vxt_ladder_" << layer_id << "_" << i;
+	DetElement ladderDE(layerDE, ladder_enum.str(), x_det.id());
+	dd4hep::printout(dd4hep::DEBUG, "Construct", "start building %s", ladder_enum.str().c_str());
+
+	//====== create the meassurement surface ===================
+	dd4hep::rec::Vector3D o(0,0,0);
+	dd4hep::rec::Vector3D u( 0., 1., 0.);
+	dd4hep::rec::Vector3D v( 0., 0., 1.);
+	dd4hep::rec::Vector3D n( 1., 0., 0.);
+	// fucd: SensorLogical only sensor_thickness, support need another surface, todo
+	double inner_thick_top = sensor_thickness/2.0;
+	double outer_thick_top = sensor_thickness/2.0;//support_height/2.0 + flex_thickness + sensor_thickness/2.0;
+	double inner_thick_bottom = sensor_thickness/2.0;//support_height/2.0 + flex_thickness + sensor_thickness/2.0;
+	double outer_thick_bottom = sensor_thickness/2.0;
+	dd4hep::rec::VolPlane surfTop(SensorTopLogical,
+				      dd4hep::rec::SurfaceType(dd4hep::rec::SurfaceType::Sensitive),
+				      inner_thick_top, outer_thick_top, u, v, n, o);
+	dd4hep::rec::VolPlane surfBottom(SensorBottomLogical,
+					 dd4hep::rec::SurfaceType(dd4hep::rec::SurfaceType::Sensitive),
+					 inner_thick_bottom, outer_thick_bottom, u, v, n, o);
+
+	for(int isensor=0; isensor < n_sensors_per_side; ++isensor){
+	  std::stringstream topsensor_str;
+	  std::stringstream bottomsensor_str;
+	  topsensor_str << ladder_enum.str() << "_top_" << isensor;
+	  // std::cout << "\tstart building " << topsensor_str.str() << ":" << endl;
+	  bottomsensor_str << ladder_enum.str() << "_bottom_" << isensor;
+	  // std::cout << "\tstart building " << bottomsensor_str.str() << ":" << endl;
+	  DetElement topsensorDE(ladderDE, topsensor_str.str(), x_det.id());
+	  DetElement bottomsensorDE(ladderDE, bottomsensor_str.str(), x_det.id());
+	  topsensorDE.setPlacement(TopSensor_pv[isensor]);
+	  volSurfaceList(topsensorDE)->push_back(surfTop);
+	  // std::cout << "\t" << topsensor_str.str() << " done." << endl;
+	  bottomsensorDE.setPlacement(BottomSensor_pv[isensor]);
+	  // std::cout << "\t" << bottomsensor_str.str() << " done." << endl;
+	  volSurfaceList(bottomsensorDE)->push_back(surfBottom);
+	}
+	Transform3D tr (RotationZYX(ladder_dphi*i,0.,0.),Position(ladder_radius*cos(ladder_phi0+ladder_dphi*i), ladder_radius*sin(ladder_phi0+ladder_dphi*i), 0.));
+	pv = layer_assembly.placeVolume(LadderLogical,tr);
+	pv.addPhysVolID("module", i ) ; 
+	ladderDE.setPlacement(pv);
+	dd4hep::printout(dd4hep::DEBUG, "Construct", "%s done.", ladder_enum.str().c_str());
+	if(i==0) dd4hep::printout(dd4hep::DEBUG, "Construct", "(x,y) = (%f, %f)mm", ladder_radius*cos(ladder_phi0)/mm, ladder_radius*sin(ladder_phi0)/mm);
+      }
+
+      // package the reconstruction data
+      dd4hep::rec::ZPlanarData::LayerLayout topLayer;
+      dd4hep::rec::ZPlanarData::LayerLayout bottomLayer;
+
+      topLayer.ladderNumber         = n_ladders;
+      topLayer.phi0                 = 0.;
+      topLayer.sensorsPerLadder     = n_sensors_per_side;
+      topLayer.lengthSensor         = sensor_active_len;
+      topLayer.distanceSupport      = sensitive_radius;
+      topLayer.thicknessSupport     = support_thickness / 2.0;
+      topLayer.offsetSupport        = -ladder_offset;
+      topLayer.widthSupport         = support_width;
+      topLayer.zHalfSupport         = support_length / 2.0;
+      topLayer.distanceSensitive    = sensitive_radius + support_height / 2.0 + flex_thickness;
+      topLayer.thicknessSensitive   = sensor_thickness;
+      topLayer.offsetSensitive      = -ladder_offset + (support_width/2.0 - sensor_active_width/2.0);
+      topLayer.widthSensitive       = sensor_active_width;
+      topLayer.zHalfSensitive       = (n_sensors_per_side*(sensor_active_len + dead_gap) - dead_gap) / 2.0;
+
+      bottomLayer.ladderNumber         = n_ladders;
+      bottomLayer.phi0                 = 0.;
+      bottomLayer.sensorsPerLadder     = n_sensors_per_side;
+      bottomLayer.lengthSensor         = sensor_active_len;
+      bottomLayer.distanceSupport      = sensitive_radius - support_height / 2.0 - flex_thickness;
+      bottomLayer.thicknessSupport     = support_thickness / 2.0;
+      bottomLayer.offsetSupport        = -ladder_offset;
+      bottomLayer.widthSupport         = support_width;
+      bottomLayer.zHalfSupport         = support_length / 2.0;
+      bottomLayer.distanceSensitive    = sensitive_radius - support_height / 2.0 - sensor_thickness - flex_thickness;
+      bottomLayer.thicknessSensitive   = sensor_thickness;
+      bottomLayer.offsetSensitive      = -ladder_offset + (support_width/2.0 - sensor_active_width/2.0);
+      bottomLayer.widthSensitive       = sensor_active_width;
+      bottomLayer.zHalfSensitive       = (n_sensors_per_side*(sensor_active_len + dead_gap) - dead_gap) / 2.0;
+
+      compositeData->layersPlanar.push_back(bottomLayer);
+      compositeData->layersPlanar.push_back(topLayer);
+    }
+  }
+  if (dd4hep::printLevel()<=dd4hep::WARNING) std::cout << (*compositeData) << endl;
+  det.addExtension<dd4hep::rec::CompositeData>(compositeData);
+
+  if (x_det.hasAttr(_U(combineHits))) det.setCombineHits(x_det.attr<bool>(_U(combineHits)),sens);
+
+  dd4hep::printout(dd4hep::INFO, "Construct", "SiTrackerComposite_v02 done."); 
+  dd4hep::setPrintLevel(oldLevel);
+
+  return det;
+}
+DECLARE_DETELEMENT(SiTrackerComposite_v02,create_element)
-- 
GitLab