Skip to content

Commit 9672ebf

Browse files
committed
ITS3: template detector coord conversion on input type
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent 37f5b04 commit 9672ebf

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ class SegmentationMosaix
151151
}
152152

153153
// Same as localToDetector w.o. checks.
154-
constexpr void localToDetectorUnchecked(float const xRow, float const zCol, int& iRow, int& iCol) const noexcept
154+
template <typename T = float>
155+
constexpr void localToDetectorUnchecked(T const xRow, T const zCol, int& iRow, int& iCol) const noexcept
155156
{
156157
iRow = static_cast<int>(std::floor((WidthH - xRow) / PitchRow));
157158
iCol = static_cast<int>(std::floor((zCol + LengthH) / PitchCol));
@@ -167,7 +168,8 @@ class SegmentationMosaix
167168
/// center of the sensitive volume.
168169
/// If iRow and or iCol is outside of the segmentation range a value of -0.5*Dx()
169170
/// or -0.5*Dz() is returned.
170-
bool detectorToLocal(float const row, float const col, float& xRow, float& zCol) const noexcept
171+
template <typename T = float, typename L = float>
172+
bool detectorToLocal(T const row, T const col, L& xRow, L& zCol) const noexcept
171173
{
172174
if (!isValidDet(row, col)) {
173175
return false;
@@ -178,25 +180,28 @@ class SegmentationMosaix
178180

179181
// Same as detectorToLocal w.o. checks.
180182
// We position ourself in the middle of the pixel.
181-
void detectorToLocalUnchecked(float const row, float const col, float& xRow, float& zCol) const noexcept
183+
template <typename T = float, typename L = float>
184+
void detectorToLocalUnchecked(T const row, T const col, L& xRow, L& zCol) const noexcept
182185
{
183186
xRow = -(row + 0.5f) * PitchRow + WidthH;
184187
zCol = (col + 0.5f) * PitchCol - LengthH;
185188
}
186189

187-
bool detectorToLocal(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
190+
template <typename T = float, typename L = float>
191+
bool detectorToLocal(T const row, T const col, math_utils::Point3D<L>& loc) const noexcept
188192
{
189-
float xRow{0.}, zCol{0.};
193+
L xRow{0.}, zCol{0.};
190194
if (!detectorToLocal(row, col, xRow, zCol)) {
191195
return false;
192196
}
193197
loc.SetCoordinates(xRow, 0.0f, zCol);
194198
return true;
195199
}
196200

197-
void detectorToLocalUnchecked(float const row, float const col, math_utils::Point3D<float>& loc) const noexcept
201+
template <typename T = float, typename L = float>
202+
void detectorToLocalUnchecked(T const row, T const col, math_utils::Point3D<L>& loc) const noexcept
198203
{
199-
float xRow{0.}, zCol{0.};
204+
L xRow{0.}, zCol{0.};
200205
detectorToLocalUnchecked(row, col, xRow, zCol);
201206
loc.SetCoordinates(xRow, 0.0f, zCol);
202207
}

Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ constexpr float DefClusError2Row = DefClusErrorRow * DefClusErrorRow;
2727
constexpr float DefClusError2Col = DefClusErrorCol * DefClusErrorCol;
2828

2929
template <class iterator, typename T = float>
30-
o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, iterator& iter, const its3::TopologyDictionary* dict, T& sig2y, T& sig2z)
30+
o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, iterator& iter, const o2::its3::TopologyDictionary* dict, T& sig2y, T& sig2z)
3131
{
3232
auto pattID = c.getPatternID();
3333
auto ib = constants::detID::isDetITS3(c.getSensorID());
@@ -50,7 +50,7 @@ o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, i
5050
}
5151

5252
template <class iterator, typename T = float>
53-
o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, iterator& iter, const its3::TopologyDictionary* dict, T& sig2y, T& sig2z, uint8_t& cls)
53+
o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, iterator& iter, const o2::its3::TopologyDictionary* dict, T& sig2y, T& sig2z, uint8_t& cls)
5454
{
5555
auto pattID = c.getPatternID();
5656
auto ib = constants::detID::isDetITS3(c.getSensorID());
@@ -69,13 +69,13 @@ o2::math_utils::Point3D<T> extractClusterData(const itsmft::CompClusterExt& c, i
6969
void convertCompactClusters(gsl::span<const itsmft::CompClusterExt> clusters,
7070
gsl::span<const unsigned char>::iterator& pattIt,
7171
std::vector<o2::BaseCluster<float>>& output,
72-
const its3::TopologyDictionary* dict);
72+
const o2::its3::TopologyDictionary* dict);
7373

7474
int loadROFrameDataITS3(its::TimeFrame<7>* tf,
7575
gsl::span<const o2::itsmft::ROFRecord> rofs,
7676
gsl::span<const itsmft::CompClusterExt> clusters,
7777
gsl::span<const unsigned char>::iterator& pattIt,
78-
const its3::TopologyDictionary* dict,
78+
const o2::its3::TopologyDictionary* dict,
7979
const dataformats::MCTruthContainer<MCCompLabel>* mcLabels = nullptr);
8080

8181
} // namespace o2::its3::ioutils

Detectors/Upgrades/ITS3/reconstruction/src/TopologyDictionary.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,5 +255,7 @@ TopologyDictionary* TopologyDictionary::loadFrom(const std::string& fname, const
255255
// Explicitly instaniate templates
256256
template math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates<float>(const itsmft::CompClusterExt& cl) const;
257257
template math_utils::Point3D<float> TopologyDictionary::getClusterCoordinates<float>(const itsmft::CompClusterExt& cl, const itsmft::ClusterPattern& patt, bool isGroup);
258+
template math_utils::Point3D<double> TopologyDictionary::getClusterCoordinates<double>(const itsmft::CompClusterExt& cl) const;
259+
template math_utils::Point3D<double> TopologyDictionary::getClusterCoordinates<double>(const itsmft::CompClusterExt& cl, const itsmft::ClusterPattern& patt, bool isGroup);
258260

259261
} // namespace o2::its3

0 commit comments

Comments
 (0)