4#ifndef NNPIXELCLUSTERCALIBRATORHELPERS_H
5#define NNPIXELCLUSTERCALIBRATORHELPERS_H
45 return std::accumulate(
81 return pixelIndex - centerIndex +
109 std::span<payload_t, static_cast<index_t>(Index::windowSize)> pitches(
112 static_cast<index_t>(Index::windowSize));
113 const std::size_t
windowSize =
static_cast<std::size_t
>(Index::windowSize);
115 std::array<double, static_cast<std::size_t>(Index::windowSize)>
118 for (std::size_t j = 0; j <
windowSize; ++j) {
123 const std::size_t centerIdx =
static_cast<std::size_t
>(Index::center);
124 const double centerValue = cumulative[centerIdx];
125 for (
double& value : cumulative) {
126 value -= centerValue;
129 const double coordsIdx =
coord +
static_cast<double>(Index::center);
130 const double floorValue = std::floor(coordsIdx);
131 const double frac = floorValue - coordsIdx;
132 const long intIdx =
static_cast<long>(floorValue);
133 const long clippedIdx = std::clamp(intIdx,
static_cast<long>(0),
135 const double base = cumulative[clippedIdx];
136 const double pitchAtIdx = pitches[clippedIdx];
137 const double centerOfCluster = pitchOffset == Index::pitchXOffset
140 return base + std::abs(frac) * pitchAtIdx + centerOfCluster;
152 std::span<payload_t, static_cast<index_t>(Index::windowSize)> pitches(
155 static_cast<index_t>(Index::windowSize));
157 const float p = ((prec > 0) ? std::sqrt(1.0f / prec) : 0.01f) +
158 static_cast<float>(Index::center);
159 float pitchPos = -100;
160 float pitchCenter = -100;
161 float pitchActual = 0;
162 for (
index_t i = 0; i < static_cast<index_t>(Index::windowSize); i++) {
163 if (p >= i and p <= (i + 1))
164 pitchPos = pitchActual + (p - i + 0.5) * pitches[i];
165 if (i ==
static_cast<index_t>(Index::center))
166 pitchCenter = pitchActual + 0.5 * pitches[i];
167 pitchActual += pitches[i];
169 return std::abs(pitchPos - pitchCenter);
182 if (i >=
static_cast<index_t>(Index::windowSize))
183 throw std::domain_error(
184 "Filling the NNinput for pixel calibration, the value should be "
185 "within 0-6, while it "
187 std::to_string(i) +
" " + context);
202 static unsigned int maxProbIndex(
const std::array<payload_t, 3>& prob) {
203 return std::ranges::distance(std::begin(prob),
204 std::ranges::max_element(prob));
245 static_cast<index_t>(Index::xOffset)];
251 static_cast<index_t>(Index::yOffset)];
257 static_cast<index_t>(Index::xPrecOffset)];
262 static_cast<index_t>(Index::yPrecOffset)];
Scalar phi() const
phi method
Scalar theta() const
theta method
double charge(const T &p)
static unsigned int totalSize(const MultiDimArray< T, N > &ht)
PositionNNoutput(const float *begin, const float *end)
index_t numberOfSubClusters()
returns number of (sub)clusters Effectively it depends on the position network used
NNinput::payload_t payload_t
payload_t y(index_t cluster)
std::vector< payload_t > & payload()
payload_t xprec(index_t cluster)
precision in nn coordinates
PositionNNoutput(int nPos)
payload_t yprec(index_t cluster)
payload_t x(index_t cluster)
x position (in nn coordinates)
std::vector< payload_t > m_payload
Identifier for the strip or pixel cell.
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
NNinput::payload_t payload_t
static unsigned int maxProbIndex(const std::array< payload_t, 3 > &prob)
! payload from NN