32 m_holeSearchTool(
"InDet::InDetTrackHoleSearchTool"),
33 m_updatorHandle(
"Trk::KalmanUpdator/TrkKalmanUpdator"),
34 m_residualPullCalculator(
"Trk::ResidualPullCalculator/ResidualPullCalculator"),
35 m_ptThreshold(0.8), m_doUpgrade(false),
66 int_decor_names[
kDecorDet]=
"measurement_det";
68 int_decor_names[
kDecorType]=
"measurement_type";
87 uint64_decor_names[
kDecorID]=
"surfaceID";
109 ATH_MSG_INFO(
"No residual/pull calculator for general hit residuals configured.");
110 ATH_MSG_INFO(
"It is recommended to give R/P calculators to the det-specific tool handle lists then.");
114 ATH_MSG_INFO(
"Generic hit residuals & pulls will be calculated in one or both available local coordinates");
116 return StatusCode::SUCCESS;
121 return StatusCode::SUCCESS;
130 return StatusCode::FAILURE;
133 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<float> > >
135 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<int> > >
137 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<uint64_t> > >
141 if (not
decorateTrack(*trk_particle, float_decor, int_decor, uint64_decor) ) {
143 return StatusCode::FAILURE;
146 return StatusCode::SUCCESS;
157 using SingleResult_t = std::tuple<
int,
int,
int,
163 using TrackResult_t = std::vector<SingleResult_t>;
167 const int invalidDetector(-1);
168 const int invalidRegion(-1);
169 const int invalidLayer(-1);
170 const int invalidWidth(-1);
171 const int invalidMeasure(-1);
173 const SingleResult_t invalidResult = std::make_tuple(invalidDetector, invalidRegion, invalidLayer,
174 invalidRes, invalidPull, invalidRes, invalidPull,
175 invalidWidth, invalidWidth, invalidMeasure,
176 invalidRes, invalidRes, invalidRes, invalidRes,
177 invalidRes, invalidRes, invalidRes, invalidRes,
179 bool isUnbiased(
true);
188 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
190 const int numberOfHits(allTrackStates.size());
191 unsigned int trackParametersCounter(numberOfHits);
193 result.reserve(numberOfHits);
198 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
203 for (
const auto *
const thisTrackState: allTrackStates) {
206 SingleResult_t thisResult(invalidResult);
207 if (not thisTrackState) {
208 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
222 if (not (thisTrackState)->trackParameters()) {
223 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
226 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
232 int measureType = -1;
243 bool anyHit = isMesb || isOutl || isHole;
249 int iLayer(invalidLayer);
251 if (not successfulIdentification) {
260 float angle(0), etaloc(0);
263 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
265 if (biasedTrackParameters) {
269 if (mesb && biasedTrackParameters) {
272 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
275 biasedTrackParameters,
277 biasedTrackParameters;
278 if (trackParameters != biasedTrackParameters) {
279 cleanup_trackparam.reset(trackParameters);
281 if (not trackParameters) {
289 if (not residualPull) {
295 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
296 pullLocX = residualPull->pull()[
Trk::loc1];
298 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
301 if (residualPull->dimension() > 1) {
302 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
303 pullLocY = residualPull->pull()[
Trk::loc2];
305 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
314 if (hit && isUnbiased) {
329 float trkphicomp = my_track.dot(my_phiax);
330 float trketacomp = my_track.dot(my_etaax);
331 float trknormcomp = my_track.dot(my_normal);
332 double bowphi = atan2(trkphicomp,trknormcomp);
333 double boweta = atan2(trketacomp,trknormcomp);
340 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
346 double thetaloc=-999.;
347 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.){
348 thetaloc =
M_PI/2.-boweta;
349 }
else if(boweta >
M_PI/2. && boweta <
M_PI){
350 thetaloc = 1.5*
M_PI-boweta;
352 thetaloc = -0.5*
M_PI-boweta;
354 etaloc = -1*
log(
tan(thetaloc/2.));
366 if (not biasedTrackParameters) {
369 --trackParametersCounter;
371 thisResult = std::make_tuple(
det,
r, iLayer,
372 residualLocX, pullLocX, residualLocY, pullLocY,
374 measurementLocX, measurementLocY,
375 trackParamLocX, trackParamLocY,
377 measurementLocCovX, measurementLocCovY,
379 result.push_back(thisResult);
382 "Out of " << numberOfHits <<
" hits, " << trackParametersCounter <<
" had track params, and " <<
result.size() <<
386 const unsigned int arraySize =
result.size();
387 std::vector<int> result_det;
388 result_det.reserve(arraySize);
389 std::vector<int> result_r;
390 result_r.reserve(arraySize);
391 std::vector<int> result_iLayer;
392 result_iLayer.reserve(arraySize);
393 std::vector<float> result_residualLocX;
394 result_residualLocX.reserve(arraySize);
395 std::vector<float> result_pullLocX;
396 result_pullLocX.reserve(arraySize);
397 std::vector<float> result_residualLocY;
398 result_residualLocY.reserve(arraySize);
399 std::vector<float> result_pullLocY;
400 result_pullLocY.reserve(arraySize);
401 std::vector<int> result_phiWidth;
402 result_phiWidth.reserve(arraySize);
403 std::vector<int> result_etaWidth;
404 result_etaWidth.reserve(arraySize);
405 std::vector<int> result_measureType;
406 result_measureType.reserve(arraySize);
407 std::vector<float> result_measurementLocX;
408 result_measurementLocX.reserve(arraySize);
409 std::vector<float> result_measurementLocY;
410 result_measurementLocY.reserve(arraySize);
411 std::vector<float> result_trackParamLocX;
412 result_trackParamLocX.reserve(arraySize);
413 std::vector<float> result_trackParamLocY;
414 result_trackParamLocY.reserve(arraySize);
415 std::vector<float> result_angle;
416 result_angle.reserve(arraySize);
417 std::vector<float> result_etaloc;
418 result_etaloc.reserve(arraySize);
419 std::vector<float> result_measurementLocCovX;
420 result_measurementLocCovX.reserve(arraySize);
421 std::vector<float> result_measurementLocCovY;
422 result_measurementLocCovY.reserve(arraySize);
423 std::vector<uint64_t> result_surfaceID;
424 result_surfaceID.reserve(arraySize);
426 for (
const SingleResult_t& single_result :
result) {
427 result_det.push_back(std::get<0>(single_result));
428 result_r.push_back(std::get<1>(single_result));
429 result_iLayer.push_back(std::get<2>(single_result));
430 result_residualLocX.push_back(std::get<3>(single_result));
431 result_pullLocX.push_back(std::get<4>(single_result));
432 result_residualLocY.push_back(std::get<5>(single_result));
433 result_pullLocY.push_back(std::get<6>(single_result));
434 result_phiWidth.push_back(std::get<7>(single_result));
435 result_etaWidth.push_back(std::get<8>(single_result));
436 result_measureType.push_back(std::get<9>(single_result));
437 result_measurementLocX.push_back(std::get<10>(single_result));
438 result_measurementLocY.push_back(std::get<11>(single_result));
439 result_trackParamLocX.push_back(std::get<12>(single_result));
440 result_trackParamLocY.push_back(std::get<13>(single_result));
441 result_angle.push_back(std::get<14>(single_result));
442 result_etaloc.push_back(std::get<15>(single_result));
443 result_measurementLocCovX.push_back(std::get<16>(single_result));
444 result_measurementLocCovY.push_back(std::get<17>(single_result));
445 result_surfaceID.push_back(std::get<18>(single_result));
489 const int normalBarrel(0);
490 const int upgradedBarrel(1);
491 const int normalTrtBarrel(1);
541 bool &isUnbiased)
const {
545 if (trkParameters->covariance()) {
547 unbiasedTrkParameters =
m_updatorHandle->removeFromState(*trkParameters,
550 if (!unbiasedTrkParameters) {
551 ATH_MSG_INFO(
"Could not get unbiased track parameters, use normal parameters" );
556 ATH_MSG_WARNING(
"TrackParameters contain no covariance, unbiased track states can not be calculated "
557 "(ie. pulls and residuals will be too small)" );
564 return unbiasedTrkParameters;