9 #define DEFINE_VECTOR(dType, varName, nEles) \
10 std::vector<dType> varName{}; \
11 varName.reserve(nEles);
18 declareInterface<IMMClusterBuilderTool>(
this);
24 return StatusCode::SUCCESS;
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;
38 std::sort(MMprds.begin(), MMprds.end(),
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()) -
66 idHelper.channel(MMprds[mergeJ -1].identify()) ) <=
static_cast<int>(
m_maxHoleSize) + 1) {
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),
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;
155 std::vector<MMPrepData>& stripsVec,
160 if (!errorCalibDB.isValid()) {
162 return StatusCode::FAILURE;
165 double weightedPosX{0.},
posY{0.}, totalCharge{0.};
169 posY = stripsVec[0].localPosition().y();
171 const double posX = strip.localPosition().x();
172 const double charge = strip.charge();
180 <<
", theta: "<<globPos.theta()<<
", eta: "<<globPos.eta()<<
", phi: "<<globPos.phi()
181 <<
" -- local direction theta: "<<lDir.theta()<<
", eta: "<<lDir.eta()
182 <<
", phi: "<<lDir.phi());
184 weightedPosX = weightedPosX / totalCharge;
188 errorCalibIn.
stripId = clustId;
190 errorCalibIn.locPhi = clusDir.phi();
191 errorCalibIn.locTheta = clusDir.theta();
192 errorCalibIn.localPos = clusterLocalPosition;
193 errorCalibIn.clusterSize = stripsVec.size();
197 const double localUncertainty = errorCalibDB->clusterUncertainty(errorCalibIn);
198 covMatrix(0, 0) = localUncertainty * localUncertainty;
199 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);
223 if (!errorCalibDB.isValid()) {
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;
234 errorCalibIn.stripId = calibratedStrips[errorCalibIn.clusterSize/2].identifier;
236 const double localUncertainty = errorCalibDB->clusterUncertainty(errorCalibIn);
238 covMatrix(0, 0) = localUncertainty * localUncertainty;
241 return RIO_Author::SimpleClusterBuilder;