From 620585034a5a2b3fa080343494175278f95d7f91 Mon Sep 17 00:00:00 2001
From: zenghao <1251935595@qq.com>
Date: Mon, 13 Jun 2022 12:16:21 +0800
Subject: [PATCH] modified the VXD name, add VXD xml file

---
 Detector/DetCRD/CMakeLists.txt                |  2 +-
 .../VXD_StaggeredLadder_v01_01.xml            | 98 +++++++++++++++++++
 ...p => SiTrackerStaggeredLadder_v01_geo.cpp} | 23 ++++-
 3 files changed, 119 insertions(+), 4 deletions(-)
 create mode 100644 Detector/DetCRD/compact/CRD_common_v01/VXD_StaggeredLadder_v01_01.xml
 rename Detector/DetCRD/src/Tracker/{SiTrackerSkewBarrel_v01_geo.cpp => SiTrackerStaggeredLadder_v01_geo.cpp} (96%)

diff --git a/Detector/DetCRD/CMakeLists.txt b/Detector/DetCRD/CMakeLists.txt
index 8f7a6613..de22c502 100644
--- a/Detector/DetCRD/CMakeLists.txt
+++ b/Detector/DetCRD/CMakeLists.txt
@@ -21,7 +21,7 @@ gaudi_add_module(DetCRD
                          src/Calorimeter/RotatedCrystalCalorimeter_v01_geo.cpp
                          src/Other/CRDBeamPipe_v01_geo.cpp
                          src/Tracker/SiTrackerSkewRing_v01_geo.cpp
-                         src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
+                         src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp
 
 		 LINK ${DD4hep_COMPONENT_LIBRARIES}
 )
diff --git a/Detector/DetCRD/compact/CRD_common_v01/VXD_StaggeredLadder_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/VXD_StaggeredLadder_v01_01.xml
new file mode 100644
index 00000000..dde9f480
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/VXD_StaggeredLadder_v01_01.xml
@@ -0,0 +1,98 @@
+<lccdd>
+  <info name="VXD_StaggeredLadder_v01_01"
+        title="CepC VXD with staggered ladders"
+        author="H.Zeng, "
+        url="http://cepc.ihep.ac.cn"
+        status="developing"
+        version="v01">
+    <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="VXDLayer1_half_length" value="90*mm" />
+    <constant name="VXDLayer2_half_length" value="90*mm" />
+    <constant name="VXDLayer3_half_length" value="90*mm" />
+    <constant name="VXD_sensor_length" value="30*mm" />
+  </define>
+
+  <detectors>
+    <detector id="DetID_VXD" name="VXD" type="SiTrackerStaggeredLadder_v01" vis="VXDVis" readout="VXDCollection" insideTrackingVolume="true">
+    <envelope>
+		  <shape type="Tube" rmin="VXD_inner_radius" rmax="VXD_outer_radius" dz="VXD_half_length" material="Air"/>
+    </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"/>
+
+      <layer layer_id="0" ladder_radius="17.4*mm" ladder_offset="(8.4-1.5)*mm" n_sensors_per_side="VXDLayer1_half_length*2/VXD_sensor_length"
+	     n_ladders="10" >
+        <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"/>
+          </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="VXDLayer2_half_length*2/VXD_sensor_length"
+             n_ladders="22" >
+        <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="VXDLayer3_half_length*2/VXD_sensor_length"
+             n_ladders="32" >
+        <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/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp b/Detector/DetCRD/src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp
similarity index 96%
rename from Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
rename to Detector/DetCRD/src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp
index 966f1993..120bbab2 100644
--- a/Detector/DetCRD/src/Tracker/SiTrackerSkewBarrel_v01_geo.cpp
+++ b/Detector/DetCRD/src/Tracker/SiTrackerStaggeredLadder_v01_geo.cpp
@@ -132,7 +132,15 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
    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         = theDetector.material(x_ladder_support.attr<string>(_Unicode(mat)));
+   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());
+   }
    std::cout << "support_length: " << support_length/mm << " mm" << endl;
    std::cout << "support_thickness: " << support_thickness/mm << " mm" << endl;
    std::cout << "support_width: " << support_width/mm << " mm" << endl;
@@ -196,7 +204,16 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
     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 = theDetector.material(x_flex_slice.attr<string>(_Unicode(mat)));
+    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));
@@ -382,4 +399,4 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
  std::cout << "vxd done." << endl; 
   return vxd;
 }
-DECLARE_DETELEMENT(SiTrackerSkewBarrel_v01,create_element)
+DECLARE_DETELEMENT(SiTrackerStaggeredLadder_v01,create_element)
-- 
GitLab