From 2b123f27f101f294d127af53916b909cc57b98a6 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Sun, 20 Dec 2020 12:43:58 +0800
Subject: [PATCH] =?UTF-8?q?Change=20the=20ratio=20of=20signal=20wire=20and?=
 =?UTF-8?q?=20field=20wire=20to=201:5,=20put=20the=20inner=20wall=20and=20?=
 =?UTF-8?q?outer=20wall=E3=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Detector/DetDriftChamber/compact/det.xml      |  5 +-
 .../src/driftchamber/DriftChamber.cpp         | 50 ++++++++++++++-----
 2 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/Detector/DetDriftChamber/compact/det.xml b/Detector/DetDriftChamber/compact/det.xml
index 6770bdd4..5593ea03 100644
--- a/Detector/DetDriftChamber/compact/det.xml
+++ b/Detector/DetDriftChamber/compact/det.xml
@@ -27,7 +27,7 @@
     <constant name="SDT_half_length" value="2225*mm"/>
     <constant name="SDT_length" value="SDT_half_length*2"/>
 
-    <constant name="SDT_inner_chamber_radius_min" value="SDT_radius_min"/>
+    <constant name="SDT_inner_chamber_radius_min" value="235*mm"/>
     <constant name="SDT_inner_chamber_radius_max" value="909*mm"/>
     <constant name="SDT_inner_chamber_length" value="SDT_length"/>
 
@@ -64,6 +64,9 @@
         </shape>
       </envelope>
 
+         <barrel  name="inner_wall" type="Tube" rmin="234.8*mm" rmax="235*mm" material="Air" vis="VisibleGreen"/>
+         <model name="outer_wall" type="Tube" rmin="1715*mm" rmax="1717.8*mm" material="Air" vis="VisibleGreen"/>
+
       <module id="0" name="SignalWire" type="Tube" rmin="0*mm" rmax="0.01*mm" vis="VisibleRed">
           <tubs name="W" type="Tube" rmin="0*mm" rmax="0.007*mm" material="Tungsten"/>
           <tubs name="Au" type="Tube" rmin="0.007*mm" rmax="0.01*mm" material="Gold"/>
diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
index 178a39ce..45c924ae 100644
--- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
+++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
@@ -95,6 +95,30 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
     dd4hep::Tube det_outer_chamber_solid(outer_chamber_radius_min, outer_chamber_radius_max, outer_chamber_length*0.5);
     dd4hep::Volume det_outer_chamber_vol(det_name+"_outer_chamber_vol", det_outer_chamber_solid, det_mat);
 
+    // - inner wall
+    xml_coll_t c(x_det,_U(barrel));
+    xml_comp_t x_barrel = c;
+    double inner_wall_rmin = x_barrel.rmin();
+    double inner_wall_rmax = x_barrel.rmax();
+    std::string inner_wall_name = x_barrel.nameStr();
+    dd4hep::Material inner_wall_mat = theDetector.material(x_barrel.materialStr());
+std::cout << inner_wall_rmin << " " << inner_wall_rmax << " " << inner_wall_name << std::endl;
+    dd4hep::Tube inner_wall_solid(inner_wall_rmin,inner_wall_rmax,chamber_length*0.5);
+    dd4hep::Volume inner_wall_vol(inner_wall_name,inner_wall_solid,inner_wall_mat);
+    inner_wall_vol.setVisAttributes(theDetector.visAttributes(x_barrel.visStr()));
+
+    // - outer wall
+    xml_coll_t l(x_det,_U(model));
+    xml_comp_t x_model = l;
+    double outer_wall_rmin = x_model.rmin();
+    double outer_wall_rmax = x_model.rmax();
+    std::string outer_wall_name = x_model.nameStr();
+    dd4hep::Material outer_wall_mat = theDetector.material(x_model.materialStr());
+std::cout << outer_wall_rmin << " " << outer_wall_rmax << " " << outer_wall_name << std::endl;
+    dd4hep::Tube outer_wall_solid(outer_wall_rmin,outer_wall_rmax,chamber_length*0.5);
+    dd4hep::Volume outer_wall_vol(outer_wall_name,outer_wall_solid,outer_wall_mat);
+    outer_wall_vol.setVisAttributes(theDetector.visAttributes(x_model.visStr()));
+
    // - wire
     dd4hep::Volume module_vol;
     dd4hep::Volume Module_vol;
@@ -176,13 +200,13 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
 
         // - wire vol
         //phi <-------------------> -phi
-        //    |       F3        F4|   Only on the outermost layer
+        //    |       F3        F4|
         //    |                   |
         //    |       S         F2|
         //    |                   |
         //    |       F0        F1|
         //    --------------------
-//     if(layer_id == 66) {
+//     if(layer_id == 1) {
         for(int icell=0; icell< numWire; icell++) {
             double wire_phi = (icell+0.5)*layer_Phi + offset;
             // - signal wire
@@ -202,16 +226,14 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
             dd4hep::Position tr3D_2 = Position(rmid*std::cos(wire_phi+layer_Phi*0.5),rmid*std::sin(wire_phi+layer_Phi*0.5),0.);
             dd4hep::Transform3D transform_Module_2(dd4hep::Rotation3D(),tr3D_2);
             Module_phy = layer_vol.placeVolume(Module_vol,transform_Module_2);
-            if(layer_id==66 || layer_id==129) {
-               // - Field wire 3
-               dd4hep::Position tr3D_3 = Position((rmid+chamber_layer_width*0.5)*std::cos(wire_phi),(rmid+chamber_layer_width*0.5)*std::sin(wire_phi),0.);
-               dd4hep::Transform3D transform_Module_3(dd4hep::Rotation3D(),tr3D_3);
-               Module_phy = layer_vol.placeVolume(Module_vol,transform_Module_3);
-               // - Field wire 4
-               dd4hep::Position tr3D_4 = Position((rmid+chamber_layer_width*0.5)*std::cos(wire_phi+layer_Phi*0.5),(rmid+chamber_layer_width*0.5)*std::sin(wire_phi+layer_Phi*0.5),0.);
-               dd4hep::Transform3D transform_Module_4(dd4hep::Rotation3D(),tr3D_4);
-               Module_phy = layer_vol.placeVolume(Module_vol,transform_Module_4);
-            }
+            // - Field wire 3
+            dd4hep::Position tr3D_3 = Position((rmid+chamber_layer_width*0.5)*std::cos(wire_phi),(rmid+chamber_layer_width*0.5)*std::sin(wire_phi),0.);
+            dd4hep::Transform3D transform_Module_3(dd4hep::Rotation3D(),tr3D_3);
+            Module_phy = layer_vol.placeVolume(Module_vol,transform_Module_3);
+            // - Field wire 4
+            dd4hep::Position tr3D_4 = Position((rmid+chamber_layer_width*0.5)*std::cos(wire_phi+layer_Phi*0.5),(rmid+chamber_layer_width*0.5)*std::sin(wire_phi+layer_Phi*0.5),0.);
+            dd4hep::Transform3D transform_Module_4(dd4hep::Rotation3D(),tr3D_4);
+            Module_phy = layer_vol.placeVolume(Module_vol,transform_Module_4);
         }
 //  }
 
@@ -248,6 +270,10 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
             dd4hep::Position(0,0,0));
     dd4hep::PlacedVolume phv = envelope.placeVolume(det_vol,transform); 
 
+    dd4hep::PlacedVolume inner_wall_phy = envelope.placeVolume(inner_wall_vol,transform);
+
+    dd4hep::PlacedVolume outer_wall_phy = envelope.placeVolume(outer_wall_vol,transform);
+
     if ( x_det.hasAttr(_U(id)) )  {
         phv.addPhysVolID("system",x_det.id());
     }
-- 
GitLab