Skip to content

Commit f6b3525

Browse files
committed
Add a macro to compare ITS3 clusters and digits on a pixel array
1 parent 3183ac7 commit f6b3525

File tree

4 files changed

+507
-28
lines changed

4 files changed

+507
-28
lines changed

Detectors/Upgrades/ITS3/base/include/ITS3Base/SegmentationMosaix.h

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,22 @@ class SegmentationMosaix
4343
// 3. The detector coordinate system. Defined by the row and column segmentation
4444
// defined at the upper edge in the flat coord.
4545

46-
// row,col=0
47-
// |
48-
// v
49-
// x----------------------x
46+
// O----------------------|
5047
// | | |
48+
// | | | ^ x
49+
// | | | |
50+
// | | | |
51+
// | | | |
52+
// | | | X----> z X marks (x,z)=(0,0)
53+
// |-----------X----------|
54+
// | | | O----> col O marks (row,col)=(0,0)
55+
// | | | |
56+
// | | | |
57+
// | | | v
58+
// | | | row
5159
// | | |
52-
// | | | ^ x
53-
// | | | |
54-
// | | | |
55-
// | | | |
56-
// |-----------X----------| X marks (x,z)=(0,0) X----> z
57-
// | | |
58-
// | | |
59-
// | | |
60-
// | | |
61-
// | | |
62-
// | | |
63-
// x----------------------x
60+
// |----------------------|
61+
6462
public:
6563
constexpr SegmentationMosaix(int layer) : mRadius(static_cast<float>(constants::radiiMiddle[layer])) {}
6664
constexpr ~SegmentationMosaix() = default;
@@ -143,8 +141,11 @@ class SegmentationMosaix
143141
/// \param int iCol Detector z cell coordinate.
144142
constexpr bool localToDetector(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
145143
{
144+
if (!isValidLoc(xRow, zCol)) {
145+
return false;
146+
}
146147
localToDetectorUnchecked(xRow, zCol, iRow, iCol);
147-
if (!isValid(iRow, iCol)) {
148+
if (!isValidDet(iRow, iCol)) {
148149
iRow = iCol = -1;
149150
return false;
150151
}
@@ -170,11 +171,11 @@ class SegmentationMosaix
170171
/// or -0.5*Dz() is returned.
171172
template <typename T>
172173
constexpr bool detectorToLocal(T const row, T const col, float& xRow, float& zCol) const noexcept {
173-
if (!isValid(row, col)) {
174+
if (!isValidDet(row, col)) {
174175
return false;
175176
}
176177
detectorToLocalUnchecked(row, col, xRow, zCol);
177-
return isValid(xRow, zCol);
178+
return isValidLoc(xRow, zCol);
178179
}
179180

180181
// Same as detectorToLocal w.o. checks.
@@ -204,14 +205,19 @@ class SegmentationMosaix
204205
}
205206

206207
private:
208+
// Check local coordinates (cm) validity.
207209
template <typename T>
208-
[[nodiscard]] constexpr bool isValid(T const row, T const col) const noexcept
210+
constexpr bool isValidLoc(T const x, T const z) const noexcept
209211
{
210-
if constexpr (std::is_floating_point_v<T>) { // compares in local coord.
211-
return (-WidthH < row && row < WidthH && -LengthH < col && col < LengthH);
212-
} else { // compares in rows/cols
213-
return !static_cast<bool>(row < 0 || row >= static_cast<int>(NRows) || col < 0 || col >= static_cast<int>(NCols));
214-
}
212+
return (-WidthH < x && x < WidthH && -LengthH < z && z < LengthH);
213+
}
214+
215+
// Check detector coordinates validity.
216+
template <typename T>
217+
constexpr bool isValidDet(T const row, T const col) const noexcept
218+
{
219+
return (row >= 0 && row < static_cast<T>(NRows) &&
220+
col >= 0 && col < static_cast<T>(NCols));
215221
}
216222

217223
float mRadius;

Detectors/Upgrades/ITS3/macros/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ its3_add_macro(CompareClusterSize.C)
2222
its3_add_macro(CheckMosaixSegment.C)
2323
its3_add_macro(CheckMosaixSegmentTrans.C)
2424
its3_add_macro(CompareClustersAndDigits.C)
25+
its3_add_macro(CompareClustersAndDigitsOnChip.C)
2526
its3_add_macro(CheckROFs.C)
2627
its3_add_macro(CheckTileNumbering.C)
2728
its3_add_macro(CreateITS3StaticDeadMap.C)

0 commit comments

Comments
 (0)