24 std::vector<MMPrepData>&& MMprds,
25 std::vector<std::unique_ptr<MMPrepData>>& clustersVect)
const {
27 ATH_MSG_DEBUG(
"Size of the output vector: " << clustersVect.size());
31 return StatusCode::SUCCESS;
34 std::ranges::sort(MMprds,
43 const int gga = idHelper.
gasGap(ida);
44 const int ggb = idHelper.
gasGap(idb);
53 const unsigned int n_input_prds = MMprds.size();
54 for (
unsigned int mergeI = 0; mergeI < n_input_prds; ) {
55 const MMPrepData& primary_prd = MMprds[mergeI];
62 unsigned mergeJ{mergeI+1};
64 while (mergeJ < n_input_prds &&
65 gasGapId ==
m_idHelperSvc->gasGapId(MMprds[mergeJ].identify()) &&
66 std::abs(idHelper.
channel(MMprds[mergeJ].identify()) -
70 unsigned int clustSize = mergeJ - mergeI;
81 double totalCharge{0.0};
83 for (
unsigned int mergeMe = mergeI; mergeMe < mergeJ; ++mergeMe) {
86 rdoList.push_back(mergedId);
87 mergeStrips.push_back(idHelper.
channel(mergedId));
88 mergeStripsTime.push_back(mergePrd.
time());
89 mergeStripsCharge.push_back(mergePrd.
charge());
90 mergeStripsDriftDists.push_back(mergePrd.
driftDist());
92 mergeStripsDriftDistErrors.emplace_back(cov(0,0), cov(1,1));
94 totalCharge += mergePrd.
charge();
102 unsigned int stripSum = 0;
103 for (
unsigned short strip : mergeStrips) stripSum +=
strip;
104 stripSum /= mergeStrips.size();
106 unsigned int centralIdx{mergeI};
107 for (
unsigned int k = 0; k < mergeStrips.size(); ++k) {
109 if (mergeStrips[k] == stripSum)
break;
111 const Identifier clusterId = MMprds[centralIdx < mergeJ ? centralIdx : mergeI].identify();
112 ATH_MSG_VERBOSE(
" Look for strip nr " << stripSum <<
" found at index " << centralIdx);
120 stripsVec.insert(stripsVec.begin(),std::make_move_iterator(MMprds.begin() + mergeI),
121 std::make_move_iterator(MMprds.begin() + mergeJ));
133 std::unique_ptr<MMPrepData> prdN = std::make_unique<MMPrepData>(clusterId,
135 std::move(clusterLocalPosition),
137 std::move(covMatrix),
138 stripsVec.front().detectorElement(),
142 std::move(mergeStrips),
143 std::move(mergeStripsTime),
144 std::move(mergeStripsCharge));
146 prdN->setDriftDist(std::move(mergeStripsDriftDists), std::move(mergeStripsDriftDistErrors));
148 clustersVect.push_back(std::move(prdN));
150 return StatusCode::SUCCESS;
156 std::vector<MMPrepData>& stripsVec,
163 return StatusCode::FAILURE;
165 covMatrix.setIdentity();
166 double weightedPosX{0.}, posY{0.}, totalCharge{0.};
170 posY = stripsVec[0].localPosition().y();
172 const double posX =
strip.localPosition().x();
174 weightedPosX += posX *
charge;
180 <<
", theta: "<<
strip.globalPosition().theta()
181 <<
", eta: "<<
strip.globalPosition().eta()
182 <<
", phi: "<<
strip.globalPosition().phi()
183 <<
" -- local direction theta: "<<lDir.theta()<<
", eta: "<<lDir.eta()
184 <<
", phi: "<<lDir.phi());
186 weightedPosX = weightedPosX / totalCharge;
190 errorCalibIn.
stripId = clustId;
192 errorCalibIn.
locPhi = clusDir.phi();
193 errorCalibIn.
locTheta = clusDir.theta();
194 errorCalibIn.
localPos = clusterLocalPosition;
199 const double localUncertainty = errorCalibDB->clusterUncertainty(errorCalibIn);
200 covMatrix(0, 0) = localUncertainty * localUncertainty;
201 return StatusCode::SUCCESS;
205 const std::vector<NSWCalib::CalibratedStrip>& calibratedStrips,
210 double xPosCalib{0.}, totalCharge{0.};
212 xPosCalib += it.charge * it.dx;
213 totalCharge += it.charge;
215 if (std::abs(totalCharge) < std::numeric_limits<float>::epsilon()) {
216 return RIO_Author::unKnownAuthor;
219 xPosCalib /= totalCharge;
221 ATH_MSG_DEBUG(
"position before calibration and correction: " << clusterLocalPosition[
Trk::locX] <<
" " << xPosCalib);
227 return RIO_Author::unKnownAuthor;
231 errorCalibIn.
clusterSize = calibratedStrips.size();
232 errorCalibIn.
clusterAuthor = RIO_Author::SimpleClusterBuilder;
233 errorCalibIn.
locPhi = dirEstimate.phi();
234 errorCalibIn.
locTheta = dirEstimate.theta();
235 errorCalibIn.
localPos = clusterLocalPosition;
238 const double localUncertainty = errorCalibDB->clusterUncertainty(errorCalibIn);
240 covMatrix(0, 0) = localUncertainty * localUncertainty;
243 return RIO_Author::SimpleClusterBuilder;