From 4679662ac6261f1cb5cdd19c0b78dd10b20b9dd1 Mon Sep 17 00:00:00 2001 From: myliu <201916234@mail.sdu.edu.cn> Date: Fri, 30 Oct 2020 15:31:35 +0800 Subject: [PATCH] Added shift --- Detector/DetDriftChamber/compact/det.xml | 2 +- .../src/driftchamber/DriftChamber.cpp | 2 +- .../DetSegmentation/GridDriftChamber.h | 16 +++----- .../DetSegmentation/src/GridDriftChamber.cpp | 39 ++++++++----------- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/Detector/DetDriftChamber/compact/det.xml b/Detector/DetDriftChamber/compact/det.xml index 1ff377f0..f6d0a84d 100644 --- a/Detector/DetDriftChamber/compact/det.xml +++ b/Detector/DetDriftChamber/compact/det.xml @@ -59,7 +59,7 @@ <readouts> <readout name="DriftChamberHitsCollection"> - <segmentation type="GridDriftChamber" cell_size="10*mm" offset_phi="0." epsilon0="Epsilon" detector_length="SDT_length" identifier_phi="cellID" /> + <segmentation type="GridDriftChamber" cell_size="10*mm" epsilon0="Epsilon" detector_length="SDT_length" identifier_phi="cellID" /> <id>system:8,chamber:1,layer:8,cellID:16</id> </readout> diff --git a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp index bc0c3e38..144dd7dd 100644 --- a/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp +++ b/Detector/DetDriftChamber/src/driftchamber/DriftChamber.cpp @@ -119,7 +119,7 @@ static dd4hep::Ref_t create_detector(dd4hep::Detector& theDetector, double layer_Phi = 2*M_PI / ncell_layer; if(layer_id %2 ==0){ offset = 0.; } - else { offset = 0.;}//0.5 * layer_Phi; } + else { offset = 0.5 * layer_Phi; } DCHseg->setGeomParams(layer_id, layer_Phi, rmid, epsilon, offset); DCHseg->setWiresInLayer(layer_id, numWire); diff --git a/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h b/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h index 769b6716..ef39f692 100644 --- a/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h +++ b/Detector/DetSegmentation/DetSegmentation/GridDriftChamber.h @@ -48,20 +48,18 @@ public: double phi(const CellID& cID) const; inline double cell_Size() const { return m_cellSize; } - inline double offset_phi() const { return m_offsetPhi; } inline double epsilon0() const { return m_epsilon0; } inline double detectorLength() const { return m_detectorLength; } inline const std::string& fieldNamePhi() const { return m_phiID; } // Setters inline double phiFromXY(const Vector3D& aposition) const { - double beta = std::atan2(aposition.Y, aposition.X) ; - if( beta < 0 ) { beta = beta + 2 * M_PI; } - return beta; + 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 layer, double layerphi, double R, double eps, double offset) { - // layer_params[layer] = {layerphi,R,eps}; layer_params.insert(std::pair<int,LAYER>(layer,LAYER(layerphi,R,eps,offset))); } @@ -71,13 +69,10 @@ public: updateParams(layer); for (int i = 0; i<numWires; ++i) { -// if(layer % 2 == 0) { phi0 = 0.; } -// else { phi0 = 0.5 * _currentLayerphi; } double phi0 = m_offset; - auto phi_start = _currentLayerphi * (i + 0.5) + phi0; - if(phi_start > 2 * M_PI) { phi_start = phi_start - 2 * M_PI; } - auto phi_end = phi_start;// + _currentLayerphi; + auto phi_start = _currentLayerphi * i + phi0; + auto phi_end = phi_start + _currentLayerphi; TVector3 Wstart = returnWirePosition(phi_start, 1); TVector3 Wend = returnWirePosition(phi_end, -1); @@ -131,7 +126,6 @@ protected: std::map<int, std::vector<std::pair<TVector3, TVector3> >> m_wiresPositions; // < layer, vec<WireMidpoint, WireDirection> > double m_cellSize; - double m_offsetPhi; double m_epsilon0; double m_detectorLength; std::string m_phiID; diff --git a/Detector/DetSegmentation/src/GridDriftChamber.cpp b/Detector/DetSegmentation/src/GridDriftChamber.cpp index d2ca3196..3b0032e0 100644 --- a/Detector/DetSegmentation/src/GridDriftChamber.cpp +++ b/Detector/DetSegmentation/src/GridDriftChamber.cpp @@ -11,7 +11,6 @@ GridDriftChamber::GridDriftChamber(const std::string& cellEncoding) : Segmentati _description = "Drift chamber segmentation in the global coordinates"; registerParameter("cell_size", "cell size", m_cellSize, 0., SegmentationParameter::LengthUnit); - registerParameter("offset_phi", "offset in phi", m_offsetPhi, 0., SegmentationParameter::LengthUnit, true); registerParameter("detector_length", "Length of the wire", m_detectorLength, 1., SegmentationParameter::LengthUnit); registerIdentifier("identifier_phi", "Cell ID identifier for phi", m_phiID, "cellID"); } @@ -22,7 +21,6 @@ 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("offset_phi", "offset in phi", m_offsetPhi, 0., SegmentationParameter::LengthUnit, 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"); @@ -46,37 +44,32 @@ CellID GridDriftChamber::cellID(const Vector3D& /*localPosition*/, const Vector3 double posy = globalPosition.Y; double offsetphi= m_offset; int _lphi; -// if(layerID % 2 == 0) { -// offsetphi = 0.; -// _lphi = (int) (phi_hit / _currentLayerphi); -// } -// else { -// offsetphi = _currentLayerphi / 2.; - if(phi_hit >= offsetphi) { - _lphi = (int) ((phi_hit - offsetphi)/ _currentLayerphi); - } - else { - _lphi = (int) ((phi_hit - offsetphi + 2 * M_PI)/ _currentLayerphi); - } -// } + + if(phi_hit >= offsetphi) { + _lphi = (int) ((phi_hit - offsetphi)/ _currentLayerphi); + } + else { + _lphi = (int) ((phi_hit - offsetphi + 2 * M_PI)/ _currentLayerphi); + } + int lphi = _lphi; _decoder->set(cID, m_phiID, lphi); -//std::cout << "#######################################: " -// << " offset : " << m_offset -// << " offsetphi: " << offsetphi -// << " layerID: " << layerID -// << " r: " << _currentRadius -// << " layerphi: " << _currentLayerphi -// << std::endl; +std::cout << "#######################################: " + << " offset : " << m_offset + << " offsetphi: " << offsetphi + << " layerID: " << layerID + << " r: " << _currentRadius + << " layerphi: " << _currentLayerphi + << std::endl; return cID; } double GridDriftChamber::phi(const CellID& cID) const { CellID phiValue = _decoder->get(cID, m_phiID); - return (_currentLayerphi * 0.5) + binToPosition(phiValue, _currentLayerphi, m_offsetPhi); + return binToPosition(phiValue, _currentLayerphi, m_offset); } double GridDriftChamber::distanceTrackWire(const CellID& cID, const TVector3& hit_start/*, -- GitLab