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;
145 using CLHEP::micrometer;
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(idHash, Gaudi::Hive::currentContext());
197 if (bowphi >
M_PI *0.5) {
200 if (bowphi < -
M_PI *0.5) {
206 double angle = std::atan(std::tan(bowphi) - readoutside * tanl);
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));
221 int PixEtaModule =
m_pixelid->eta_module(element_id);
222 int PixPhiModule =
m_pixelid->phi_module(element_id);
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) {
243 const int row =
m_pixelid->phi_index(rId);
244 const int col =
m_pixelid->eta_index(rId);
245 rowmin = std::min(rowmin, row);
246 rowmax = std::max(rowmax,row);
247 colmin = std::min(colmin, col);
248 colmax = std::max(colmax, col);
251 meanpos = meanpos / rdos.size();
262 double shift =
m_lorentzAngleTool->getLorentzShift(idHash, Gaudi::Hive::currentContext());
263 int nrows = rowmax - rowmin + 1;
264 int ncol = colmax - colmin + 1;
270 localphi = centroid.
xPhi() + shift;
271 localeta = centroid.
xEta();
273 std::pair<double,double> delta = offlineITkCalibDataHandle->getClusterErrorData()->getDelta(idHash,nrows,
angle,ncol,etaloc);
274 double delta_phi = nrows != 1 ? delta.first : 0.;
275 double delta_eta = ncol != 1 ? delta.second : 0.;
276 localphi += delta_phi*(omegaphi-0.5);
277 localeta += delta_eta*(omegaeta-0.5);
281 localphi = meanpos.
xPhi() + shift;
282 localeta = meanpos.
xEta();
294 if (std::abs(
angle) > 1) {
295 errphi = 250 * micrometer * std::tan(std::abs(
angle)) * TOPHAT_SIGMA;
296 erreta =
width.z() > 250 * micrometer * std::tan(std::abs(boweta)) ?
297 width.z() * TOPHAT_SIGMA : 250 * micrometer * std::tan(std::abs(boweta)) * TOPHAT_SIGMA;
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;
308 std::pair<double,double> delta_err = offlineITkCalibDataHandle->getClusterErrorData()->getDeltaError(idHash);
309 errphi = nrows != 1 ? delta_err.first :
width.phiR()*TOPHAT_SIGMA;
310 erreta = ncol != 1 ? delta_err.second :
width.z()*TOPHAT_SIGMA;
325 cov(0, 0) = errphi * errphi;
328 cov(1, 1) = erreta * erreta;
337 ->getScaledCovariance(std::move(cov), *
m_pixelid,
343 idHash, 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), idHash, 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)) );
433 ->getScaledCovariance(std::move(cov), *
m_pixelid,
447 std::move(cov), idHash,
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++) {
575 ATH_MSG_VERBOSE(
" distance n.: " << i <<
" distance is: " << distances[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];
677 if (distance < minDistance) {
679 minDistance = distance;
683 finalposition = allLocalPositions[
index];
684 finalerrormatrix = allErrorMatrix[
index];
#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...
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.
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
PixelClusterStrategy
creates PixelClusterOnTrack objects allowing to calibrate cluster position and error using a given tr...
ParametersBase< TrackParametersDim, Charged > TrackParameters
const T_res * ErrorScalingCast(const T_src *src)
bool isTooBigToBeSplit() const