134 using SingleResult_t = std::tuple<int, int, int,
141 float, float, uint64_t>;
142 using TrackResult_t = std::vector<SingleResult_t>;
143 constexpr float invalidFloat(-1.);
144 constexpr int invalidInteger(-1);
145 constexpr uint64_t invalidID(0);
146 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
147 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
148 invalidInteger, invalidInteger, invalidInteger,
149 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
150 invalidFloat, invalidFloat, invalidFloat, invalidFloat,
152 bool isUnbiased(
true);
157 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
158 const auto& allTrackStates = *(trackWithHoles->trackStateOnSurfaces());
159 const int numberOfHits(allTrackStates.size());
160 unsigned int trackParametersCounter(numberOfHits);
161 TrackResult_t result;
162 result.reserve(numberOfHits);
166 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
169 ATH_MSG_DEBUG(
"Num. track states in track " << ++trackNumber <<
": " << allTrackStates.size());
171 for (
const auto *
const thisTrackState: allTrackStates) {
174 SingleResult_t thisResult(invalidResult);
175 if (not thisTrackState) {
176 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
190 if (not (thisTrackState)->trackParameters()) {
191 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
194 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
200 int measureType = -1;
211 bool anyHit = isMesb || isOutl || isHole;
217 int iLayer(invalidInteger);
219 if (not successfulIdentification) {
225 float residualLocX(invalidFloat), pullLocX(invalidFloat);
226 float residualLocY(invalidFloat), pullLocY(invalidFloat);
227 float measurementLocX(invalidFloat), trackParamLocX(invalidFloat), measurementLocCovX(invalidFloat);
228 float measurementLocY(invalidFloat), trackParamLocY(invalidFloat), measurementLocCovY(invalidFloat);
229 float angle(0.), etaloc(0.);
230 int phiWidth(invalidInteger), etaWidth(invalidInteger);
231 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
233 if (biasedTrackParameters) {
237 if (mesb && biasedTrackParameters) {
240 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
243 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
245 if (trackParameters != biasedTrackParameters) {
246 cleanup_trackparam.reset(trackParameters);
248 if (not trackParameters) {
257 if (not residualPull) {
264 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
265 pullLocX = residualPull->pull()[
Trk::loc1];
267 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
270 if (residualPull->dimension() > 1) {
271 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
272 pullLocY = residualPull->pull()[
Trk::loc2];
274 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
281 if (hit && isUnbiased) {
287 phiWidth = int(
width.colRow().x());
288 etaWidth = int(
width.colRow().y());
296 double trkphicomp = my_track.dot(my_phiax);
297 double trketacomp = my_track.dot(my_etaax);
298 double trknormcomp = my_track.dot(my_normal);
299 double bowphi = std::atan2(trkphicomp,trknormcomp);
300 double boweta = std::atan2(trketacomp,trknormcomp);
307 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
312 angle = std::atan(std::tan(bowphi)-readoutside*tanl);
314 double thetaloc=-999.;
315 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
316 thetaloc =
M_PI/2.-boweta;
317 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
318 thetaloc = 1.5*
M_PI-boweta;
320 thetaloc = -0.5*
M_PI-boweta;
322 etaloc = -1*log(tan(thetaloc/2.));
330 if (not biasedTrackParameters) {
333 --trackParametersCounter;
335 thisResult = std::make_tuple(det,
r, iLayer,
336 residualLocX, pullLocX, residualLocY, pullLocY,
337 phiWidth, etaWidth, measureType,
338 measurementLocX, measurementLocY,
339 trackParamLocX, trackParamLocY,
341 measurementLocCovX, measurementLocCovY,
343 result.push_back(thisResult);
345 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
346 <<
" had track params, and " << result.size() <<
" had residuals.");
347 if (not result.empty()) {
348 const unsigned int arraySize = result.size();
349 std::vector<int> result_det;
350 result_det.reserve(arraySize);
351 std::vector<int> result_r;
352 result_r.reserve(arraySize);
353 std::vector<int> result_iLayer;
354 result_iLayer.reserve(arraySize);
355 std::vector<float> result_residualLocX;
356 result_residualLocX.reserve(arraySize);
357 std::vector<float> result_pullLocX;
358 result_pullLocX.reserve(arraySize);
359 std::vector<float> result_residualLocY;
360 result_residualLocY.reserve(arraySize);
361 std::vector<float> result_pullLocY;
362 result_pullLocY.reserve(arraySize);
363 std::vector<int> result_phiWidth;
364 result_phiWidth.reserve(arraySize);
365 std::vector<int> result_etaWidth;
366 result_etaWidth.reserve(arraySize);
367 std::vector<int> result_measureType;
368 result_measureType.reserve(arraySize);
369 std::vector<float> result_measurementLocX;
370 result_measurementLocX.reserve(arraySize);
371 std::vector<float> result_measurementLocY;
372 result_measurementLocY.reserve(arraySize);
373 std::vector<float> result_trackParamLocX;
374 result_trackParamLocX.reserve(arraySize);
375 std::vector<float> result_trackParamLocY;
376 result_trackParamLocY.reserve(arraySize);
377 std::vector<float> result_angle;
378 result_angle.reserve(arraySize);
379 std::vector<float> result_etaloc;
380 result_etaloc.reserve(arraySize);
381 std::vector<float> result_measurementLocCovX;
382 result_measurementLocCovX.reserve(arraySize);
383 std::vector<float> result_measurementLocCovY;
384 result_measurementLocCovY.reserve(arraySize);
385 std::vector<uint64_t> result_surfaceID;
386 result_surfaceID.reserve(arraySize);
388 for (
const SingleResult_t& single_result : result) {
389 result_det.push_back(std::get<0>(single_result));
390 result_r.push_back(std::get<1>(single_result));
391 result_iLayer.push_back(std::get<2>(single_result));
392 result_residualLocX.push_back(std::get<3>(single_result));
393 result_pullLocX.push_back(std::get<4>(single_result));
394 result_residualLocY.push_back(std::get<5>(single_result));
395 result_pullLocY.push_back(std::get<6>(single_result));
396 result_phiWidth.push_back(std::get<7>(single_result));
397 result_etaWidth.push_back(std::get<8>(single_result));
398 result_measureType.push_back(std::get<9>(single_result));
399 result_measurementLocX.push_back(std::get<10>(single_result));
400 result_measurementLocY.push_back(std::get<11>(single_result));
401 result_trackParamLocX.push_back(std::get<12>(single_result));
402 result_trackParamLocY.push_back(std::get<13>(single_result));
403 result_angle.push_back(std::get<14>(single_result));
404 result_etaloc.push_back(std::get<15>(single_result));
405 result_measurementLocCovX.push_back(std::get<16>(single_result));
406 result_measurementLocCovY.push_back(std::get<17>(single_result));
407 result_surfaceID.push_back(std::get<18>(single_result));
410 int_decor[
kDecorRegion](particle) = std::move(result_r);
411 int_decor[
kDecorDet](particle) = std::move(result_det);
412 int_decor[
kDecorILayer](particle) = std::move(result_iLayer);
415 int_decor[
kDecorType](particle) = std::move(result_measureType);
418 float_decor[
kDecorPullLocX](particle) = std::move(result_pullLocX);
419 float_decor[
kDecorMeasLocX](particle) = std::move(result_measurementLocX);
424 float_decor[
kDecorPullLocY](particle) = std::move(result_pullLocY);
425 float_decor[
kDecorMeasLocY](particle) = std::move(result_measurementLocY);
429 float_decor[
kDecorAngle](particle) = std::move(result_angle);
430 float_decor[
kDecorEtaLoc](particle) = std::move(result_etaloc);
432 uint64_decor[
kDecorID](particle) = std::move(result_surfaceID);