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};
113 for (
int i=0; i<
s_nbineta-1; i++)
m_etax[i+1]=(etacen[i]+etacen[i+1])/2.;
120 return StatusCode::SUCCESS;
131return StatusCode::SUCCESS;
180 using CLHEP::micrometer;
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) {
243 double angle = std::atan(std::tan(bowphi) - readoutside * tanl);
247 int PixEtaModule =
m_pixelid->eta_module(element_id);
248 int PixPhiModule =
m_pixelid->phi_module(element_id);
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) {
269 const int row =
m_pixelid->phi_index(rId);
270 const int col =
m_pixelid->eta_index(rId);
271 rowmin = std::min(rowmin, row);
272 rowmax = std::max(rowmax,row);
273 colmin = std::min(colmin, col);
274 colmax = std::max(colmax, col);
277 meanpos = meanpos / rdos.size();
289 int nrows = rowmax - rowmin + 1;
290 int ncol = colmax - colmin + 1;
297 localphi = centroid.
xPhi() + shift;
298 localeta = centroid.
xEta();
301 ang = 180 *
angle * M_1_PI;
304 delta = offlineCalibData->getPixelChargeInterpolationParameters()->getDeltaXbarrel(nrows, ang, 1);
316 ATH_MSG_ERROR(
"bin out of range in line " << __LINE__ <<
" of PixelClusterOnTrackTool.cxx.");
320 if (offlineCalibData->getPixelChargeInterpolationParameters()->getVersion()<-1) {
321 delta = offlineCalibData->getPixelChargeInterpolationParameters()->getDeltaXbarrel(nrows, ang, 0);
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));
336 delta = offlineCalibData->getPixelChargeInterpolationParameters()->getDeltaYbarrel(ncol, etaloc, 1);
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.");
360 if (offlineCalibData->getPixelChargeInterpolationParameters()->getVersion()<-1) {
361 delta = offlineCalibData->getPixelChargeInterpolationParameters()->getDeltaYbarrel(ncol, std::abs(etaloc), 0);
364 localeta += delta * (omegaeta - 0.5);
370 localphi += deltax * (omegaphi - 0.5);
371 localeta += deltay * (omegaeta - 0.5);
377 double deltax = 35 * micrometer;
378 double deltay = 35 * micrometer;
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) {
400 errphi = 250 * micrometer * std::tan(std::abs(
angle)) * TOPHAT_SIGMA;
401 erreta =
width.z() > 250 * micrometer * std::tan(std::abs(boweta)) ?
402 width.z() * TOPHAT_SIGMA : 250 * micrometer * std::tan(std::abs(boweta)) * TOPHAT_SIGMA;
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;
415 int ibin = offlineCalibData->getPixelClusterOnTrackErrorData()->getBarrelBinPhi(ang, nrows);
416 errphi = offlineCalibData->getPixelClusterOnTrackErrorData()->getPixelBarrelPhiError(ibin);
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.");
440 int ibin = offlineCalibData->getPixelClusterOnTrackErrorData()->getBarrelBinEta(std::abs(etatrack), ncol, nrows);
441 erreta = offlineCalibData->getPixelClusterOnTrackErrorData()->getPixelBarrelEtaError(ibin);
443 double etaloc = std::abs(etatrack);
445 erreta =
width.z() * TOPHAT_SIGMA;
448 while (bin < s_nbineta && etaloc >
m_etax[
bin + 1]) {
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;
467 int ibin = offlineCalibData->getPixelClusterErrorData()->getEndcapBin(ncol, nrows);
468 errphi = offlineCalibData->getPixelClusterErrorData()->getPixelEndcapPhiError(ibin);
469 erreta = offlineCalibData->getPixelClusterErrorData()->getPixelEndcapRError(ibin);
471 if (errphi > erreta) {
472 erreta =
width.z() * TOPHAT_SIGMA;
493 cov(0, 0) = errphi * errphi;
496 cov(1, 1) = erreta * erreta;
505 ->getScaledCovariance(std::move(cov), *
m_pixelid,
512 glob,
pix->gangedPixel(), isbroad);
517 const double theta,
const EventContext& ctx)
const {
527 const InDet::PixelClusterStrategy strategy,
const EventContext& ctx)
const {
528 int initial_errorStrategy;
532 case InDet::PIXELCLUSTER_OUTLIER:
533 case InDet::PIXELCLUSTER_SHARED:
536 newROT =
correct(rio, trackPar, ctx);
541 return correct(rio, trackPar, ctx);
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, ctx)) {
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);
639 ->getScaledCovariance(std::move(cov), *
m_pixelid,
663 const EventContext& ctx)
const {
664 std::vector<Amg::Vector2D> vectorOfPositions;
665 int numberOfSubclusters = 1;
666 vectorOfPositions.push_back(pixelPrepCluster->
localPosition());
670 InDet::PixelGangedClusterAmbiguities::const_iterator mapBegin = splitClusterMap->begin();
671 InDet::PixelGangedClusterAmbiguities::const_iterator mapEnd = splitClusterMap->end();
672 for (InDet::PixelGangedClusterAmbiguities::const_iterator mapIter = mapBegin; mapIter != mapEnd; ++mapIter) {
673 const SiCluster *first = (*mapIter).first;
674 const SiCluster *second = (*mapIter).second;
675 if (first == pixelPrepCluster && second != pixelPrepCluster) {
676 ATH_MSG_DEBUG(
"Found additional split cluster in ambiguity map (+=1).");
677 numberOfSubclusters += 1;
683 if (pixelAddCluster ==
nullptr) {
684 ATH_MSG_WARNING(
"Pixel ambiguity map has empty pixel cluster. Please DEBUG!");
687 vectorOfPositions.push_back(pixelAddCluster->
localPosition());
700 "Parameters are not at a plane ! Aborting cluster correction... ");
704 std::vector<Amg::Vector2D> allLocalPositions;
705 std::vector<Amg::MatrixX> allErrorMatrix;
711 numberOfSubclusters);
713 if (allLocalPositions.empty()) {
714 ATH_MSG_DEBUG(
" Cluster cannot be treated by NN. Giving back to default clusterization " );
719 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
720 ATH_MSG_WARNING(
"Returned position vector size " << allLocalPositions.size() <<
721 " not according to expected number of subclusters: " << numberOfSubclusters <<
". Abort cluster correction..." );
729 if (numberOfSubclusters == 1) {
730 finalposition = allLocalPositions[0];
731 finalerrormatrix = allErrorMatrix[0];
734 else if (numberOfSubclusters == 2) {
736 square(vectorOfPositions[0][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
737 square(vectorOfPositions[1][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
738 square(vectorOfPositions[0][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
739 square(vectorOfPositions[1][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
742 square(vectorOfPositions[1][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
743 square(vectorOfPositions[0][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
744 square(vectorOfPositions[1][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
745 square(vectorOfPositions[0][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
748 " Old pix (1) x: " << vectorOfPositions[0][0] <<
" y: " << vectorOfPositions[0][1] <<
"\n"
749 <<
" Old pix (2) x: " << vectorOfPositions[1][0] <<
" y: " << vectorOfPositions[1][1] <<
"\n"
750 <<
" Pix (1) x: " << allLocalPositions[0][0] <<
" +/- " << std::sqrt(allErrorMatrix[0](0, 0))
751 <<
" y: " << allLocalPositions[0][1] <<
" +/- " << std::sqrt(allErrorMatrix[0](1, 1)) <<
"\n"
752 <<
" Pix (2) x: " << allLocalPositions[1][0] <<
" +/- " << std::sqrt(allErrorMatrix[1](0, 0))
753 <<
" y: " << allLocalPositions[1][1] <<
" +/- " << std::sqrt(allErrorMatrix[1](1, 1)) <<
"\n"
754 <<
" Old (1) new (1) dist: " << std::sqrt(distancesq1) <<
" Old (1) new (2) " << std::sqrt(distancesq2) );
757 if (distancesq1 < distancesq2) {
758 finalposition = allLocalPositions[0];
759 finalerrormatrix = allErrorMatrix[0];
761 finalposition = allLocalPositions[1];
762 finalerrormatrix = allErrorMatrix[1];
767 else if (numberOfSubclusters == 3) {
770 distances[0] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 1, 2);
771 distances[1] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 2, 1);
772 distances[2] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 0, 2);
773 distances[3] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 2, 0);
774 distances[4] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 0, 1);
775 distances[5] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 1, 0);
777 int smallestDistanceIndex = -10;
778 double minDistance = 1e10;
780 for (
int i = 0; i < 6; i++) {
781 ATH_MSG_VERBOSE(
" distance n.: " << i <<
" distance is: " << distances[i]);
783 if (distances[i] < minDistance) {
784 minDistance = distances[i];
785 smallestDistanceIndex = i;
789 ATH_MSG_DEBUG(
" The minimum distance is : " << minDistance <<
" for index: " << smallestDistanceIndex);
791 if (smallestDistanceIndex == 0 || smallestDistanceIndex == 1) {
792 finalposition = allLocalPositions[0];
793 finalerrormatrix = allErrorMatrix[0];
795 if (smallestDistanceIndex == 2 || smallestDistanceIndex == 4) {
796 finalposition = allLocalPositions[1];
797 finalerrormatrix = allErrorMatrix[1];
799 if (smallestDistanceIndex == 3 || smallestDistanceIndex == 5) {
800 finalposition = allLocalPositions[2];
801 finalerrormatrix = allErrorMatrix[2];
812 const EventContext& ctx)
const {
814 std::vector<Amg::Vector2D> vectorOfPositions;
815 int numberOfSubclusters = 1;
818 numberOfSubclusters = 1 + splitClusterMap->count(pixelPrepCluster);
820 if (splitClusterMap->count(pixelPrepCluster) == 0 && splitProb.
isSplit()) {
821 numberOfSubclusters = 2;
823 if (splitClusterMap->count(pixelPrepCluster) != 0 && !splitProb.
isSplit()) {
824 numberOfSubclusters = 1;
829 if(numberOfSubclusters>3) numberOfSubclusters = 3;
834 ATH_MSG_WARNING(
"Parameters are not at a plane surface ! Aborting cluster "
839 std::vector<Amg::Vector2D> allLocalPositions;
840 std::vector<Amg::MatrixX> allErrorMatrix;
846 numberOfSubclusters);
848 if (allLocalPositions.empty()) {
850 " Cluster cannot be treated by NN. Giving back to default clusterization, too big: " <<
855 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
857 "Returned position vector size " << allLocalPositions.size() <<
" not according to expected number of subclusters: " << numberOfSubclusters <<
858 ". Abort cluster correction...");
865 if (numberOfSubclusters == 1) {
866 finalposition = allLocalPositions[0];
867 finalerrormatrix = allErrorMatrix[0];
875 if (trackPar.covariance()) {
876 localerr =
Amg::Vector2D(std::sqrt((*trackPar.covariance())(0, 0)), std::sqrt((*trackPar.covariance())(1, 1)));
879 double minDistance(1e300);
882 for (
unsigned int i(0); i < allLocalPositions.size(); ++i) {
884 square(localpos[0] - allLocalPositions[i][0]) / localerr[0]
885 + square(localpos[1] - allLocalPositions[i][1]) / localerr[1];
887 if (distance < minDistance) {
889 minDistance = distance;
893 finalposition = allLocalPositions[
index];
894 finalerrormatrix = allErrorMatrix[
index];
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This is an Identifier helper class for the Pixel subdetector.
double angle(const GeoTrf::Vector2D &a, const GeoTrf::Vector2D &b)
const ServiceHandle< StoreGateSvc > & detStore() const
This is a "hash" representation of an Identifier.
int readoutSide() const
ReadoutSide.
Class used to describe the design of a module (diode segmentation and readout scheme).
SiLocalPosition positionFromColumnRow(const int column, const int row) const
Given row and column index of a diode, return position of diode center ALTERNATIVE/PREFERED way is to...
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
Class to represent a position in the natural frame of a silicon sensor, for Pixel and SCT For Pixel: ...
double xPhi() const
position along phi direction:
double xEta() const
position along eta direction:
const Amg::Vector3D & etaAxis() const
virtual const Amg::Vector3D & normal() const override final
Get reconstruction local normal axes in global frame.
virtual IdentifierHash identifyHash() const override final
identifier hash (inline)
HepGeom::Point3D< double > globalPosition(const HepGeom::Point3D< double > &localPos) const
transform a reconstruction local position into a global position (inline):
virtual Identifier identify() const override final
identifier of this detector element (inline)
const Amg::Vector3D & phiAxis() const
Specific class to represent the pixel measurements.
const Amg::Vector3D & globalPosition() const
return global position reference
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
static float getDeltaXendcap()
static float getDeltaYendcap()
double eta() const
Access method for pseudorapidity - from momentum.
const Amg::Vector3D & momentum() const
Access method for the momentum.
virtual constexpr SurfaceType surfaceType() const override=0
Returns the Surface Type enum for the surface used to define the derived class.
virtual constexpr ParametersType type() const override=0
Return the ParametersType enum.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
double pT() const
Access method for transverse momentum.
Amg::Vector2D localPosition() const
Access method for the local coordinates, local parameter definitions differ for each surface type.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
const Amg::Vector2D & localPosition() const
return the local position reference
virtual bool type(PrepRawDataType type) const
Interface method checking the type.
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
ParametersBase< TrackParametersDim, Charged > TrackParameters
const T_res * ErrorScalingCast(const T_src *src)
bool isTooBigToBeSplit() const