@@ -52,18 +52,20 @@ class SegmentationMosaix
5252 // | | |
5353 // x----------------------x
5454 public:
55- ~ SegmentationMosaix () = default ;
56- SegmentationMosaix ( const SegmentationMosaix& ) = default ;
57- SegmentationMosaix (SegmentationMosaix&& ) = delete ;
58- SegmentationMosaix& operator =( const SegmentationMosaix&) = default ;
59- SegmentationMosaix& operator =(SegmentationMosaix&& ) = delete ;
60- constexpr SegmentationMosaix ( int layer) : mLayer{layer} {}
55+ constexpr SegmentationMosaix (int layer) : mRadius( static_cast < float >(constants::radiiMiddle[layer])) {}
56+ constexpr ~ SegmentationMosaix( ) = default ;
57+ constexpr SegmentationMosaix (const SegmentationMosaix&) = default ;
58+ constexpr SegmentationMosaix ( SegmentationMosaix&& ) = delete ;
59+ constexpr SegmentationMosaix& operator =(const SegmentationMosaix&) = default ;
60+ constexpr SegmentationMosaix& operator =(SegmentationMosaix&&) = delete ;
6161
6262 static constexpr int NCols{constants::pixelarray::nCols};
6363 static constexpr int NRows{constants::pixelarray::nRows};
6464 static constexpr int NPixels{NCols * NRows};
6565 static constexpr float Length{constants::pixelarray::length};
66+ static constexpr float LengthH{Length / 2 .f };
6667 static constexpr float Width{constants::pixelarray::width};
68+ static constexpr float WidthH{Width / 2 .f };
6769 static constexpr float PitchCol{constants::pixelarray::length / static_cast <float >(NCols)};
6870 static constexpr float PitchRow{constants::pixelarray::width / static_cast <float >(NRows)};
6971 static constexpr float SensorLayerThickness{constants::totalThickness};
@@ -77,16 +79,16 @@ class SegmentationMosaix
7779 // / the center of the sensitive volume.
7880 // / \param yFlat Detector local flat coordinate y in cm with respect to
7981 // / the center of the sensitive volume.
80- void curvedToFlat (const float xCurved, const float yCurved, float & xFlat, float & yFlat) const noexcept
82+ constexpr void curvedToFlat (const float xCurved, const float yCurved, float & xFlat, float & yFlat) const noexcept
8183 {
8284 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
8385 // stack
8486 float dist = std::hypot (xCurved, yCurved);
8587 float phi = std::atan2 (yCurved, xCurved);
86- xFlat = (getRadius () * phi) - Width / 2 . f ;
88+ xFlat = (mRadius * phi) - WidthH ;
8789 // the y position is in the silicon volume however we need the chip volume (silicon+metalstack)
8890 // this is accounted by a y shift
89- yFlat = dist - getRadius () + static_cast <float >(constants::nominalYShift);
91+ yFlat = dist + ( static_cast <float >(constants::nominalYShift) - mRadius );
9092 }
9193
9294 // / Transformation from the flat surface to a curved surface
@@ -99,15 +101,15 @@ class SegmentationMosaix
99101 // / the center of the sensitive volume.
100102 // / \param yCurved Detector local curved coordinate y in cm with respect to
101103 // / the center of the sensitive volume.
102- void flatToCurved (float xFlat, float yFlat, float & xCurved, float & yCurved) const noexcept
104+ constexpr void flatToCurved (float xFlat, float yFlat, float & xCurved, float & yCurved) const noexcept
103105 {
104106 // MUST align the flat surface with the curved surface with the original pixel array is on and account for metal
105107 // stack
106108 // the y position is in the chip volume however we need the silicon volume
107109 // this is accounted by a -y shift
108- float dist = yFlat + getRadius () - static_cast <float >(constants::nominalYShift);
109- xCurved = dist * std::cos ((xFlat + Width / 2 . f ) / getRadius () );
110- yCurved = dist * std::sin ((xFlat + Width / 2 . f ) / getRadius () );
110+ float dist = yFlat + ( mRadius - static_cast <float >(constants::nominalYShift) );
111+ xCurved = dist * std::cos ((xFlat + WidthH ) / mRadius );
112+ yCurved = dist * std::sin ((xFlat + WidthH ) / mRadius );
111113 }
112114
113115 // / Transformation from Geant detector centered local coordinates (cm) to
@@ -121,7 +123,7 @@ class SegmentationMosaix
121123 // / the center of the sensitive volume.
122124 // / \param int iRow Detector x cell coordinate.
123125 // / \param int iCol Detector z cell coordinate.
124- bool localToDetector (float const xRow, float const zCol, int & iRow, int & iCol) const noexcept
126+ constexpr bool localToDetector (float const xRow, float const zCol, int & iRow, int & iCol) const noexcept
125127 {
126128 localToDetectorUnchecked (xRow, zCol, iRow, iCol);
127129 if (!isValid (iRow, iCol)) {
@@ -132,10 +134,10 @@ class SegmentationMosaix
132134 }
133135
134136 // Same as localToDetector w.o. checks.
135- void localToDetectorUnchecked (float const xRow, float const zCol, int & iRow, int & iCol) const noexcept
137+ constexpr void localToDetectorUnchecked (float const xRow, float const zCol, int & iRow, int & iCol) const noexcept
136138 {
137- iRow = std::floor ((Width / 2 . - xRow) / PitchRow);
138- iCol = std::floor ((zCol + Length / 2 . ) / PitchCol);
139+ iRow = static_cast < int >( std::floor ((WidthH - xRow) / PitchRow) );
140+ iCol = static_cast < int >( std::floor ((zCol + LengthH ) / PitchCol) );
139141 }
140142
141143 // / Transformation from Detector cell coordinates to Geant detector centered
@@ -148,7 +150,7 @@ class SegmentationMosaix
148150 // / center of the sensitive volume.
149151 // / If iRow and or iCol is outside of the segmentation range a value of -0.5*Dx()
150152 // / or -0.5*Dz() is returned.
151- bool detectorToLocal (int const iRow, int const iCol, float & xRow, float & zCol) const noexcept
153+ constexpr bool detectorToLocal (int const iRow, int const iCol, float & xRow, float & zCol) const noexcept
152154 {
153155 if (!isValid (iRow, iCol)) {
154156 return false ;
@@ -159,13 +161,13 @@ class SegmentationMosaix
159161
160162 // Same as detectorToLocal w.o. checks.
161163 // We position ourself in the middle of the pixel.
162- void detectorToLocalUnchecked (int const iRow, int const iCol, float & xRow, float & zCol) const noexcept
164+ constexpr void detectorToLocalUnchecked (int const iRow, int const iCol, float & xRow, float & zCol) const noexcept
163165 {
164- xRow = -(static_cast <float >(iRow) + 0 .5f ) * PitchRow + Width / 2 . f ;
165- zCol = (static_cast <float >(iCol) + 0 .5f ) * PitchCol - Length / 2 . f ;
166+ xRow = -(static_cast <float >(iRow) + 0 .5f ) * PitchRow + WidthH ;
167+ zCol = (static_cast <float >(iCol) + 0 .5f ) * PitchCol - LengthH ;
166168 }
167169
168- bool detectorToLocal (int const row, int const col, math_utils::Point3D<float >& loc) const noexcept
170+ bool detectorToLocal (int const row, int const col, math_utils::Point3D<float >& loc) const noexcept
169171 {
170172 float xRow{0 .}, zCol{0 .};
171173 if (!detectorToLocal (row, col, xRow, zCol)) {
@@ -175,7 +177,7 @@ class SegmentationMosaix
175177 return true ;
176178 }
177179
178- void detectorToLocalUnchecked (int const row, int const col, math_utils::Point3D<float >& loc) const noexcept
180+ void detectorToLocalUnchecked (int const row, int const col, math_utils::Point3D<float >& loc) const noexcept
179181 {
180182 float xRow{0 .}, zCol{0 .};
181183 detectorToLocalUnchecked (row, col, xRow, zCol);
@@ -184,22 +186,16 @@ class SegmentationMosaix
184186
185187 private:
186188 template <typename T>
187- [[nodiscard]] bool isValid (T const row, T const col) const noexcept
189+ [[nodiscard]] constexpr bool isValid (T const row, T const col) const noexcept
188190 {
189191 if constexpr (std::is_floating_point_v<T>) { // compares in local coord.
190- namespace cp = constants::pixelarray;
191- return !static_cast <bool >(row <= -cp::width / 2 . || cp::width / 2 . <= row || col <= -cp::length / 2 . || cp::length / 2 . <= col);
192+ return (-WidthH < row && row < WidthH && -LengthH < col && col < LengthH);
192193 } else { // compares in rows/cols
193194 return !static_cast <bool >(row < 0 || row >= static_cast <int >(NRows) || col < 0 || col >= static_cast <int >(NCols));
194195 }
195196 }
196197
197- float getRadius () const noexcept
198- {
199- return static_cast <float >(constants::radiiMiddle[mLayer ]);
200- }
201-
202- int mLayer {0 }; // /< chip layer
198+ float mRadius ;
203199};
204200
205201} // namespace o2::its3
0 commit comments