46 int_decor_names[
kDecorDet]=
"measurement_det";
48 int_decor_names[
kDecorType]=
"measurement_type";
67 uint64_decor_names[
kDecorID]=
"surfaceID";
84 ATH_MSG_INFO(
"No residual/pull calculator for general hit residuals configured.");
85 ATH_MSG_INFO(
"It is recommended to give R/P calculators to the det-specific tool handle lists then.");
89 ATH_MSG_INFO(
"Generic hit residuals & pulls will be calculated in one or both available local coordinates");
91 return StatusCode::SUCCESS;
96 return StatusCode::SUCCESS;
105 return StatusCode::FAILURE;
108 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<float> > >
110 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<int> > >
112 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<uint64_t> > >
116 if (not
decorateTrack(*trk_particle, float_decor, int_decor, uint64_decor) ) {
118 return StatusCode::FAILURE;
121 return StatusCode::SUCCESS;
132 using SingleResult_t = std::tuple<
int,
int,
int,
140 using TrackResult_t = std::vector<SingleResult_t>;
142 constexpr
int invalidInteger(-1);
144 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
146 invalidInteger, invalidInteger, invalidInteger,
150 bool isUnbiased(
true);
155 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
157 const int numberOfHits(allTrackStates.size());
158 unsigned int trackParametersCounter(numberOfHits);
160 result.reserve(numberOfHits);
164 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
169 for (
const auto *
const thisTrackState: allTrackStates) {
172 SingleResult_t thisResult(invalidResult);
173 if (not thisTrackState) {
174 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
188 if (not (thisTrackState)->trackParameters()) {
192 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
198 int measureType = -1;
209 bool anyHit = isMesb || isOutl || isHole;
215 int iLayer(invalidInteger);
217 if (not successfulIdentification) {
227 float angle(0.), etaloc(0.);
228 int phiWidth(invalidInteger), etaWidth(invalidInteger);
229 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
231 if (biasedTrackParameters) {
235 if (mesb && biasedTrackParameters) {
238 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
241 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
243 if (trackParameters != biasedTrackParameters) {
244 cleanup_trackparam.reset(trackParameters);
246 if (not trackParameters) {
255 if (not residualPull) {
262 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
263 pullLocX = residualPull->pull()[
Trk::loc1];
265 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
268 if (residualPull->dimension() > 1) {
269 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
270 pullLocY = residualPull->pull()[
Trk::loc2];
272 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
279 if (hit && isUnbiased) {
294 double trkphicomp = my_track.dot(my_phiax);
295 double trketacomp = my_track.dot(my_etaax);
296 double trknormcomp = my_track.dot(my_normal);
297 double bowphi = std::atan2(trkphicomp,trknormcomp);
298 double boweta = std::atan2(trketacomp,trknormcomp);
305 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
312 double thetaloc=-999.;
313 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
314 thetaloc =
M_PI/2.-boweta;
315 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
316 thetaloc = 1.5*
M_PI-boweta;
318 thetaloc = -0.5*
M_PI-boweta;
320 etaloc = -1*
log(
tan(thetaloc/2.));
328 if (not biasedTrackParameters) {
331 --trackParametersCounter;
333 thisResult = std::make_tuple(
det,
r, iLayer,
334 residualLocX, pullLocX, residualLocY, pullLocY,
336 measurementLocX, measurementLocY,
337 trackParamLocX, trackParamLocY,
339 measurementLocCovX, measurementLocCovY,
341 result.push_back(thisResult);
343 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
344 <<
" had track params, and " <<
result.size() <<
" had residuals.");
346 const unsigned int arraySize =
result.size();
347 std::vector<int> result_det;
348 result_det.reserve(arraySize);
349 std::vector<int> result_r;
350 result_r.reserve(arraySize);
351 std::vector<int> result_iLayer;
352 result_iLayer.reserve(arraySize);
353 std::vector<float> result_residualLocX;
354 result_residualLocX.reserve(arraySize);
355 std::vector<float> result_pullLocX;
356 result_pullLocX.reserve(arraySize);
357 std::vector<float> result_residualLocY;
358 result_residualLocY.reserve(arraySize);
359 std::vector<float> result_pullLocY;
360 result_pullLocY.reserve(arraySize);
361 std::vector<int> result_phiWidth;
362 result_phiWidth.reserve(arraySize);
363 std::vector<int> result_etaWidth;
364 result_etaWidth.reserve(arraySize);
365 std::vector<int> result_measureType;
366 result_measureType.reserve(arraySize);
367 std::vector<float> result_measurementLocX;
368 result_measurementLocX.reserve(arraySize);
369 std::vector<float> result_measurementLocY;
370 result_measurementLocY.reserve(arraySize);
371 std::vector<float> result_trackParamLocX;
372 result_trackParamLocX.reserve(arraySize);
373 std::vector<float> result_trackParamLocY;
374 result_trackParamLocY.reserve(arraySize);
375 std::vector<float> result_angle;
376 result_angle.reserve(arraySize);
377 std::vector<float> result_etaloc;
378 result_etaloc.reserve(arraySize);
379 std::vector<float> result_measurementLocCovX;
380 result_measurementLocCovX.reserve(arraySize);
381 std::vector<float> result_measurementLocCovY;
382 result_measurementLocCovY.reserve(arraySize);
383 std::vector<uint64_t> result_surfaceID;
384 result_surfaceID.reserve(arraySize);
386 for (
const SingleResult_t& single_result :
result) {
387 result_det.push_back(std::get<0>(single_result));
388 result_r.push_back(std::get<1>(single_result));
389 result_iLayer.push_back(std::get<2>(single_result));
390 result_residualLocX.push_back(std::get<3>(single_result));
391 result_pullLocX.push_back(std::get<4>(single_result));
392 result_residualLocY.push_back(std::get<5>(single_result));
393 result_pullLocY.push_back(std::get<6>(single_result));
394 result_phiWidth.push_back(std::get<7>(single_result));
395 result_etaWidth.push_back(std::get<8>(single_result));
396 result_measureType.push_back(std::get<9>(single_result));
397 result_measurementLocX.push_back(std::get<10>(single_result));
398 result_measurementLocY.push_back(std::get<11>(single_result));
399 result_trackParamLocX.push_back(std::get<12>(single_result));
400 result_trackParamLocY.push_back(std::get<13>(single_result));
401 result_angle.push_back(std::get<14>(single_result));
402 result_etaloc.push_back(std::get<15>(single_result));
403 result_measurementLocCovX.push_back(std::get<16>(single_result));
404 result_measurementLocCovY.push_back(std::get<17>(single_result));
405 result_surfaceID.push_back(std::get<18>(single_result));
447 const int pixelSctBarrelIndex(0);
448 const int trtBarrelIndex(1);
479 bool &isUnbiased)
const {
483 if (trkParameters->covariance()) {
485 unbiasedTrkParameters =
m_updatorHandle->removeFromState(*trkParameters,
488 if (!unbiasedTrkParameters) {
489 ATH_MSG_INFO(
"Could not get unbiased track parameters, use normal parameters" );
494 ATH_MSG_WARNING(
"TrackParameters contain no covariance, unbiased track states can not be calculated "
495 "(ie. pulls and residuals will be too small)" );
502 return unbiasedTrkParameters;