From 4fd03abdab0fa5525d588e6c44b3ddaf3ff0718c Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 21:44:55 +0800
Subject: [PATCH 1/7] change output position of hits

---
 .../src/TrackerCombineSensitiveDetector.h      | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.h b/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.h
index cf0cb844..b2ba6828 100644
--- a/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.h
+++ b/Simulation/DetSimSD/src/TrackerCombineSensitiveDetector.h
@@ -45,13 +45,18 @@ namespace dd4hep {
 	  clear();
 	  return 0;
 	}
+	Position pos     = 0.5 * (pre.position + post.position);
+	Position path    = post.position - pre.position;
+	double   hit_len = path.R();
+
+#ifdef CylinderOnly
+	// calculate point at center of two surface for cylinder measurement
+	// obsolete, deal in digitization for both planar and cylinder
 	double rho1 = pre.position.Rho();
-	double rho2 = post.position.Rho();
-	double rho = 0.5*(rho1+rho2);
-	Position pos = 0.5 * (pre.position + post.position);
+        double rho2 = post.position.Rho();
+        double rho = 0.5*(rho1+rho2);
 	double z = pos.z();
 	double r = sqrt(rho*rho+z*z);
-	Position path = post.position - pre.position;
 	double angle_O_pre_post = acos(-pre.position.Unit().Dot(path.Unit()));
 	double angle_O_post_pre = acos(post.position.Unit().Dot(path.Unit()));
 	double angle_O_P_pre = asin(pre.position.R()*sin(angle_O_pre_post)/r);
@@ -61,6 +66,7 @@ namespace dd4hep {
 	  double pre2P = r/sin(angle_O_pre_post)*sin(angle_O_pre_post+angle_O_P_pre);
 	  pos = pre.position + pre2P*path.Unit();
 	}
+#endif
 	Momentum mom = 0.5 * (pre.momentum + post.momentum);
 	Geant4TrackerHit* hit = new Geant4TrackerHit(pre.truth.trackID,
 						     pre.truth.pdgID,
@@ -68,8 +74,8 @@ namespace dd4hep {
 						     pre.truth.time);
 	hit->cellID   = cellID;
 	hit->position = pos;
-	hit->momentum = mom;
-	hit->length   = path.R();;
+	hit->momentum = path.Unit()*mom.R();
+	hit->length   = hit_len;
 	clear();
 	c->insert(hit);
 	return hit;
-- 
GitLab


From 4c5fd7ecfd5966703521182e91f3143f69779cbf Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 21:47:36 +0800
Subject: [PATCH 2/7] modify u v direction and extension data

---
 .../DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp   | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp b/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
index 037fe844..615ff099 100644
--- a/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
+++ b/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
@@ -679,8 +679,8 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
 
       //====== create the meassurement surface ===================
       dd4hep::rec::Vector3D o(0,0,0);
-      dd4hep::rec::Vector3D u( 0., 0., 1.);
-      dd4hep::rec::Vector3D v( 0., 1., 0.);
+      dd4hep::rec::Vector3D u( 0., 1., 0.);
+      dd4hep::rec::Vector3D v( 0., 0., 1.);
       dd4hep::rec::Vector3D n( 1., 0., 0.);
       double inner_thick = tube_outer_radius*2. + support_thickness + module_thickness/2.0;
       double outer_thick = max_connector_thickness + flex_thickness + module_thickness / 2.0;
@@ -731,14 +731,15 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
     //Layer.lengthModule         = module_active_length;
     Layer.lengthSensor         = module_length;//sensor_active_length;
     Layer.distanceSupport      = stave_radius*cos(stave_phi0) + StaveSupportenv_start_height; //sensitive_radius;
-    Layer.thicknessSupport     = support_thickness / 2.0;
+    Layer.thicknessSupport     = support_thickness;
     Layer.offsetSupport        = stave_radius*sin(stave_phi0);//-stave_offset;
     Layer.widthSupport         = support_width;
     Layer.zHalfSupport         = module_length*n_modules_per_stave/2.0;//support_half_length;
     Layer.distanceSensitive    = stave_radius*cos(stave_phi0) + StaveSupportenv_start_height + support_thickness;
                                //sensitive_radius + tube_outer_radius*2. + support_thickness;
     Layer.thicknessSensitive   = sensor_thickness;//module_thickness;
-    Layer.offsetSensitive      = stave_radius*sin(stave_phi0);//-stave_offset;//stave_offset/2.0;
+    // FIXME: save flex thickness as offsetSensitive
+    Layer.offsetSensitive      = flex_thickness;//stave_radius*sin(stave_phi0);//-stave_offset;//stave_offset/2.0;
     Layer.widthSensitive       = module_width;
     Layer.zHalfSensitive       = module_length*n_modules_per_stave/2.0;//support_half_length;
 
-- 
GitLab


From b39819dbcdf8d0a72e5bd33e2bbd48864d92309e Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 21:52:03 +0800
Subject: [PATCH 3/7] set combineHits as true

---
 Detector/DetCRD/compact/CRD_common_v01/OTKBarrel_v01_01.xml    | 2 +-
 Detector/DetCRD/compact/CRD_common_v02/FTD_SkewRing_v01_07.xml | 3 ++-
 .../DetCRD/compact/CRD_common_v02/SIT_StaggeredStave_v02.xml   | 2 +-
 .../DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml     | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Detector/DetCRD/compact/CRD_common_v01/OTKBarrel_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/OTKBarrel_v01_01.xml
index 4f503c9e..e52d9722 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/OTKBarrel_v01_01.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/OTKBarrel_v01_01.xml
@@ -37,7 +37,7 @@
 
   <detectors>
     <!--detector id="DetID_OTKBarrel" limits="otk_limits" name="OTKBarrel" type="SiTracker_otkbarrel_v01" vis="OTKBarrelVis" readout="OTKBarrelCollection" insideTrackingVolume="true"-->
-    <detector id="DetID_OTKBarrel" name="OTKBarrel" type="SiTracker_otkbarrel_v01" vis="OTKBarrelVis" readout="OTKBarrelCollection" insideTrackingVolume="true">
+    <detector id="DetID_OTKBarrel" name="OTKBarrel" type="SiTracker_otkbarrel_v01" vis="OTKBarrelVis" readout="OTKBarrelCollection" combineHits="true" insideTrackingVolume="true">
       <envelope>
         <shape type="Tube" rmin="OTKBarrel_inner_radius" rmax="OTKBarrel_outer_radius" dz="OTKBarrel_half_length" material="Air"/>
       </envelope>
diff --git a/Detector/DetCRD/compact/CRD_common_v02/FTD_SkewRing_v01_07.xml b/Detector/DetCRD/compact/CRD_common_v02/FTD_SkewRing_v01_07.xml
index 6656cb2a..7d84b7a7 100644
--- a/Detector/DetCRD/compact/CRD_common_v02/FTD_SkewRing_v01_07.xml
+++ b/Detector/DetCRD/compact/CRD_common_v02/FTD_SkewRing_v01_07.xml
@@ -8,7 +8,8 @@
   </define>
 
   <detectors>
-    <detector id="DetID_FTD" name="FTD" type="SiTrackerSkewRing_v01" vis="FTDVis" readout="FTDCollection" insideTrackingVolume="true" reflect="true">
+    <detector id="DetID_FTD" name="FTD" type="SiTrackerSkewRing_v01" vis="FTDVis" readout="FTDCollection" combineHits="true"
+	      insideTrackingVolume="true" reflect="true">
       <envelope>
 	<shape type="Assembly"/>
       </envelope>
diff --git a/Detector/DetCRD/compact/CRD_common_v02/SIT_StaggeredStave_v02.xml b/Detector/DetCRD/compact/CRD_common_v02/SIT_StaggeredStave_v02.xml
index f7eb74a7..4329abb0 100644
--- a/Detector/DetCRD/compact/CRD_common_v02/SIT_StaggeredStave_v02.xml
+++ b/Detector/DetCRD/compact/CRD_common_v02/SIT_StaggeredStave_v02.xml
@@ -13,7 +13,7 @@
   </define>
 
   <detectors>
-    <detector id="DetID_SIT" name="SIT" type="SiTracker_itkbarrel_v02" vis="SITVis" readout="SITCollection" insideTrackingVolume="true">
+    <detector id="DetID_SIT" name="SIT" type="SiTracker_itkbarrel_v02" vis="SITVis" readout="SITCollection" combineHits="true" insideTrackingVolume="true">
       <envelope>
 	<shape type="Assembly"/>
         <!--shape type="BooleanShape" operation="Union" material="Air" >
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
index 1fea5860..8ea458a5 100644
--- a/Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml
+++ b/Detector/DetCRD/compact/CRD_common_v02/VXD_Composite_v01_02.xml
@@ -19,7 +19,7 @@
   </define>
 
   <detectors>
-    <detector id="DetID_VXD" name="VXD" type="SiTrackerComposite_v02" vis="VXDVis" readout="VXDCollection" insideTrackingVolume="true" printLevel="INFO">
+    <detector id="DetID_VXD" name="VXD" type="SiTrackerComposite_v02" vis="VXDVis" readout="VXDCollection" combineHits="true" insideTrackingVolume="true" printLevel="INFO">
       <envelope>
         <shape type="Assembly"/>
       </envelope>
-- 
GitLab


From 3c10b9abaa222317fca0f68f6848c4480e4ed563 Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 23:21:09 +0800
Subject: [PATCH 4/7] change u v direction

---
 Detector/DetCRD/src/Tracker/SiTracker_otkbarrel_v01_geo.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Detector/DetCRD/src/Tracker/SiTracker_otkbarrel_v01_geo.cpp b/Detector/DetCRD/src/Tracker/SiTracker_otkbarrel_v01_geo.cpp
index 711c90f6..762f80f1 100644
--- a/Detector/DetCRD/src/Tracker/SiTracker_otkbarrel_v01_geo.cpp
+++ b/Detector/DetCRD/src/Tracker/SiTracker_otkbarrel_v01_geo.cpp
@@ -324,8 +324,8 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
 
             //====== create the meassurement surface ===================
             dd4hep::rec::Vector3D o(0,0,0);
-            dd4hep::rec::Vector3D u( 0., 0., 1.);
-            dd4hep::rec::Vector3D v( 0., 1., 0.);
+            dd4hep::rec::Vector3D u( 0., 1., 0.);
+            dd4hep::rec::Vector3D v( 0., 0., 1.);
             dd4hep::rec::Vector3D n( 1., 0., 0.);
             double inner_thick = sensor_thickness/2.0;
             double outer_thick = (support_height + sensor_thickness)/2.0;
-- 
GitLab


From 2fd7ed2d9d2f746d89fe74c5a7e87257a5f0e1df Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 23:23:06 +0800
Subject: [PATCH 5/7] update center for Cylinder

---
 Digitization/DigiSimple/src/SmearDigiTool.cpp | 44 +++++++++++++------
 Digitization/DigiSimple/src/SmearDigiTool.h   |  8 ++--
 2 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/Digitization/DigiSimple/src/SmearDigiTool.cpp b/Digitization/DigiSimple/src/SmearDigiTool.cpp
index a99c6ac4..474b1377 100644
--- a/Digitization/DigiSimple/src/SmearDigiTool.cpp
+++ b/Digitization/DigiSimple/src/SmearDigiTool.cpp
@@ -43,8 +43,13 @@ StatusCode SmearDigiTool::initialize() {
     return StatusCode::FAILURE;
   }
 
-  m_surfaces = m_geosvc->getSurfaceMap(m_detName);
-  debug() << "Surface map size: " << m_surfaces->size() << endmsg;
+  if (m_detName=="") {
+    std::string toolName = name();
+    m_detName = toolName.substr(toolName.find(".")+1);
+    debug() << toolName << " --> " << m_detName.value() << endmsg;
+  }
+  m_surfaces = m_geosvc->getSurfaceMap(m_detName.value());
+  debug() << "Surface map size of " << m_detName.value() << ": " << m_surfaces->size() << endmsg;
   if (msgLevel(MSG::VERBOSE)) {
     unsigned long old = 0; 
     for (const auto& pair : *m_surfaces) {
@@ -54,8 +59,9 @@ StatusCode SmearDigiTool::initialize() {
     }
   }
 
-  debug() << "Readout name: " << m_readoutName << endmsg;
-  m_decoder = m_geosvc->getDecoder(m_readoutName);
+  if (m_readoutName=="") m_readoutName = m_detName.value() + "Collection";
+  debug() << "Readout name: " << m_readoutName.value() << endmsg;
+  m_decoder = m_geosvc->getDecoder(m_readoutName.value());
   if(!m_decoder){
     error() << "Failed to get the decoder. " << endmsg;
     return StatusCode::FAILURE;
@@ -114,7 +120,8 @@ StatusCode SmearDigiTool::Call(edm4hep::SimTrackerHit simhit, edm4hep::TrackerHi
     return StatusCode::FAILURE;
   }
 
-  dd4hep::rec::Vector3D oldPos(pos.x*dd4hep::mm/CLHEP::mm, pos.y*dd4hep::mm/CLHEP::mm, pos.z*dd4hep::mm/CLHEP::mm);
+  // CLHEP::mm is divided while Edm4hepWriterAnaElemTool write, so pos without unit
+  dd4hep::rec::Vector3D oldPos(pos.x*dd4hep::mm, pos.y*dd4hep::mm, pos.z*dd4hep::mm);
   dd4hep::rec::Vector3D uVec = surface->u(oldPos);
   dd4hep::rec::Vector3D vVec = surface->v(oldPos);
   float u_direction[2];
@@ -158,8 +165,8 @@ StatusCode SmearDigiTool::Call(edm4hep::SimTrackerHit simhit, edm4hep::TrackerHi
     resV = m_parV[0] + m_parV[1] * y + m_parV[2] * exp(-m_parV[9] * y) * cos(m_parV[3] * y + m_parV[4])
       + m_parV[5] * exp(-0.5 * pow(((y - m_parV[6]) / m_parV[7]), 2)) + m_parV[8] * pow(y, 0.5);
   }
-  resU *= dd4hep::mm/CLHEP::mm;
-  resV *= dd4hep::mm/CLHEP::mm;
+  resU *= dd4hep::mm;
+  resV *= dd4hep::mm;
   // parameterize only for position now, todo
   resT = (m_resT.size() > 1 ? m_resT.value().at(layer) : m_resT.value().at(0));
   // from ps (input unit) to ns (record unit, Geant4)
@@ -174,6 +181,17 @@ StatusCode SmearDigiTool::Call(edm4hep::SimTrackerHit simhit, edm4hep::TrackerHi
 
   if (typeSurface.isPlane() || typeSurface.isCylinder()) {
     dd4hep::rec::Vector2D localPoint = surface->globalToLocal(oldPos);
+    if (typeSurface.isCylinder()) {
+      dd4hep::rec::Vector3D mom_ddrec(mom.x*dd4hep::GeV, mom.y*dd4hep::GeV, mom.z*dd4hep::GeV);
+      double length = simhit.getPathLength()*dd4hep::mm;
+      dd4hep::rec::Vector3D pre       = oldPos - (0.5*length)*mom_ddrec.unit();
+      dd4hep::rec::Vector3D post      = oldPos + (0.5*length)*mom_ddrec.unit();
+      dd4hep::rec::Vector2D localPre  = surface->globalToLocal(pre);
+      dd4hep::rec::Vector2D localPost = surface->globalToLocal(post);
+      localPoint = dd4hep::rec::Vector2D(0.5*(localPre.u()+localPost.u()), 0.5*(localPre.v()+localPost.v()));
+      debug() << "pre: (" << pre.x() << " " << pre.y() << " " << pre.z() << " ) local (" << localPre.u() << ", " << localPre.v() << " ) "
+	      << "post: (" << post.x() << " " << post.y() << " " << post.z() << " ) local (" << localPost.u() << ", " << localPost.v() << " ) " << endmsg;
+    }
     dd4hep::rec::Vector3D local3D(localPoint.u(), localPoint.v(), 0);
     // A small check, if the hit is in the boundaries:
     if (!surface->insideBounds(oldPos)) {
@@ -186,7 +204,7 @@ StatusCode SmearDigiTool::Call(edm4hep::SimTrackerHit simhit, edm4hep::TrackerHi
     dd4hep::rec::Vector3D globalPointSmeared;//CLHEP::Hep3Vector globalPoint(pos[0],pos[1],pos[2]);
     dd4hep::rec::Vector2D localPointSmeared;
 
-    debug() << std::setprecision(8) << " Before smearing global: (" << pos[0]/CLHEP::mm << " " << pos[1]/CLHEP::mm << " " << pos[2]/CLHEP::mm << ") "
+    debug() << std::setprecision(8) << " Before smearing global: (" << pos[0] << " " << pos[1] << " " << pos[2] << ") "
 	    << "local: (" << localPoint.u()/dd4hep::mm << " " << localPoint.v()/dd4hep::mm << ")" << endmsg;
 
     unsigned tries = 0;
@@ -234,13 +252,13 @@ StatusCode SmearDigiTool::Call(edm4hep::SimTrackerHit simhit, edm4hep::TrackerHi
     auto outhit = hitCol->create();
     outhit.setCellID(cellId);
 
-    edm4hep::Vector3d smearedPos(globalPointSmeared.x()*CLHEP::mm/dd4hep::mm,
-				 globalPointSmeared.y()*CLHEP::mm/dd4hep::mm,
-				 globalPointSmeared.z()*CLHEP::mm/dd4hep::mm);
+    edm4hep::Vector3d smearedPos(globalPointSmeared.x()/dd4hep::mm,
+				 globalPointSmeared.y()/dd4hep::mm,
+				 globalPointSmeared.z()/dd4hep::mm);
     outhit.setPosition(smearedPos);
     // recover CLHEP/Geant4 unit
-    resU /= dd4hep::mm/CLHEP::mm;
-    resV /= dd4hep::mm/CLHEP::mm;
+    resU /= dd4hep::mm;
+    resV /= dd4hep::mm;
 
     std::bitset<32> type;
     if (typeSurface.isPlane() && m_usePlanarTag) {
diff --git a/Digitization/DigiSimple/src/SmearDigiTool.h b/Digitization/DigiSimple/src/SmearDigiTool.h
index 2f8f9fa1..273e12de 100644
--- a/Digitization/DigiSimple/src/SmearDigiTool.h
+++ b/Digitization/DigiSimple/src/SmearDigiTool.h
@@ -30,8 +30,8 @@ class SmearDigiTool : public extends<AlgTool, IDigiTool> {
   StatusCode finalize() override;
 
  private:
-  Gaudi::Property<std::string> m_detName{this, "DetName", "VXD"};
-  Gaudi::Property<std::string> m_readoutName{this, "Readout", "VXDCollection"};
+  Gaudi::Property<std::string> m_detName{this, "DetName", ""};
+  Gaudi::Property<std::string> m_readoutName{this, "Readout", ""};
 
   Gaudi::Property<float> m_eThreshold{this, "EnergyThreshold", 0};
   Gaudi::Property<float> m_efficiency{this, "Efficiency", 1};
@@ -53,8 +53,8 @@ class SmearDigiTool : public extends<AlgTool, IDigiTool> {
   Gaudi::Property<std::vector<float> > m_parV{this, "ParametersV", {0}};
 
   SmartIF<IRndmGenSvc> m_randSvc;
-  SmartIF<IGeomSvc> m_geosvc;
-  dd4hep::DDSegmentation::BitFieldCoder* m_decoder;
+  SmartIF<IGeomSvc>    m_geosvc;
+  dd4hep::DDSegmentation::BitFieldCoder* m_decoder = nullptr;
   const dd4hep::rec::SurfaceMap* m_surfaces;
   //void* m_pAlgUsing = nullptr;
 };
-- 
GitLab


From a4c6881a2129839cf5d6359b8f6c495b40fb1cd8 Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 23:23:56 +0800
Subject: [PATCH 6/7] change digi to tool

---
 .../DetCRD/scripts/TDR_o1_v01/tracking.py     | 70 ++++++++-----------
 1 file changed, 29 insertions(+), 41 deletions(-)

diff --git a/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py b/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
index ab968e52..a5f9324f 100644
--- a/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
+++ b/Detector/DetCRD/scripts/TDR_o1_v01/tracking.py
@@ -71,19 +71,14 @@ sethitname  = "OTKBarrelTrackerHits"
 setspname   = "OTKBarrelSpacePoints"
 ftdhitname  = "FTDTrackerHits"
 ftdspname   = "FTDSpacePoints"
-from Configurables import SmearDigiTool
+from Configurables import SmearDigiTool,SiTrackerDigiAlg
+
+## VXD ##
 vxdtool = SmearDigiTool("VXD")
 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]
-vxdtool.ParametersV = [5.60959e-03, 5.74913e-03, 7.03433e-03, 1.99516, -663.952, 3.752e-03, 0, -0.0704734, 0.0454867e-03, 1.07359]
 #vxdtool.OutputLevel = DEBUG
 
-
-## VXD ##
-from Configurables import SiTrackerDigiAlg
 digiVXD = SiTrackerDigiAlg("VXDDigi")
 digiVXD.SimTrackHitCollection = "VXDCollection"
 digiVXD.TrackerHitCollection = vxdhitname
@@ -91,50 +86,43 @@ digiVXD.TrackerHitAssociationCollection = "VXDTrackerHitAssociation"
 digiVXD.DigiTool = "SmearDigiTool/VXD"
 #digiVXD.OutputLevel = DEBUG
 
-
 ## SIT ##
-from Configurables import PlanarDigiAlg
-digiSIT = PlanarDigiAlg("SITDigi")
-digiSIT.IsStrip = False
+sittool = SmearDigiTool("SIT")
+sittool.ResolutionU = [0.0098]
+sittool.ResolutionV = [0.0433]
+#sittool.OutputLevel = DEBUG
+
+digiSIT = SiTrackerDigiAlg("SITDigi")
 digiSIT.SimTrackHitCollection = "SITCollection"
 digiSIT.TrackerHitCollection = sithitname
 digiSIT.TrackerHitAssociationCollection = "SITTrackerHitAssociation"
-digiSIT.ResolutionU = [0.0098]
-digiSIT.ResolutionV = [0.0433]
-digiSIT.UsePlanarTag = True
-digiSIT.ParameterizeResolution = False
-digiSIT.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]
-digiSIT.ParametersV = [1.44629e-02, 2.20108e-03, 1.03044e-02, 4.39195e+00, 3.29641e+00, 1.55167e+18, -5.41954e+01, 5.72986e+00, -6.80699e-03, 5.04095e-01]
+digiSIT.DigiTool = "SmearDigiTool/SIT"
 #digiSIT.OutputLevel = DEBUG
 
+## OTKBarrel ##
+otkbtool = SmearDigiTool("OTKBarrel")
+otkbtool.ResolutionU = [0.010]
+otkbtool.ResolutionV = [1.000]
+#otkbtool.OutputLevel = DEBUG
 
-## SET ##
-digiSET = PlanarDigiAlg("SETDigi")
-digiSET.IsStrip = False
-digiSET.SimTrackHitCollection = "OTKBarrelCollection"
-digiSET.TrackerHitCollection = sethitname
-digiSET.TrackerHitAssociationCollection = "OTKBarrelTrackerHitAssociation"
-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]
-digiSET.ParametersV = [1.44629e-02, 2.20108e-03, 1.03044e-02, 4.39195e+00, 3.29641e+00, 1.55167e+18, -5.41954e+01, 5.72986e+00, -6.80699e-03, 5.04095e-01]
-#digiSET.OutputLevel = DEBUG
-
+digiOTKB = SiTrackerDigiAlg("OTKBarrelDigi")
+digiOTKB.SimTrackHitCollection = "OTKBarrelCollection"
+digiOTKB.TrackerHitCollection = sethitname
+digiOTKB.TrackerHitAssociationCollection = "OTKBarrelTrackerHitAssociation"
+digiOTKB.DigiTool = "SmearDigiTool/OTKBarrel"
+#digiOTKB.OutputLevel = DEBUG
 
 ## FTD ##
-digiFTD = PlanarDigiAlg("FTDDigi")
-digiFTD.IsStrip = False
+ftdtool = SmearDigiTool("FTD")
+ftdtool.ResolutionU = [0.0072]
+ftdtool.ResolutionV = [0.086]
+#ftdtool.OutputLevel = DEBUG
+
+digiFTD = SiTrackerDigiAlg("FTDDigi")
 digiFTD.SimTrackHitCollection = "FTDCollection"
 digiFTD.TrackerHitCollection = ftdhitname
 digiFTD.TrackerHitAssociationCollection = "FTDTrackerHitAssociation"
-digiFTD.ResolutionU = [0.0072]
-digiFTD.ResolutionV = [0.086]
-digiFTD.UsePlanarTag = True
-digiFTD.ParameterizeResolution = False
-digiFTD.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]
-digiFTD.ParametersV = [1.44629e-02, 2.20108e-03, 1.03044e-02, 4.39195e+00, 3.29641e+00, 1.55167e+18, -5.41954e+01, 5.72986e+00, -6.80699e-03, 5.04095e-01]
+digiFTD.DigiTool = "SmearDigiTool/FTD"
 #digiFTD.OutputLevel = DEBUG
 
 ## TPC ##
@@ -290,7 +278,7 @@ out.outputCommands = ["keep *"]
 # ApplicationMgr
 from Configurables import ApplicationMgr
 mgr = ApplicationMgr(
-    TopAlg = [podioinput, digiVXD, digiSIT, digiSET, digiFTD, digiTPC, digiMuon, tracking, forward, subset, clupatra, full, tpr, tpc_dndx, tmt, out],
+    TopAlg = [podioinput, digiVXD, digiSIT, digiOTKB, digiFTD, digiTPC, digiMuon, tracking, forward, subset, clupatra, full, tpr, tpc_dndx, tmt, out],
     EvtSel = 'NONE',
     EvtMax = 50,
     ExtSvc = [rndmengine, rndmgensvc, dsvc, evtseeder, geosvc, gearsvc, tracksystemsvc, pidsvc],
-- 
GitLab


From 1e58eff35eb210166d37f484bbef06286b5b2c37 Mon Sep 17 00:00:00 2001
From: Chengdong Fu <fucd@ihep.ac.cn>
Date: Tue, 17 Dec 2024 23:35:51 +0800
Subject: [PATCH 7/7] correct wrong data

---
 Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp b/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
index 615ff099..3fbbff8d 100644
--- a/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
+++ b/Detector/DetCRD/src/Tracker/SiTracker_itkbarrel_v02_geo.cpp
@@ -738,8 +738,7 @@ static dd4hep::Ref_t create_element(dd4hep::Detector& theDetector, xml_h e, dd4h
     Layer.distanceSensitive    = stave_radius*cos(stave_phi0) + StaveSupportenv_start_height + support_thickness;
                                //sensitive_radius + tube_outer_radius*2. + support_thickness;
     Layer.thicknessSensitive   = sensor_thickness;//module_thickness;
-    // FIXME: save flex thickness as offsetSensitive
-    Layer.offsetSensitive      = flex_thickness;//stave_radius*sin(stave_phi0);//-stave_offset;//stave_offset/2.0;
+    Layer.offsetSensitive      = stave_radius*sin(stave_phi0);//-stave_offset;//stave_offset/2.0;
     Layer.widthSensitive       = module_width;
     Layer.zHalfSensitive       = module_length*n_modules_per_stave/2.0;//support_half_length;
 
-- 
GitLab