37 square(
const double x) {
42 distance(
const std::vector<Amg::Vector2D> &vectorOfPositions,
43 const std::vector<Amg::Vector2D> &allLocalPositions,
44 const std::vector<Amg::MatrixX> &allErrorMatrix,
45 const int i,
const int j,
const int k) {
47 square(vectorOfPositions[
i][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
48 square(vectorOfPositions[j][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
49 square(vectorOfPositions[
k][0] - allLocalPositions[2][0]) / allErrorMatrix[2](0, 0) +
50 square(vectorOfPositions[
i][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
51 square(vectorOfPositions[j][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1) +
52 square(vectorOfPositions[
k][1] - allLocalPositions[2][1]) / allErrorMatrix[2](1, 1);
60 (
const std::string &
t,
const std::string &
n,
const IInterface *
p) :
63 declareInterface<IRIO_OnTrackCreator>(
this);
96 return StatusCode::SUCCESS;
148 const double TOPHAT_SIGMA = 1. / std::sqrt(12.);
175 if (
pix->rdoList().empty()) {
176 ATH_MSG_WARNING(
"Pixel RDO-list size is 0, check integrity of pixel clusters! stop ROT creation.");
187 float trkphicomp = my_track.dot(my_phiax);
188 float trketacomp = my_track.dot(my_etaax);
189 float trknormcomp = my_track.dot(my_normal);
190 double bowphi = std::atan2(trkphicomp, trknormcomp);
191 double boweta = std::atan2(trketacomp, trknormcomp);
193 float tanl =
m_lorentzAngleTool->getTanLorentzAngle(iH, Gaudi::Hive::currentContext());
197 if (bowphi >
M_PI *0.5) {
200 if (bowphi < -
M_PI *0.5) {
209 double thetaloc = -999.;
210 if (boweta > -0.5 *
M_PI && boweta <
M_PI / 2.) {
211 thetaloc = M_PI_2 - boweta;
212 }
else if (boweta > M_PI_2 && boweta <
M_PI) {
213 thetaloc = 1.5 *
M_PI - boweta;
215 thetaloc = -M_PI_2 - boweta;
217 double etaloc = -1 *
log(
tan(thetaloc * 0.5));
223 double PixTrkPt = trackPar.
pT();
224 double PixTrkEta = trackPar.
eta();
225 ATH_MSG_VERBOSE(
"tanl = " << tanl <<
" readout side is " << readoutside <<
226 " module " << PixEtaModule <<
" " << PixPhiModule <<
227 " track pt, eta = " << PixTrkPt <<
" " << PixTrkEta <<
228 " track momentum phi, norm = " << trkphicomp <<
" " <<
229 trknormcomp <<
" bowphi = " << bowphi <<
" angle = " <<
angle);
231 float omegaphi =
pix->omegax();
232 float omegaeta =
pix->omegay();
233 double localphi = -9999.;
234 double localeta = -9999.;
236 const std::vector<Identifier> & rdos =
pix->rdoList();
242 for (
const auto & rId:rdos) {
251 meanpos = meanpos / rdos.size();
262 double shift =
m_lorentzAngleTool->getLorentzShift(iH, Gaudi::Hive::currentContext());
263 int nrows = rowmax - rowmin + 1;
264 int ncol = colmax - colmin + 1;
274 double delta_phi = nrows != 1 ? delta.first : 0.;
275 double delta_eta = ncol != 1 ? delta.second : 0.;
277 localeta += delta_eta*(omegaeta-0.5);
281 localphi = meanpos.
xPhi() + shift;
282 localeta = meanpos.
xEta();
294 if (std::abs(
angle) > 1) {
298 ATH_MSG_VERBOSE(
"Shallow track with tanl = " << tanl <<
" bowphi = " <<
299 bowphi <<
" angle = " <<
angle <<
" width.z = " <<
width.z() <<
300 " errphi = " << errphi <<
" erreta = " << erreta);
302 errphi =
width.phiR() * TOPHAT_SIGMA;
303 erreta =
width.z() * TOPHAT_SIGMA;
305 errphi = (
width.phiR() / nrows) * TOPHAT_SIGMA;
306 erreta = (
width.z() / ncol) * TOPHAT_SIGMA;
309 errphi = nrows != 1 ? delta_err.first : (
width.phiR()/nrows)*TOPHAT_SIGMA;
310 erreta = ncol != 1 ? delta_err.second : (
width.z()/ncol)*TOPHAT_SIGMA;
325 cov(0, 0) = errphi * errphi;
328 cov(1, 1) = erreta * erreta;
336 cov = Trk::ErrorScalingCast<PixelRIO_OnTrackErrorScaling>(*error_scaling)
343 iH, glob,
pix->gangedPixel(), isbroad);
351 int initial_errorStrategy;
359 newROT =
correct(rio, trackPar);
379 if (pixelPrepCluster ==
nullptr) {
386 ATH_MSG_WARNING(
"Cannot access detector element. Aborting cluster correction...");
400 std::move(
cov), iH, glob,
410 if (!
getErrorsTIDE_Ambi(pixelPrepCluster, trackPar, finalposition, finalerrormatrix)) {
422 <<
" +/- " << std::sqrt(pixelPrepCluster->
localCovariance()(1, 1)) <<
"\n"
423 <<
" Final position x: " << finalposition[0]
424 <<
" +/- " << std::sqrt(finalerrormatrix(0, 0))
425 <<
" y: " << finalposition[1] <<
" +/- "
426 <<std::sqrt(finalerrormatrix(1, 1)) );
432 cov = Trk::ErrorScalingCast<PixelRIO_OnTrackErrorScaling>(*error_scaling)
458 std::vector<Amg::Vector2D> vectorOfPositions;
459 int numberOfSubclusters = 1;
460 vectorOfPositions.push_back(pixelPrepCluster->
localPosition());
464 InDet::PixelGangedClusterAmbiguities::const_iterator mapBegin = splitClusterMap->begin();
465 InDet::PixelGangedClusterAmbiguities::const_iterator mapEnd = splitClusterMap->end();
466 for (InDet::PixelGangedClusterAmbiguities::const_iterator mapIter = mapBegin; mapIter != mapEnd; ++mapIter) {
469 if (
first == pixelPrepCluster &&
second != pixelPrepCluster) {
470 ATH_MSG_DEBUG(
"Found additional split cluster in ambiguity map (+=1).");
471 numberOfSubclusters += 1;
477 if (pixelAddCluster ==
nullptr) {
478 ATH_MSG_WARNING(
"Pixel ambiguity map has empty pixel cluster. Please DEBUG!");
481 vectorOfPositions.push_back(pixelAddCluster->
localPosition());
494 "Parameters are not at a plane ! Aborting cluster correction... ");
498 std::vector<Amg::Vector2D> allLocalPositions;
499 std::vector<Amg::MatrixX> allErrorMatrix;
505 numberOfSubclusters);
507 if (allLocalPositions.empty()) {
508 ATH_MSG_DEBUG(
" Cluster cannot be treated by NN. Giving back to default clusterization " );
513 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
514 ATH_MSG_WARNING(
"Returned position vector size " << allLocalPositions.size() <<
515 " not according to expected number of subclusters: " << numberOfSubclusters <<
". Abort cluster correction..." );
523 if (numberOfSubclusters == 1) {
524 finalposition = allLocalPositions[0];
525 finalerrormatrix = allErrorMatrix[0];
528 else if (numberOfSubclusters == 2) {
530 square(vectorOfPositions[0][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
531 square(vectorOfPositions[1][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
532 square(vectorOfPositions[0][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
533 square(vectorOfPositions[1][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
536 square(vectorOfPositions[1][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
537 square(vectorOfPositions[0][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
538 square(vectorOfPositions[1][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
539 square(vectorOfPositions[0][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
542 " Old pix (1) x: " << vectorOfPositions[0][0] <<
" y: " << vectorOfPositions[0][1] <<
"\n"
543 <<
" Old pix (2) x: " << vectorOfPositions[1][0] <<
" y: " << vectorOfPositions[1][1] <<
"\n"
544 <<
" Pix (1) x: " << allLocalPositions[0][0] <<
" +/- " << std::sqrt(allErrorMatrix[0](0, 0))
545 <<
" y: " << allLocalPositions[0][1] <<
" +/- " << std::sqrt(allErrorMatrix[0](1, 1)) <<
"\n"
546 <<
" Pix (2) x: " << allLocalPositions[1][0] <<
" +/- " << std::sqrt(allErrorMatrix[1](0, 0))
547 <<
" y: " << allLocalPositions[1][1] <<
" +/- " << std::sqrt(allErrorMatrix[1](1, 1)) <<
"\n"
548 <<
" Old (1) new (1) dist: " << std::sqrt(distancesq1) <<
" Old (1) new (2) " << std::sqrt(distancesq2) );
551 if (distancesq1 < distancesq2) {
552 finalposition = allLocalPositions[0];
553 finalerrormatrix = allErrorMatrix[0];
555 finalposition = allLocalPositions[1];
556 finalerrormatrix = allErrorMatrix[1];
561 else if (numberOfSubclusters == 3) {
564 distances[0] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 1, 2);
565 distances[1] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 2, 1);
566 distances[2] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 0, 2);
567 distances[3] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 2, 0);
568 distances[4] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 0, 1);
569 distances[5] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 1, 0);
571 int smallestDistanceIndex = -10;
572 double minDistance = 1e10;
574 for (
int i = 0;
i < 6;
i++) {
577 if (distances[
i] < minDistance) {
578 minDistance = distances[
i];
579 smallestDistanceIndex =
i;
583 ATH_MSG_DEBUG(
" The minimum distance is : " << minDistance <<
" for index: " << smallestDistanceIndex);
585 if (smallestDistanceIndex == 0 || smallestDistanceIndex == 1) {
586 finalposition = allLocalPositions[0];
587 finalerrormatrix = allErrorMatrix[0];
589 if (smallestDistanceIndex == 2 || smallestDistanceIndex == 4) {
590 finalposition = allLocalPositions[1];
591 finalerrormatrix = allErrorMatrix[1];
593 if (smallestDistanceIndex == 3 || smallestDistanceIndex == 5) {
594 finalposition = allLocalPositions[2];
595 finalerrormatrix = allErrorMatrix[2];
607 std::vector<Amg::Vector2D> vectorOfPositions;
608 int numberOfSubclusters = 1;
611 numberOfSubclusters = 1 + splitClusterMap->count(pixelPrepCluster);
613 if (splitClusterMap->count(pixelPrepCluster) == 0 && splitProb.
isSplit()) {
614 numberOfSubclusters = 2;
616 if (splitClusterMap->count(pixelPrepCluster) != 0 && !splitProb.
isSplit()) {
617 numberOfSubclusters = 1;
624 ATH_MSG_WARNING(
"Parameters are not at a plane surface ! Aborting cluster "
629 std::vector<Amg::Vector2D> allLocalPositions;
630 std::vector<Amg::MatrixX> allErrorMatrix;
636 numberOfSubclusters);
638 if (allLocalPositions.empty()) {
640 " Cluster cannot be treated by NN. Giving back to default clusterization, too big: " <<
645 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
647 "Returned position vector size " << allLocalPositions.size() <<
" not according to expected number of subclusters: " << numberOfSubclusters <<
648 ". Abort cluster correction...");
655 if (numberOfSubclusters == 1) {
656 finalposition = allLocalPositions[0];
657 finalerrormatrix = allErrorMatrix[0];
665 if (trackPar.covariance()) {
666 localerr =
Amg::Vector2D(std::sqrt((*trackPar.covariance())(0, 0)), std::sqrt((*trackPar.covariance())(1, 1)));
669 double minDistance(1e300);
672 for (
unsigned int i(0);
i < allLocalPositions.size(); ++
i) {
674 square(localpos[0] - allLocalPositions[
i][0]) / localerr[0]
675 + square(localpos[1] - allLocalPositions[
i][1]) / localerr[1];
683 finalposition = allLocalPositions[
index];
684 finalerrormatrix = allErrorMatrix[
index];