32 m_holeSearchTool(
"InDet::InDetTrackHoleSearchTool"),
33 m_updatorHandle(
"Trk::KalmanUpdator/TrkKalmanUpdator"),
34 m_residualPullCalculator(
"Trk::ResidualPullCalculator/ResidualPullCalculator"),
60 int_decor_names[
kDecorDet]=
"measurement_det";
62 int_decor_names[
kDecorType]=
"measurement_type";
81 uint64_decor_names[
kDecorID]=
"surfaceID";
101 ATH_MSG_INFO(
"No residual/pull calculator for general hit residuals configured.");
102 ATH_MSG_INFO(
"It is recommended to give R/P calculators to the det-specific tool handle lists then.");
106 ATH_MSG_INFO(
"Generic hit residuals & pulls will be calculated in one or both available local coordinates");
108 return StatusCode::SUCCESS;
113 return StatusCode::SUCCESS;
122 return StatusCode::FAILURE;
125 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<float> > >
127 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<int> > >
129 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<uint64_t> > >
133 if (not
decorateTrack(*trk_particle, float_decor, int_decor, uint64_decor) ) {
135 return StatusCode::FAILURE;
138 return StatusCode::SUCCESS;
149 using SingleResult_t = std::tuple<
int,
int,
int,
157 using TrackResult_t = std::vector<SingleResult_t>;
159 const int invalidInteger(-1);
161 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
163 invalidInteger, invalidInteger, invalidInteger,
167 bool isUnbiased(
true);
172 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
174 const int numberOfHits(allTrackStates.size());
175 unsigned int trackParametersCounter(numberOfHits);
177 result.reserve(numberOfHits);
181 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
186 for (
const auto *
const thisTrackState: allTrackStates) {
189 SingleResult_t thisResult(invalidResult);
190 if (not thisTrackState) {
191 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
205 if (not (thisTrackState)->trackParameters()) {
206 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
209 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
215 int measureType = -1;
226 bool anyHit = isMesb || isOutl || isHole;
232 int iLayer(invalidInteger);
234 if (not successfulIdentification) {
244 float angle(0.), etaloc(0.);
245 int phiWidth(invalidInteger), etaWidth(invalidInteger);
246 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
248 if (biasedTrackParameters) {
252 if (mesb && biasedTrackParameters) {
255 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
258 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
260 if (trackParameters != biasedTrackParameters) {
261 cleanup_trackparam.reset(trackParameters);
263 if (not trackParameters) {
272 if (not residualPull) {
279 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
280 pullLocX = residualPull->pull()[
Trk::loc1];
282 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
285 if (residualPull->dimension() > 1) {
286 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
287 pullLocY = residualPull->pull()[
Trk::loc2];
289 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
296 if (hit && isUnbiased) {
311 float trkphicomp = my_track.dot(my_phiax);
312 float trketacomp = my_track.dot(my_etaax);
313 float trknormcomp = my_track.dot(my_normal);
314 double bowphi = atan2(trkphicomp,trknormcomp);
315 double boweta = atan2(trketacomp,trknormcomp);
322 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
329 double thetaloc=-999.;
330 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
331 thetaloc =
M_PI/2.-boweta;
332 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
333 thetaloc = 1.5*
M_PI-boweta;
335 thetaloc = -0.5*
M_PI-boweta;
337 etaloc = -1*
log(
tan(thetaloc/2.));
346 if (not biasedTrackParameters) {
349 --trackParametersCounter;
351 thisResult = std::make_tuple(
det,
r, iLayer,
352 residualLocX, pullLocX, residualLocY, pullLocY,
354 measurementLocX, measurementLocY,
355 trackParamLocX, trackParamLocY,
357 measurementLocCovX, measurementLocCovY,
359 result.push_back(thisResult);
361 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
362 <<
" had track params, and " <<
result.size() <<
" had residuals.");
364 const unsigned int arraySize =
result.size();
365 std::vector<int> result_det;
366 result_det.reserve(arraySize);
367 std::vector<int> result_r;
368 result_r.reserve(arraySize);
369 std::vector<int> result_iLayer;
370 result_iLayer.reserve(arraySize);
371 std::vector<float> result_residualLocX;
372 result_residualLocX.reserve(arraySize);
373 std::vector<float> result_pullLocX;
374 result_pullLocX.reserve(arraySize);
375 std::vector<float> result_residualLocY;
376 result_residualLocY.reserve(arraySize);
377 std::vector<float> result_pullLocY;
378 result_pullLocY.reserve(arraySize);
379 std::vector<int> result_phiWidth;
380 result_phiWidth.reserve(arraySize);
381 std::vector<int> result_etaWidth;
382 result_etaWidth.reserve(arraySize);
383 std::vector<int> result_measureType;
384 result_measureType.reserve(arraySize);
385 std::vector<float> result_measurementLocX;
386 result_measurementLocX.reserve(arraySize);
387 std::vector<float> result_measurementLocY;
388 result_measurementLocY.reserve(arraySize);
389 std::vector<float> result_trackParamLocX;
390 result_trackParamLocX.reserve(arraySize);
391 std::vector<float> result_trackParamLocY;
392 result_trackParamLocY.reserve(arraySize);
393 std::vector<float> result_angle;
394 result_angle.reserve(arraySize);
395 std::vector<float> result_etaloc;
396 result_etaloc.reserve(arraySize);
397 std::vector<float> result_measurementLocCovX;
398 result_measurementLocCovX.reserve(arraySize);
399 std::vector<float> result_measurementLocCovY;
400 result_measurementLocCovY.reserve(arraySize);
401 std::vector<uint64_t> result_surfaceID;
402 result_surfaceID.reserve(arraySize);
404 for (
const SingleResult_t& single_result :
result) {
405 result_det.push_back(std::get<0>(single_result));
406 result_r.push_back(std::get<1>(single_result));
407 result_iLayer.push_back(std::get<2>(single_result));
408 result_residualLocX.push_back(std::get<3>(single_result));
409 result_pullLocX.push_back(std::get<4>(single_result));
410 result_residualLocY.push_back(std::get<5>(single_result));
411 result_pullLocY.push_back(std::get<6>(single_result));
412 result_phiWidth.push_back(std::get<7>(single_result));
413 result_etaWidth.push_back(std::get<8>(single_result));
414 result_measureType.push_back(std::get<9>(single_result));
415 result_measurementLocX.push_back(std::get<10>(single_result));
416 result_measurementLocY.push_back(std::get<11>(single_result));
417 result_trackParamLocX.push_back(std::get<12>(single_result));
418 result_trackParamLocY.push_back(std::get<13>(single_result));
419 result_angle.push_back(std::get<14>(single_result));
420 result_etaloc.push_back(std::get<15>(single_result));
421 result_measurementLocCovX.push_back(std::get<16>(single_result));
422 result_measurementLocCovY.push_back(std::get<17>(single_result));
423 result_surfaceID.push_back(std::get<18>(single_result));
465 const int pixelSctBarrelIndex(0);
466 const int trtBarrelIndex(1);
497 bool &isUnbiased)
const {
501 if (trkParameters->covariance()) {
503 unbiasedTrkParameters =
m_updatorHandle->removeFromState(*trkParameters,
506 if (!unbiasedTrkParameters) {
507 ATH_MSG_INFO(
"Could not get unbiased track parameters, use normal parameters" );
512 ATH_MSG_WARNING(
"TrackParameters contain no covariance, unbiased track states can not be calculated "
513 "(ie. pulls and residuals will be too small)" );
520 return unbiasedTrkParameters;