28 std::vector<MMPrepData>&& MMprds,
29 std::vector<std::unique_ptr<MMPrepData>>& clustersVect)
const {
31 ATH_MSG_DEBUG(
"Size of the output vector: " << clustersVect.size());
35 return StatusCode::SUCCESS;
40 const Identifier ida = a.identify(), idb = b.identify();
41 const int mla = idHelper.multilayer(ida);
42 const int mlb = idHelper.multilayer(idb);
43 if (mla!=mlb) return mla<mlb;
44 const int gga = idHelper.gasGap(ida);
45 const int ggb = idHelper.gasGap(idb);
46 if (gga!=ggb) return gga<ggb;
47 return idHelper.channel(ida) < idHelper.channel(idb);
52 const unsigned int n_input_prds = MMprds.size();
53 for (
unsigned int mergeI = 0; mergeI < n_input_prds; ) {
54 const MMPrepData& primary_prd = MMprds[mergeI];
61 unsigned mergeJ{mergeI+1};
63 while (mergeJ < n_input_prds &&
64 gasGapId ==
m_idHelperSvc->gasGapId(MMprds[mergeJ].identify()) &&
65 std::abs(idHelper.
channel(MMprds[mergeJ].identify()) -
69 unsigned int clustSize = mergeJ - mergeI;
80 double totalCharge{0.0};
82 for (
unsigned int mergeMe = mergeI; mergeMe < mergeJ; ++mergeMe) {
85 rdoList.push_back(mergedId);
86 mergeStrips.push_back(idHelper.
channel(mergedId));
87 mergeStripsTime.push_back(mergePrd.
time());
88 mergeStripsCharge.push_back(mergePrd.
charge());
89 mergeStripsDriftDists.push_back(mergePrd.
driftDist());
91 mergeStripsDriftDistErrors.emplace_back(cov(0,0), cov(1,1));
93 totalCharge += mergePrd.
charge();
101 unsigned int stripSum = 0;
102 for (
unsigned short strip : mergeStrips) stripSum +=
strip;
103 stripSum /= mergeStrips.size();
105 unsigned int centralIdx{mergeI};
106 for (
unsigned int k = 0; k < mergeStrips.size(); ++k) {
108 if (mergeStrips[k] == stripSum)
break;
110 const Identifier clusterId = MMprds[centralIdx < mergeJ ? centralIdx : mergeI].identify();
111 ATH_MSG_VERBOSE(
" Look for strip nr " << stripSum <<
" found at index " << centralIdx);
119 stripsVec.insert(stripsVec.begin(),std::make_move_iterator(MMprds.begin() + mergeI),
120 std::make_move_iterator(MMprds.begin() + mergeJ));
132 std::unique_ptr<MMPrepData> prdN = std::make_unique<MMPrepData>(clusterId,
134 std::move(clusterLocalPosition),
136 std::move(covMatrix),
137 stripsVec.front().detectorElement(),
141 std::move(mergeStrips),
142 std::move(mergeStripsTime),
143 std::move(mergeStripsCharge));
145 prdN->setDriftDist(std::move(mergeStripsDriftDists), std::move(mergeStripsDriftDistErrors));
147 clustersVect.push_back(std::move(prdN));
149 return StatusCode::SUCCESS;
203 const std::vector<NSWCalib::CalibratedStrip>& calibratedStrips,
208 double xPosCalib{0.}, totalCharge{0.};
210 xPosCalib += it.charge * it.dx;
211 totalCharge += it.charge;
213 if (std::abs(totalCharge) < std::numeric_limits<float>::epsilon()) {
214 return RIO_Author::unKnownAuthor;
217 xPosCalib /= totalCharge;
219 ATH_MSG_DEBUG(
"position before calibration and correction: " << clusterLocalPosition[
Trk::locX] <<
" " << xPosCalib);
225 return RIO_Author::unKnownAuthor;
229 errorCalibIn.
clusterSize = calibratedStrips.size();
230 errorCalibIn.
clusterAuthor = RIO_Author::SimpleClusterBuilder;
231 errorCalibIn.
locPhi = dirEstimate.phi();
232 errorCalibIn.
locTheta = dirEstimate.theta();
233 errorCalibIn.
localPos = clusterLocalPosition;
236 const double localUncertainty = errorCalibDB->clusterUncertainty(errorCalibIn);
238 covMatrix(0, 0) = localUncertainty * localUncertainty;
241 return RIO_Author::SimpleClusterBuilder;