327 bool consistent(
false);
342 Eigen::Vector3f firstPosToNextPosVec = nextCenter - firstCenter;
343 Eigen::Vector3f firstPosToNextPosUnit = firstPosToNextPosVec.normalized();
344 float firstPosToNextPosLen = firstPosToNextPosVec.norm();
352 float arcLenToNextDoca = firstPosToNextPosVec.dot(firstAxis2);
356 if (arcLenToNextDoca < 0.)
358 firstAxis0 = -firstAxis0;
359 firstAxis1 = -firstAxis1;
360 firstAxis2 = -firstAxis2;
361 arcLenToNextDoca = -arcLenToNextDoca;
371 Eigen::Vector2f firstProj01Unit = Eigen::Vector2f(firstPosToNextPosUnit.dot(firstAxis0),firstPosToNextPosUnit.dot(firstAxis1)).normalized();
372 float firstEigen0Proj = firstEigenVals[0] * firstProj01Unit[0];
373 float firstEigen1Proj = firstEigenVals[1] * firstProj01Unit[1];
374 float rMaxFirst = std::sqrt(firstEigen0Proj * firstEigen0Proj + firstEigen1Proj * firstEigen1Proj);
375 float cosMaxFirst = firstEigenVals[2] / std::sqrt(firstEigenVals[2] * firstEigenVals[2] + rMaxFirst * rMaxFirst);
376 float cosFirstAxis = firstAxis2.dot(firstPosToNextPosUnit);
379 float firstEigenVal2 = firstEigenVals[2];
380 float firstToNextProjEigen = firstEigenVal2;
383 if (cosFirstAxis < cosMaxFirst)
386 float sinFirstAxis = std::sqrt(1. - cosFirstAxis * cosFirstAxis);
389 firstToNextProjEigen = rMaxFirst / sinFirstAxis;
391 else firstToNextProjEigen /= cosFirstAxis;
394 float firstPosToNextPosScaleFactor = 8.;
407 if (firstPosToNextPosLen < firstPosToNextPosScaleFactor * firstToNextProjEigen)
415 float cosFirstNextAxis = firstAxis2.dot(nextAxis2);
419 if (cosFirstNextAxis < 0.)
421 nextAxis0 = -nextAxis0;
422 nextAxis1 = -nextAxis1;
423 nextAxis2 = -nextAxis2;
424 cosFirstNextAxis = -cosFirstNextAxis;
433 Eigen::Vector2f nextProj01Unit = Eigen::Vector2f(firstPosToNextPosUnit.dot(nextAxis0),firstPosToNextPosUnit.dot(nextAxis1)).normalized();
434 float nextEigen0Proj = nextEigenVals[0] * nextProj01Unit[0];
435 float nextEigen1Proj = nextEigenVals[1] * nextProj01Unit[1];
436 float rMaxNext = std::sqrt(nextEigen0Proj * nextEigen0Proj + nextEigen1Proj * nextEigen1Proj);
437 float cosMaxNext = nextEigenVals[2] / std::sqrt(nextEigenVals[2] * nextEigenVals[2] + rMaxNext * rMaxNext);
438 float cosNextAxis =
std::abs(nextAxis2.dot(firstPosToNextPosUnit));
441 float nextToFirstProjEigen = nextEigenVals[2];
444 if (cosNextAxis < cosMaxNext)
447 float sinNextAxis = std::sqrt(1. - cosNextAxis * cosNextAxis);
450 nextToFirstProjEigen = rMaxNext / sinNextAxis;
452 else nextToFirstProjEigen /= cosNextAxis;
456 float nextToFirstScaleFactor = 8. * cosFirstNextAxis;
460 float gapFirstToNext = firstPosToNextPosLen - firstToNextProjEigen - nextToFirstProjEigen;
463 Eigen::Vector3f firstEndPoint = firstCenter + firstEigenVals[2] * firstAxis2;
464 Eigen::Vector3f nextTailPoint = nextCenter - nextEigenVals[2] * nextAxis2;
465 Eigen::Vector3f endToTailVec = nextTailPoint - firstEndPoint;
468 float endPointProjection = endToTailVec.dot(firstPosToNextPosUnit);
469 float endToTailLen = endToTailVec.norm();
487 if (gapFirstToNext < nextToFirstScaleFactor * nextToFirstProjEigen || (
std::abs(endPointProjection) < nextToFirstProjEigen && endToTailLen < nextEigenVals[2]))
491 Eigen::Vector3f firstPoca;
492 Eigen::Vector3f nextPoca;
493 Eigen::Vector3f firstToNextUnit;
496 float lineDoca =
closestApproach(firstCenter, firstAxis2, nextCenter, nextAxis2, firstPoca, nextPoca, firstToNextUnit);
499 Eigen::Vector3f firstPOCAProjUnit = Eigen::Vector3f(firstToNextUnit.dot(firstAxis0),firstToNextUnit.dot(firstAxis1),firstToNextUnit.dot(firstAxis1)).normalized();
500 float firstPOCAVecProjEigen = std::sqrt(
std::pow(firstEigenVals[0] * firstPOCAProjUnit[0],2)
501 +
std::pow(firstEigenVals[1] * firstPOCAProjUnit[1],2)
502 +
std::pow(firstEigenVals[2] * firstPOCAProjUnit[2],2));
505 Eigen::Vector3f nextPOCAProjUnit = Eigen::Vector3f(firstToNextUnit.dot(firstAxis0),firstToNextUnit.dot(firstAxis1),firstToNextUnit.dot(firstAxis1)).normalized();
506 float nextPOCAVecProjEigen = std::sqrt(
std::pow(nextEigenVals[0] * nextPOCAProjUnit[0],2)
507 +
std::pow(nextEigenVals[1] * nextPOCAProjUnit[1],2)
508 +
std::pow(nextEigenVals[2] * nextPOCAProjUnit[2],2));
513 float arcLenToFirstPoca = (firstPoca - firstCenter).
dot(firstAxis2);
514 float arcLenToNextPoca = (nextPoca - nextCenter ).
dot(nextAxis2);
522 float rMaxScaleFactor = 1.2;
524 if (lineDoca < rMaxScaleFactor * (firstPOCAVecProjEigen + nextPOCAVecProjEigen))
std::vector< TH1F * > fNextEigenValueHists
Next Cluster eigen value.
float closestApproach(const Eigen::Vector3f &, const Eigen::Vector3f &, const Eigen::Vector3f &, const Eigen::Vector3f &, Eigen::Vector3f &, Eigen::Vector3f &, Eigen::Vector3f &) const
TH1F * fCosMaxFirstHist
Cos angle beteeen cylinder axis and edge.
TH1F * f2ndDocaArcLRatHist
arc length to POCA for DOCA second cluster
bool fOutputHistograms
Take the time to create and fill some histograms for diagnostics.
TH1F * fRMaxFirstHist
radius of "cylinder" first cluster
TH1F * fCosFirstAxisHist
Cos angle between vector between centers and first axis.
TH1F * fProjEndPointRatHist
Ratio of projection to vector length.
const EigenValues & getEigenValues() const
reco::PrincipalComponents & getFullPCA()
TH1F * fCosNextAxisHist
Cos angle between vector between centers and next axis.
TH1F * f2ndTo1stProjEigenHist
arc length along vector between centers from next center to cylinder
TH1F * f1stTo2ndPosLenRatHist
Ratio of distance between centers and first proj eigen.
const Eigen::Vector3f & getAvePosition() const
TH1F * fRMaxNextHist
radius of "cylinder" next cluster
TH1F * f1stTo2ndProjEigenHist
arc length along vector between centers from first center to cylinder
static int max(int a, int b)
TH1F * fProjEndPointLenHist
Projection of vector between the endpoints.
float fMinTransEigenVal
Set a mininum allowed value for the transverse eigen values.
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
TH1F * fAxesDocaHist
Closest distance between two primary axes.
TH1F * fCosMaxNextHist
Cos angle beteeen cylinder axis and edge.
TH1F * fGapBetweenClusHist
Gap between clusters.
TH1F * f1stDocaArcLRatHist
arc length to POCA for DOCA first cluster
TH1F * f1stTo2ndPosLenHist
Distance between cluster centers.
const EigenVectors & getEigenVectors() const