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 const 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 float trkphicomp = my_track.dot(my_phiax);
295 float trketacomp = my_track.dot(my_etaax);
296 float trknormcomp = my_track.dot(my_normal);
297 double bowphi = atan2(trkphicomp,trknormcomp);
298 double boweta = 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.));
329 if (not biasedTrackParameters) {
332 --trackParametersCounter;
334 thisResult = std::make_tuple(
det,
r, iLayer,
335 residualLocX, pullLocX, residualLocY, pullLocY,
337 measurementLocX, measurementLocY,
338 trackParamLocX, trackParamLocY,
340 measurementLocCovX, measurementLocCovY,
342 result.push_back(thisResult);
344 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
345 <<
" had track params, and " <<
result.size() <<
" had residuals.");
347 const unsigned int arraySize =
result.size();
348 std::vector<int> result_det;
349 result_det.reserve(arraySize);
350 std::vector<int> result_r;
351 result_r.reserve(arraySize);
352 std::vector<int> result_iLayer;
353 result_iLayer.reserve(arraySize);
354 std::vector<float> result_residualLocX;
355 result_residualLocX.reserve(arraySize);
356 std::vector<float> result_pullLocX;
357 result_pullLocX.reserve(arraySize);
358 std::vector<float> result_residualLocY;
359 result_residualLocY.reserve(arraySize);
360 std::vector<float> result_pullLocY;
361 result_pullLocY.reserve(arraySize);
362 std::vector<int> result_phiWidth;
363 result_phiWidth.reserve(arraySize);
364 std::vector<int> result_etaWidth;
365 result_etaWidth.reserve(arraySize);
366 std::vector<int> result_measureType;
367 result_measureType.reserve(arraySize);
368 std::vector<float> result_measurementLocX;
369 result_measurementLocX.reserve(arraySize);
370 std::vector<float> result_measurementLocY;
371 result_measurementLocY.reserve(arraySize);
372 std::vector<float> result_trackParamLocX;
373 result_trackParamLocX.reserve(arraySize);
374 std::vector<float> result_trackParamLocY;
375 result_trackParamLocY.reserve(arraySize);
376 std::vector<float> result_angle;
377 result_angle.reserve(arraySize);
378 std::vector<float> result_etaloc;
379 result_etaloc.reserve(arraySize);
380 std::vector<float> result_measurementLocCovX;
381 result_measurementLocCovX.reserve(arraySize);
382 std::vector<float> result_measurementLocCovY;
383 result_measurementLocCovY.reserve(arraySize);
384 std::vector<uint64_t> result_surfaceID;
385 result_surfaceID.reserve(arraySize);
387 for (
const SingleResult_t& single_result :
result) {
388 result_det.push_back(std::get<0>(single_result));
389 result_r.push_back(std::get<1>(single_result));
390 result_iLayer.push_back(std::get<2>(single_result));
391 result_residualLocX.push_back(std::get<3>(single_result));
392 result_pullLocX.push_back(std::get<4>(single_result));
393 result_residualLocY.push_back(std::get<5>(single_result));
394 result_pullLocY.push_back(std::get<6>(single_result));
395 result_phiWidth.push_back(std::get<7>(single_result));
396 result_etaWidth.push_back(std::get<8>(single_result));
397 result_measureType.push_back(std::get<9>(single_result));
398 result_measurementLocX.push_back(std::get<10>(single_result));
399 result_measurementLocY.push_back(std::get<11>(single_result));
400 result_trackParamLocX.push_back(std::get<12>(single_result));
401 result_trackParamLocY.push_back(std::get<13>(single_result));
402 result_angle.push_back(std::get<14>(single_result));
403 result_etaloc.push_back(std::get<15>(single_result));
404 result_measurementLocCovX.push_back(std::get<16>(single_result));
405 result_measurementLocCovY.push_back(std::get<17>(single_result));
406 result_surfaceID.push_back(std::get<18>(single_result));
448 const int pixelSctBarrelIndex(0);
449 const int trtBarrelIndex(1);
480 bool &isUnbiased)
const {
484 if (trkParameters->covariance()) {
486 unbiasedTrkParameters =
m_updatorHandle->removeFromState(*trkParameters,
489 if (!unbiasedTrkParameters) {
490 ATH_MSG_INFO(
"Could not get unbiased track parameters, use normal parameters" );
495 ATH_MSG_WARNING(
"TrackParameters contain no covariance, unbiased track states can not be calculated "
496 "(ie. pulls and residuals will be too small)" );
503 return unbiasedTrkParameters;