38 square(
const double x) {
43 distance(
const std::vector<Amg::Vector2D> &vectorOfPositions,
44 const std::vector<Amg::Vector2D> &allLocalPositions,
45 const std::vector<Amg::MatrixX> &allErrorMatrix,
46 const int i,
const int j,
const int k) {
48 square(vectorOfPositions[
i][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
49 square(vectorOfPositions[j][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
50 square(vectorOfPositions[
k][0] - allLocalPositions[2][0]) / allErrorMatrix[2](0, 0) +
51 square(vectorOfPositions[
i][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
52 square(vectorOfPositions[j][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1) +
53 square(vectorOfPositions[
k][1] - allLocalPositions[2][1]) / allErrorMatrix[2](1, 1);
58 (
const std::string &
t,
const std::string &
n,
const IInterface *
p) :
60 declareInterface<IRIO_OnTrackCreator>(
this);
109 constexpr
double phimin=-0.27, phimax=0.27;
111 constexpr
double etacen[
s_nbineta]={-0.,1.,1.55,1.9,2.15,2.35};
120 return StatusCode::SUCCESS;
131 return StatusCode::SUCCESS;
182 const double TOPHAT_SIGMA = 1. / std::sqrt(12.);
211 if (
pix->rdoList().empty()) {
212 ATH_MSG_WARNING(
"Pixel RDO-list size is 0, check integrity of pixel clusters! stop ROT creation.");
223 float trkphicomp = my_track.dot(my_phiax);
224 float trketacomp = my_track.dot(my_etaax);
225 float trknormcomp = my_track.dot(my_normal);
226 double bowphi = std::atan2(trkphicomp, trknormcomp);
227 double boweta = std::atan2(trketacomp, trknormcomp);
228 float etatrack = trackPar.
eta();
234 if (bowphi >
M_PI *0.5) {
237 if (bowphi < -
M_PI *0.5) {
249 double PixTrkPt = trackPar.
pT();
250 double PixTrkEta = trackPar.
eta();
251 ATH_MSG_VERBOSE(
"tanl = " << tanl <<
" readout side is " << readoutside <<
252 " module " << PixEtaModule <<
" " << PixPhiModule <<
253 " track pt, eta = " << PixTrkPt <<
" " << PixTrkEta <<
254 " track momentum phi, norm = " << trkphicomp <<
" " <<
255 trknormcomp <<
" bowphi = " << bowphi <<
" angle = " <<
angle);
257 float omegaphi =
pix->omegax();
258 float omegaeta =
pix->omegay();
259 double localphi = -9999.;
260 double localeta = -9999.;
262 const std::vector<Identifier> & rdos =
pix->rdoList();
268 for (
const auto & rId:rdos) {
277 meanpos = meanpos / rdos.size();
289 int nrows = rowmax - rowmin + 1;
290 int ncol = colmax - colmin + 1;
301 ang = 180 *
angle * M_1_PI;
316 ATH_MSG_ERROR(
"bin out of range in line " << __LINE__ <<
" of PixelClusterOnTrackTool.cxx.");
324 localphi += delta * (omegaphi - 0.5);
326 double thetaloc = -999.;
327 if (boweta > -0.5 *
M_PI && boweta <
M_PI / 2.) {
328 thetaloc = M_PI_2 - boweta;
329 }
else if (boweta > M_PI_2 && boweta <
M_PI) {
330 thetaloc = 1.5 *
M_PI - boweta;
332 thetaloc = -M_PI_2 - boweta;
334 double etaloc = -1 *
log(
tan(thetaloc * 0.5));
338 etaloc = std::abs(etaloc);
349 }
else if (ncol ==
bin + 1) {
351 }
else if (ncol ==
bin + 2) {
357 ATH_MSG_ERROR(
"bin out of range in line " << __LINE__ <<
" of PixelClusterOnTrackTool.cxx.");
364 localeta += delta * (omegaeta - 0.5);
370 localphi += deltax * (omegaphi - 0.5);
371 localeta += deltay * (omegaeta - 0.5);
379 localphi += deltax * (omegaphi - 0.5);
380 localeta += deltay * (omegaeta - 0.5);
386 localphi = meanpos.
xPhi() + shift;
387 localeta = meanpos.
xEta();
399 if (std::abs(
angle) > 1) {
403 ATH_MSG_VERBOSE(
"Shallow track with tanl = " << tanl <<
" bowphi = " <<
404 bowphi <<
" angle = " <<
angle <<
" width.z = " <<
width.z() <<
405 " errphi = " << errphi <<
" erreta = " << erreta);
407 errphi =
width.phiR() * TOPHAT_SIGMA;
408 erreta =
width.z() * TOPHAT_SIGMA;
410 errphi = (
width.phiR() / nrows) * TOPHAT_SIGMA;
411 erreta = (
width.z() / ncol) * TOPHAT_SIGMA;
419 errphi =
width.phiR() * TOPHAT_SIGMA;
428 }
else if (nrows == 2) {
434 ATH_MSG_ERROR(
"bin out of range in line " << __LINE__ <<
" of PixelClusterOnTrackTool.cxx.");
443 double etaloc = std::abs(etatrack);
445 erreta =
width.z() * TOPHAT_SIGMA;
452 ATH_MSG_ERROR(
"bin out of range in line " << __LINE__ <<
" of PixelClusterOnTrackTool.cxx.");
456 }
else if (ncol ==
bin + 1) {
458 }
else if (ncol ==
bin + 2) {
461 erreta =
width.z() * TOPHAT_SIGMA;
471 if (errphi > erreta) {
472 erreta =
width.z() * TOPHAT_SIGMA;
493 cov(0, 0) = errphi * errphi;
496 cov(1, 1) = erreta * erreta;
504 cov = Trk::ErrorScalingCast<PixelRIO_OnTrackErrorScaling>(*error_scaling)
512 glob,
pix->gangedPixel(), isbroad);
517 const double theta,
const EventContext& ctx)
const {
528 int initial_errorStrategy;
536 newROT =
correct(rio, trackPar);
550 const EventContext& ctx)
const {
557 if (pixelPrepCluster ==
nullptr) {
564 ATH_MSG_WARNING(
"Cannot access detector element. Aborting cluster correction...");
577 float trkphicomp = my_track.dot(my_phiax);
578 float trketacomp = my_track.dot(my_etaax);
579 float trknormcomp = my_track.dot(my_normal);
580 double bowphi = std::atan2(trkphicomp, trknormcomp);
581 double boweta = std::atan2(trketacomp, trknormcomp);
601 if (!
getErrorsTIDE_Ambi(pixelPrepCluster, trackPar, finalposition, finalerrormatrix)) {
613 <<
" +/- " << std::sqrt(pixelPrepCluster->
localCovariance()(1, 1)) <<
"\n"
614 <<
" Final position x: " << finalposition[0]
615 <<
" +/- " << std::sqrt(finalerrormatrix(0, 0))
616 <<
" y: " << finalposition[1] <<
" +/- "
617 <<std::sqrt(finalerrormatrix(1, 1)) );
623 float trkphicomp = my_track.dot(my_phiax);
624 float trketacomp = my_track.dot(my_etaax);
625 float trknormcomp = my_track.dot(my_normal);
626 double bowphi = std::atan2(trkphicomp, trknormcomp);
627 double boweta = std::atan2(trketacomp, trknormcomp);
638 cov = Trk::ErrorScalingCast<PixelRIO_OnTrackErrorScaling>(*error_scaling)
663 std::vector<Amg::Vector2D> vectorOfPositions;
664 int numberOfSubclusters = 1;
665 vectorOfPositions.push_back(pixelPrepCluster->
localPosition());
669 InDet::PixelGangedClusterAmbiguities::const_iterator mapBegin = splitClusterMap->begin();
670 InDet::PixelGangedClusterAmbiguities::const_iterator mapEnd = splitClusterMap->end();
671 for (InDet::PixelGangedClusterAmbiguities::const_iterator mapIter = mapBegin; mapIter != mapEnd; ++mapIter) {
674 if (
first == pixelPrepCluster &&
second != pixelPrepCluster) {
675 ATH_MSG_DEBUG(
"Found additional split cluster in ambiguity map (+=1).");
676 numberOfSubclusters += 1;
682 if (pixelAddCluster ==
nullptr) {
683 ATH_MSG_WARNING(
"Pixel ambiguity map has empty pixel cluster. Please DEBUG!");
686 vectorOfPositions.push_back(pixelAddCluster->
localPosition());
699 "Parameters are not at a plane ! Aborting cluster correction... ");
703 std::vector<Amg::Vector2D> allLocalPositions;
704 std::vector<Amg::MatrixX> allErrorMatrix;
710 numberOfSubclusters);
712 if (allLocalPositions.empty()) {
713 ATH_MSG_DEBUG(
" Cluster cannot be treated by NN. Giving back to default clusterization " );
718 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
719 ATH_MSG_WARNING(
"Returned position vector size " << allLocalPositions.size() <<
720 " not according to expected number of subclusters: " << numberOfSubclusters <<
". Abort cluster correction..." );
728 if (numberOfSubclusters == 1) {
729 finalposition = allLocalPositions[0];
730 finalerrormatrix = allErrorMatrix[0];
733 else if (numberOfSubclusters == 2) {
735 square(vectorOfPositions[0][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
736 square(vectorOfPositions[1][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
737 square(vectorOfPositions[0][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
738 square(vectorOfPositions[1][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
741 square(vectorOfPositions[1][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
742 square(vectorOfPositions[0][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
743 square(vectorOfPositions[1][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
744 square(vectorOfPositions[0][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
747 " Old pix (1) x: " << vectorOfPositions[0][0] <<
" y: " << vectorOfPositions[0][1] <<
"\n"
748 <<
" Old pix (2) x: " << vectorOfPositions[1][0] <<
" y: " << vectorOfPositions[1][1] <<
"\n"
749 <<
" Pix (1) x: " << allLocalPositions[0][0] <<
" +/- " << std::sqrt(allErrorMatrix[0](0, 0))
750 <<
" y: " << allLocalPositions[0][1] <<
" +/- " << std::sqrt(allErrorMatrix[0](1, 1)) <<
"\n"
751 <<
" Pix (2) x: " << allLocalPositions[1][0] <<
" +/- " << std::sqrt(allErrorMatrix[1](0, 0))
752 <<
" y: " << allLocalPositions[1][1] <<
" +/- " << std::sqrt(allErrorMatrix[1](1, 1)) <<
"\n"
753 <<
" Old (1) new (1) dist: " << std::sqrt(distancesq1) <<
" Old (1) new (2) " << std::sqrt(distancesq2) );
756 if (distancesq1 < distancesq2) {
757 finalposition = allLocalPositions[0];
758 finalerrormatrix = allErrorMatrix[0];
760 finalposition = allLocalPositions[1];
761 finalerrormatrix = allErrorMatrix[1];
766 else if (numberOfSubclusters == 3) {
769 distances[0] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 1, 2);
770 distances[1] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 2, 1);
771 distances[2] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 0, 2);
772 distances[3] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 2, 0);
773 distances[4] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 0, 1);
774 distances[5] =
distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 1, 0);
776 int smallestDistanceIndex = -10;
777 double minDistance = 1e10;
779 for (
int i = 0;
i < 6;
i++) {
782 if (distances[
i] < minDistance) {
783 minDistance = distances[
i];
784 smallestDistanceIndex =
i;
788 ATH_MSG_DEBUG(
" The minimum distance is : " << minDistance <<
" for index: " << smallestDistanceIndex);
790 if (smallestDistanceIndex == 0 || smallestDistanceIndex == 1) {
791 finalposition = allLocalPositions[0];
792 finalerrormatrix = allErrorMatrix[0];
794 if (smallestDistanceIndex == 2 || smallestDistanceIndex == 4) {
795 finalposition = allLocalPositions[1];
796 finalerrormatrix = allErrorMatrix[1];
798 if (smallestDistanceIndex == 3 || smallestDistanceIndex == 5) {
799 finalposition = allLocalPositions[2];
800 finalerrormatrix = allErrorMatrix[2];
812 std::vector<Amg::Vector2D> vectorOfPositions;
813 int numberOfSubclusters = 1;
816 numberOfSubclusters = 1 + splitClusterMap->count(pixelPrepCluster);
818 if (splitClusterMap->count(pixelPrepCluster) == 0 && splitProb.
isSplit()) {
819 numberOfSubclusters = 2;
821 if (splitClusterMap->count(pixelPrepCluster) != 0 && !splitProb.
isSplit()) {
822 numberOfSubclusters = 1;
829 ATH_MSG_WARNING(
"Parameters are not at a plane surface ! Aborting cluster "
834 std::vector<Amg::Vector2D> allLocalPositions;
835 std::vector<Amg::MatrixX> allErrorMatrix;
841 numberOfSubclusters);
843 if (allLocalPositions.empty()) {
845 " Cluster cannot be treated by NN. Giving back to default clusterization, too big: " <<
850 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
852 "Returned position vector size " << allLocalPositions.size() <<
" not according to expected number of subclusters: " << numberOfSubclusters <<
853 ". Abort cluster correction...");
860 if (numberOfSubclusters == 1) {
861 finalposition = allLocalPositions[0];
862 finalerrormatrix = allErrorMatrix[0];
870 if (trackPar.covariance()) {
871 localerr =
Amg::Vector2D(std::sqrt((*trackPar.covariance())(0, 0)), std::sqrt((*trackPar.covariance())(1, 1)));
874 double minDistance(1e300);
877 for (
unsigned int i(0);
i < allLocalPositions.size(); ++
i) {
879 square(localpos[0] - allLocalPositions[
i][0]) / localerr[0]
880 + square(localpos[1] - allLocalPositions[
i][1]) / localerr[1];
888 finalposition = allLocalPositions[
index];
889 finalerrormatrix = allErrorMatrix[
index];