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;
146 const double TOPHAT_SIGMA = 1. / std::sqrt(12.);
173 if (
pix->rdoList().empty()) {
174 ATH_MSG_WARNING(
"Pixel RDO-list size is 0, check integrity of pixel clusters! stop ROT creation.");
185 float trkphicomp = my_track.dot(my_phiax);
186 float trketacomp = my_track.dot(my_etaax);
187 float trknormcomp = my_track.dot(my_normal);
188 double bowphi = std::atan2(trkphicomp, trknormcomp);
189 double boweta = std::atan2(trketacomp, trknormcomp);
195 if (bowphi >
M_PI *0.5) {
198 if (bowphi < -
M_PI *0.5) {
204 double angle = std::atan(std::tan(bowphi) - readoutside * tanl);
207 double thetaloc = -999.;
208 if (boweta > -0.5 *
M_PI && boweta <
M_PI / 2.) {
209 thetaloc = M_PI_2 - boweta;
210 }
else if (boweta > M_PI_2 && boweta <
M_PI) {
211 thetaloc = 1.5 *
M_PI - boweta;
213 thetaloc = -M_PI_2 - boweta;
215 double etaloc = -1 * log(tan(thetaloc * 0.5));
219 int PixEtaModule =
m_pixelid->eta_module(element_id);
220 int PixPhiModule =
m_pixelid->phi_module(element_id);
221 double PixTrkPt = trackPar.
pT();
222 double PixTrkEta = trackPar.
eta();
223 ATH_MSG_VERBOSE(
"tanl = " << tanl <<
" readout side is " << readoutside <<
224 " module " << PixEtaModule <<
" " << PixPhiModule <<
225 " track pt, eta = " << PixTrkPt <<
" " << PixTrkEta <<
226 " track momentum phi, norm = " << trkphicomp <<
" " <<
227 trknormcomp <<
" bowphi = " << bowphi <<
" angle = " <<
angle);
229 float omegaphi =
pix->omegax();
230 float omegaeta =
pix->omegay();
231 double localphi = -9999.;
232 double localeta = -9999.;
234 const std::vector<Identifier> & rdos =
pix->rdoList();
240 for (
const auto & rId:rdos) {
241 const int row =
m_pixelid->phi_index(rId);
242 const int col =
m_pixelid->eta_index(rId);
243 rowmin = std::min(rowmin, row);
244 rowmax = std::max(rowmax,row);
245 colmin = std::min(colmin, col);
246 colmax = std::max(colmax, col);
249 meanpos = meanpos / rdos.size();
261 int nrows = rowmax - rowmin + 1;
262 int ncol = colmax - colmin + 1;
268 localphi = centroid.
xPhi() + shift;
269 localeta = centroid.
xEta();
271 std::pair<double,double> delta = offlineITkCalibDataHandle->getClusterErrorData()->getDelta(idHash,nrows,
angle,ncol,etaloc);
272 double delta_phi = nrows != 1 ? delta.first : 0.;
273 double delta_eta = ncol != 1 ? delta.second : 0.;
274 localphi += delta_phi*(omegaphi-0.5);
275 localeta += delta_eta*(omegaeta-0.5);
279 localphi = meanpos.
xPhi() + shift;
280 localeta = meanpos.
xEta();
292 if (std::abs(
angle) > 1) {
293 const double thickness = element->
thickness();
294 errphi = thickness * std::tan(std::abs(
angle)) * TOPHAT_SIGMA;
295 erreta =
width.z() > thickness * std::tan(std::abs(boweta)) ?
296 width.z() * TOPHAT_SIGMA : thickness * std::tan(std::abs(boweta)) * TOPHAT_SIGMA;
297 ATH_MSG_VERBOSE(
"Shallow track with tanl = " << tanl <<
" bowphi = " <<
298 bowphi <<
" angle = " <<
angle <<
" width.z = " <<
width.z() <<
299 " errphi = " << errphi <<
" erreta = " << erreta);
301 errphi =
width.phiR() * TOPHAT_SIGMA;
302 erreta =
width.z() * TOPHAT_SIGMA;
304 errphi = (
width.phiR() / nrows) * TOPHAT_SIGMA;
305 erreta = (
width.z() / ncol) * TOPHAT_SIGMA;
307 std::pair<double,double> delta_err = offlineITkCalibDataHandle->getClusterErrorData()->getDeltaError(idHash);
308 errphi = nrows != 1 ? delta_err.first :
width.phiR()*TOPHAT_SIGMA;
309 erreta = ncol != 1 ? delta_err.second :
width.z()*TOPHAT_SIGMA;
324 cov(0, 0) = errphi * errphi;
327 cov(1, 1) = erreta * erreta;
336 ->getScaledCovariance(std::move(cov), *
m_pixelid,
342 idHash, glob,
pix->gangedPixel(), isbroad);
350 int initial_errorStrategy;
358 newROT =
correct(rio, trackPar, ctx);
363 return correct(rio, trackPar, ctx);
372 const EventContext& ctx)
const {
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, ctx)) {
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 const EventContext& ctx)
const {
459 std::vector<Amg::Vector2D> vectorOfPositions;
460 int numberOfSubclusters = 1;
461 vectorOfPositions.push_back(pixelPrepCluster->
localPosition());
465 InDet::PixelGangedClusterAmbiguities::const_iterator mapBegin = splitClusterMap->begin();
466 InDet::PixelGangedClusterAmbiguities::const_iterator mapEnd = splitClusterMap->end();
467 for (InDet::PixelGangedClusterAmbiguities::const_iterator mapIter = mapBegin; mapIter != mapEnd; ++mapIter) {
470 if (first == pixelPrepCluster && second != pixelPrepCluster) {
471 ATH_MSG_DEBUG(
"Found additional split cluster in ambiguity map (+=1).");
472 numberOfSubclusters += 1;
478 if (pixelAddCluster ==
nullptr) {
479 ATH_MSG_WARNING(
"Pixel ambiguity map has empty pixel cluster. Please DEBUG!");
482 vectorOfPositions.push_back(pixelAddCluster->
localPosition());
495 "Parameters are not at a plane ! Aborting cluster correction... ");
499 std::vector<Amg::Vector2D> allLocalPositions;
500 std::vector<Amg::MatrixX> allErrorMatrix;
506 numberOfSubclusters);
508 if (allLocalPositions.empty()) {
509 ATH_MSG_DEBUG(
" Cluster cannot be treated by NN. Giving back to default clusterization " );
514 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
515 ATH_MSG_WARNING(
"Returned position vector size " << allLocalPositions.size() <<
516 " not according to expected number of subclusters: " << numberOfSubclusters <<
". Abort cluster correction..." );
524 if (numberOfSubclusters == 1) {
525 finalposition = allLocalPositions[0];
526 finalerrormatrix = allErrorMatrix[0];
529 else if (numberOfSubclusters == 2) {
531 square(vectorOfPositions[0][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
532 square(vectorOfPositions[1][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
533 square(vectorOfPositions[0][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
534 square(vectorOfPositions[1][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
537 square(vectorOfPositions[1][0] - allLocalPositions[0][0]) / allErrorMatrix[0](0, 0) +
538 square(vectorOfPositions[0][0] - allLocalPositions[1][0]) / allErrorMatrix[1](0, 0) +
539 square(vectorOfPositions[1][1] - allLocalPositions[0][1]) / allErrorMatrix[0](1, 1) +
540 square(vectorOfPositions[0][1] - allLocalPositions[1][1]) / allErrorMatrix[1](1, 1);
543 " Old pix (1) x: " << vectorOfPositions[0][0] <<
" y: " << vectorOfPositions[0][1] <<
"\n"
544 <<
" Old pix (2) x: " << vectorOfPositions[1][0] <<
" y: " << vectorOfPositions[1][1] <<
"\n"
545 <<
" Pix (1) x: " << allLocalPositions[0][0] <<
" +/- " << std::sqrt(allErrorMatrix[0](0, 0))
546 <<
" y: " << allLocalPositions[0][1] <<
" +/- " << std::sqrt(allErrorMatrix[0](1, 1)) <<
"\n"
547 <<
" Pix (2) x: " << allLocalPositions[1][0] <<
" +/- " << std::sqrt(allErrorMatrix[1](0, 0))
548 <<
" y: " << allLocalPositions[1][1] <<
" +/- " << std::sqrt(allErrorMatrix[1](1, 1)) <<
"\n"
549 <<
" Old (1) new (1) dist: " << std::sqrt(distancesq1) <<
" Old (1) new (2) " << std::sqrt(distancesq2) );
552 if (distancesq1 < distancesq2) {
553 finalposition = allLocalPositions[0];
554 finalerrormatrix = allErrorMatrix[0];
556 finalposition = allLocalPositions[1];
557 finalerrormatrix = allErrorMatrix[1];
562 else if (numberOfSubclusters == 3) {
565 distances[0] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 1, 2);
566 distances[1] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 0, 2, 1);
567 distances[2] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 0, 2);
568 distances[3] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 1, 2, 0);
569 distances[4] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 0, 1);
570 distances[5] = distance(vectorOfPositions, allLocalPositions, allErrorMatrix, 2, 1, 0);
572 int smallestDistanceIndex = -10;
573 double minDistance = 1e10;
575 for (
int i = 0; i < 6; i++) {
576 ATH_MSG_VERBOSE(
" distance n.: " << i <<
" distance is: " << distances[i]);
578 if (distances[i] < minDistance) {
579 minDistance = distances[i];
580 smallestDistanceIndex = i;
584 ATH_MSG_DEBUG(
" The minimum distance is : " << minDistance <<
" for index: " << smallestDistanceIndex);
586 if (smallestDistanceIndex == 0 || smallestDistanceIndex == 1) {
587 finalposition = allLocalPositions[0];
588 finalerrormatrix = allErrorMatrix[0];
590 if (smallestDistanceIndex == 2 || smallestDistanceIndex == 4) {
591 finalposition = allLocalPositions[1];
592 finalerrormatrix = allErrorMatrix[1];
594 if (smallestDistanceIndex == 3 || smallestDistanceIndex == 5) {
595 finalposition = allLocalPositions[2];
596 finalerrormatrix = allErrorMatrix[2];
607 const EventContext& ctx)
const {
609 std::vector<Amg::Vector2D> vectorOfPositions;
610 int numberOfSubclusters = 1;
613 numberOfSubclusters = 1 + splitClusterMap->count(pixelPrepCluster);
615 if (splitClusterMap->count(pixelPrepCluster) == 0 && splitProb.
isSplit()) {
616 numberOfSubclusters = 2;
618 if (splitClusterMap->count(pixelPrepCluster) != 0 && !splitProb.
isSplit()) {
619 numberOfSubclusters = 1;
626 ATH_MSG_WARNING(
"Parameters are not at a plane surface ! Aborting cluster "
631 std::vector<Amg::Vector2D> allLocalPositions;
632 std::vector<Amg::MatrixX> allErrorMatrix;
638 numberOfSubclusters);
640 if (allLocalPositions.empty()) {
642 " Cluster cannot be treated by NN. Giving back to default clusterization, too big: " <<
647 if (allLocalPositions.size() !=
size_t(numberOfSubclusters)) {
649 "Returned position vector size " << allLocalPositions.size() <<
" not according to expected number of subclusters: " << numberOfSubclusters <<
650 ". Abort cluster correction...");
657 if (numberOfSubclusters == 1) {
658 finalposition = allLocalPositions[0];
659 finalerrormatrix = allErrorMatrix[0];
667 if (trackPar.covariance()) {
668 localerr =
Amg::Vector2D(std::sqrt((*trackPar.covariance())(0, 0)), std::sqrt((*trackPar.covariance())(1, 1)));
671 double minDistance(1e300);
674 for (
unsigned int i(0); i < allLocalPositions.size(); ++i) {
676 square(localpos[0] - allLocalPositions[i][0]) / localerr[0]
677 + square(localpos[1] - allLocalPositions[i][1]) / localerr[1];
679 if (distance < minDistance) {
681 minDistance = distance;
685 finalposition = allLocalPositions[
index];
686 finalerrormatrix = allErrorMatrix[
index];
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(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.
double pT() const
Access method for transverse momentum.
virtual const Surface & associatedSurface() const =0
Access to the Surface associated to the Parameters.
virtual constexpr SurfaceType surfaceType() const =0
Returns the Surface Type enum for the surface used to define the derived class.
Amg::Vector2D localPosition() const
Access method for the local coordinates, local parameter definitions differ for each surface type.
virtual constexpr ParametersType type() const =0
Return the ParametersType enum.
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