25 {
27 ATH_MSG_DEBUG(
"Size of the output vector: " << clustersVect.size());
28
29 if (MMprds.empty()) {
31 return StatusCode::SUCCESS;
32 }
34 std::ranges::sort(MMprds,
35 [&](
const MMPrepData&
a,
const MMPrepData& b){
36 const Identifier ida{
a.identify()};
37 const Identifier
idb{
b.identify()};
40 if (mla!=mlb) {
41 return mla < mlb;
42 }
43 const int gga = idHelper.
gasGap(ida);
44 const int ggb = idHelper.
gasGap(idb);
45 if (gga!=ggb) {
46 return gga < ggb;
47 }
49 });
50
51
52 const IdentifierHash
hash = MMprds.at(0).collectionHash();
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];
56 const Identifier id_prd = primary_prd.identify();
58
60 << " z " << primary_prd.globalPosition().z());
62 unsigned mergeJ{mergeI+1};
63
64 while (mergeJ < n_input_prds &&
65 gasGapId ==
m_idHelperSvc->gasGapId(MMprds[mergeJ].identify()) &&
66 std::abs(idHelper.
channel(MMprds[mergeJ].identify()) -
68 ++mergeJ;
69 }
70 unsigned int clustSize = mergeJ - mergeI;
72 mergeI = mergeJ;
73 continue;
74 }
81 double totalCharge{0.0};
83 for (unsigned int mergeMe = mergeI; mergeMe < mergeJ; ++mergeMe) {
85 const Identifier mergedId = mergePrd.identify();
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));
93
94 totalCharge += mergePrd.charge();
95 }
96
98
99
100
101
102 unsigned int stripSum = 0;
103 for (
unsigned short strip : mergeStrips) stripSum +=
strip;
104 stripSum /= mergeStrips.size();
105
106 unsigned int centralIdx{mergeI};
107 for (
unsigned int k = 0;
k < mergeStrips.size(); ++
k) {
108 ++centralIdx;
109 if (mergeStrips[k] == stripSum) break;
110 }
111 const Identifier clusterId = MMprds[centralIdx < mergeJ ? centralIdx : mergeI].identify();
112 ATH_MSG_VERBOSE(
" Look for strip nr " << stripSum <<
" found at index " << centralIdx);
113
117
119
120 stripsVec.insert(stripsVec.begin(),std::make_move_iterator(MMprds.begin() + mergeI),
121 std::make_move_iterator(MMprds.begin() + mergeJ));
122
124 mergeI = mergeJ;
128
133 std::unique_ptr<MMPrepData> prdN = std::make_unique<MMPrepData>(clusterId,
134 hash,
135 std::move(clusterLocalPosition),
136 std::move(rdoList),
137 std::move(covMatrix),
138 stripsVec.front().detectorElement(),
139 0,
140 totalCharge,
141 0.f,
142 std::move(mergeStrips),
143 std::move(mergeStripsTime),
144 std::move(mergeStripsCharge));
145
146 prdN->setDriftDist(std::move(mergeStripsDriftDists), std::move(mergeStripsDriftDistErrors));
148 clustersVect.push_back(std::move(prdN));
149 }
150 return StatusCode::SUCCESS;
151}
#define ATH_CHECK
Evaluate an expression and check for errors.
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.