From bb67011bb523eafa391b73dd7353a0deb3f69427 Mon Sep 17 00:00:00 2001 From: gwm17 Date: Tue, 30 Aug 2022 15:01:11 -0400 Subject: [PATCH] Fix up detector geometry, make names clearer for dets and constexpr more of the geometry --- src/Detectors/AnasenEfficiency.cpp | 8 +- src/Detectors/AnasenEfficiency.h | 6 +- src/Detectors/CMakeLists.txt | 4 +- src/Detectors/QQQDetector.cpp | 47 ++++++------ src/Detectors/QQQDetector.h | 12 +-- .../{StripDetector.cpp => SX3Detector.cpp} | 73 ++++++++----------- .../{StripDetector.h => SX3Detector.h} | 25 ++++--- src/Detectors/SabreDetector.cpp | 53 ++++++-------- src/Detectors/SabreDetector.h | 53 ++++++-------- src/Detectors/SabreEfficiency.cpp | 2 +- src/Detectors/SabreEfficiency.h | 3 - 11 files changed, 123 insertions(+), 163 deletions(-) rename src/Detectors/{StripDetector.cpp => SX3Detector.cpp} (70%) rename src/Detectors/{StripDetector.h => SX3Detector.h} (76%) diff --git a/src/Detectors/AnasenEfficiency.cpp b/src/Detectors/AnasenEfficiency.cpp index 5a0b7d8..8c6cd19 100644 --- a/src/Detectors/AnasenEfficiency.cpp +++ b/src/Detectors/AnasenEfficiency.cpp @@ -11,16 +11,16 @@ AnasenEfficiency::AnasenEfficiency() : { for(int i=0; i #include "DetectorEfficiency.h" -#include "StripDetector.h" +#include "SX3Detector.h" #include "QQQDetector.h" #include "Target.h" #include "Nucleus.h" @@ -39,15 +39,11 @@ private: static constexpr int s_nSX3PerBarrel = 12; static constexpr int s_nQQQ = 4; static constexpr double s_sx3Length = 0.075; - static constexpr double s_sx3Width = 0.04; static constexpr double s_barrelGap = 0.0254; static constexpr double s_sx3FrameGap = 0.049; //0.049 is base gap due to frames static constexpr double s_barrel1Z = s_sx3Length/2.0 + s_sx3FrameGap + s_barrelGap/2.0; static constexpr double s_barrel2Z = (-1.0)*(s_barrelGap/2.0 + s_sx3Length/2.0); static constexpr double s_qqqZ = 0.0125 + s_sx3Length + s_sx3FrameGap + s_barrelGap/2.0; - static constexpr double s_qqqInnerR = 0.0501; - static constexpr double s_qqqOuterR = 0.0990; - static constexpr double s_qqqDeltaPhi = 1.52119; static constexpr double s_qqqZList[4] = {s_qqqZ, s_qqqZ, s_qqqZ, s_qqqZ}; static constexpr double s_qqqPhiList[4] = {5.49779, 0.785398, 2.35619, 3.92699}; static constexpr double s_barrelRhoList[12] = {0.0890601, 0.0889871, 0.0890354, 0.0890247, 0.0890354, 0.0890354, 0.0890247, diff --git a/src/Detectors/CMakeLists.txt b/src/Detectors/CMakeLists.txt index c3c5232..3c949eb 100644 --- a/src/Detectors/CMakeLists.txt +++ b/src/Detectors/CMakeLists.txt @@ -16,8 +16,8 @@ target_sources(Detectors PUBLIC SabreDetector.h SabreEfficiency.cpp SabreEfficiency.h - StripDetector.cpp - StripDetector.h + SX3Detector.cpp + SX3Detector.h ) target_link_libraries(Detectors diff --git a/src/Detectors/QQQDetector.cpp b/src/Detectors/QQQDetector.cpp index 11d5155..0f7046a 100644 --- a/src/Detectors/QQQDetector.cpp +++ b/src/Detectors/QQQDetector.cpp @@ -1,11 +1,8 @@ #include "QQQDetector.h" -QQQDetector::QQQDetector(double R_in, double R_out, double deltaPhi, double phiCentral, double z, double x, double y) : - m_innerR(R_in), m_outerR(R_out), m_deltaPhi(deltaPhi), m_centralPhi(phiCentral), m_translation(x,y,z), m_norm(0.0,0.0,1.0), - m_uniformFraction(0.0, 1.0), m_isSmearing(false) +QQQDetector::QQQDetector(double phiCentral, double zOffset, double xOffset, double yOffset) : + m_centralPhi(phiCentral), m_translation(xOffset,yOffset,zOffset), m_norm(0.0,0.0,1.0), m_uniformFraction(0.0, 1.0), m_isSmearing(false) { - m_deltaR = (m_outerR - m_innerR)/s_nRings; - m_deltaPhiWedge = m_deltaPhi/s_nWedges; m_zRotation.SetAngle(m_centralPhi); m_ringCoords.resize(s_nRings); m_wedgeCoords.resize(s_nWedges); @@ -28,23 +25,23 @@ void QQQDetector::CalculateCorners() //Generate flat ring corner coordinates for(int i=0; i> m_ringCoords, m_wedgeCoords; @@ -60,6 +55,11 @@ private: static constexpr int s_nRings = 16; static constexpr int s_nWedges = 16; static constexpr double s_deg2rad = M_PI/180.0; + static constexpr double s_innerR = 0.0501; + static constexpr double s_outerR = 0.0990; + static constexpr double s_deltaR = (s_outerR - s_innerR) / s_nRings; + static constexpr double s_deltaPhiTotal = 1.52119; + static constexpr double s_deltaPhi = s_deltaPhiTotal / s_nWedges; }; #endif \ No newline at end of file diff --git a/src/Detectors/StripDetector.cpp b/src/Detectors/SX3Detector.cpp similarity index 70% rename from src/Detectors/StripDetector.cpp rename to src/Detectors/SX3Detector.cpp index 126e90f..47688ae 100644 --- a/src/Detectors/StripDetector.cpp +++ b/src/Detectors/SX3Detector.cpp @@ -1,5 +1,4 @@ -#include "StripDetector.h" -#include +#include "SX3Detector.h" /* Corner layout for each strip in the un-rotated frame @@ -10,36 +9,22 @@ | | | | x 2--------------------------3 z<--------X - | - | - | - y + | + | + | + y */ -StripDetector::StripDetector(int ns, double len, double wid, double cphi, double cz, double crho) : - m_norm(1.0,0.0,0.0), m_uniformFraction(0.0, 1.0), m_isSmearing(false) +StripDetector::StripDetector(double centerPhi, double centerZ, double centerRho) : + m_centerPhi(centerPhi), m_centerZ(centerZ), m_centerRho(centerRho), m_norm(1.0,0.0,0.0), m_uniformFraction(0.0, 1.0), m_isSmearing(false) { - - m_nStrips = ns; - - m_stripLength = std::fabs(len); - m_totalWidth = std::fabs(wid); - m_frontStripWidth = m_totalWidth/m_nStrips; - m_backStripLength = m_stripLength/m_nStrips; - - while (cphi < 0) - cphi += 2*M_PI; - m_centerPhi = cphi; - m_centerZ = cz; - m_centerRho = std::fabs(crho); - m_zRotation.SetAngle(m_centerPhi); - m_frontStripCoords.resize(m_nStrips); - m_backStripCoords.resize(m_nStrips); - m_rotFrontStripCoords.resize(m_nStrips); - m_rotBackStripCoords.resize(m_nStrips); - for(int i=0; i det_max_phi) @@ -138,18 +123,18 @@ StripHit StripDetector::GetChannelRatio(double theta, double phi) double yhit = xhit*tan(phi); double zhit = sqrt(xhit*xhit+yhit*yhit)/tan(theta); - for (int s=0; s=m_frontStripCoords[s][0].X() && xhit <=m_frontStripCoords[s][0].X() && //Check min and max x (constant in flat) yhit >=m_frontStripCoords[s][1].Y() && yhit <=m_frontStripCoords[s][2].Y() && //Check min and max y zhit >=m_frontStripCoords[s][1].Z() && zhit <=m_frontStripCoords[s][0].Z()) //Check min and max z { hit.front_strip_index = s; - hit.front_ratio = (zhit-m_centerZ)/(m_stripLength/2); + hit.front_ratio = (zhit-m_centerZ)/(s_totalLength/2); break; } } - for (int s=0; s= m_backStripCoords[s][0].X() && xhit <= m_backStripCoords[s][0].X() && //Check min and max x (constant in flat) yhit >= m_backStripCoords[s][1].Y() && yhit <= m_backStripCoords[s][2].Y() && //Check min and max y zhit >= m_backStripCoords[s][1].Z() && zhit <= m_backStripCoords[s][0].Z()) //Check min and max z diff --git a/src/Detectors/StripDetector.h b/src/Detectors/SX3Detector.h similarity index 76% rename from src/Detectors/StripDetector.h rename to src/Detectors/SX3Detector.h index cc6463a..965e488 100644 --- a/src/Detectors/StripDetector.h +++ b/src/Detectors/SX3Detector.h @@ -1,5 +1,5 @@ -#ifndef STRIP_DETECTOR_H -#define STRIP_DETECTOR_H +#ifndef SX3_DETECTOR_H +#define SX3_DETECTOR_H // +z is along beam axis // +y is vertically "downward" in the lab frame @@ -30,7 +30,7 @@ class StripDetector { public: - StripDetector(int ns, double len, double wid, double cphi, double cz, double crho); + StripDetector(double centerPhi, double centerZ, double centerRho); ~StripDetector(); const ROOT::Math::XYZPoint& GetFrontStripCoordinates(int stripch, int corner) const { return m_frontStripCoords[stripch][corner]; } const ROOT::Math::XYZPoint& GetBackStripCoordinates(int stripch, int corner) const { return m_backStripCoords[stripch][corner]; } @@ -50,18 +50,10 @@ public: StripHit GetChannelRatio(double theta, double phi); private: - bool ValidChannel(int f) { return ((f >= 0 && f < m_nStrips) ? true : false); }; + bool ValidChannel(int f) { return ((f >= 0 && f < s_nStrips) ? true : false); }; bool ValidRatio(double r) { return ((r >= -1 && r <= 1) ? true : false); }; void CalculateCorners(); - int m_nStrips; - static constexpr int s_nCorners = 4; - - double m_stripLength; //common to all strips, hence total - double m_totalWidth; - double m_frontStripWidth; //assuming equal widths - double m_backStripLength; //assuming equal widths - double m_centerPhi; //assuming det centered above x-axis (corresponds to zero phi) double m_centerZ; double m_centerRho; //perpendicular radius from axis @@ -77,6 +69,15 @@ private: bool m_isSmearing; + //Units in meters + static constexpr double s_nStrips = 4; //Same for front and back + static constexpr double s_nCorners = 4; + static constexpr double s_totalLength = 0.075; //length of front strips + static constexpr double s_backStripLength = s_totalLength / s_nStrips; + static constexpr double s_totalWidth = 0.04; //width of back strips + static constexpr double s_frontStripWidth = s_totalWidth / s_nStrips; + static constexpr double s_deg2rad = M_PI/180.0; + }; #endif diff --git a/src/Detectors/SabreDetector.cpp b/src/Detectors/SabreDetector.cpp index 9d9da27..cf143ee 100644 --- a/src/Detectors/SabreDetector.cpp +++ b/src/Detectors/SabreDetector.cpp @@ -53,8 +53,7 @@ #include "SabreDetector.h" SabreDetector::SabreDetector() : -m_outerR(0.1351), m_innerR(0.0326), m_deltaPhiFlat(54.4*s_deg2rad), m_centerPhi(0.0), m_tilt(0.0), - m_translation(0.,0.,0.), m_norm(0,0,1.0), m_detectorID(-1) +m_centerPhi(0.0), m_tilt(0.0), m_translation(0.,0.,0.), m_norm(0,0,1.0), m_detectorID(-1) { m_yRotation.SetAngle(m_tilt); m_zRotation.SetAngle(m_centerPhi); @@ -73,17 +72,11 @@ m_outerR(0.1351), m_innerR(0.0326), m_deltaPhiFlat(54.4*s_deg2rad), m_centerPhi( m_tiltWedgeCoords[i].resize(4); } - m_deltaRFlat = m_outerR - m_innerR; - m_deltaRFlatRing = m_deltaRFlat/s_nRings; - m_deltaPhiFlatWedge = m_deltaPhiFlat/s_nWedges; - CalculateCorners(); } -SabreDetector::SabreDetector(int detID, double Rin, double Rout, double deltaPhi_flat, double phiCentral, - double tiltFromVert, double zdist, double xdist, double ydist) : - m_outerR(Rout), m_innerR(Rin), m_deltaPhiFlat(deltaPhi_flat), m_centerPhi(phiCentral), m_tilt(tiltFromVert), - m_translation(xdist, ydist, zdist), m_norm(0,0,1.0), m_detectorID(detID) +SabreDetector::SabreDetector(int detID, double phiCentral, double tiltFromVert, double zdist, double xdist, double ydist) : + m_centerPhi(phiCentral), m_tilt(tiltFromVert), m_translation(xdist, ydist, zdist), m_norm(0,0,1.0), m_detectorID(detID) { m_yRotation.SetAngle(m_tilt); m_zRotation.SetAngle(m_centerPhi); @@ -104,10 +97,6 @@ SabreDetector::SabreDetector(int detID, double Rin, double Rout, double deltaPhi m_tiltWedgeCoords[i].resize(4); } - m_deltaRFlat = m_outerR - m_innerR; - m_deltaRFlatRing = m_deltaRFlat/s_nRings; - m_deltaPhiFlatWedge = m_deltaPhiFlat/s_nWedges; - CalculateCorners(); } @@ -123,23 +112,23 @@ void SabreDetector::CalculateCorners() //Generate flat ring corner coordinates for(int i=0; i m_innerR && r < m_outerR) || CheckPositionEqual(r, m_innerR) || CheckPositionEqual(r, m_outerR)) + double phi_1 = s_deltaPhiTotal/2.0; + double phi_2 = M_PI*2.0 - s_deltaPhiTotal/2.0; + return (((r > s_innerR && r < s_outerR) || CheckPositionEqual(r, s_innerR) || CheckPositionEqual(r, s_outerR)) && (phi > phi_2 || phi < phi_1 || CheckAngleEqual(phi, phi_1) || CheckAngleEqual(phi, phi_2))); }; @@ -121,57 +118,43 @@ private: */ bool IsRing(double r, int ringch) { - double ringtop = m_innerR + m_deltaRFlatRing*(ringch + 1); - double ringbottom = m_innerR + m_deltaRFlatRing*(ringch); + double ringtop = s_innerR + s_deltaR*(ringch + 1); + double ringbottom = s_innerR + s_deltaR*(ringch); return (r>ringbottom && rwedgebottom && phi> m_flatRingCoords, m_flatWedgeCoords; std::vector> m_tiltRingCoords, m_tiltWedgeCoords; + /*Class constants*/ + static constexpr double s_deg2rad = M_PI/180.0; + static constexpr int s_nRings = 16; + static constexpr int s_nWedges = 8; + static constexpr double s_outerR = 0.1351; + static constexpr double s_innerR = 0.0326; + static constexpr double s_deltaR = (s_outerR - s_innerR) / s_nRings; + static constexpr double s_deltaPhiTotal = 54.4 * s_deg2rad; + static constexpr double s_deltaPhi = (s_deltaPhiTotal / s_nWedges); + /*These are implicitly the width of the spacing between detector active strips*/ + static constexpr double s_positionTol = 0.0001; //0.1 mm position tolerance + static constexpr double s_angularTol = 0.1*M_PI/180.0; // 0.1 degree angular tolerance }; diff --git a/src/Detectors/SabreEfficiency.cpp b/src/Detectors/SabreEfficiency.cpp index 5d0a7b2..0ce0619 100644 --- a/src/Detectors/SabreEfficiency.cpp +++ b/src/Detectors/SabreEfficiency.cpp @@ -13,7 +13,7 @@ SabreEfficiency::SabreEfficiency() : { for(int i=0; i