From bd4e2d97976a82ba4643ecca72441cd36d8dcb87 Mon Sep 17 00:00:00 2001
From: zenghao <1251935595@qq.com>
Date: Fri, 10 Jun 2022 19:36:12 +0800
Subject: [PATCH] fix flex thickness issue, fix some code conflict

---
 Detector/DetCRD/CMakeLists.txt                |   3 +-
 .../compact/CRD_common_v01/VXD_v02_01.xml     | 165 ------------------
 .../CRD_o1_v02/CRD_o1_v02-onlyTracker.xml     |   2 +-
 .../DetCRD/compact/CRD_o1_v02/CRD_o1_v02.xml  |   6 +-
 .../compact/CRD_o1_v03/CRD_o1_v03-onlyVXD.xml |  13 +-
 .../DetCRD/compact/CRD_o1_v03/CRD_o1_v03.xml  |   4 +-
 Detector/DetCRD/scripts/CRD-Sim.py            |  19 +-
 .../Tracker/SiTrackerSkewBarrel_v01_geo.cpp   |  11 +-
 Service/GearSvc/src/GearSvc.cpp               |  65 +------
 Service/GearSvc/src/GearSvc.h                 |   2 -
 10 files changed, 44 insertions(+), 246 deletions(-)
 delete mode 100644 Detector/DetCRD/compact/CRD_common_v01/VXD_v02_01.xml

diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt
index 08194569..8f7a6613 100644
--- a/Detector/DetCRD/CMakeLists.txt
+++ b/Detector/DetCRD/CMakeLists.txt
@@ -17,7 +17,7 @@ find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
 
 gaudi_add_module(DetCRD
                  SOURCES src/Calorimeter/CRDEcal_v01.cpp
-			 src/Calorimeter/RotatedPolyhedraBarrelCalorimeter_v01_geo.cpp
+                         src/Calorimeter/RotatedPolyhedraBarrelCalorimeter_v01_geo.cpp
                          src/Calorimeter/RotatedCrystalCalorimeter_v01_geo.cpp
                          src/Other/CRDBeamPipe_v01_geo.cpp
                          src/Tracker/SiTrackerSkewRing_v01_geo.cpp
@@ -25,6 +25,7 @@ gaudi_add_module(DetCRD
 
 		 LINK ${DD4hep_COMPONENT_LIBRARIES}
 )
+
 set(LIBRARY_OUTPUT_PATH ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 message(STATUS "LIBRARY_OUTPUT_PATH -> ${LIBRARY_OUTPUT_PATH}")
 dd4hep_generate_rootmap(DetCRD)
diff --git a/Detector/DetCRD/compact/CRD_common_v01/VXD_v02_01.xml b/Detector/DetCRD/compact/CRD_common_v01/VXD_v02_01.xml
deleted file mode 100644
index 0d781974..00000000
--- a/Detector/DetCRD/compact/CRD_common_v01/VXD_v02_01.xml
+++ /dev/null
@@ -1,165 +0,0 @@
-<lccdd>
-  <info name="VXD_v02_01"
-        title="CepC VXD with skewed ladders"
-        author="H.Zeng, "
-        url="http://cepc.ihep.ac.cn"
-        status="developing"
-        version="v02">
-    <comment>CepC vertex detector based on MOST2 project </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="VXD_inner_radius_1" value="BeamPipe_VertexRegion_rmax"/>
-    <constant name="VXD_radius_r1" value="16*mm"/>
-    <constant name="VXD_radius_r3" value="37*mm"/>
-    <constant name="VXD_radius_r5" value="58*mm"/>
-    <constant name="VXD_length_r1" value="62.5*mm"/>
-    <constant name="VXD_length_r3" value="125*mm"/>
-    <constant name="VXD_length_r5" value="125*mm"/>
-    <constant name="VXD_cone_max_z" value="Vertex_half_length-10*mm"/>
-    <constant name="VXD_cone_min_z" value="VXD_length_r5+10*mm"/>
-    <!--0.17mm silicon + 1.0mm carbon -> 0.65% of X0-->
-    <constant name="VXD_sensitive_thickness" value="0.17*mm"/>
-    <constant name="VXD_support_thickness"   value="1*mm"/>
-    <constant name="VXD_sensor_length"       value="30*mm"/>
-    <constant name="VXD1_inner_radius"   value="16*mm"/>
-    <constant name="VXD2_inner_radius"   value="37*mm"/>
-    <constant name="VXD3_inner_radius"   value="58*mm"/>
-    <constant name="VXD4_inner_radius"   value="79*mm"/>
-    <!-- <constant name="VXD_inner_radius_1"   value="VXD_inner_radius + env_safety"/> -->
-    <!-- <constant name="VXD_outer_radius_1" value="VXD_inner_radius_1/cos(pi/8)"/> -->
-    <!-- <constant name="VXD_inner_radius_2" value="VXD2_inner_radius"/> -->
-    <!-- <constant name="VXD_outer_radius"   value="OuterTracker_inner_radius"/> -->
-    <constant name="VXD1_half_length"    value="90*mm"/>
-    <constant name="VXD2_half_length"    value="90*mm"/>
-    <constant name="VXD3_half_length"    value="90*mm"/>
-    <constant name="VXD4_half_length"    value="90*mm"/>
-    <!-- <constant name="VXD_half_length_1"  value="VXD1_half_length"/> -->
-    <!-- <constant name="VXD_layer_gap" value="2.5*mm"/> -->
-    <constant name="VXD4_half_length"    value="90*mm"/>
-  </define>
-
-  <detectors>
-    <detector id="DetID_VXD" name="VXD" type="SiTrackerSkewBarrel_v01" vis="VXDVis" readout="VXDCollection" insideTrackingVolume="true">
-      <!-- <envelope> -->
-	<!-- <shape type="Assembly"/> -->
-        <!--shape type="BooleanShape" operation="Union" material="Air" >
-          <shape type="Tube" rmin="VXD_inner_radius"   rmax="VXD_outer_radius_1" dz="VXD_half_length_1" />
-          <shape type="Tube" rmin="VXD_inner_radius_2" rmax="VXD_outer_radius"   dz="VXD_half_length" />
-        </shape-->
-      <!-- </envelope> -->
-    <envelope vis="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>    
-
-      <type_flags type="DetType_TRACKER + DetType_BARREL + DetType_PIXEL "/>
-
-      <reconstruction strip_width="0." strip_length="0." strip_pitch="0." strip_angle="0*deg"  />
-
-      <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"/>
-      <!-- <display ladder="SeeThrough" support="BlackVis" flex="VXDFlexVis" sens_env="SeeThrough" sens="GrayVis" deadsensor="GreenVis" deadwire="RedVis"/> -->
-      <!-- <display ladder="SeeThrough" support="SeeThrough" flex="SeeThrough" sens_env="SeeThrough" sens="YellowVis" deadsensor="GreenVis" deadwire="SeeThrough"/> -->
-
-      <layer layer_id="0" ladder_radius="17.4*mm" ladder_offset="(8.4-1.5)*mm" n_sensors_per_side="VXD1_half_length*2/VXD_sensor_length"
-	     n_ladders="10" ladder_clearance="0.1*mm" faces_IP="1" is_VXD1="1" is_VXD2="0"  >
-        <ladder isDoubleSided="true">
-          <ladderSupport height="2*mm" length="200*mm" thickness="350*um" width="16.8*mm" mat="CarbonFiber"/>
-          <flex n_slices="3">
-            <slice length="200*mm" thickness="60*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="74*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="26.8*um" width="16.8*mm" mat="G4_Al"/>
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/> -->
-            <!-- <slice length="200*mm" thickness="50*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="14.8*mm" mat="Epoxy"/> -->
-          </flex>
-          <sensor n_sensors="7" 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="(7*(25.6+0.1)-0.1)*mm" deadwire_width="2*mm" deadwire_thickness="(50/10)*um" deadwire_mat="G4_Al"/>
-        </ladder>
-      </layer>
-      <layer layer_id="1" ladder_radius="36.9*mm" ladder_offset="(8.4+5.0)*mm" n_sensors_per_side="VXD2_half_length*2/VXD_sensor_length"
-             n_ladders="22" ladder_clearance="0.1*mm" faces_IP="1" is_VXD1="0" is_VXD2="1"  >
-        <ladder isDoubleSided="true">
-          <ladderSupport height="2*mm" length="200*mm" thickness="350*um" width="16.8*mm" mat="CarbonFiber"/>
-          <flex n_slices="3">
-            <slice length="200*mm" thickness="60*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="74*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="26.8*um" width="16.8*mm" mat="G4_Al"/>
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/> -->
-            <!-- <slice length="200*mm" thickness="50*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/> -->
-            <!-- <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/> -->
-            <!-- <slice length="200*mm" thickness="15*um" width="14.8*mm" mat="Epoxy"/> -->
-          </flex>
-          <sensor n_sensors="7" 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="(7*(25.6+0.1)-0.1)*mm" deadwire_width="2*mm" deadwire_thickness="(50/10)*um" deadwire_mat="G4_Al"/>
-        </ladder>
-      </layer>
-      <layer layer_id="2" ladder_radius="57.7*mm" ladder_offset="(8.4+9.6)*mm" n_sensors_per_side="VXD3_half_length*2/VXD_sensor_length"
-             n_ladders="32" ladder_clearance="0.1*mm" faces_IP="1" is_VXD1="0" is_VXD2="0"  >
-        <ladder isDoubleSided="true">
-          <ladderSupport height="2*mm" length="200*mm" thickness="350*um" width="16.8*mm" mat="CarbonFiber"/>
-          <flex n_slices="3">
-            <slice length="200*mm" thickness="60*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="74*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="26.8*um" width="16.8*mm" mat="G4_Al"/>
-            <!-- <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/>
-            <slice length="200*mm" thickness="50*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="13.4*um" width="16.8*mm" mat="G4_Al"/>
-            <slice length="200*mm" thickness="15*um" width="16.8*mm" mat="Epoxy"/>
-            <slice length="200*mm" thickness="12*um" width="16.8*mm" mat="Kapton"/>
-            <slice length="200*mm" thickness="15*um" width="14.8*mm" mat="Epoxy"/> -->
-          </flex>
-          <sensor n_sensors="7" 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="(7*(25.6+0.1)-0.1)*mm" deadwire_width="2*mm" deadwire_thickness="(50/10)*um" deadwire_mat="G4_Al"/>
-        </ladder>
-      </layer>
-
-
-    </detector>
-
-    
-  </detectors>
-  
-  <readouts>
-    <readout name="VXDCollection">
-      <id>system:5,side:-2,layer:9,module:8,sensor:8,barrelside:-2</id>
-    </readout>
-  </readouts>
-</lccdd>
diff --git a/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02-onlyTracker.xml b/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02-onlyTracker.xml
index 661b0ff9..2397761d 100644
--- a/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02-onlyTracker.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02-onlyTracker.xml
@@ -31,7 +31,7 @@
   <include ref="../CRD_common_v01/VXD_v01_01.xml"/>
   <include ref="../CRD_common_v01/FTD_SkewRing_v01_01.xml"/>
   <include ref="../CRD_common_v01/SIT_SimplePixel_v01_01.xml"/>
-  <!-- <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/> -->
+  <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/>
   <include ref="../CRD_common_v01/SET_SimplePlanar_v01_01.xml"/>
 
   <fields>
diff --git a/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02.xml b/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02.xml
index 6b7487a5..cc466395 100644
--- a/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v02/CRD_o1_v02.xml
@@ -31,15 +31,15 @@
   <include ref="../CRD_common_v01/VXD_v01_01.xml"/>
   <include ref="../CRD_common_v01/FTD_SkewRing_v01_01.xml"/>
   <include ref="../CRD_common_v01/SIT_SimplePixel_v01_01.xml"/>
-  <!-- <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/> -->
+  <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/>
   <include ref="../CRD_common_v01/SET_SimplePlanar_v01_01.xml"/>
   <include ref="../CRD_common_v01/Ecal_Crystal_Barrel_v01_01.xml"/>
   <!--include ref="../CRD_common_v01/Ecal_Crystal_Endcap_v01_01.xml"/-->
-  <!--include ref="../CRD_common_v01/Coil_Simple_v01_01.xml"/>
+  <include ref="../CRD_common_v01/Coil_Simple_v01_01.xml"/>
   <include ref="../CRD_common_v01/Hcal_Rpc_Barrel_v01_01.xml"/>
   <include ref="../CRD_common_v01/Hcal_Rpc_Endcaps_v01_01.xml"/>
   <include ref="../CRD_common_v01/Yoke_Barrel_v01_01.xml"/>
-  <include ref="../CRD_common_v01/Yoke_Endcaps_v01_01.xml"/-->
+  <include ref="../CRD_common_v01/Yoke_Endcaps_v01_01.xml"/>
   <!--include ref="../CRD_common_v01/Lcal_v01_01.xml"/-->
 
   <fields>
diff --git a/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03-onlyVXD.xml b/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03-onlyVXD.xml
index 36943247..44eb691c 100644
--- a/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03-onlyVXD.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03-onlyVXD.xml
@@ -4,10 +4,10 @@
        xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd">
   <info name="CRD_o1_v02"
         title="CepC reference detctor with coil inside Hcal, pixel SIT and strip SET"
-        author="C.D.Fu, "
+        author="Hao Zeng"
         url="http://cepc.ihep.ac.cn"
         status="developing"
-        version="v02">
+        version="v01">
     <comment>CepC reference detector simulation models used for detector study </comment>
   </info>
   
@@ -26,14 +26,9 @@
     <include ref="${DD4hepINSTALL}/DDDetectors/compact/detector_types.xml"/>
   </define>
 
-  <include ref="./CRD_Dimensions_v01_02.xml"/>
+  <include ref="../CRD_o1_v02/CRD_Dimensions_v01_02.xml"/>
 
-  <!-- <include ref="../CRD_common_v01/Beampipe_v01_01.xml"/> -->
-  <include ref="../CRD_common_v01/VXD_v02_01.xml"/>
-  <!-- <include ref="../CRD_common_v01/FTD_SkewRing_v01_01.xml"/> -->
-  <!-- <include ref="../CRD_common_v01/SIT_SimplePixel_v01_01.xml"/> -->
-  <!-- <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/> -->
-  <!-- <include ref="../CRD_common_v01/SET_SimplePlanar_v01_01.xml"/> -->
+  <include ref="../CRD_common_v01/VXD_StaggeredLadder_v01_01.xml"/>
 
   <fields>
     <field name="InnerSolenoid" type="solenoid"
diff --git a/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03.xml b/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03.xml
index 3083b139..27ec2513 100644
--- a/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v03/CRD_o1_v03.xml
@@ -2,7 +2,7 @@
 <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="CRD_o1_v02"
+  <info name="CRD_o1_v03"
         title="CepC reference detctor with coil inside Hcal, pixel SIT and strip SET"
         author="C.D.Fu, "
         url="http://cepc.ihep.ac.cn"
@@ -29,7 +29,7 @@
   <include ref="./CRD_Dimensions_v01_02.xml"/>
 
   <include ref="../CRD_common_v01/Beampipe_v01_01.xml"/>
-  <include ref="../CRD_common_v01/VXD_v02_01.xml"/>
+  <include ref="../CRD_common_v01/VXD_StaggeredLadder_v01_01.xml"/>
   <include ref="../CRD_common_v01/FTD_SkewRing_v01_01.xml"/>
   <include ref="../CRD_common_v01/SIT_SimplePixel_v01_01.xml"/>
   <!-- <include ref="../CRD_common_v01/DC_Simple_v01_01.xml"/> -->
diff --git a/Detector/DetCRD/scripts/CRD-Sim.py b/Detector/DetCRD/scripts/CRD-Sim.py
index 09a8e488..0e734b78 100644
--- a/Detector/DetCRD/scripts/CRD-Sim.py
+++ b/Detector/DetCRD/scripts/CRD-Sim.py
@@ -89,6 +89,23 @@ detsimalg.AnaElems = [
 ]
 detsimalg.RootDetElem = "WorldDetElemTool"
 
+dedxoption = "BetheBlochEquationDedxSimTool"
+from Configurables import DriftChamberSensDetTool
+dc_sensdettool = DriftChamberSensDetTool("DriftChamberSensDetTool")
+dc_sensdettool.DedxSimTool = dedxoption
+
+from Configurables import DummyDedxSimTool
+from Configurables import BetheBlochEquationDedxSimTool
+
+if dedxoption == "DummyDedxSimTool":
+    dedx_simtool = DummyDedxSimTool("DummyDedxSimTool")
+elif dedxoption == "BetheBlochEquationDedxSimTool":
+    dedx_simtool = BetheBlochEquationDedxSimTool("BetheBlochEquationDedxSimTool")
+    dedx_simtool.material_Z = 2
+    dedx_simtool.material_A = 4
+    dedx_simtool.scale = 10
+    dedx_simtool.resolution = 0.0001
+
 # output
 from Configurables import PodioOutput
 out = PodioOutput("outputalg")
@@ -100,7 +117,7 @@ from Configurables import ApplicationMgr
 ApplicationMgr(
     TopAlg = [genalg, detsimalg, out],
     EvtSel = 'NONE',
-    EvtMax = 10000,
+    EvtMax = 100,
     ExtSvc = [rndmengine, rndmgensvc, dsvc, geosvc],
     OutputLevel=INFO
 )
diff --git a/Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp b/Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
index e7c0c36c..966f1993 100644
--- a/Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
+++ b/Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
@@ -189,7 +189,7 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
   //vxd.setVisAttributes(theDetector, flexVis, FlexEnvelopeLogical);
 
   //create the flex layers inside the flex envelope
-  double flex_height(0); 
+  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);
@@ -197,15 +197,16 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
     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 = theDetector.material(x_flex_slice.attr<string>(_Unicode(mat)));
-    flex_height += x_flex_slice_thickness;
     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));
-    pv = FlexEnvelopeLogical.placeVolume(FlexLayerLogical, Position(flex_height/2.0, 0., 0.));
+    double flex_slice_height = flex_start_height + x_flex_slice_thickness/2.;
+    pv = FlexEnvelopeLogical.placeVolume(FlexLayerLogical, Position(flex_slice_height, 0., 0.));
     std::cout << "flex thickness = " << x_flex_slice_thickness << std::endl;
     std::cout << "flex width = " << x_flex_slice_width << std::endl;
     std::cout << "flex length = " << x_flex_slice_length << std::endl;
     // std::cout << "flex material: " << x_flex_slice_mat << std::endl;
+    flex_start_height += x_flex_slice_thickness;
     index++;
   }
 
@@ -301,8 +302,8 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
 	  dd4hep::rec::Vector3D v( 0., 1., 0.);
 	  dd4hep::rec::Vector3D n( 1., 0., 0.);
     double inner_thick_top = sensor_thickness/2.0;
-    double outer_thick_top = support_height/2.0 + flex_height + sensor_thickness/2.0;
-    double inner_thick_bottom = support_height/2.0 + flex_height + sensor_thickness/2.0;
+    double outer_thick_top = support_height/2.0 + flex_thickness + sensor_thickness/2.0;
+    double inner_thick_bottom = support_height/2.0 + flex_thickness + sensor_thickness/2.0;
     double outer_thick_bottom = sensor_thickness/2.0;
     dd4hep::rec::VolPlane surfTop( SensorLogical ,
                                 dd4hep::rec::SurfaceType(dd4hep::rec::SurfaceType::Sensitive),
diff --git a/Service/GearSvc/src/GearSvc.cpp b/Service/GearSvc/src/GearSvc.cpp
index 2dd18059..81c3611f 100644
--- a/Service/GearSvc/src/GearSvc.cpp
+++ b/Service/GearSvc/src/GearSvc.cpp
@@ -86,9 +86,6 @@ StatusCode GearSvc::initialize()
       else if(it->first=="VXD"){
 	sc = convertVXD(sub);
       }
-      else if(it->first=="VXDskew"){
-	sc = convertVXDskew(sub);
-      }
       else if(it->first=="FTD"){
         sc = convertFTD(sub);
       }
@@ -209,9 +206,9 @@ StatusCode GearSvc::convertVXD(dd4hep::DetElement& vxd){
   double phi0=0;
   helpLayer thisLadder;
   double beryllium_ladder_block_length=0,end_electronics_half_z=0,side_band_electronics_width=0;
-  double rAlu=0, drAlu, rSty, drSty, dzSty, rInner, aluEndcapZ, aluHalfZ, alu_RadLen, Cryostat_dEdx;
-  double VXDSupportDensity, VXDSupportZeff, VXDSupportAeff, VXDSupportRadLen, VXDSupportIntLen=0;
-  double styDensity, styZeff, styAeff, styRadLen, styIntLen; 
+  double rAlu=0, drAlu=0, rSty=0, drSty=0, dzSty=0, rInner=0, aluEndcapZ=0, aluHalfZ=0, alu_RadLen=0, Cryostat_dEdx=0;
+  double VXDSupportDensity=0, VXDSupportZeff=0, VXDSupportAeff=0, VXDSupportRadLen=0, VXDSupportIntLen=0;
+  double styDensity=0, styZeff=0, styAeff=0, styRadLen=0, styIntLen=0; 
   dd4hep::Volume vxd_vol = vxd.volume();
   for(int i=0;i<vxd_vol->GetNdaughters();i++){
     TGeoNode* daughter = vxd_vol->GetNode(i);
@@ -405,11 +402,11 @@ StatusCode GearSvc::convertVXD(dd4hep::DetElement& vxd){
 
       int nFlexCable = 0, nFoamSpacer=0, nMetalTraces=0;
       int currentLayer = -1;
-      double tFlexCable, tFoamSpacer, tMetalTraces;
-      double radLFlexCable, radLFoamSpacer, radLMetalTraces;
-      double intLFlexCable, intLFoamSpacer, intLMetalTraces;
-      double dFlexCable, dFoamSpacer, dMetalTraces;
-      double metalZeff, metalZAeff, foamZeff, foamZAeff, flexZeff, flexZAeff;
+      double tFlexCable=0, tFoamSpacer=0, tMetalTraces=0;
+      double radLFlexCable=0, radLFoamSpacer=0, radLMetalTraces=0;
+      double intLFlexCable=0, intLFoamSpacer=0, intLMetalTraces=0;
+      double dFlexCable=0, dFoamSpacer=0, dMetalTraces=0;
+      double metalZeff=0, metalZAeff=0, foamZeff=0, foamZAeff=0, flexZeff=0, flexZAeff=0;
       for(int i=0;i<vol->GetNdaughters();i++){
 	TGeoNode* daughter = vol->GetNode(i);
         TGeoMaterial* matDaughter = daughter->GetMedium()->GetMaterial();
@@ -605,52 +602,6 @@ StatusCode GearSvc::convertVXD(dd4hep::DetElement& vxd){
   return sc;
 }
 
-StatusCode GearSvc::convertVXDskew(dd4hep::DetElement& vxd){
-  dd4hep::rec::ZPlanarData* vxdskewData = nullptr;
-  try{
-    vxdskewData = vxd.extension<dd4hep::rec::ZPlanarData>();
-  }
-  catch(std::runtime_error& e){
-    warning() << e.what() << " " << vxdskewData << endmsg;
-    return StatusCode::FAILURE;
-  }
-
-  std::vector<dd4hep::rec::ZPlanarData::LayerLayout>& vxdlayers = vxdskewData->layers;
-  int nLayers = vxdlayers.size();
-  double strip_angle_deg = vxdskewData->angleStrip*rad_to_deg;
-  
-  gear::ZPlanarParametersImpl* vxdParams = new gear::ZPlanarParametersImpl(gear::ZPlanarParametersImpl::CMOS, 0.0, 0.0, 0.0, 0.0, 0.0);
-  // sitParams->setDoubleVal("strip_width_mm",  sitData->widthStrip*CLHEP::cm);
-  // sitParams->setDoubleVal("strip_length_mm", sitData->lengthStrip*CLHEP::cm);
-  // sitParams->setDoubleVal("strip_pitch_mm",  sitData->pitchStrip*CLHEP::cm);
-  // sitParams->setDoubleVal("strip_angle_deg", strip_angle_deg);
-  std::vector<int> n_sensors_per_ladder;
-  for( int layer=0; layer < nLayers; layer++){
-    dd4hep::rec::ZPlanarData::LayerLayout& layout = vxdlayers[layer];
-
-    int nLadders = layout.ladderNumber;
-    double phi0 = layout.phi0;
-    double supRMin = layout.distanceSupport*CLHEP::mm;
-    double supOffset = layout.offsetSupport*CLHEP::mm;
-    double supThickness = layout.thicknessSupport*CLHEP::mm;
-    double supHalfLength = layout.zHalfSupport*CLHEP::mm;
-    double supWidth = layout.widthSupport*CLHEP::mm;
-    double senRMin = layout.distanceSensitive*CLHEP::mm;
-    double senOffset = layout.offsetSensitive*CLHEP::mm;
-    double senThickness = layout.thicknessSensitive*CLHEP::mm;
-    double senHalfLength = layout.zHalfSensitive*CLHEP::mm;
-    double senWidth = layout.widthSensitive*CLHEP::mm;
-    int nSensorsPerLadder = layout.sensorsPerLadder;
-    double stripAngle = strip_angle_deg*CLHEP::degree;
-    n_sensors_per_ladder.push_back(nSensorsPerLadder);
-    vxdParams->addLayer(nLadders, phi0, supRMin, supOffset, supThickness, supHalfLength, supWidth, 0, senRMin, senOffset, senThickness, senHalfLength, senWidth, 0);
-  }
-  vxdParams->setIntVals("n_sensors_per_ladder",n_sensors_per_ladder);
-  m_gearMgr->setVXDParameters( vxdParams ) ;
-
-  return StatusCode::SUCCESS;
-}
-
 StatusCode GearSvc::convertFTD(dd4hep::DetElement& ftd){
   dd4hep::rec::ZDiskPetalsData* ftdData = nullptr;
   try{
diff --git a/Service/GearSvc/src/GearSvc.h b/Service/GearSvc/src/GearSvc.h
index 52865a56..3048526c 100644
--- a/Service/GearSvc/src/GearSvc.h
+++ b/Service/GearSvc/src/GearSvc.h
@@ -4,7 +4,6 @@
 #include "GearSvc/IGearSvc.h"
 #include <GaudiKernel/Service.h>
 #include "DD4hep/Detector.h"
-class dd4hep::DetElement;
 class TGeoNode;
 
 class GearSvc : public extends<Service, IGearSvc>
@@ -21,7 +20,6 @@ class GearSvc : public extends<Service, IGearSvc>
     private:
 	StatusCode convertBeamPipe(dd4hep::DetElement& pipe);
 	StatusCode convertVXD(dd4hep::DetElement& vxd);
-	StatusCode convertVXDskew(dd4hep::DetElement& vxd);
 	StatusCode convertSIT(dd4hep::DetElement& sit);
 	StatusCode convertTPC(dd4hep::DetElement& tpc);
 	StatusCode convertDC (dd4hep::DetElement& dc);
-- 
GitLab