From eb7a1417dde3ef00369db8ecb0132cc95870e64e Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Thu, 28 Oct 2021 14:27:53 +0800
Subject: [PATCH 01/27] Increase the diagonal wire version
---
.../CRD_common_v01/DC_Simple_v01_01.xml | 12 ++-
.../CRD_common_v01/DC_Simple_v01_02.xml | 8 +-
.../CRD_o1_v01/CRD_Dimensions_v01_01.xml | 4 +-
.../CRD_o1_v01/CRD_o1_v01-onlyTracker.xml | 2 +-
.../CRD_o1_v02/CRD_Dimensions_v01_02.xml | 4 +-
.../CRD_o1_v02/CRD_o1_v02-onlyTracker.xml | 2 +-
Detector/DetDriftChamber/CMakeLists.txt | 1 +
Detector/DetDriftChamber/compact/det.xml | 16 +--
.../src/driftchamber/DriftChamber.cpp | 20 +++-
.../DetSegmentation/GridDriftChamber.h | 64 ++++++++++-
.../DetSegmentation/src/GridDriftChamber.cpp | 101 +++++++++++++++++-
11 files changed, 202 insertions(+), 32 deletions(-)
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml
index a1da46679..73594f243 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml
@@ -28,7 +28,7 @@
-
+
@@ -42,7 +42,7 @@
-
+
@@ -53,8 +53,10 @@
-
-
+
+
+
+
@@ -78,7 +80,7 @@
-
+
system:5,layer:7:9,chamber:8,cellID:32:16
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml
index ae4ccbe02..0b6e8f67e 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml
@@ -28,7 +28,7 @@
-
+
@@ -54,7 +54,9 @@
-
+
+
+
@@ -79,7 +81,7 @@
-
+
system:5,layer:7:9,chamber:8,cellID:32:16
diff --git a/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml b/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
index 4f631eb52..46959ebbe 100644
--- a/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
@@ -102,8 +102,10 @@
+
+
-
+
diff --git a/Detector/DetCRD/compact/CRD_o1_v01/CRD_o1_v01-onlyTracker.xml b/Detector/DetCRD/compact/CRD_o1_v01/CRD_o1_v01-onlyTracker.xml
index 9ede81b79..d8c788d21 100644
--- a/Detector/DetCRD/compact/CRD_o1_v01/CRD_o1_v01-onlyTracker.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v01/CRD_o1_v01-onlyTracker.xml
@@ -32,7 +32,7 @@
-
+
diff --git a/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml b/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
index 4f631eb52..46959ebbe 100644
--- a/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
@@ -102,8 +102,10 @@
+
+
-
+
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 2397761df..7f1a6986b 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 @@
-
+
diff --git a/Detector/DetDriftChamber/CMakeLists.txt b/Detector/DetDriftChamber/CMakeLists.txt
index fbf8e01ce..7321b5e64 100644
--- a/Detector/DetDriftChamber/CMakeLists.txt
+++ b/Detector/DetDriftChamber/CMakeLists.txt
@@ -16,6 +16,7 @@ find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
gaudi_add_module(DetDriftChamber
SOURCES src/driftchamber/DriftChamber.cpp
+ SOURCES src/driftchamber/DriftChamber_tile.cpp
LINK DetSegmentation
${DD4hep_COMPONENT_LIBRARIES}
# ROOT Geant4
diff --git a/Detector/DetDriftChamber/compact/det.xml b/Detector/DetDriftChamber/compact/det.xml
index b62dd532d..08b29c928 100644
--- a/Detector/DetDriftChamber/compact/det.xml
+++ b/Detector/DetDriftChamber/compact/det.xml
@@ -19,7 +19,7 @@
-
+
@@ -40,8 +40,8 @@
-
-
+
+
@@ -51,7 +51,7 @@
-
+
@@ -74,7 +74,7 @@
-
+
@@ -85,7 +85,9 @@
-
+
+
+
@@ -110,7 +112,7 @@
-
+
system:5,layer:7:9,chamber:8,cellID:32:16
diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
index be98c1c14..02732bf5d 100644
--- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
+++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
@@ -38,6 +38,9 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
xml_coll_t c(x_det,_U(chamber));
xml_comp_t x_chamber = c;
+ xml_coll_t cc(x_det,_U(side));
+ xml_comp_t x_side = cc;
+
std::string det_name = x_det.nameStr();
std::string det_type = x_det.typeStr();
@@ -45,6 +48,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
// - global
double chamber_half_length = theDetector.constant("DC_half_length");
+ double chamber_length = theDetector.constant("DC_length");
// - chamber
double chamber_radius_min = theDetector.constant("SDT_chamber_radius_min");
@@ -60,7 +64,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
int chamber_layer_number = floor((chamber_layer_rend-chamber_layer_rbegin)/chamber_layer_width);
double safe_distance = theDetector.constant("DC_safe_distance");
- double epsilon = theDetector.constant("Epsilon");
+ double alpha = theDetector.constant("Alpha");
// =======================================================================
// Detector Construction
@@ -75,8 +79,10 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet ;
- dd4hep::Material det_mat(theDetector.material("Air"));
- dd4hep::Material chamber_mat(theDetector.material("GasHe_90Isob_10"));
+// dd4hep::Material det_mat(theDetector.material("Air"));
+ dd4hep::Material det_mat(theDetector.material(x_det.materialStr()));
+// dd4hep::Material chamber_mat(theDetector.material("GasHe_90Isob_10"));
+ dd4hep::Material chamber_mat = theDetector.material(x_chamber.materialStr());
// - global
Assembly det_vol( det_name+"_assembly" ) ;
@@ -91,7 +97,8 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
double chamber_outer_wall_rmin = theDetector.constant("SDT_chamber_outer_wall_radius_min");
double chamber_outer_wall_rmax = theDetector.constant("SDT_chamber_outer_wall_radius_max");
- dd4hep::Material wall_mat(theDetector.material("CarbonFiber"));
+// dd4hep::Material wall_mat(theDetector.material("CarbonFiber"));
+ dd4hep::Material wall_mat(theDetector.material(x_side.materialStr()));
double wall_rmin[2] = {chamber_inner_wall_rmin, chamber_outer_wall_rmin};
double wall_rmax[2] = {chamber_inner_wall_rmax, chamber_outer_wall_rmax};
@@ -153,13 +160,14 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
for(int layer_id = 0; layer_id < chamber_layer_number; layer_id++) {
double rmin,rmax,offset=0;
dd4hep::Volume* current_vol_ptr = nullptr;
- current_vol_ptr = &det_chamber_vol;
+// current_vol_ptr = &det_chamber_vol;
rmin = chamber_layer_rbegin+(layer_id*chamber_layer_width);
rmax = rmin+chamber_layer_width;
layerIndex = layer_id;
//Construction of drift chamber layers
double rmid = delta_a_func(rmin,rmax);
+ double Rmid = rmid/std::cos(alpha/2);
double ilayer_cir = 2 * M_PI * rmid;
double ncell = ilayer_cir / chamber_layer_width;
int ncell_layer = floor(ncell);
@@ -169,6 +177,8 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
if(layer_id %2 ==0){ offset = 0.; }
else { offset = 0.5 * layer_Phi; }
+ double epsilon = 0;
+
DCHseg->setGeomParams(chamber_id, layerIndex, layer_Phi, rmid, epsilon, offset);
DCHseg->setWiresInLayer(chamber_id, layerIndex, numWire);
diff --git a/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h b/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
index 0233ccf82..ad9d03604 100644
--- a/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
+++ b/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
@@ -60,16 +60,19 @@ class GridDriftChamber : public Segmentation {
virtual CellID cellID(const Vector3D& aLocalPosition, const Vector3D& aGlobalPosition,
const VolumeID& aVolumeID) const;
virtual double distanceTrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const;
+ virtual double distanceTrackWire2(const CellID& cID, const TVector3& hit_pos) const;
virtual void cellposition(const CellID& cID, TVector3& Wstart, TVector3& Wend) const;
+ virtual void cellposition2(int chamber, int layer, int cell, TVector3& Wstart, TVector3& Wend) const;
TVector3 LineLineIntersect(TVector3& p1, TVector3& p2, TVector3& p3, TVector3& p4) const;
virtual TVector3 distanceClosestApproach(const CellID& cID, const TVector3& hitPos) const;
virtual TVector3 Line_TrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const;
virtual TVector3 IntersectionTrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const;
virtual TVector3 wirePos_vs_z(const CellID& cID, const double& zpos) const;
+ virtual double Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition) const;
// double phi(const CellID& cID) const;
inline double cell_Size() const { return m_cellSize; }
- inline double epsilon0() const { return m_epsilon0; }
+ inline double epsilon() const { return m_epsilon; }
inline double detectorLength() const { return m_detectorLength; }
inline double safe_distance() const { return m_safe_distance; }
inline double layer_width() const { return m_layer_width; }
@@ -114,6 +117,52 @@ class GridDriftChamber : public Segmentation {
inline auto returnAllWires() const { return m_wiresPositions; }
+// TVector3 LineLineIntersect(TVector3 p1, TVector3 p2, TVector3 p3, TVector3 p4) const {
+// TVector3 p13, p43, p21;
+// double d1343, d4321, d1321, d4343, d2121;
+// double numer, denom;
+// double mua, mub;
+// TVector3 pa, pb;
+//
+// p13.SetX(p1.X() - p3.X());
+// p13.SetY(p1.Y() - p3.Y());
+// p13.SetZ(p1.Z() - p3.Z());
+// p43.SetX(p4.X() - p3.X());
+// p43.SetY(p4.Y() - p3.Y());
+// p43.SetZ(p4.Z() - p3.Z());
+// /* if (ABS(p43.X()) < EPS && ABS(p43.Y()) < EPS && ABS(p43.Z()) < EPS) */
+// /* return(FALSE); */
+// p21.SetX(p2.X() - p1.X());
+// p21.SetY(p2.Y() - p1.Y());
+// p21.SetZ(p2.Z() - p1.Z());
+// /* if (ABS(p21.X()) < EPS && ABS(p21.Y()) < EPS && ABS(p21.Z()) < EPS) */
+// /* return(FALSE); */
+//
+// d1343 = p13.X() * p43.X() + p13.Y() * p43.Y() + p13.Z() * p43.Z();
+// d4321 = p43.X() * p21.X() + p43.Y() * p21.Y() + p43.Z() * p21.Z();
+// d1321 = p13.X() * p21.X() + p13.Y() * p21.Y() + p13.Z() * p21.Z();
+// d4343 = p43.X() * p43.X() + p43.Y() * p43.Y() + p43.Z() * p43.Z();
+// d2121 = p21.X() * p21.X() + p21.Y() * p21.Y() + p21.Z() * p21.Z();
+//
+// denom = d2121 * d4343 - d4321 * d4321;
+// /* if (ABS(denom) < EPS) */
+// /* return(FALSE); */
+// numer = d1343 * d4321 - d1321 * d4343;
+//
+// mua = numer / denom;
+// mub = (d1343 + d4321 * (mua)) / d4343;
+//
+// pa.SetX(p1.X() + mua * p21.X());
+// pa.SetY(p1.Y() + mua * p21.Y());
+// pa.SetZ(p1.Z() + mua * p21.Z());
+// pb.SetX(p3.X() + mub * p43.X());
+// pb.SetY(p3.Y() + mub * p43.Y());
+// pb.SetZ(p3.Z() + mub * p43.Z());
+//
+// return pb - pa;
+// }
+
+
void updateParams(int chamber, int layer) const{
auto it_end = layer_params.cend();
--it_end;
@@ -136,6 +185,15 @@ class GridDriftChamber : public Segmentation {
m_epsilon = Eps;
m_offset = Offset;
}
+ inline Vector3D returnPosWire0(double z) const {
+ double alpha = returnAlpha();
+ double t = 0.5 * (1 - 2.0 * z / m_detectorLength);
+ double x = _currentRadius * (1 + t * (std::cos(alpha) - 1));
+ double y = _currentRadius * t * std::sin(alpha);
+
+ Vector3D vec(x, y, z);
+ return vec;
+ }
protected:
@@ -152,12 +210,12 @@ class GridDriftChamber : public Segmentation {
}
inline double returnAlpha() const {
- double alpha = 2 * std::asin(m_detectorLength * std::tan(m_epsilon0)/(2 * _currentRadius));
+ double alpha = 2 * std::asin(m_detectorLength * std::tan(m_epsilon)/(2 * _currentRadius));
return alpha;
}
double m_cellSize;
- double m_epsilon0;
+// double m_epsilon0;
double m_detectorLength;
double m_layer_width;
double m_safe_distance;
diff --git a/Detector/DetSegmentation/src/GridDriftChamber.cpp b/Detector/DetSegmentation/src/GridDriftChamber.cpp
index a4302ebf5..a2d0029c2 100644
--- a/Detector/DetSegmentation/src/GridDriftChamber.cpp
+++ b/Detector/DetSegmentation/src/GridDriftChamber.cpp
@@ -22,7 +22,7 @@ GridDriftChamber::GridDriftChamber(const BitFieldCoder* decoder) : Segmentation(
_description = "Drift chamber segmentation in the global coordinates";
registerParameter("cell_size", "cell size", m_cellSize, 1., SegmentationParameter::LengthUnit);
- registerParameter("epsilon0", "epsilon", m_epsilon0, 0., SegmentationParameter::AngleUnit, true);
+// registerParameter("epsilon0", "epsilon", m_epsilon0, 0., SegmentationParameter::AngleUnit, true);
registerParameter("detector_length", "Length of the wire", m_detectorLength, 1., SegmentationParameter::LengthUnit);
registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "cellID");
registerIdentifier("layerID", "layer id", layer_id, "layer");
@@ -48,6 +48,10 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
double posx = globalPosition.X;
double posy = globalPosition.Y;
+ double posz = globalPosition.Z;
+ Vector3D wire0 = returnPosWire0(posz);
+ double phi_wire0 = phiFromXY(wire0);
+
double radius = sqrt(posx*posx+posy*posy);
int m_DC_layer_number = floor((m_DC_rend-m_DC_rbegin)/m_layer_width);
@@ -58,7 +62,7 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
layerid = floor((radius - m_DC_rbegin)/DC_layerdelta);
} else if ( radius>= (m_DC_rmin-m_safe_distance) && radius < m_DC_rbegin) {
layerid = 0;
- } else if ( radius> m_DC_rend && radius <= (m_DC_rmax+m_safe_distance)) {
+ } else if ( radius> m_DC_rend ) {//&& radius <= (m_DC_rmax+m_safe_distance)) {
layerid = m_DC_layer_number-1;
}
@@ -68,14 +72,30 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
double offsetphi= m_offset;
int _lphi;
- if(phi_hit >= offsetphi) {
- _lphi = (int) ((phi_hit - offsetphi)/ _currentLayerphi);
+ if(phi_hit >= (offsetphi+phi_wire0)) {
+ _lphi = (int) ((phi_hit - offsetphi - phi_wire0)/ _currentLayerphi);
}
else {
- _lphi = (int) ((phi_hit - offsetphi + 2 * M_PI)/ _currentLayerphi);
+ _lphi = (int) ((phi_hit - offsetphi - phi_wire0 + 2 * M_PI)/ _currentLayerphi);
}
int lphi = _lphi;
+
+std::cout << "#######################################: "
+ << " posx= " << posx
+ << " posy= " << posy
+ << " posz= " << posz
+ << " phi_hit: " << phi_hit
+ << " phi_wire0: " << phi_wire0
+ << " _lphi: " << _lphi
+ << " offset : " << m_offset
+ << " offsetphi: " << offsetphi
+ << " layerID: " << layerid
+ << " r: " << _currentRadius
+ << " layerphi: " << _currentLayerphi
+ << std::endl;
+
+
_decoder->set(cID, layer_id, layerid);
_decoder->set(cID, m_phiID, lphi);
@@ -102,6 +122,17 @@ void GridDriftChamber::cellposition(const CellID& cID, TVector3& Wstart,
Wend = returnWirePosition(phi_end, 1);
}
+void GridDriftChamber::cellposition2(int chamber,int layer, int cell,
+ TVector3& Wstart, TVector3& Wend) const {
+ updateParams(chamber,layer);
+ double phi_start = binToPosition(cell, _currentLayerphi, m_offset);
+ double phi_mid = phi_start + _currentLayerphi/2.;
+ double phi_end = phi_mid + returnAlpha();
+
+ Wstart = returnWirePosition(phi_mid, -1);
+ Wend = returnWirePosition(phi_end, 1);
+}
+
TVector3 GridDriftChamber::LineLineIntersect(TVector3& p1, TVector3& p2, TVector3& p3, TVector3& p4) const {
TVector3 p13, p43, p21;
@@ -171,6 +202,20 @@ double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hi
return DCA;
}
+double GridDriftChamber::distanceTrackWire2(const CellID& cID, const TVector3& hit_pos) const {
+
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
+
+ TVector3 denominator = Wend - Wstart;
+ TVector3 numerator = denominator.Cross(Wstart-hit_pos);
+
+ double DCA = numerator.Mag()/denominator.Mag() ;
+
+ return DCA;
+}
+
TVector3 GridDriftChamber::distanceClosestApproach(const CellID& cID, const TVector3& hitPos) const {
// Distance of the closest approach between a single hit (point) and the closest wire
@@ -253,6 +298,52 @@ TVector3 GridDriftChamber::IntersectionTrackWire(const CellID& cID, const TVecto
return intersect;
}
+double GridDriftChamber::Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition) const {
+
+ //For two lines r=r1+t1.v1 & r=r2+t2.v2
+ //the closest approach is d=|(r2-r1).(v1 x v2)|/|v1 x v2|
+ //the point where closest approach are
+ //t1=(v1 x v2).[(r2-r1) x v2]/[(v1 x v2).(v1 x v2)]
+ //t2=(v1 x v2).[(r2-r1) x v1]/[(v1 x v2).(v1 x v2)]
+ //if v1 x v2=0 means two lines are parallel
+ //d=|(r2-r1) x v1|/|v1|
+
+ double t1,distance,dInOut,dHitIn,dHitOut;
+ //Get wirepoint @ endplate
+ TVector3 west = {0,0,0};
+ TVector3 east = {0,0,0};
+ cellposition(cID,west,east);
+ TVector3 wireLine=east - west;
+ TVector3 hitLine=pointOut - pointIn;
+
+ TVector3 hitXwire=hitLine.Cross(wireLine);
+ TVector3 wire2hit=east-pointOut;
+ //Hitposition is the position on hit line where closest approach
+ //of two lines, but it may out the area from pointIn to pointOut
+ if(hitXwire.Mag()==0){
+ distance=wireLine.Cross(wire2hit).Mag()/wireLine.Mag();
+ hitPosition=pointIn;
+ }else{
+ t1=hitXwire.Dot(wire2hit.Cross(wireLine))/hitXwire.Mag2();
+ hitPosition=pointOut+t1*hitLine;
+
+ dInOut=(pointOut-pointIn).Mag();
+ dHitIn=(hitPosition-pointIn).Mag();
+ dHitOut=(hitPosition-pointOut).Mag();
+ if(dHitIn<=dInOut && dHitOut<=dInOut){ //Between point in & out
+ distance=fabs(wire2hit.Dot(hitXwire)/hitXwire.Mag());
+ }else if(dHitOut>dHitIn){ // out pointIn
+ distance=wireLine.Cross(pointIn-east).Mag()/wireLine.Mag();
+ hitPosition=pointIn;
+ }else{ // out pointOut
+ distance=wireLine.Cross(pointOut-east).Mag()/wireLine.Mag();
+ hitPosition=pointOut;
+ }
+ }
+
+ return distance;
+}
+
}
}
From 5b7f124ce93ae92d5a6d6e8ff9cca93ecc445217 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Thu, 28 Oct 2021 14:34:10 +0800
Subject: [PATCH 02/27] Remove unimportant output information
---
.../src/driftchamber/DriftChamber_tile.cpp | 307 ++++++++++++++++++
.../DetSegmentation/src/GridDriftChamber.cpp | 15 -
2 files changed, 307 insertions(+), 15 deletions(-)
create mode 100644 Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp
diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp
new file mode 100644
index 000000000..9fc2da070
--- /dev/null
+++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp
@@ -0,0 +1,307 @@
+//====================================================================
+// Detector description implementation of the Drift Chamber
+//--------------------------------------------------------------------
+//
+// Author: Tao Lin
+// Mengyao Liu
+//
+//====================================================================
+
+#include "DD4hep/DetFactoryHelper.h"
+#include "DD4hep/Printout.h"
+#include "XML/Layering.h"
+#include "XML/Utilities.h"
+#include "XML/XMLElements.h"
+#include "DDRec/DetectorData.h"
+#include "DDSegmentation/Segmentation.h"
+#include "DetSegmentation/GridDriftChamber.h"
+
+using namespace dd4hep;
+using namespace dd4hep::detail;
+using namespace dd4hep::rec ;
+
+#define MYDEBUG(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << x << std::endl;
+#define MYDEBUGVAL(x) std::cout << __FILE__ << ":" << __LINE__ << ": " << #x << ": " << x << std::endl;
+
+static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
+ xml_h e,
+ dd4hep::SensitiveDetector sens) {
+ // ------- Lambda functions ---- //
+ auto delta_a_func = [](auto x, auto y) { return 0.5 * ( x + y ); };
+ auto delta_b_func = [](auto x, auto y) { return 2 * std::sqrt((x + y) * (x - y)); };
+ auto epsilon_func = [](auto delta_a, auto L) { return std::atan(delta_a / L); };
+
+ // =======================================================================
+ // Parameter Definition
+ // =======================================================================
+
+ xml_det_t x_det = e;
+
+ xml_coll_t c(x_det,_U(chamber));
+ xml_comp_t x_chamber = c;
+
+ xml_coll_t cc(x_det,_U(side));
+ xml_comp_t x_side = cc;
+
+ std::string det_name = x_det.nameStr();
+ std::string det_type = x_det.typeStr();
+
+ dd4hep::SensitiveDetector sd = sens;
+
+ // - global
+ double chamber_half_length = theDetector.constant("DC_half_length");
+ double chamber_length = theDetector.constant("DC_length");
+
+ // - chamber
+ double chamber_radius_min = theDetector.constant("SDT_chamber_radius_min");
+ double chamber_radius_max = theDetector.constant("SDT_chamber_radius_max");
+ double SDT_half_length = theDetector.constant("SDT_chamber_half_length");
+ int chamberID = x_chamber.id();
+
+ // - layer
+ double chamber_layer_width = theDetector.constant("SDT_chamber_layer_width");
+ double chamber_cell_width = theDetector.constant("SDT_chamber_cell_width");
+ double chamber_layer_rbegin = theDetector.constant("DC_chamber_layer_rbegin");
+ double chamber_layer_rend = theDetector.constant("DC_chamber_layer_rend");
+ int chamber_layer_number = floor((chamber_layer_rend-chamber_layer_rbegin)/chamber_layer_width);
+
+ double cellsize = theDetector.constant("SDT_chamber_cell_width");
+
+ double safe_distance = theDetector.constant("DC_safe_distance");
+ double alpha = theDetector.constant("Alpha");
+
+ // =======================================================================
+ // Detector Construction
+ // =======================================================================
+
+ dd4hep::DetElement sdet(det_name, x_det.id());
+
+ Volume envelope = dd4hep::xml::createPlacedEnvelope( theDetector, e , sdet ) ;
+
+ dd4hep::xml::setDetectorTypeFlag( e, sdet ) ;
+
+ if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet ;
+
+
+// dd4hep::Material det_mat(theDetector.material("Air"));
+ dd4hep::Material det_mat(theDetector.material(x_det.materialStr()));
+// dd4hep::Material chamber_mat(theDetector.material("GasHe_90Isob_10"));
+ dd4hep::Material chamber_mat = theDetector.material(x_chamber.materialStr());
+
+ // - global
+ Assembly det_vol( det_name+"_assembly" ) ;
+
+ // - chamber volume
+ dd4hep::Tube det_chamber_solid(chamber_radius_min, chamber_radius_max, chamber_half_length);
+ dd4hep::Volume det_chamber_vol(det_name+"_chamber_vol", det_chamber_solid, chamber_mat);
+
+ // - wall
+ double chamber_inner_wall_rmin = theDetector.constant("SDT_chamber_inner_wall_radius_min");
+ double chamber_inner_wall_rmax = theDetector.constant("SDT_chamber_inner_wall_radius_max");
+ double chamber_outer_wall_rmin = theDetector.constant("SDT_chamber_outer_wall_radius_min");
+ double chamber_outer_wall_rmax = theDetector.constant("SDT_chamber_outer_wall_radius_max");
+
+// dd4hep::Material wall_mat(theDetector.material("CarbonFiber"));
+ dd4hep::Material wall_mat(theDetector.material(x_side.materialStr()));
+
+ double wall_rmin[2] = {chamber_inner_wall_rmin, chamber_outer_wall_rmin};
+ double wall_rmax[2] = {chamber_inner_wall_rmax, chamber_outer_wall_rmax};
+
+ // - wire
+ dd4hep::Volume module_vol;
+ dd4hep::Volume Module_vol;
+ for(xml_coll_t c(x_det,_U(module)); c; ++c) {
+ xml_comp_t x_module = c;
+ double module_rmin = x_module.rmin();
+ double module_rmax = x_module.rmax();
+ std::string module_name = x_module.nameStr();
+ dd4hep::Tube module_solid(module_rmin,module_rmax,chamber_half_length);
+ if(x_module.id()==0) {
+ module_vol = dd4hep::Volume(module_name,module_solid,det_mat);
+ module_vol.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
+ } else {
+ Module_vol = dd4hep::Volume(module_name,module_solid,det_mat);
+ Module_vol.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
+ }
+
+ for(xml_coll_t l(x_module,_U(tubs)); l; ++l) {
+ xml_comp_t x_tube =l;
+ double tube_rmin = x_tube.rmin();
+ double tube_rmax = x_tube.rmax();
+ std::string tube_name = x_tube.nameStr();
+ std::string wire_name= module_name + tube_name;
+ dd4hep::Material tube_mat = theDetector.material(x_tube.materialStr());
+ dd4hep::Tube wire_solid(tube_rmin,tube_rmax,chamber_half_length);
+ dd4hep::Volume wire_vol(wire_name,wire_solid,tube_mat);
+ dd4hep::Transform3D transform_wire(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.));
+ dd4hep::PlacedVolume wire_phy;
+ if(x_module.id()==0) {
+ wire_phy = module_vol.placeVolume(wire_vol,transform_wire);
+ } else {
+ wire_phy = Module_vol.placeVolume(wire_vol,transform_wire);
+ }
+ }
+ }
+
+ // End cap
+ double Endcap_rmin = theDetector.constant("DC_Endcap_rmin");
+ double Endcap_rmax = theDetector.constant("DC_Endcap_rmax");
+ double Endcap_z = theDetector.constant("DC_Endcap_dz");
+ dd4hep::Tube det_Endcap_solid(Endcap_rmin,Endcap_rmax,0.5*Endcap_z);
+ dd4hep::Volume det_Endcap_vol(det_name+"Endcap",det_Endcap_solid,det_mat);
+ det_Endcap_vol.setVisAttributes(theDetector,"YellowVis");
+
+ //Initialize the segmentation
+ dd4hep::Readout readout = sd.readout();
+ dd4hep::Segmentation geomseg = readout.segmentation();
+ dd4hep::Segmentation* _geoSeg = &geomseg;
+
+ auto DCHseg = dynamic_cast(_geoSeg->segmentation());
+
+ // - layer
+ int chamber_id = 0;
+ int layerIndex = -1;
+ for(int layer_id = 0; layer_id < chamber_layer_number; layer_id++) {
+
+ double rmin,rmax,offset=0;
+
+ double sign_eps = 1;
+
+ dd4hep::Volume* current_vol_ptr = nullptr;
+// current_vol_ptr = &det_chamber_vol;
+ rmin = chamber_layer_rbegin+(layer_id*chamber_layer_width);
+ rmax = rmin+chamber_layer_width;
+ layerIndex = layer_id;
+
+ //Construction of drift chamber layers
+ double rmid = delta_a_func(rmin,rmax);
+ double Rmid = rmid/std::cos(alpha/2);
+ double ilayer_cir = 2 * M_PI * rmid;
+ double ncell = ilayer_cir / chamber_layer_width;
+ int ncell_layer = floor(ncell);
+ int numWire = ncell_layer;
+ double layer_Phi = 2*M_PI / ncell_layer;
+
+ if(layer_id %2 ==0)
+ {
+ offset = 0.;
+ sign_eps = -1;
+ }
+ else { offset = 0.5 * layer_Phi; }
+
+
+ double epsilon = sign_eps*std::atan(2 * Rmid * std::tan(alpha / 2.0) / chamber_length);
+ double alpha0 = 2*std::asin(chamber_length * std::tan(epsilon)/(2*Rmid));
+
+ DCHseg->setGeomParams(chamber_id, layerIndex, layer_Phi, rmid, epsilon, offset);
+ DCHseg->setWiresInLayer(chamber_id, layerIndex, numWire);
+
+ double r_in_test = rmid*std::cos(alpha / 2.0);
+
+ double r_in0 = rmid - cellsize / 2.0;
+ double r_in = r_in0 / std::cos(alpha / 2.0);
+
+ double r_out0 = rmid + cellsize / 2.0;
+ double r_out = r_out0 / std::cos(alpha / 2.0);
+
+ double delta_a_in = delta_b_func(r_in, r_in0);
+ double delta_a_out = delta_b_func(r_out, r_out0);
+
+ double eps_in = epsilon_func(delta_a_in, chamber_length );
+ double eps_out = epsilon_func(delta_a_out, chamber_length );
+
+// dd4hep::Tube layer_vol_solid(rmin,rmax,chamber_half_length);
+ dd4hep::Hyperboloid layer_vol_solid(r_in0, eps_in, r_out0, eps_out, chamber_half_length);
+ dd4hep::Volume layer_vol(det_name+"_layer_vol",layer_vol_solid,det_mat);
+ current_vol_ptr = &layer_vol;
+
+ if ( x_det.isSensitive() ) {
+ layer_vol.setRegion(theDetector,x_det.regionStr());
+ layer_vol.setLimitSet(theDetector,x_det.limitsStr());
+ layer_vol.setSensitiveDetector(sens);
+ sd.setType("tracker");
+ }
+
+ // - wire vol
+ //phi <-------------------> -phi
+ // | F8 F7 F6 F5| Only on the outermost layer.
+ // | |
+ // | S F4|
+ // | |
+ // | F0 F1 F2 F3|
+ // -----------------------
+ for(int icell=0; icell< numWire; icell++) {
+ double wire_phi = (icell+0.5)*layer_Phi + offset;
+
+ // - signal wire
+ dd4hep::RotationZ rz(wire_phi);
+ dd4hep::RotationY ry(epsilon);
+ dd4hep::Position tr3D = Position(rmid*std::cos(0.5*M_PI+wire_phi),rmid*std::sin(0.5*M_PI+wire_phi),0.);
+ dd4hep::Transform3D transform_signal_wire(rz*ry,tr3D);
+
+ dd4hep::PlacedVolume module_phy = (*current_vol_ptr).placeVolume(module_vol,transform_signal_wire);
+ // - Field wire
+ dd4hep::PlacedVolume Module_phy;
+ double radius[5] = {rmid-chamber_layer_width*0.5+safe_distance,rmid-chamber_layer_width*0.5+safe_distance,rmid,rmid+chamber_layer_width*0.5-safe_distance,rmid+chamber_layer_width*0.5-safe_distance};
+ double phi[5] = {wire_phi,wire_phi-layer_Phi*0.5,wire_phi-layer_Phi*0.5,wire_phi-layer_Phi*0.5,wire_phi};
+ int num = 3;
+ if(layer_id==(chamber_layer_number-1)) {
+ num = 5;
+ }
+ for(int i=0; iset(cID, layer_id, layerid);
_decoder->set(cID, m_phiID, lphi);
From 6a46894c2a312996122f8674fcc9dd55352b996d Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Thu, 28 Oct 2021 14:59:17 +0800
Subject: [PATCH 03/27] Slanted version of the XML file
---
.../compact/det_inclined_wire.xml | 129 ++++++++++++++++++
1 file changed, 129 insertions(+)
create mode 100644 Detector/DetDriftChamber/compact/det_inclined_wire.xml
diff --git a/Detector/DetDriftChamber/compact/det_inclined_wire.xml b/Detector/DetDriftChamber/compact/det_inclined_wire.xml
new file mode 100644
index 000000000..b3cbfd81c
--- /dev/null
+++ b/Detector/DetDriftChamber/compact/det_inclined_wire.xml
@@ -0,0 +1,129 @@
+
+
+
+
+ Test with Drift Chamber
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ system:5,layer:7:9,chamber:8,cellID:32:16
+
+
+
+
+
+
+
+
+
+
+
+
From 7ce14446b3d8923896a6dbe26977dc5aadfddba3 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Thu, 28 Oct 2021 15:02:49 +0800
Subject: [PATCH 04/27] The diagonal wire version of the drift chamber in SDT
---
.../CRD_common_v01/DC_Simple_v01_03.xml | 88 +++++++++++++++++++
1 file changed, 88 insertions(+)
create mode 100644 Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml
new file mode 100644
index 000000000..801ad541c
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml
@@ -0,0 +1,88 @@
+
+
+
+
+ Test with Drift Chamber
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ system:5,layer:7:9,chamber:8,cellID:32:16
+
+
+
+
From bee3359587d8adf09f70ca22b5a7616bb6bdc3d8 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Sun, 31 Oct 2021 21:51:50 +0800
Subject: [PATCH 05/27] Modify the name of the DC's xml file
---
.../{DC_Simple_v01_03.xml => DC_Stero_v01_01.xml} | 3 ++-
.../{DC_Simple_v01_01.xml => DC_Straight_v01_01.xml} | 0
.../{DC_Simple_v01_02.xml => DC_Straight_v01_02.xml} | 0
Detector/DetDriftChamber/CMakeLists.txt | 2 +-
.../compact/{det_inclined_wire.xml => det_stero.xml} | 2 +-
.../{DriftChamber_tile.cpp => DriftChamber_stero.cpp} | 2 +-
6 files changed, 5 insertions(+), 4 deletions(-)
rename Detector/DetCRD/compact/CRD_common_v01/{DC_Simple_v01_03.xml => DC_Stero_v01_01.xml} (93%)
rename Detector/DetCRD/compact/CRD_common_v01/{DC_Simple_v01_01.xml => DC_Straight_v01_01.xml} (100%)
rename Detector/DetCRD/compact/CRD_common_v01/{DC_Simple_v01_02.xml => DC_Straight_v01_02.xml} (100%)
rename Detector/DetDriftChamber/compact/{det_inclined_wire.xml => det_stero.xml} (96%)
rename Detector/DetDriftChamber/src/driftchamber/{DriftChamber_tile.cpp => DriftChamber_stero.cpp} (99%)
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Stero_v01_01.xml
similarity index 93%
rename from Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml
rename to Detector/DetCRD/compact/CRD_common_v01/DC_Stero_v01_01.xml
index 801ad541c..fe303a521 100644
--- a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_03.xml
+++ b/Detector/DetCRD/compact/CRD_common_v01/DC_Stero_v01_01.xml
@@ -46,11 +46,12 @@
+
-
+
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Straight_v01_01.xml
similarity index 100%
rename from Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_01.xml
rename to Detector/DetCRD/compact/CRD_common_v01/DC_Straight_v01_01.xml
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Straight_v01_02.xml
similarity index 100%
rename from Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_02.xml
rename to Detector/DetCRD/compact/CRD_common_v01/DC_Straight_v01_02.xml
diff --git a/Detector/DetDriftChamber/CMakeLists.txt b/Detector/DetDriftChamber/CMakeLists.txt
index 7321b5e64..70a29ad77 100644
--- a/Detector/DetDriftChamber/CMakeLists.txt
+++ b/Detector/DetDriftChamber/CMakeLists.txt
@@ -16,7 +16,7 @@ find_package(ROOT COMPONENTS MathCore GenVector Geom REQUIRED)
gaudi_add_module(DetDriftChamber
SOURCES src/driftchamber/DriftChamber.cpp
- SOURCES src/driftchamber/DriftChamber_tile.cpp
+ SOURCES src/driftchamber/DriftChamber_stero.cpp
LINK DetSegmentation
${DD4hep_COMPONENT_LIBRARIES}
# ROOT Geant4
diff --git a/Detector/DetDriftChamber/compact/det_inclined_wire.xml b/Detector/DetDriftChamber/compact/det_stero.xml
similarity index 96%
rename from Detector/DetDriftChamber/compact/det_inclined_wire.xml
rename to Detector/DetDriftChamber/compact/det_stero.xml
index b3cbfd81c..44e919087 100644
--- a/Detector/DetDriftChamber/compact/det_inclined_wire.xml
+++ b/Detector/DetDriftChamber/compact/det_stero.xml
@@ -83,7 +83,7 @@
-
+
diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber_stero.cpp
similarity index 99%
rename from Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp
rename to Detector/DetDriftChamber/src/driftchamber/DriftChamber_stero.cpp
index 9fc2da070..0b9061a9f 100644
--- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber_tile.cpp
+++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber_stero.cpp
@@ -304,4 +304,4 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
}
-DECLARE_DETELEMENT(DriftChamber_tile, create_detector);
+DECLARE_DETELEMENT(DriftChamber_Stero, create_detector);
From a466721423eacea00555bc75f53df7e6ee4f76c6 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Sun, 31 Oct 2021 22:49:55 +0800
Subject: [PATCH 06/27] Add a layer of protection to variables
---
Digitisers/DCHDigi/src/DCHDigiAlg.cpp | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
index 4a68a1eaa..f9384dd89 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
@@ -92,7 +92,10 @@ StatusCode DCHDigiAlg::execute()
m_start = clock();
info() << "Processing " << _nEvt << " events " << endmsg;
- m_evt = _nEvt;
+ if(m_WriteAna && (nullptr!=m_tuple))
+ {
+ m_evt = _nEvt;
+ }
edm4hep::TrackerHitCollection* Vec = w_DigiDCHCol.createAndPut();
edm4hep::MCRecoTrackerAssociationCollection* AssoVec = w_AssociationCol.createAndPut();
const edm4hep::SimTrackerHitCollection* SimHitCol = r_SimDCHCol.get();
@@ -227,15 +230,15 @@ StatusCode DCHDigiAlg::execute()
debug()<<"output digi DCHhit size="<< Vec->size() <write();
if ( status.isFailure() ) {
error() << " Cannot fill N-tuple:" << long( m_tuple ) << endmsg;
return StatusCode::FAILURE;
}
}
- m_end = clock();
- m_time = (m_end - m_start);
return StatusCode::SUCCESS;
}
From b0baa330d0d242501d7a71a329561c9aaae8d804 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Wed, 23 Feb 2022 22:38:06 +0800
Subject: [PATCH 07/27] fix simulation issues
---
.../CRD_common_v01/DC_Simple_v01_05.xml | 79 ++++
.../CRD_o1_v01/CRD_Dimensions_v01_01.xml | 19 +-
.../CRD_o1_v02/CRD_Dimensions_v01_02.xml | 19 +-
Detector/DetDriftChamber/compact/det.xml | 59 ++-
.../src/driftchamber/DriftChamber.cpp | 292 +++++++------
.../DetSegmentation/GridDriftChamber.h | 72 +---
.../DetSegmentation/src/GridDriftChamber.cpp | 398 +++++++++---------
Digitisers/DCHDigi/src/DCHDigiAlg.cpp | 77 ++--
Digitisers/DCHDigi/src/DCHDigiAlg.h | 16 +-
9 files changed, 547 insertions(+), 484 deletions(-)
create mode 100644 Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_05.xml
diff --git a/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_05.xml b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_05.xml
new file mode 100644
index 000000000..6c05c4fa0
--- /dev/null
+++ b/Detector/DetCRD/compact/CRD_common_v01/DC_Simple_v01_05.xml
@@ -0,0 +1,79 @@
+
+
+
+
+ Test with Drift Chamber
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ system:5,layer:7:9,chamber:8,cellID:32:16
+
+
+
+
diff --git a/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml b/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
index 46959ebbe..5c0950c2a 100644
--- a/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v01/CRD_Dimensions_v01_01.xml
@@ -83,12 +83,16 @@
+
+
+
+
-
-
-
+
+
+
@@ -98,15 +102,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml b/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
index 46959ebbe..5c0950c2a 100644
--- a/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
+++ b/Detector/DetCRD/compact/CRD_o1_v02/CRD_Dimensions_v01_02.xml
@@ -83,12 +83,16 @@
+
+
+
+
-
-
-
+
+
+
@@ -98,15 +102,6 @@
-
-
-
-
-
-
-
-
-
diff --git a/Detector/DetDriftChamber/compact/det.xml b/Detector/DetDriftChamber/compact/det.xml
index 08b29c928..3c86627d3 100644
--- a/Detector/DetDriftChamber/compact/det.xml
+++ b/Detector/DetDriftChamber/compact/det.xml
@@ -1,15 +1,13 @@
-
+
- Test with Drift Chamber
+ version="v2">
+ Drift Chamber
@@ -17,7 +15,6 @@
-
@@ -25,41 +22,39 @@
-
+
-
-
+
+
+
+
+
-
-
+
+
-
-
+
-
-
-
-
-
-
+
+
-
-
-
+
+
+
+
+
+
+
-
-
-
-
+
+
-
-
@@ -84,13 +79,13 @@
-
+
-
+
@@ -112,7 +107,7 @@
-
+
system:5,layer:7:9,chamber:8,cellID:32:16
diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
index 02732bf5d..67b36859b 100644
--- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
+++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp
@@ -1,12 +1,3 @@
-//====================================================================
-// Detector description implementation of the Drift Chamber
-//--------------------------------------------------------------------
-//
-// Author: Tao Lin
-// Mengyao Liu
-//
-//====================================================================
-
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
#include "XML/Layering.h"
@@ -16,6 +7,9 @@
#include "DDSegmentation/Segmentation.h"
#include "DetSegmentation/GridDriftChamber.h"
+#include
+#include
+
using namespace dd4hep;
using namespace dd4hep::detail;
using namespace dd4hep::rec ;
@@ -27,12 +21,15 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
xml_h e,
dd4hep::SensitiveDetector sens) {
// ------- Lambda functions ---- //
- auto delta_a_func = [](auto x, auto y) { return 0.5 * ( x + y ); };
+ auto delta_b_func = [](auto x, auto y) { return 2 * std::sqrt((x + y) * (x - y)); };
+ auto epsilon_func = [](auto delta_a, auto L) { return std::atan(delta_a / L); };
// =======================================================================
// Parameter Definition
// =======================================================================
+ auto start = std::chrono::steady_clock::now();
+
xml_det_t x_det = e;
xml_coll_t c(x_det,_U(chamber));
@@ -47,24 +44,34 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
dd4hep::SensitiveDetector sd = sens;
// - global
- double chamber_half_length = theDetector.constant("DC_half_length");
- double chamber_length = theDetector.constant("DC_length");
+ double chamber_half_length = theDetector.constant("Gas_half_length");
+ double chamber_length = chamber_half_length*2;
- // - chamber
- double chamber_radius_min = theDetector.constant("SDT_chamber_radius_min");
- double chamber_radius_max = theDetector.constant("SDT_chamber_radius_max");
- double SDT_half_length = theDetector.constant("SDT_chamber_half_length");
+ double alpha = theDetector.constant("Alpha");
+ double Pi = 0;
+ if(0!=alpha) Pi = 0.5*M_PI;
+
+ double safe_distance = theDetector.constant("DC_safe_distance");
+
+ double DC_inner_wall_thickness = theDetector.constant("DC_inner_wall_thickness");
+ double DC_outer_wall_thickness = theDetector.constant("DC_outer_wall_thickness");
+
+ // - chamber gas
+ double DC_rend = theDetector.constant("DC_rend");
+
+ double chamber_radius_min = theDetector.constant("Gas_radius_min");
+ double chamber_radius_max = DC_rend-safe_distance-DC_outer_wall_thickness;
+ double layer_radius_max = chamber_radius_max*std::cos(alpha);
int chamberID = x_chamber.id();
// - layer
- double chamber_layer_width = theDetector.constant("SDT_chamber_layer_width");
- double chamber_cell_width = theDetector.constant("SDT_chamber_cell_width");
- double chamber_layer_rbegin = theDetector.constant("DC_chamber_layer_rbegin");
- double chamber_layer_rend = theDetector.constant("DC_chamber_layer_rend");
- int chamber_layer_number = floor((chamber_layer_rend-chamber_layer_rbegin)/chamber_layer_width);
+ int DC_layer_number = theDetector.constant("DC_layer_number");
- double safe_distance = theDetector.constant("DC_safe_distance");
- double alpha = theDetector.constant("Alpha");
+ double layer_width = (layer_radius_max-chamber_radius_min)/DC_layer_number;
+
+ double cell_width = theDetector.constant("DC_cell_width");
+
+ int DC_construct_wire = theDetector.constant("DC_construct_wire");
// =======================================================================
// Detector Construction
@@ -78,112 +85,113 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
if( theDetector.buildType() == BUILD_ENVELOPE ) return sdet ;
-
-// dd4hep::Material det_mat(theDetector.material("Air"));
dd4hep::Material det_mat(theDetector.material(x_det.materialStr()));
-// dd4hep::Material chamber_mat(theDetector.material("GasHe_90Isob_10"));
dd4hep::Material chamber_mat = theDetector.material(x_chamber.materialStr());
- // - global
+ /// - global
Assembly det_vol( det_name+"_assembly" ) ;
- // - chamber volume
+ /// - chamber volume
dd4hep::Tube det_chamber_solid(chamber_radius_min, chamber_radius_max, chamber_half_length);
dd4hep::Volume det_chamber_vol(det_name+"_chamber_vol", det_chamber_solid, chamber_mat);
- // - wall
- double chamber_inner_wall_rmin = theDetector.constant("SDT_chamber_inner_wall_radius_min");
- double chamber_inner_wall_rmax = theDetector.constant("SDT_chamber_inner_wall_radius_max");
- double chamber_outer_wall_rmin = theDetector.constant("SDT_chamber_outer_wall_radius_min");
- double chamber_outer_wall_rmax = theDetector.constant("SDT_chamber_outer_wall_radius_max");
+ /// - wall
+ double chamber_inner_wall_rmin = theDetector.constant("DC_inner_wall_radius_min");
+ double chamber_inner_wall_rmax = theDetector.constant("DC_inner_wall_radius_max");
+ double chamber_outer_wall_rmin = chamber_radius_max+safe_distance;
+ double chamber_outer_wall_rmax = chamber_outer_wall_rmin+DC_outer_wall_thickness;
-// dd4hep::Material wall_mat(theDetector.material("CarbonFiber"));
dd4hep::Material wall_mat(theDetector.material(x_side.materialStr()));
double wall_rmin[2] = {chamber_inner_wall_rmin, chamber_outer_wall_rmin};
double wall_rmax[2] = {chamber_inner_wall_rmax, chamber_outer_wall_rmax};
- // - wire
- dd4hep::Volume module_vol;
- dd4hep::Volume Module_vol;
- for(xml_coll_t c(x_det,_U(module)); c; ++c) {
- xml_comp_t x_module = c;
- double module_rmin = x_module.rmin();
- double module_rmax = x_module.rmax();
- std::string module_name = x_module.nameStr();
- dd4hep::Tube module_solid(module_rmin,module_rmax,chamber_half_length);
- if(x_module.id()==0) {
- module_vol = dd4hep::Volume(module_name,module_solid,det_mat);
- module_vol.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
- } else {
- Module_vol = dd4hep::Volume(module_name,module_solid,det_mat);
- Module_vol.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
- }
-
- for(xml_coll_t l(x_module,_U(tubs)); l; ++l) {
- xml_comp_t x_tube =l;
- double tube_rmin = x_tube.rmin();
- double tube_rmax = x_tube.rmax();
- std::string tube_name = x_tube.nameStr();
- std::string wire_name= module_name + tube_name;
- dd4hep::Material tube_mat = theDetector.material(x_tube.materialStr());
- dd4hep::Tube wire_solid(tube_rmin,tube_rmax,chamber_half_length);
- dd4hep::Volume wire_vol(wire_name,wire_solid,tube_mat);
- dd4hep::Transform3D transform_wire(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.));
- dd4hep::PlacedVolume wire_phy;
- if(x_module.id()==0) {
- wire_phy = module_vol.placeVolume(wire_vol,transform_wire);
- } else {
- wire_phy = Module_vol.placeVolume(wire_vol,transform_wire);
- }
- }
- }
-
- // End cap
- double Endcap_rmin = theDetector.constant("DC_Endcap_rmin");
- double Endcap_rmax = theDetector.constant("DC_Endcap_rmax");
- double Endcap_z = theDetector.constant("DC_Endcap_dz");
- dd4hep::Tube det_Endcap_solid(Endcap_rmin,Endcap_rmax,0.5*Endcap_z);
+ /// - construct wires
+ dd4hep::Volume signalWireVolume;
+ dd4hep::Volume fieldWireVolume;
+ for(xml_coll_t dcModule(x_det,_U(module)); dcModule; ++dcModule) {
+ xml_comp_t x_module = dcModule;
+ std::string module_name = x_module.nameStr();
+ dd4hep::Tube module_solid(x_module.rmin(),x_module.rmax(),chamber_half_length);
+ if(0==x_module.id()) {
+ signalWireVolume = dd4hep::Volume(module_name,module_solid,det_mat);
+ signalWireVolume.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
+ } else {
+ fieldWireVolume = dd4hep::Volume(module_name,module_solid,det_mat);
+ fieldWireVolume.setVisAttributes(theDetector.visAttributes(x_module.visStr()));
+ }
+
+ /// construct wire tubes
+ for(xml_coll_t l(x_module,_U(tubs)); l; ++l) {
+ xml_comp_t x_tube =l;
+ std::string wire_name= module_name + x_tube.nameStr();
+ dd4hep::Material tube_mat = theDetector.material(x_tube.materialStr());
+ dd4hep::Tube wire_solid(x_tube.rmin(),x_tube.rmax(),chamber_half_length);
+ dd4hep::Volume wire_vol(wire_name,wire_solid,tube_mat);
+ dd4hep::Transform3D transform_wire(dd4hep::Rotation3D(),dd4hep::Position(0.,0.,0.));
+ if(0==x_module.id()) {
+ signalWireVolume.placeVolume(wire_vol,transform_wire);
+ } else {
+ fieldWireVolume.placeVolume(wire_vol,transform_wire);
+ }
+ }//end of construct tubes
+ }//end of construct wire
+
+ /// construct End cap
+ double endcap_rmin = theDetector.constant("DC_Endcap_rmin");
+ double endcap_rmax = theDetector.constant("DC_Endcap_rmax");
+ double endcap_z = theDetector.constant("DC_Endcap_dz");
+ dd4hep::Tube det_Endcap_solid(endcap_rmin,endcap_rmax,0.5*endcap_z);
dd4hep::Volume det_Endcap_vol(det_name+"Endcap",det_Endcap_solid,det_mat);
det_Endcap_vol.setVisAttributes(theDetector,"YellowVis");
- //Initialize the segmentation
- dd4hep::Readout readout = sd.readout();
- dd4hep::Segmentation geomseg = readout.segmentation();
- dd4hep::Segmentation* _geoSeg = &geomseg;
-
- auto DCHseg = dynamic_cast(_geoSeg->segmentation());
+ ///Initialize the segmentation
+ auto segmentationDC =
+ dynamic_cast
+ (sd.readout().segmentation().segmentation());
- // - layer
+ /// - construct layers
int chamber_id = 0;
- int layerIndex = -1;
- for(int layer_id = 0; layer_id < chamber_layer_number; layer_id++) {
- double rmin,rmax,offset=0;
+ for(int layer_id = 0; layer_id < DC_layer_number; layer_id++) {
dd4hep::Volume* current_vol_ptr = nullptr;
-// current_vol_ptr = &det_chamber_vol;
- rmin = chamber_layer_rbegin+(layer_id*chamber_layer_width);
- rmax = rmin+chamber_layer_width;
- layerIndex = layer_id;
+ double layer_rmin = chamber_radius_min+(layer_id*layer_width);
+ double layer_rmax = layer_rmin+layer_width;
+ double rmid_zZero = (layer_rmin+layer_rmax)/2.; // z=0
+ double rmid_zEnd = rmid_zZero/std::cos(alpha/2); // z=endcap
+ int nCell = floor((2. * M_PI * rmid_zZero) / layer_width);
+ int nWire = nCell;
+ if(!DC_construct_wire) nWire =0;
+ double cell_phi = 2*M_PI / nCell;
+ double offset=0;//phi offset of first cell in each layer
+ double sign_eps = 1;// setero angle sign
+ if(0==(layer_id%2)) {
+ offset = 0.;
+ sign_eps = -1;
+ } else {
+ offset = 0.5 * cell_phi;
+ }
+ double epsilon = sign_eps*std::atan(rmid_zZero * std::tan(alpha / 2.0) / chamber_half_length);
+ //double alpha0 = 2*std::asin(chamber_length * std::tan(epsilon)/(2*rmid_zEnd));
- //Construction of drift chamber layers
- double rmid = delta_a_func(rmin,rmax);
- double Rmid = rmid/std::cos(alpha/2);
- double ilayer_cir = 2 * M_PI * rmid;
- double ncell = ilayer_cir / chamber_layer_width;
- int ncell_layer = floor(ncell);
- int numWire = ncell_layer;
- double layer_Phi = 2*M_PI / ncell_layer;
+ segmentationDC->setGeomParams(chamber_id, layer_id, cell_phi, rmid_zEnd , epsilon, offset);
+ segmentationDC->setWiresInLayer(chamber_id, layer_id, nCell);
- if(layer_id %2 ==0){ offset = 0.; }
- else { offset = 0.5 * layer_Phi; }
+ double r_in_test = rmid_zZero*std::cos(alpha / 2.0);
- double epsilon = 0;
+ double r_in0 = rmid_zZero - layer_width / 2.0;//
+ double r_in = r_in0 / std::cos(alpha / 2.0);//layer min at z=half length
- DCHseg->setGeomParams(chamber_id, layerIndex, layer_Phi, rmid, epsilon, offset);
- DCHseg->setWiresInLayer(chamber_id, layerIndex, numWire);
+ double r_out0 = rmid_zZero + layer_width / 2.0;
+ double r_out = r_out0 / std::cos(alpha / 2.0);
+ double delta_a_in = delta_b_func(r_in, r_in0);
+ double delta_a_out = delta_b_func(r_out, r_out0);
- dd4hep::Tube layer_vol_solid(rmin,rmax,chamber_half_length);
+ double eps_in = epsilon_func(delta_a_in, chamber_length );
+ double eps_out = epsilon_func(delta_a_out, chamber_length );
+
+ /// create hyper layer volume
+ dd4hep::Hyperboloid layer_vol_solid(r_in0, eps_in, r_out0, eps_out, chamber_half_length);
dd4hep::Volume layer_vol(det_name+"_layer_vol",layer_vol_solid,det_mat);
current_vol_ptr = &layer_vol;
@@ -194,46 +202,56 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector,
sd.setType("tracker");
}
- // - wire vol
- //phi <-------------------> -phi
- // | F8 F7 F6 F5| Only on the outermost layer.
- // | |
- // | S F4|
- // | |
- // | F0 F1 F2 F3|
- // -----------------------
- for(int icell=0; icell< numWire; icell++) {
- double wire_phi = (icell+0.5)*layer_Phi + offset;
+ // - create wire volume
+ //phi <---------------> -phi
+ // | F4 F3| Only on the outermost layer.
+ // | |
+ // | S F2|
+ // | |
+ // | F0 F1|
+ //--------------------
+ // loop over cells
+ for(int icell=0; icell elapsed_seconds = end-start;
+ std::cout << "elapsed time: " << elapsed_seconds.count() << "s\n";
return sdet;
}
diff --git a/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h b/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
index ad9d03604..911a6f4cb 100644
--- a/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
+++ b/Detector/DetSegmentation/include/DetSegmentation/GridDriftChamber.h
@@ -64,22 +64,21 @@ class GridDriftChamber : public Segmentation {
virtual void cellposition(const CellID& cID, TVector3& Wstart, TVector3& Wend) const;
virtual void cellposition2(int chamber, int layer, int cell, TVector3& Wstart, TVector3& Wend) const;
TVector3 LineLineIntersect(TVector3& p1, TVector3& p2, TVector3& p3, TVector3& p4) const;
- virtual TVector3 distanceClosestApproach(const CellID& cID, const TVector3& hitPos) const;
+ virtual TVector3 distanceClosestApproach(const CellID& cID, const TVector3& hitPos, TVector3& PCA) const;
virtual TVector3 Line_TrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const;
virtual TVector3 IntersectionTrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const;
virtual TVector3 wirePos_vs_z(const CellID& cID, const double& zpos) const;
- virtual double Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition) const;
+ virtual double Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition, TVector3& PCA) const;
+ virtual TVector3 returnPhi0(int chamber,int layer, double z) const;
+
// double phi(const CellID& cID) const;
inline double cell_Size() const { return m_cellSize; }
inline double epsilon() const { return m_epsilon; }
inline double detectorLength() const { return m_detectorLength; }
- inline double safe_distance() const { return m_safe_distance; }
inline double layer_width() const { return m_layer_width; }
inline double DC_rbegin() const { return m_DC_rbegin; }
inline double DC_rend() const { return m_DC_rend; }
- inline double DC_rmax() const { return m_DC_rmax; }
- inline double DC_rmin() const { return m_DC_rmin; }
inline const std::string& fieldNamePhi() const { return m_phiID; }
inline const std::string& Layerid() const { return layer_id; }
@@ -91,7 +90,13 @@ class GridDriftChamber : public Segmentation {
return hit_phi;
}
- inline void setGeomParams(int chamberID, int layerID, double layerphi, double R, double eps, double offset) {
+ inline double phiFromXY2(const TVector3& aposition) const {
+ double hit_phi = std::atan2(aposition.Y(), aposition.X()) ;
+ if( hit_phi < 0 ) { hit_phi += 2 * M_PI; }
+ return hit_phi;
+ }
+
+ inline void setGeomParams(int chamberID, int layerID, double layerphi, double R, double eps, double offset) {
layer_params.insert(std::pair(vID(chamberID,layerID),LAYER(layerphi,R,eps,offset)));
@@ -117,52 +122,6 @@ class GridDriftChamber : public Segmentation {
inline auto returnAllWires() const { return m_wiresPositions; }
-// TVector3 LineLineIntersect(TVector3 p1, TVector3 p2, TVector3 p3, TVector3 p4) const {
-// TVector3 p13, p43, p21;
-// double d1343, d4321, d1321, d4343, d2121;
-// double numer, denom;
-// double mua, mub;
-// TVector3 pa, pb;
-//
-// p13.SetX(p1.X() - p3.X());
-// p13.SetY(p1.Y() - p3.Y());
-// p13.SetZ(p1.Z() - p3.Z());
-// p43.SetX(p4.X() - p3.X());
-// p43.SetY(p4.Y() - p3.Y());
-// p43.SetZ(p4.Z() - p3.Z());
-// /* if (ABS(p43.X()) < EPS && ABS(p43.Y()) < EPS && ABS(p43.Z()) < EPS) */
-// /* return(FALSE); */
-// p21.SetX(p2.X() - p1.X());
-// p21.SetY(p2.Y() - p1.Y());
-// p21.SetZ(p2.Z() - p1.Z());
-// /* if (ABS(p21.X()) < EPS && ABS(p21.Y()) < EPS && ABS(p21.Z()) < EPS) */
-// /* return(FALSE); */
-//
-// d1343 = p13.X() * p43.X() + p13.Y() * p43.Y() + p13.Z() * p43.Z();
-// d4321 = p43.X() * p21.X() + p43.Y() * p21.Y() + p43.Z() * p21.Z();
-// d1321 = p13.X() * p21.X() + p13.Y() * p21.Y() + p13.Z() * p21.Z();
-// d4343 = p43.X() * p43.X() + p43.Y() * p43.Y() + p43.Z() * p43.Z();
-// d2121 = p21.X() * p21.X() + p21.Y() * p21.Y() + p21.Z() * p21.Z();
-//
-// denom = d2121 * d4343 - d4321 * d4321;
-// /* if (ABS(denom) < EPS) */
-// /* return(FALSE); */
-// numer = d1343 * d4321 - d1321 * d4343;
-//
-// mua = numer / denom;
-// mub = (d1343 + d4321 * (mua)) / d4343;
-//
-// pa.SetX(p1.X() + mua * p21.X());
-// pa.SetY(p1.Y() + mua * p21.Y());
-// pa.SetZ(p1.Z() + mua * p21.Z());
-// pb.SetX(p3.X() + mub * p43.X());
-// pb.SetY(p3.Y() + mub * p43.Y());
-// pb.SetZ(p3.Z() + mub * p43.Z());
-//
-// return pb - pa;
-// }
-
-
void updateParams(int chamber, int layer) const{
auto it_end = layer_params.cend();
--it_end;
@@ -184,8 +143,9 @@ class GridDriftChamber : public Segmentation {
_currentRadius = Radius;
m_epsilon = Eps;
m_offset = Offset;
- }
- inline Vector3D returnPosWire0(double z) const {
+ }
+
+ inline Vector3D returnPosWire0(double z) const {
double alpha = returnAlpha();
double t = 0.5 * (1 - 2.0 * z / m_detectorLength);
double x = _currentRadius * (1 + t * (std::cos(alpha) - 1));
@@ -195,6 +155,7 @@ class GridDriftChamber : public Segmentation {
return vec;
}
+
protected:
double phi(const CellID& cID) const;
@@ -218,11 +179,8 @@ class GridDriftChamber : public Segmentation {
// double m_epsilon0;
double m_detectorLength;
double m_layer_width;
- double m_safe_distance;
double m_DC_rbegin;
double m_DC_rend;
- double m_DC_rmax;
- double m_DC_rmin;
std::string m_phiID;
std::string layer_id;
diff --git a/Detector/DetSegmentation/src/GridDriftChamber.cpp b/Detector/DetSegmentation/src/GridDriftChamber.cpp
index b602315ba..b6cc05850 100644
--- a/Detector/DetSegmentation/src/GridDriftChamber.cpp
+++ b/Detector/DetSegmentation/src/GridDriftChamber.cpp
@@ -22,16 +22,12 @@ GridDriftChamber::GridDriftChamber(const BitFieldCoder* decoder) : Segmentation(
_description = "Drift chamber segmentation in the global coordinates";
registerParameter("cell_size", "cell size", m_cellSize, 1., SegmentationParameter::LengthUnit);
-// registerParameter("epsilon0", "epsilon", m_epsilon0, 0., SegmentationParameter::AngleUnit, true);
registerParameter("detector_length", "Length of the wire", m_detectorLength, 1., SegmentationParameter::LengthUnit);
registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "cellID");
registerIdentifier("layerID", "layer id", layer_id, "layer");
- registerParameter("safe_distance", "safe_distance", m_safe_distance, 0., SegmentationParameter::LengthUnit);
registerParameter("layer_width", "layer_width", m_layer_width, 0., SegmentationParameter::LengthUnit);
registerParameter("DC_rbegin", "DC_rbegin", m_DC_rbegin, 0., SegmentationParameter::LengthUnit);
registerParameter("DC_rend", "DC_rend", m_DC_rend, 0., SegmentationParameter::LengthUnit);
- registerParameter("DC_rmin", "DC_rmin", m_DC_rmin, 0., SegmentationParameter::LengthUnit);
- registerParameter("DC_rmax", "DC_rmax", m_DC_rmax, 0., SegmentationParameter::LengthUnit);
}
Vector3D GridDriftChamber::position(const CellID& /*cID*/) const {
@@ -45,146 +41,148 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3
CellID cID = vID;
int chamberID = _decoder->get(cID, "chamber");
+ int layerid = _decoder->get(cID, "layer");
double posx = globalPosition.X;
double posy = globalPosition.Y;
double posz = globalPosition.Z;
- Vector3D wire0 = returnPosWire0(posz);
- double phi_wire0 = phiFromXY(wire0);
-
- double radius = sqrt(posx*posx+posy*posy);
-
- int m_DC_layer_number = floor((m_DC_rend-m_DC_rbegin)/m_layer_width);
- double DC_layerdelta = m_layer_width;
-
- int layerid;
- if( radius<= m_DC_rend && radius>= m_DC_rbegin) {
- layerid = floor((radius - m_DC_rbegin)/DC_layerdelta);
- } else if ( radius>= (m_DC_rmin-m_safe_distance) && radius < m_DC_rbegin) {
- layerid = 0;
- } else if ( radius> m_DC_rend ) {//&& radius <= (m_DC_rmax+m_safe_distance)) {
- layerid = m_DC_layer_number-1;
- }
updateParams(chamberID,layerid);
+ TVector3 Phi0 = returnPhi0(chamberID,layerid,posz);
+ double phi0 = phiFromXY2(Phi0);
+
double phi_hit = phiFromXY(globalPosition);
double offsetphi= m_offset;
- int _lphi;
+ double _lphi;
- if(phi_hit >= (offsetphi+phi_wire0)) {
- _lphi = (int) ((phi_hit - offsetphi - phi_wire0)/ _currentLayerphi);
+ _lphi = phi_hit - phi0 + _currentLayerphi/2.;
+ if(_lphi<0.){
+ _lphi+=2*M_PI;
+ }else if(_lphi>2*M_PI){
+ _lphi=fmod(_lphi,2*M_PI);
}
- else {
- _lphi = (int) ((phi_hit - offsetphi - phi_wire0 + 2 * M_PI)/ _currentLayerphi);
- }
-
- int lphi = _lphi;
+ int cellID=floor(_lphi/_currentLayerphi);
- _decoder->set(cID, layer_id, layerid);
- _decoder->set(cID, m_phiID, lphi);
+ _decoder->set(cID, m_phiID, cellID);
return cID;
}
double GridDriftChamber::phi(const CellID& cID) const {
- CellID phiValue = _decoder->get(cID, m_phiID);
- return binToPosition(phiValue, _currentLayerphi, m_offset);
+ CellID phiValue = _decoder->get(cID, m_phiID);
+ return binToPosition(phiValue, _currentLayerphi, m_offset);
}
void GridDriftChamber::cellposition(const CellID& cID, TVector3& Wstart,
- TVector3& Wend) const {
+ TVector3& Wend) const {
- auto chamberIndex = _decoder->get(cID, "chamber");
- auto layerIndex = _decoder->get(cID, "layer");
- updateParams(chamberIndex,layerIndex);
+ auto chamberIndex = _decoder->get(cID, "chamber");
+ auto layerIndex = _decoder->get(cID, "layer");
+ updateParams(chamberIndex,layerIndex);
- double phi_start = phi(cID);
- double phi_mid = phi_start + _currentLayerphi/2.;
- double phi_end = phi_mid + returnAlpha();
+ double phi_start = phi(cID);
+ double phi_end = phi_start + returnAlpha();
- Wstart = returnWirePosition(phi_mid, -1);
- Wend = returnWirePosition(phi_end, 1);
+ Wstart = returnWirePosition(phi_start, -1);
+ Wend = returnWirePosition(phi_end, 1);
}
+TVector3 GridDriftChamber::returnPhi0(int chamber,int layer, double z) const
+{
+ updateParams(chamber,layer);
+
+ double phi_wire_start = binToPosition(0 , _currentLayerphi, m_offset);
+ double phi_wire_end = phi_wire_start + returnAlpha();
+
+ TVector3 wire_start = returnWirePosition(phi_wire_start, -1);
+ TVector3 wire_end = returnWirePosition(phi_wire_end, 1);
+
+ double ratio = fabs(z - wire_start.Z())/fabs(wire_end.Z() - wire_start.Z());
+ double x_pos = ratio * (wire_end.X() - wire_start.X()) + wire_start.X();
+ double y_pos = ratio * (wire_end.Y() - wire_start.Y()) + wire_start.Y();
+
+ return TVector3(x_pos,y_pos,z);
+}
+
+
void GridDriftChamber::cellposition2(int chamber,int layer, int cell,
- TVector3& Wstart, TVector3& Wend) const {
- updateParams(chamber,layer);
- double phi_start = binToPosition(cell, _currentLayerphi, m_offset);
- double phi_mid = phi_start + _currentLayerphi/2.;
- double phi_end = phi_mid + returnAlpha();
-
- Wstart = returnWirePosition(phi_mid, -1);
- Wend = returnWirePosition(phi_end, 1);
+ TVector3& Wstart, TVector3& Wend) const {
+ updateParams(chamber,layer);
+ double phi_start = binToPosition(cell, _currentLayerphi, m_offset);
+ double phi_end = phi_start + returnAlpha();
+
+ Wstart = returnWirePosition(phi_start, -1);
+ Wend = returnWirePosition(phi_end, 1);
}
TVector3 GridDriftChamber::LineLineIntersect(TVector3& p1, TVector3& p2, TVector3& p3, TVector3& p4) const {
- TVector3 p13, p43, p21;
- double d1343, d4321, d1321, d4343, d2121;
- double numer, denom;
- double mua, mub;
- TVector3 pa, pb;
-
- p13.SetX(p1.X() - p3.X());
- p13.SetY(p1.Y() - p3.Y());
- p13.SetZ(p1.Z() - p3.Z());
- p43.SetX(p4.X() - p3.X());
- p43.SetY(p4.Y() - p3.Y());
- p43.SetZ(p4.Z() - p3.Z());
- /* if (ABS(p43.X()) < EPS && ABS(p43.Y()) < EPS && ABS(p43.Z()) < EPS) */
- /* return(FALSE); */
- p21.SetX(p2.X() - p1.X());
- p21.SetY(p2.Y() - p1.Y());
- p21.SetZ(p2.Z() - p1.Z());
- /* if (ABS(p21.X()) < EPS && ABS(p21.Y()) < EPS && ABS(p21.Z()) < EPS) */
- /* return(FALSE); */
-
- d1343 = p13.X() * p43.X() + p13.Y() * p43.Y() + p13.Z() * p43.Z();
- d4321 = p43.X() * p21.X() + p43.Y() * p21.Y() + p43.Z() * p21.Z();
- d1321 = p13.X() * p21.X() + p13.Y() * p21.Y() + p13.Z() * p21.Z();
- d4343 = p43.X() * p43.X() + p43.Y() * p43.Y() + p43.Z() * p43.Z();
- d2121 = p21.X() * p21.X() + p21.Y() * p21.Y() + p21.Z() * p21.Z();
-
- denom = d2121 * d4343 - d4321 * d4321;
- /* if (ABS(denom) < EPS) */
- /* return(FALSE); */
- numer = d1343 * d4321 - d1321 * d4343;
-
- mua = numer / denom;
- mub = (d1343 + d4321 * (mua)) / d4343;
-
- pa.SetX(p1.X() + mua * p21.X());
- pa.SetY(p1.Y() + mua * p21.Y());
- pa.SetZ(p1.Z() + mua * p21.Z());
- pb.SetX(p3.X() + mub * p43.X());
- pb.SetY(p3.Y() + mub * p43.Y());
- pb.SetZ(p3.Z() + mub * p43.Z());
-
- return pb - pa;
+ TVector3 p13, p43, p21;
+ double d1343, d4321, d1321, d4343, d2121;
+ double numer, denom;
+ double mua, mub;
+ TVector3 pa, pb;
+
+ p13.SetX(p1.X() - p3.X());
+ p13.SetY(p1.Y() - p3.Y());
+ p13.SetZ(p1.Z() - p3.Z());
+ p43.SetX(p4.X() - p3.X());
+ p43.SetY(p4.Y() - p3.Y());
+ p43.SetZ(p4.Z() - p3.Z());
+ /* if (ABS(p43.X()) < EPS && ABS(p43.Y()) < EPS && ABS(p43.Z()) < EPS) */
+ /* return(FALSE); */
+ p21.SetX(p2.X() - p1.X());
+ p21.SetY(p2.Y() - p1.Y());
+ p21.SetZ(p2.Z() - p1.Z());
+ /* if (ABS(p21.X()) < EPS && ABS(p21.Y()) < EPS && ABS(p21.Z()) < EPS) */
+ /* return(FALSE); */
+
+ d1343 = p13.X() * p43.X() + p13.Y() * p43.Y() + p13.Z() * p43.Z();
+ d4321 = p43.X() * p21.X() + p43.Y() * p21.Y() + p43.Z() * p21.Z();
+ d1321 = p13.X() * p21.X() + p13.Y() * p21.Y() + p13.Z() * p21.Z();
+ d4343 = p43.X() * p43.X() + p43.Y() * p43.Y() + p43.Z() * p43.Z();
+ d2121 = p21.X() * p21.X() + p21.Y() * p21.Y() + p21.Z() * p21.Z();
+
+ denom = d2121 * d4343 - d4321 * d4321;
+ /* if (ABS(denom) < EPS) */
+ /* return(FALSE); */
+ numer = d1343 * d4321 - d1321 * d4343;
+
+ mua = numer / denom;
+ mub = (d1343 + d4321 * (mua)) / d4343;
+
+ pa.SetX(p1.X() + mua * p21.X());
+ pa.SetY(p1.Y() + mua * p21.Y());
+ pa.SetZ(p1.Z() + mua * p21.Z());
+ pb.SetX(p3.X() + mub * p43.X());
+ pb.SetY(p3.Y() + mub * p43.Y());
+ pb.SetZ(p3.Z() + mub * p43.Z());
+
+ return pb - pa;
}
double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hit_start,
- const TVector3& hit_end) const {
+ const TVector3& hit_end) const {
- TVector3 Wstart = {0,0,0};
- TVector3 Wend = {0,0,0};
- cellposition(cID,Wstart,Wend);
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
- TVector3 a = (hit_end - hit_start).Unit();
- TVector3 b = (Wend - Wstart).Unit();
- TVector3 c = Wstart - hit_start;
+ TVector3 a = (hit_end - hit_start).Unit();
+ TVector3 b = (Wend - Wstart).Unit();
+ TVector3 c = Wstart - hit_start;
- double num = std::abs(c.Dot(a.Cross(b)));
- double denum = (a.Cross(b)).Mag();
+ double num = std::abs(c.Dot(a.Cross(b)));
+ double denum = (a.Cross(b)).Mag();
- double DCA = 0;
+ double DCA = 0;
- if (denum) {
- DCA = num / denum;
- }
+ if (denum) {
+ DCA = num / denum;
+ }
- return DCA;
+ return DCA;
}
double GridDriftChamber::distanceTrackWire2(const CellID& cID, const TVector3& hit_pos) const {
@@ -201,132 +199,134 @@ double GridDriftChamber::distanceTrackWire2(const CellID& cID, const TVector3& h
return DCA;
}
-TVector3 GridDriftChamber::distanceClosestApproach(const CellID& cID, const TVector3& hitPos) const {
- // Distance of the closest approach between a single hit (point) and the closest wire
+TVector3 GridDriftChamber::distanceClosestApproach(const CellID& cID, const TVector3& hitPos, TVector3& PCA) const {
+ // Distance of the closest approach between a single hit (point) and the closest wire
- TVector3 Wstart = {0,0,0};
- TVector3 Wend = {0,0,0};
- cellposition(cID,Wstart,Wend);
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
- TVector3 temp = (Wend + Wstart);
- TVector3 Wmid(temp.X() / 2.0, temp.Y() / 2.0, temp.Z() / 2.0);
+ TVector3 temp = (Wend + Wstart);
+ TVector3 Wmid(temp.X() / 2.0, temp.Y() / 2.0, temp.Z() / 2.0);
- double hitPhi = hitPos.Phi();
- if (hitPhi < 0) {
- hitPhi = hitPhi + 2 * M_PI;
- }
+ double hitPhi = hitPos.Phi();
+ if (hitPhi < 0) {
+ hitPhi = hitPhi + 2 * M_PI;
+ }
- TVector3 PCA = Wstart + ((Wend - Wstart).Unit()).Dot((hitPos - Wstart)) * ((Wend - Wstart).Unit());
- TVector3 dca = hitPos - PCA;
+ PCA = Wstart + ((Wend - Wstart).Unit()).Dot((hitPos - Wstart)) * ((Wend - Wstart).Unit());
+ TVector3 dca = hitPos - PCA;
- return dca;
+ return dca;
}
TVector3 GridDriftChamber::Line_TrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const {
- // The line connecting a particle track to the closest wire
- // Returns the vector connecting the both
- TVector3 Wstart = {0,0,0};
- TVector3 Wend = {0,0,0};
- cellposition(cID,Wstart,Wend);
-
- TVector3 P1 = hit_start;
- TVector3 P2 = hit_end;
- TVector3 P3 = Wstart;
- TVector3 P4 = Wend;
-
- TVector3 intersect = LineLineIntersect(P1, P2, P3, P4);
- return intersect;
+ // The line connecting a particle track to the closest wire
+ // Returns the vector connecting the both
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
+
+ TVector3 P1 = hit_start;
+ TVector3 P2 = hit_end;
+ TVector3 P3 = Wstart;
+ TVector3 P4 = Wend;
+
+ TVector3 intersect = LineLineIntersect(P1, P2, P3, P4);
+ return intersect;
}
// Get the wire position for a z
TVector3 GridDriftChamber::wirePos_vs_z(const CellID& cID, const double& zpos) const {
- TVector3 Wstart = {0,0,0};
- TVector3 Wend = {0,0,0};
- cellposition(cID,Wstart,Wend);
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
- double t = (zpos - Wstart.Z())/(Wend.Z()-Wstart.Z());
- double x = Wstart.X()+t*(Wend.X()-Wstart.X());
- double y = Wstart.Y()+t*(Wend.Y()-Wstart.Y());
+ double t = (zpos - Wstart.Z())/(Wend.Z()-Wstart.Z());
+ double x = Wstart.X()+t*(Wend.X()-Wstart.X());
+ double y = Wstart.Y()+t*(Wend.Y()-Wstart.Y());
- TVector3 wireCoord(x, y, zpos);
- return wireCoord;
+ TVector3 wireCoord(x, y, zpos);
+ return wireCoord;
}
TVector3 GridDriftChamber::IntersectionTrackWire(const CellID& cID, const TVector3& hit_start, const TVector3& hit_end) const {
- // Intersection between the particle track and the wire assuming that the track between hit_start and hit_end is linear
+ // Intersection between the particle track and the wire assuming that the track between hit_start and hit_end is linear
- TVector3 Wstart = {0,0,0};
- TVector3 Wend = {0,0,0};
- cellposition(cID,Wstart,Wend);
+ TVector3 Wstart = {0,0,0};
+ TVector3 Wend = {0,0,0};
+ cellposition(cID,Wstart,Wend);
- TVector3 P1 = hit_start;
- TVector3 V1 = hit_end-hit_start;
+ TVector3 P1 = hit_start;
+ TVector3 V1 = hit_end-hit_start;
- TVector3 P2 = Wstart;
- TVector3 V2 = Wend - Wstart;
+ TVector3 P2 = Wstart;
+ TVector3 V2 = Wend - Wstart;
- TVector3 denom = V1.Cross(V2);
- double mag_denom = denom.Mag();
+ TVector3 denom = V1.Cross(V2);
+ double mag_denom = denom.Mag();
- TVector3 intersect(0, 0, 0);
+ TVector3 intersect(0, 0, 0);
- if (mag_denom !=0)
+ if (mag_denom !=0)
{
- TVector3 num = ((P2-P1)).Cross(V2);
- double mag_num = num.Mag();
- double a = mag_num / mag_denom;
+ TVector3 num = ((P2-P1)).Cross(V2);
+ double mag_num = num.Mag();
+ double a = mag_num / mag_denom;
- intersect = P1 + a * V1;
+ intersect = P1 + a * V1;
}
- return intersect;
+ return intersect;
}
-double GridDriftChamber::Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition) const {
-
- //For two lines r=r1+t1.v1 & r=r2+t2.v2
- //the closest approach is d=|(r2-r1).(v1 x v2)|/|v1 x v2|
- //the point where closest approach are
- //t1=(v1 x v2).[(r2-r1) x v2]/[(v1 x v2).(v1 x v2)]
- //t2=(v1 x v2).[(r2-r1) x v1]/[(v1 x v2).(v1 x v2)]
- //if v1 x v2=0 means two lines are parallel
- //d=|(r2-r1) x v1|/|v1|
-
- double t1,distance,dInOut,dHitIn,dHitOut;
- //Get wirepoint @ endplate
- TVector3 west = {0,0,0};
- TVector3 east = {0,0,0};
- cellposition(cID,west,east);
- TVector3 wireLine=east - west;
- TVector3 hitLine=pointOut - pointIn;
-
- TVector3 hitXwire=hitLine.Cross(wireLine);
- TVector3 wire2hit=east-pointOut;
- //Hitposition is the position on hit line where closest approach
- //of two lines, but it may out the area from pointIn to pointOut
- if(hitXwire.Mag()==0){
- distance=wireLine.Cross(wire2hit).Mag()/wireLine.Mag();
- hitPosition=pointIn;
- }else{
- t1=hitXwire.Dot(wire2hit.Cross(wireLine))/hitXwire.Mag2();
- hitPosition=pointOut+t1*hitLine;
-
- dInOut=(pointOut-pointIn).Mag();
- dHitIn=(hitPosition-pointIn).Mag();
- dHitOut=(hitPosition-pointOut).Mag();
- if(dHitIn<=dInOut && dHitOut<=dInOut){ //Between point in & out
- distance=fabs(wire2hit.Dot(hitXwire)/hitXwire.Mag());
- }else if(dHitOut>dHitIn){ // out pointIn
- distance=wireLine.Cross(pointIn-east).Mag()/wireLine.Mag();
- hitPosition=pointIn;
- }else{ // out pointOut
- distance=wireLine.Cross(pointOut-east).Mag()/wireLine.Mag();
- hitPosition=pointOut;
+double GridDriftChamber::Distance(const CellID& cID, const TVector3& pointIn, const TVector3& pointOut, TVector3& hitPosition, TVector3& PCA) const {
+
+ //For two lines r=r1+t1.v1 & r=r2+t2.v2
+ //the closest approach is d=|(r2-r1).(v1 x v2)|/|v1 x v2|
+ //the point where closest approach are
+ //t1=(v1 x v2).[(r2-r1) x v2]/[(v1 x v2).(v1 x v2)]
+ //t2=(v1 x v2).[(r2-r1) x v1]/[(v1 x v2).(v1 x v2)]
+ //if v1 x v2=0 means two lines are parallel
+ //d=|(r2-r1) x v1|/|v1|
+
+ double t1,distance,dInOut,dHitIn,dHitOut;
+ //Get wirepoint @ endplate
+ TVector3 west = {0,0,0};
+ TVector3 east = {0,0,0};
+ cellposition(cID,west,east);
+ TVector3 wireLine=east - west;
+ TVector3 hitLine=pointOut - pointIn;
+
+ TVector3 hitXwire=hitLine.Cross(wireLine);
+ TVector3 wire2hit=east-pointOut;
+ //Hitposition is the position on hit line where closest approach
+ //of two lines, but it may out the area from pointIn to pointOut
+ if(hitXwire.Mag()==0){
+ distance=wireLine.Cross(wire2hit).Mag()/wireLine.Mag();
+ hitPosition=pointIn;
+ }else{
+ t1=hitXwire.Dot(wire2hit.Cross(wireLine))/hitXwire.Mag2();
+ hitPosition=pointOut+t1*hitLine;
+
+ dInOut=(pointOut-pointIn).Mag();
+ dHitIn=(hitPosition-pointIn).Mag();
+ dHitOut=(hitPosition-pointOut).Mag();
+ if(dHitIn<=dInOut && dHitOut<=dInOut){ //Between point in & out
+ distance=fabs(wire2hit.Dot(hitXwire)/hitXwire.Mag());
+ }else if(dHitOut>dHitIn){ // out pointIn
+ distance=wireLine.Cross(pointIn-east).Mag()/wireLine.Mag();
+ hitPosition=pointIn;
+ }else{ // out pointOut
+ distance=wireLine.Cross(pointOut-east).Mag()/wireLine.Mag();
+ hitPosition=pointOut;
+ }
}
- }
- return distance;
+ PCA = west + ((east - west).Unit()).Dot((hitPosition - west)) * ((east - west).Unit());
+
+ return distance;
}
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
index f9384dd89..661f59f60 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
@@ -1,4 +1,3 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include "DCHDigiAlg.h"
@@ -28,15 +27,15 @@ DCHDigiAlg::DCHDigiAlg(const std::string& name, ISvcLocator* svcLoc)
: GaudiAlgorithm(name, svcLoc),
_nEvt(0)
{
-
+
// Input collections
declareProperty("SimDCHitCollection", r_SimDCHCol, "Handle of the Input SimHit collection");
-
+
// Output collections
declareProperty("DigiDCHitCollection", w_DigiDCHCol, "Handle of Digi DCHit collection");
-
+
declareProperty("AssociationCollection", w_AssociationCol, "Handle of Association collection");
-
+
}
StatusCode DCHDigiAlg::initialize()
@@ -54,6 +53,7 @@ StatusCode DCHDigiAlg::initialize()
}
if(m_WriteAna){
+
NTuplePtr nt( ntupleSvc(), "MyTuples/DCH_digi_evt" );
if ( nt ) m_tuple = nt;
else {
@@ -71,10 +71,16 @@ StatusCode DCHDigiAlg::initialize()
m_tuple->addItem( "cell" , m_n_digi, m_cell ).ignore();
m_tuple->addItem( "cell_x" , m_n_digi, m_cell_x ).ignore();
m_tuple->addItem( "cell_y" , m_n_digi, m_cell_y ).ignore();
+ m_tuple->addItem( "cell1_x" , m_n_digi, m_cell1_x ).ignore();
+ m_tuple->addItem( "cell1_y" , m_n_digi, m_cell1_y ).ignore();
m_tuple->addItem( "hit_x" , m_n_digi,m_hit_x ).ignore();
m_tuple->addItem( "hit_y" , m_n_digi,m_hit_y ).ignore();
m_tuple->addItem( "hit_z" , m_n_digi,m_hit_z ).ignore();
- m_tuple->addItem( "dca" , m_n_digi,m_dca ).ignore();
+ m_tuple->addItem( "mom_x" , m_n_digi,m_mom_x ).ignore();
+ m_tuple->addItem( "mom_y" , m_n_digi,m_mom_y ).ignore();
+ m_tuple->addItem( "dca" , m_n_digi, m_dca ).ignore();
+ m_tuple->addItem( "poca_x" , m_n_digi, m_poca_x ).ignore();
+ m_tuple->addItem( "poca_y" , m_n_digi, m_poca_y ).ignore();
m_tuple->addItem( "hit_dE" , m_n_digi,m_hit_dE ).ignore();
m_tuple->addItem( "hit_dE_dx", m_n_digi,m_hit_dE_dx ).ignore();
} else { // did not manage to book the N tuple....
@@ -92,10 +98,7 @@ StatusCode DCHDigiAlg::execute()
m_start = clock();
info() << "Processing " << _nEvt << " events " << endmsg;
- if(m_WriteAna && (nullptr!=m_tuple))
- {
- m_evt = _nEvt;
- }
+ if(m_WriteAna) m_evt = _nEvt;
edm4hep::TrackerHitCollection* Vec = w_DigiDCHCol.createAndPut();
edm4hep::MCRecoTrackerAssociationCollection* AssoVec = w_AssociationCol.createAndPut();
const edm4hep::SimTrackerHitCollection* SimHitCol = r_SimDCHCol.get();
@@ -105,8 +108,8 @@ StatusCode DCHDigiAlg::execute()
debug()<<"input sim hit size="<< SimHitCol->size() <at(0);
- std::map > id_hits_map;
- //std::map > id_hits_map;
+ std::map> id_hits_map;
+
for( int i = 0; i < SimHitCol->size(); i++ )
{
@@ -114,7 +117,8 @@ StatusCode DCHDigiAlg::execute()
unsigned long long id = SimHit.getCellID();
float sim_hit_mom = sqrt( SimHit.getMomentum()[0]*SimHit.getMomentum()[0] + SimHit.getMomentum()[1]*SimHit.getMomentum()[1] + SimHit.getMomentum()[2]*SimHit.getMomentum()[2] );//GeV
if(sim_hit_mom < m_mom_threshold) continue;
- if(SimHit.getEDep() <= 0) continue;
+ if(sim_hit_mom > m_mom_threshold_high) continue;
+ if(SimHit.getEDep() <= m_edep_threshold) continue;
if ( id_hits_map.find(id) != id_hits_map.end()) id_hits_map[id].push_back(SimHit);
else
@@ -138,6 +142,7 @@ StatusCode DCHDigiAlg::execute()
double pos_x = 0 ;
double pos_y = 0 ;
double pos_z = 0 ;
+ double momx,momy = 0;
int simhit_size = iter->second.size();
for(unsigned int i=0; i< simhit_size; i++)
{
@@ -151,50 +156,48 @@ StatusCode DCHDigiAlg::execute()
m_segmentation->cellposition(wcellid, Wstart, Wend);
float dd4hep_mm = dd4hep::mm;
//std::cout<<"dd4hep_mm="<second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] + iter->second.at(i).getMomentum()[2]*iter->second.at(i).getMomentum()[2] );//GeV
float sim_hit_pt = sqrt( iter->second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] );//GeV
TVector3 pos(iter->second.at(i).getPosition()[0]*dd4hep_mm, iter->second.at(i).getPosition()[1]*dd4hep_mm, iter->second.at(i).getPosition()[2]*dd4hep_mm);
-// TVector3 numerator = denominator.Cross(Wstart-pos) ;
-// float tmp_distance = numerator.Mag()/denominator.Mag() ;
-
TVector3 sim_mon(iter->second.at(i).getMomentum()[0],iter->second.at(i).getMomentum()[1],iter->second.at(i).getMomentum()[2]);
float Steplength = iter->second.at(i).getPathLength();
TVector3 pos_start = pos - 0.5 * Steplength * sim_mon.Unit();
TVector3 pos_end = pos + 0.5 * Steplength * sim_mon.Unit();
- if(m_Doca) {
- tmp_distance = m_segmentation->distanceTrackWire(wcellid,pos_start,pos_end);
- tmp_distance = tmp_distance/dd4hep_mm; //mm
- } else {
- tmp_distance = (m_segmentation->distanceClosestApproach(wcellid,pos)).Mag();
- tmp_distance = tmp_distance/dd4hep_mm; //mm
- }
-
+ tmp_distance = m_segmentation->Distance(wcellid,pos_start,pos_end,hitPosition,PCA);
+ tmp_distance = tmp_distance/dd4hep_mm; //mm
// std::cout << " Steplength= " << Steplength << std::endl;
- // std::cout<<"tmp_distance="<second.at(i).getMomentum()[0];
+ momy = iter->second.at(i).getMomentum()[1];
}
tot_length += iter->second.at(i).getPathLength();//mm
auto asso = AssoVec->create();
asso.setRec(trkHit);
asso.setSim(iter->second.at(i));
asso.setWeight(iter->second.at(i).getEDep()/tot_edep);
+ //std::cout<<" asso setRec setSim "<second.at(i)< m_cell ;
NTuple::Array m_cell_x ;
NTuple::Array m_cell_y ;
+ NTuple::Array m_cell1_x ;
+ NTuple::Array m_cell1_y ;
NTuple::Array m_simhit_x ;
NTuple::Array m_simhit_y ;
NTuple::Array m_simhit_z ;
NTuple::Array m_hit_x ;
NTuple::Array m_hit_y ;
NTuple::Array m_hit_z ;
+ NTuple::Array m_mom_x ;
+ NTuple::Array m_mom_y ;
NTuple::Array m_dca ;
+ NTuple::Array m_poca_x ;
+ NTuple::Array m_poca_y ;
NTuple::Array m_hit_dE ;
NTuple::Array m_hit_dE_dx ;
@@ -69,16 +75,18 @@ class DCHDigiAlg : public GaudiAlgorithm
dd4hep::rec::CellIDPositionConverter* m_cellIDConverter;
dd4hep::DDSegmentation::GridDriftChamber* m_segmentation;
dd4hep::DDSegmentation::BitFieldCoder* m_decoder;
-
+
Gaudi::Property m_readout_name{ this, "readout", "DriftChamberHitsCollection"};//readout for getting segmentation
-
+
Gaudi::Property m_res_x { this, "res_x", 0.11};//mm
Gaudi::Property m_res_y { this, "res_y", 0.11};//mm
Gaudi::Property m_res_z { this, "res_z", 1 };//mm
Gaudi::Property m_velocity { this, "drift_velocity", 40};// um/ns
Gaudi::Property m_mom_threshold { this, "mom_threshold", 0};// GeV
+ Gaudi::Property m_mom_threshold_high { this, "mom_threshold_high", 1e9};// GeV
+ Gaudi::Property m_edep_threshold{ this, "edep_threshold", 0};// GeV
Gaudi::Property m_WriteAna { this, "WriteAna", false};
- Gaudi::Property m_Doca { this, "Doca", false};//1:line dca 0:point dca
+ Gaudi::Property m_debug{ this, "debug", false};
// Input collections
@@ -86,6 +94,6 @@ class DCHDigiAlg : public GaudiAlgorithm
// Output collections
DataHandle w_DigiDCHCol{"DigiDCHitCollection", Gaudi::DataHandle::Writer, this};
DataHandle w_AssociationCol{"DCHitAssociationCollection", Gaudi::DataHandle::Writer, this};
-
};
+
#endif
From 2a2999bd033b42a651d8f817ae5b83529ea372f9 Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Thu, 24 Feb 2022 09:37:06 +0800
Subject: [PATCH 08/27] delete blank lines
---
Digitisers/DCHDigi/src/DCHDigiAlg.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
index 661f59f60..41f70a4b9 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
@@ -110,7 +110,6 @@ StatusCode DCHDigiAlg::execute()
auto SimHit0 = SimHitCol->at(0);
std::map> id_hits_map;
-
for( int i = 0; i < SimHitCol->size(); i++ )
{
auto SimHit = SimHitCol->at(i);
From a80dc6fb99686a0fad3b40bd72c548164eb7740c Mon Sep 17 00:00:00 2001
From: myliu <201916234@mail.sdu.edu.cn>
Date: Sun, 5 Jun 2022 21:35:39 +0800
Subject: [PATCH 09/27] update 101
---
Digitisers/DCHDigi/src/DCHDigiAlg.cpp | 224 ++-
Digitisers/DCHDigi/src/DCHDigiAlg.h | 12 +-
Reconstruction/RecGenfitAlg/CMakeLists.txt | 6 +-
.../RecGenfitAlg/src/GenfitField.cpp | 26 +-
.../RecGenfitAlg/src/GenfitFitter.cpp | 236 +--
.../RecGenfitAlg/src/GenfitFitter.h | 52 +-
.../src/GenfitMaterialInterface.cpp | 47 +-
.../src/GenfitMaterialInterface.h | 11 +
.../RecGenfitAlg/src/GenfitTrack.cpp | 1765 ++++++++++++-----
Reconstruction/RecGenfitAlg/src/GenfitTrack.h | 207 +-
.../include/Tracking/TrackingHelper.h | 1 -
.../src/TruthTracker/TruthTrackerAlg.cpp | 877 ++++++--
.../src/TruthTracker/TruthTrackerAlg.h | 179 +-
Utilities/DataHelper/CMakeLists.txt | 4 +-
.../include/DataHelper/HelixClass.h | 51 +-
Utilities/DataHelper/src/HelixClass.cc | 69 +
Utilities/DataHelper/src/TrackerHitHelper.cpp | 43 +
17 files changed, 2801 insertions(+), 1009 deletions(-)
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
index 41f70a4b9..d516b50f4 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.cpp
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
#include "DCHDigiAlg.h"
@@ -52,6 +53,8 @@ StatusCode DCHDigiAlg::initialize()
return StatusCode::FAILURE;
}
+ fRandom.SetSeed(105105);//FIXME: set by users
+
if(m_WriteAna){
NTuplePtr nt( ntupleSvc(), "MyTuples/DCH_digi_evt" );
@@ -66,6 +69,10 @@ StatusCode DCHDigiAlg::initialize()
m_tuple->addItem( "simhit_x", m_n_sim, m_simhit_x).ignore();
m_tuple->addItem( "simhit_y", m_n_sim, m_simhit_y).ignore();
m_tuple->addItem( "simhit_z", m_n_sim, m_simhit_z).ignore();
+ m_tuple->addItem( "Simdca" , m_n_sim, m_Simdca ).ignore();
+ m_tuple->addItem( "simhitT", m_n_sim, m_simhitT ).ignore();
+ m_tuple->addItem( "simhitmom", m_n_sim, m_simhitmom ).ignore();
+ m_tuple->addItem( "simPDG", m_n_sim, m_simPDG ).ignore();
m_tuple->addItem( "chamber" , m_n_digi, m_chamber ).ignore();
m_tuple->addItem( "layer" , m_n_digi, m_layer ).ignore();
m_tuple->addItem( "cell" , m_n_digi, m_cell ).ignore();
@@ -83,6 +90,7 @@ StatusCode DCHDigiAlg::initialize()
m_tuple->addItem( "poca_y" , m_n_digi, m_poca_y ).ignore();
m_tuple->addItem( "hit_dE" , m_n_digi,m_hit_dE ).ignore();
m_tuple->addItem( "hit_dE_dx", m_n_digi,m_hit_dE_dx ).ignore();
+ m_tuple->addItem( "truthlength", m_n_digi,m_truthlength).ignore();
} else { // did not manage to book the N tuple....
info() << " Cannot book N-tuple:" << long( m_tuple ) << endmsg;
}
@@ -110,6 +118,7 @@ StatusCode DCHDigiAlg::execute()
auto SimHit0 = SimHitCol->at(0);
std::map> id_hits_map;
+
for( int i = 0; i < SimHitCol->size(); i++ )
{
auto SimHit = SimHitCol->at(i);
@@ -119,6 +128,10 @@ StatusCode DCHDigiAlg::execute()
if(sim_hit_mom > m_mom_threshold_high) continue;
if(SimHit.getEDep() <= m_edep_threshold) continue;
+ //Wire efficiency
+ double hitProb = fRandom.Uniform(1.);
+ if(hitProb > m_wireEff) continue;
+
if ( id_hits_map.find(id) != id_hits_map.end()) id_hits_map[id].push_back(SimHit);
else
{
@@ -133,116 +146,119 @@ StatusCode DCHDigiAlg::execute()
}
for(auto iter = id_hits_map.begin(); iter != id_hits_map.end(); iter++)
{
- unsigned long long wcellid = iter->first;
- auto trkHit = Vec->create();
- trkHit.setCellID(wcellid);
- double tot_edep = 0 ;
- double tot_length = 0 ;
- double pos_x = 0 ;
- double pos_y = 0 ;
- double pos_z = 0 ;
- double momx,momy = 0;
- int simhit_size = iter->second.size();
- for(unsigned int i=0; i< simhit_size; i++)
- {
- tot_edep += iter->second.at(i).getEDep();//GeV
- }
- int chamber = m_decoder->get(wcellid, "chamber");
- int layer = m_decoder->get(wcellid, "layer" );
- int cellID = m_decoder->get(wcellid, "cellID" );
- TVector3 Wstart(0,0,0);
- TVector3 Wend (0,0,0);
- m_segmentation->cellposition(wcellid, Wstart, Wend);
- float dd4hep_mm = dd4hep::mm;
- //std::cout<<"dd4hep_mm="<second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] + iter->second.at(i).getMomentum()[2]*iter->second.at(i).getMomentum()[2] );//GeV
- float sim_hit_pt = sqrt( iter->second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] );//GeV
- TVector3 pos(iter->second.at(i).getPosition()[0]*dd4hep_mm, iter->second.at(i).getPosition()[1]*dd4hep_mm, iter->second.at(i).getPosition()[2]*dd4hep_mm);
-
- TVector3 sim_mon(iter->second.at(i).getMomentum()[0],iter->second.at(i).getMomentum()[1],iter->second.at(i).getMomentum()[2]);
- float Steplength = iter->second.at(i).getPathLength();
- TVector3 pos_start = pos - 0.5 * Steplength * sim_mon.Unit();
- TVector3 pos_end = pos + 0.5 * Steplength * sim_mon.Unit();
- tmp_distance = m_segmentation->Distance(wcellid,pos_start,pos_end,hitPosition,PCA);
- tmp_distance = tmp_distance/dd4hep_mm; //mm
-
- // std::cout << " Steplength= " << Steplength << std::endl;
-
- if(tmp_distance < min_distance){
- min_distance = tmp_distance;
- pos_x = hitPosition.x(); //pos.x();
- pos_y = hitPosition.y(); //pos.y();
- pos_z = pos.z();
- momx = iter->second.at(i).getMomentum()[0];
- momy = iter->second.at(i).getMomentum()[1];
- }
- tot_length += iter->second.at(i).getPathLength();//mm
- auto asso = AssoVec->create();
- asso.setRec(trkHit);
- asso.setSim(iter->second.at(i));
- asso.setWeight(iter->second.at(i).getEDep()/tot_edep);
- //std::cout<<" asso setRec setSim "<second.at(i)<{m_res_x, 0, m_res_y, 0, 0, m_res_z});//cov(x,x) , cov(y,x) , cov(y,y) , cov(z,x) , cov(z,y) , cov(z,z) in mm
-
- if(m_WriteAna && (nullptr!=m_tuple)) { // && min_distance <0.3){
- m_chamber [m_n_digi] = chamber;
- m_layer [m_n_digi] = layer ;
- m_cell [m_n_digi] = cellID;
- m_cell_x [m_n_digi] = Wstart.x();
- m_cell_y [m_n_digi] = Wstart.y();
- m_cell1_x [m_n_digi] = Wend.x();
- m_cell1_y [m_n_digi] = Wend.y();
- m_hit_x [m_n_digi] = pos_x;
- m_hit_y [m_n_digi] = pos_y;
- m_hit_z [m_n_digi] = pos_z;
- m_mom_x [m_n_digi] = momx ;
- m_mom_y [m_n_digi] = momy ;
- m_dca [m_n_digi] = min_distance;
- m_poca_x [m_n_digi] = PCA.x();
- m_poca_y [m_n_digi] = PCA.y();
- m_hit_dE [m_n_digi] = trkHit.getEDep();
- m_hit_dE_dx[m_n_digi] = trkHit.getEdx() ;
- m_n_digi ++ ;
- }
- }
+ unsigned long long wcellid = iter->first;
+ auto trkHit = Vec->create();
+ trkHit.setCellID(wcellid);
+ double tot_edep = 0 ;
+ double tot_length = 0 ;
+ double pos_x = 0 ;
+ double pos_y = 0 ;
+ double pos_z = 0 ;
+ double momx,momy = 0;
+ int simhit_size = iter->second.size();
+ for(unsigned int i=0; i< simhit_size; i++)
+ {
+ tot_edep += iter->second.at(i).getEDep();//GeV
+ }
+ int chamber = m_decoder->get(wcellid, "chamber");
+ int layer = m_decoder->get(wcellid, "layer" );
+ int cellID = m_decoder->get(wcellid, "cellID" );
+ TVector3 Wstart(0,0,0);
+ TVector3 Wend (0,0,0);
+ m_segmentation->cellposition(wcellid, Wstart, Wend);
+ float dd4hep_mm = dd4hep::mm;
+ //std::cout<<"dd4hep_mm="<second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] + iter->second.at(i).getMomentum()[2]*iter->second.at(i).getMomentum()[2] );//GeV
+ float sim_hit_pt = sqrt( iter->second.at(i).getMomentum()[0]*iter->second.at(i).getMomentum()[0] + iter->second.at(i).getMomentum()[1]*iter->second.at(i).getMomentum()[1] );//GeV
+ TVector3 pos(iter->second.at(i).getPosition()[0]*dd4hep_mm, iter->second.at(i).getPosition()[1]*dd4hep_mm, iter->second.at(i).getPosition()[2]*dd4hep_mm);
+
+ TVector3 sim_mon(iter->second.at(i).getMomentum()[0],iter->second.at(i).getMomentum()[1],iter->second.at(i).getMomentum()[2]);
+ float Steplength = iter->second.at(i).getPathLength();
+ TVector3 pos_start = pos - 0.5 * Steplength * sim_mon.Unit();
+ TVector3 pos_end = pos + 0.5 * Steplength * sim_mon.Unit();
+ tmp_distance = m_segmentation->Distance(wcellid,pos_start,pos_end,hitPosition,PCA);
+ tmp_distance = tmp_distance/dd4hep_mm; //mm
+ sim_distance = tmp_distance;
+ if(tmp_distance < min_distance){
+ min_distance = tmp_distance;
+ pos_x = hitPosition.x(); //pos.x();
+ pos_y = hitPosition.y(); //pos.y();
+ pos_z = pos.z();
+ momx = iter->second.at(i).getMomentum()[0];
+ momy = iter->second.at(i).getMomentum()[1];
+ }
+ tot_length += iter->second.at(i).getPathLength();//mm
+ auto asso = AssoVec->create();
+ asso.setRec(trkHit);
+ asso.setSim(iter->second.at(i));
+ asso.setWeight(iter->second.at(i).getEDep()/tot_edep);
+ //std::cout<<" asso setRec setSim "<second.at(i)<second.at(i).getTime();
+ m_simhitmom[m_n_sim] = sim_hit_mom;
+ m_simPDG[m_n_sim] = iter->second.at(i).getMCParticle().getPDG();
+ m_n_sim ++ ;
+ }
+ }
+
+ trkHit.setTime(min_distance*1e3/m_velocity);//m_velocity is um/ns, drift time in ns
+ trkHit.setEDep(tot_edep);// GeV
+ trkHit.setEdx (tot_edep/tot_length); // GeV/mm
+ trkHit.setPosition (edm4hep::Vector3d(pos_x, pos_y, pos_z));//position of closest sim hit
+ trkHit.setCovMatrix(std::array{m_res_x, 0, m_res_y, 0, 0, m_res_z});//cov(x,x) , cov(y,x) , cov(y,y) , cov(z,x) , cov(z,y) , cov(z,z) in mm
+
+ if(m_WriteAna && (nullptr!=m_tuple)) {
+ m_chamber [m_n_digi] = chamber;
+ m_layer [m_n_digi] = layer ;
+ m_cell [m_n_digi] = cellID;
+ m_cell_x [m_n_digi] = Wstart.x();
+ m_cell_y [m_n_digi] = Wstart.y();
+ m_cell1_x [m_n_digi] = Wend.x();
+ m_cell1_y [m_n_digi] = Wend.y();
+ m_hit_x [m_n_digi] = pos_x;
+ m_hit_y [m_n_digi] = pos_y;
+ m_hit_z [m_n_digi] = pos_z;
+ m_mom_x [m_n_digi] = momx ;
+ m_mom_y [m_n_digi] = momy ;
+ m_dca [m_n_digi] = min_distance;
+ m_poca_x [m_n_digi] = PCA.x();
+ m_poca_y [m_n_digi] = PCA.y();
+ m_hit_dE [m_n_digi] = trkHit.getEDep();
+ m_hit_dE_dx[m_n_digi] = trkHit.getEdx() ;
+ m_truthlength[m_n_digi] = tot_length ;
+ m_n_digi ++ ;
+ }
+
+ }
debug()<<"output digi DCHhit size="<< Vec->size() <write();
if ( status.isFailure() ) {
- error() << " Cannot fill N-tuple:" << long( m_tuple ) << endmsg;
- return StatusCode::FAILURE;
+ error() << " Cannot fill N-tuple:" << long( m_tuple ) << endmsg;
+ return StatusCode::FAILURE;
}
}
m_end = clock();
@@ -255,6 +271,6 @@ StatusCode DCHDigiAlg::execute()
StatusCode DCHDigiAlg::finalize()
{
- info() << "Processed " << _nEvt << " events " << endmsg;
- return GaudiAlgorithm::finalize();
+ info() << "Processed " << _nEvt << " events " << endmsg;
+ return GaudiAlgorithm::finalize();
}
diff --git a/Digitisers/DCHDigi/src/DCHDigiAlg.h b/Digitisers/DCHDigi/src/DCHDigiAlg.h
index d674dc775..4dcf76944 100644
--- a/Digitisers/DCHDigi/src/DCHDigiAlg.h
+++ b/Digitisers/DCHDigi/src/DCHDigiAlg.h
@@ -7,6 +7,7 @@
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackerHitCollection.h"
#include "edm4hep/MCRecoTrackerAssociationCollection.h"
+#include "edm4hep/MCParticleConst.h"
#include
#include
@@ -15,8 +16,7 @@
#include "DetSegmentation/GridDriftChamber.h"
#include "TVector3.h"
-
-
+#include "TRandom3.h"
class DCHDigiAlg : public GaudiAlgorithm
{
@@ -44,6 +44,8 @@ class DCHDigiAlg : public GaudiAlgorithm
typedef std::vector FloatVec;
int _nEvt ;
+ TRandom3 fRandom;
+
NTuple::Tuple* m_tuple = nullptr ;
NTuple::Item m_evt;
NTuple::Item m_n_sim;
@@ -59,16 +61,21 @@ class DCHDigiAlg : public GaudiAlgorithm
NTuple::Array m_simhit_x ;
NTuple::Array m_simhit_y ;
NTuple::Array m_simhit_z ;
+ NTuple::Array m_simhitT ;
+ NTuple::Array m_simhitmom ;
+ NTuple::Array m_simPDG ;
NTuple::Array m_hit_x ;
NTuple::Array m_hit_y ;
NTuple::Array m_hit_z ;
NTuple::Array m_mom_x ;
NTuple::Array m_mom_y ;
NTuple::Array m_dca ;
+ NTuple::Array m_Simdca ;
NTuple::Array m_poca_x ;
NTuple::Array m_poca_y ;
NTuple::Array m_hit_dE ;
NTuple::Array m_hit_dE_dx ;
+ NTuple::Array m_truthlength ;
clock_t m_start,m_end;
@@ -87,6 +94,7 @@ class DCHDigiAlg : public GaudiAlgorithm
Gaudi::Property m_edep_threshold{ this, "edep_threshold", 0};// GeV
Gaudi::Property m_WriteAna { this, "WriteAna", false};
Gaudi::Property m_debug{ this, "debug", false};
+ Gaudi::Property m_wireEff{ this, "wireEff", 1.0};
// Input collections
diff --git a/Reconstruction/RecGenfitAlg/CMakeLists.txt b/Reconstruction/RecGenfitAlg/CMakeLists.txt
index 566801d15..6136171a0 100644
--- a/Reconstruction/RecGenfitAlg/CMakeLists.txt
+++ b/Reconstruction/RecGenfitAlg/CMakeLists.txt
@@ -2,11 +2,15 @@
if (GenFit_FOUND)
gaudi_add_module(RecGenfitAlg
- SOURCES src/RecGenfitAlgDC.cpp
+ SOURCES src/RecGenfitAlgSDT.cpp
src/GenfitTrack.cpp
+ src/GenfitHit.cpp
src/GenfitField.cpp
src/GenfitFitter.cpp
src/GenfitMaterialInterface.cpp
+ src/LSFitting.cpp
+ src/WireMeasurementDC.cpp
+ src/PlanarMeasurementSDT.cpp
LINK GearSvc
Gaudi::GaudiAlgLib
Gaudi::GaudiKernel
diff --git a/Reconstruction/RecGenfitAlg/src/GenfitField.cpp b/Reconstruction/RecGenfitAlg/src/GenfitField.cpp
index 744084254..e0b8e3548 100644
--- a/Reconstruction/RecGenfitAlg/src/GenfitField.cpp
+++ b/Reconstruction/RecGenfitAlg/src/GenfitField.cpp
@@ -1,4 +1,5 @@
#include "GenfitField.h"
+#include "GenfitUnit.h"
//External
#include "DD4hep/DD4hepUnits.h"
@@ -39,16 +40,21 @@ GenfitField::get(const double& posX, const double& posY, const double& posZ,
{
/// get field from dd4hepField
const dd4hep::Direction& field=m_dd4hepField.magneticField(
- dd4hep::Position(posX/dd4hep::cm,posY/dd4hep::cm,posZ/dd4hep::cm));
- //m_dd4hepField.magneticField(pos,B);
-
- Bx=field.X()/dd4hep::kilogauss;
- By=field.Y()/dd4hep::kilogauss;
- Bz=field.Z()/dd4hep::kilogauss;
-
-// std::cout<<"GenfitField "
-// <