18 template <
typename Array>
20 size_t size0 = 7
u,
size_t size1 = 7
u) {
27 std::vector<double> weights;
34 for (
size_t i = 0;
i < cluster.
channels.size();
i++) {
35 acc0 += cluster.
channels.at(
i).bin[0] * weights.at(
i);
36 acc1 += cluster.
channels.at(
i).bin[1] * weights.at(
i);
41 int offset0 =
static_cast<int>(acc0) - size0 / 2;
42 int offset1 =
static_cast<int>(acc1) - size1 / 2;
45 arr = Eigen::ArrayXXf::Zero(1, size0 * size1);
49 int iMat = cell.
bin[0] - offset0;
50 int jMat = cell.
bin[1] - offset1;
51 if (iMat >= 0 && iMat < (
int)size0 && jMat >= 0 && jMat < (
int)size1) {
53 if (index < arr.size()) {
65 std::vector<size_t> volumeIds)
66 : m_env(ORT_LOGGING_LEVEL_WARNING,
"NeuralCalibrator"),
67 m_model(m_env, modelPath.c_str()),
68 m_nComponents{nComponents},
78 const IndexSourceLink& idxSourceLink = sourceLink.
get<IndexSourceLink>();
79 assert((idxSourceLink.index() < measurements.size()) and
80 "Source link index is outside the container bounds");
82 if (std::find(m_volumeIds.begin(), m_volumeIds.end(),
83 idxSourceLink.geometryId().volume()) == m_volumeIds.end()) {
84 m_fallback.calibrate(measurements, clusters, gctx, cctx, sourceLink,
90 auto input = inputBatch(0, Eigen::all);
96 input, (*clusters)[idxSourceLink.index()], matSize0, matSize1);
98 input[iInput++] = idxSourceLink.geometryId().volume();
99 input[iInput++] = idxSourceLink.geometryId().layer();
104 [&](
const auto& measurement) {
105 auto E = measurement.expander();
106 auto P = measurement.projector();
109 E * measurement.covariance() *
E.transpose();
124 std::pair<double, double> angles =
127 input[iInput++] = angles.first;
128 input[iInput++] = angles.second;
133 if (iInput != m_nInputs) {
134 throw std::runtime_error(
"Expected input size of " +
140 std::vector<float>
output =
141 m_model.runONNXInference(inputBatch).front();
146 size_t nParams = 5 * m_nComponents;
147 if (output.size() != nParams) {
148 throw std::runtime_error(
155 if (m_nComponents > 1) {
158 std::max_element(output.begin(), output.begin() + m_nComponents));
160 size_t iLoc0 = m_nComponents + iMax * 2;
161 size_t iVar0 = 3 * m_nComponents + iMax * 2;
168 constexpr
size_t kSize =
170 std::array<Acts::BoundIndices, kSize> indices = measurement.indices();
182 measurements[idxSourceLink.index()]);