46 int_decor_names[
kDecorDet]=
"measurement_det";
48 int_decor_names[
kDecorType]=
"measurement_type";
67 uint64_decor_names[
kDecorID]=
"surfaceID";
87 ATH_MSG_INFO(
"No residual/pull calculator for general hit residuals configured.");
88 ATH_MSG_INFO(
"It is recommended to give R/P calculators to the det-specific tool handle lists then.");
92 ATH_MSG_INFO(
"Generic hit residuals & pulls will be calculated in one or both available local coordinates");
94 return StatusCode::SUCCESS;
99 return StatusCode::SUCCESS;
108 return StatusCode::FAILURE;
111 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<float> > >
113 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<int> > >
115 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,std::vector<uint64_t> > >
119 if (not
decorateTrack(*trk_particle, float_decor, int_decor, uint64_decor) ) {
121 return StatusCode::FAILURE;
124 return StatusCode::SUCCESS;
135 using SingleResult_t = std::tuple<
int,
int,
int,
143 using TrackResult_t = std::vector<SingleResult_t>;
145 const int invalidInteger(-1);
147 const SingleResult_t invalidResult = std::make_tuple(invalidInteger, invalidInteger, invalidInteger,
149 invalidInteger, invalidInteger, invalidInteger,
153 bool isUnbiased(
true);
158 std::unique_ptr<const Trk::Track> trackWithHoles(
m_holeSearchTool->getTrackWithHoles(**trackLink));
160 const int numberOfHits(allTrackStates.size());
161 unsigned int trackParametersCounter(numberOfHits);
163 result.reserve(numberOfHits);
167 ATH_MSG_WARNING(
"The updater handle is empty, now using biased estimators");
172 for (
const auto *
const thisTrackState: allTrackStates) {
175 SingleResult_t thisResult(invalidResult);
176 if (not thisTrackState) {
177 msg(MSG::ERROR) <<
"TSOS is NULL" << (thisTrackState) <<
endmsg;
191 if (not (thisTrackState)->trackParameters()) {
192 msg(MSG::INFO) <<
"TSOS surface is NULL" <<
endmsg;
195 surfaceID = (thisTrackState)->trackParameters()->associatedSurface().associatedDetectorElementIdentifier();
201 int measureType = -1;
212 bool anyHit = isMesb || isOutl || isHole;
218 int iLayer(invalidInteger);
220 if (not successfulIdentification) {
230 float angle(0.), etaloc(0.);
231 int phiWidth(invalidInteger), etaWidth(invalidInteger);
232 std::optional<Trk::ResidualPull> residualPull(std::nullopt);
234 if (biasedTrackParameters) {
238 if (mesb && biasedTrackParameters) {
241 std::unique_ptr<const Trk::TrackParameters> cleanup_trackparam;
244 biasedTrackParameters, mesb, isUnbiased) : biasedTrackParameters;
246 if (trackParameters != biasedTrackParameters) {
247 cleanup_trackparam.reset(trackParameters);
249 if (not trackParameters) {
258 if (not residualPull) {
265 residualLocX = 1000. * residualPull->residual()[
Trk::loc1];
266 pullLocX = residualPull->pull()[
Trk::loc1];
268 trackParamLocX = trackParameters->parameters()[
Trk::loc1];
271 if (residualPull->dimension() > 1) {
272 residualLocY = 1000. * residualPull->residual()[
Trk::loc2];
273 pullLocY = residualPull->pull()[
Trk::loc2];
275 trackParamLocY = trackParameters->parameters()[
Trk::loc2];
282 if (hit && isUnbiased) {
297 float trkphicomp = my_track.dot(my_phiax);
298 float trketacomp = my_track.dot(my_etaax);
299 float trknormcomp = my_track.dot(my_normal);
300 double bowphi = atan2(trkphicomp,trknormcomp);
301 double boweta = atan2(trketacomp,trknormcomp);
308 if(bowphi < -
M_PI/2) bowphi +=
M_PI;
315 double thetaloc=-999.;
316 if(boweta > -0.5*
M_PI && boweta <
M_PI/2.) {
317 thetaloc =
M_PI/2.-boweta;
318 }
else if(boweta >
M_PI/2. && boweta <
M_PI) {
319 thetaloc = 1.5*
M_PI-boweta;
321 thetaloc = -0.5*
M_PI-boweta;
323 etaloc = -1*
log(
tan(thetaloc/2.));
332 if (not biasedTrackParameters) {
335 --trackParametersCounter;
337 thisResult = std::make_tuple(
det,
r, iLayer,
338 residualLocX, pullLocX, residualLocY, pullLocY,
340 measurementLocX, measurementLocY,
341 trackParamLocX, trackParamLocY,
343 measurementLocCovX, measurementLocCovY,
345 result.push_back(thisResult);
347 ATH_MSG_DEBUG(
"Out of " << numberOfHits <<
" hits, " << trackParametersCounter
348 <<
" had track params, and " <<
result.size() <<
" had residuals.");
350 const unsigned int arraySize =
result.size();
351 std::vector<int> result_det;
352 result_det.reserve(arraySize);
353 std::vector<int> result_r;
354 result_r.reserve(arraySize);
355 std::vector<int> result_iLayer;
356 result_iLayer.reserve(arraySize);
357 std::vector<float> result_residualLocX;
358 result_residualLocX.reserve(arraySize);
359 std::vector<float> result_pullLocX;
360 result_pullLocX.reserve(arraySize);
361 std::vector<float> result_residualLocY;
362 result_residualLocY.reserve(arraySize);
363 std::vector<float> result_pullLocY;
364 result_pullLocY.reserve(arraySize);
365 std::vector<int> result_phiWidth;
366 result_phiWidth.reserve(arraySize);
367 std::vector<int> result_etaWidth;
368 result_etaWidth.reserve(arraySize);
369 std::vector<int> result_measureType;
370 result_measureType.reserve(arraySize);
371 std::vector<float> result_measurementLocX;
372 result_measurementLocX.reserve(arraySize);
373 std::vector<float> result_measurementLocY;
374 result_measurementLocY.reserve(arraySize);
375 std::vector<float> result_trackParamLocX;
376 result_trackParamLocX.reserve(arraySize);
377 std::vector<float> result_trackParamLocY;
378 result_trackParamLocY.reserve(arraySize);
379 std::vector<float> result_angle;
380 result_angle.reserve(arraySize);
381 std::vector<float> result_etaloc;
382 result_etaloc.reserve(arraySize);
383 std::vector<float> result_measurementLocCovX;
384 result_measurementLocCovX.reserve(arraySize);
385 std::vector<float> result_measurementLocCovY;
386 result_measurementLocCovY.reserve(arraySize);
387 std::vector<uint64_t> result_surfaceID;
388 result_surfaceID.reserve(arraySize);
390 for (
const SingleResult_t& single_result :
result) {
391 result_det.push_back(std::get<0>(single_result));
392 result_r.push_back(std::get<1>(single_result));
393 result_iLayer.push_back(std::get<2>(single_result));
394 result_residualLocX.push_back(std::get<3>(single_result));
395 result_pullLocX.push_back(std::get<4>(single_result));
396 result_residualLocY.push_back(std::get<5>(single_result));
397 result_pullLocY.push_back(std::get<6>(single_result));
398 result_phiWidth.push_back(std::get<7>(single_result));
399 result_etaWidth.push_back(std::get<8>(single_result));
400 result_measureType.push_back(std::get<9>(single_result));
401 result_measurementLocX.push_back(std::get<10>(single_result));
402 result_measurementLocY.push_back(std::get<11>(single_result));
403 result_trackParamLocX.push_back(std::get<12>(single_result));
404 result_trackParamLocY.push_back(std::get<13>(single_result));
405 result_angle.push_back(std::get<14>(single_result));
406 result_etaloc.push_back(std::get<15>(single_result));
407 result_measurementLocCovX.push_back(std::get<16>(single_result));
408 result_measurementLocCovY.push_back(std::get<17>(single_result));
409 result_surfaceID.push_back(std::get<18>(single_result));
451 const int pixelSctBarrelIndex(0);
452 const int trtBarrelIndex(1);
483 bool &isUnbiased)
const {
487 if (trkParameters->covariance()) {
489 unbiasedTrkParameters =
m_updatorHandle->removeFromState(*trkParameters,
492 if (!unbiasedTrkParameters) {
493 ATH_MSG_INFO(
"Could not get unbiased track parameters, use normal parameters" );
498 ATH_MSG_WARNING(
"TrackParameters contain no covariance, unbiased track states can not be calculated "
499 "(ie. pulls and residuals will be too small)" );
506 return unbiasedTrkParameters;