From 6c172b3fb3b091ab0c071e39d60a6869ee49bb65 Mon Sep 17 00:00:00 2001 From: myliu <201916234@mail.sdu.edu.cn> Date: Wed, 4 Nov 2020 22:19:38 +0800 Subject: [PATCH] Add function cellposition() --- .../DetSegmentation/GridDriftChamber.h | 36 +++++++++++++------ .../DetSegmentation/src/GridDriftChamber.cpp | 26 +++++++++++--- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h b/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h index d6fcd5df..38e236c0 100644 --- a/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h +++ b/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h @@ -45,6 +45,7 @@ public: 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 void cellposition(const CellID& cID, TVector3& Wstart, TVector3& Wend) const; // double phi(const CellID& cID) const; inline double cell_Size() const { return m_cellSize; } @@ -86,13 +87,13 @@ public: inline auto returnAllWires() const { return m_wiresPositions; } - inline TVector3 returnWirePosition(double angle, int sign) const { - TVector3 w(0, 0, 0); - w.SetX(_currentRadius * std::cos(angle)); - w.SetY(_currentRadius * std::sin(angle)); - w.SetZ(sign * m_detectorLength / 2.0); - return w; - } +// inline TVector3 returnWirePosition(double angle, int sign) const { +// TVector3 w(0, 0, 0); +// w.SetX(_currentRadius * std::cos(angle)); +// w.SetY(_currentRadius * std::sin(angle)); +// w.SetZ(sign * m_detectorLength / 2.0); +// return w; +// } void updateParams(int layer) const{ auto it_end = layer_params.cend(); @@ -115,10 +116,10 @@ public: m_offset = offset; } - inline double returnAlpha() const { - double alpha = 2 * std::asin(m_detectorLength * std::tan(m_epsilon0)/(2 * _currentRadius)); - return alpha; - } +// inline double returnAlpha() const { +// double alpha = 2 * std::asin(m_detectorLength * std::tan(m_epsilon0)/(2 * _currentRadius)); +// return alpha; +// } protected: @@ -126,6 +127,19 @@ protected: std::map<int,LAYER> layer_params; // <layer, {layerphi, R, eps, offset}> std::map<int, std::vector<std::pair<TVector3, TVector3> >> m_wiresPositions; // < layer, vec<WireMidpoint, WireDirection> > + inline TVector3 returnWirePosition(double angle, int sign) const { + TVector3 w(0, 0, 0); + w.SetX(_currentRadius * std::cos(angle)); + w.SetY(_currentRadius * std::sin(angle)); + w.SetZ(sign * m_detectorLength / 2.0); + return w; + } + + inline double returnAlpha() const { + double alpha = 2 * std::asin(m_detectorLength * std::tan(m_epsilon0)/(2 * _currentRadius)); + return alpha; + } + double m_cellSize; double m_epsilon0; double m_detectorLength; diff --git a/Detector/DetSegmentation/src/GridDriftChamber.cpp b/Detector/DetSegmentation/src/GridDriftChamber.cpp index 4063a5ee..b65edb2d 100644 --- a/Detector/DetSegmentation/src/GridDriftChamber.cpp +++ b/Detector/DetSegmentation/src/GridDriftChamber.cpp @@ -72,8 +72,8 @@ double GridDriftChamber::phi(const CellID& cID) const { return binToPosition(phiValue, _currentLayerphi, m_offset); } -double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hit_start, - const TVector3& hit_end) const { +void GridDriftChamber::cellposition(const CellID& cID, TVector3& Wstart, + TVector3& Wend) const { auto layerIndex = _decoder->get(cID, "layer"); updateParams(layerIndex); @@ -81,8 +81,26 @@ double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hi double phi_start = phi(cID); double phi_end = phi_start + returnAlpha(); - TVector3 Wstart = returnWirePosition(phi_start, -1); // The default centimeter unit in DD4hep - TVector3 Wend = returnWirePosition(phi_end, 1); // The default centimeter unit in DD4hep + Wstart = returnWirePosition(phi_start, -1); + Wend = returnWirePosition(phi_end, 1); +} + + + +double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hit_start, + const TVector3& hit_end) const { + +// auto layerIndex = _decoder->get(cID, "layer"); +// updateParams(layerIndex); +// +// double phi_start = phi(cID); +// double phi_end = phi_start + returnAlpha(); + +// TVector3 Wstart = returnWirePosition(phi_start, -1); // The default centimeter unit in DD4hep +// TVector3 Wend = returnWirePosition(phi_end, 1); // The default centimeter unit in DD4hep + TVector3 Wstart = {0,0,0}; + TVector3 Wend = {0,0,0}; + cellposition(cID,Wstart,Wend); TVector3 a = hit_end - hit_start; TVector3 b = Wend - Wstart; -- GitLab