367 double aveHitDoca(0.);
368 TVector3 avePosUpdate(0.,0.,0.);
379 std::vector<TVector3> hitPosVec;
382 for (
const auto& hit3D : hitPairVector)
385 for (
const auto&
hit : hit3D->getHits())
394 double wirePosArr[3] = {0.,0.,0.};
397 TVector3 wireCenter(wirePosArr[0], wirePosArr[1], wirePosArr[2]);
398 TVector3 wireDirVec(wire_geom.
Direction());
401 double hitPeak(
hit->getHit().PeakTime());
406 TVector3 xAxis(1.,0.,0.);
407 TVector3 planeNormal = xAxis.Cross(wireDirVec);
409 double docaInPlane(wirePos[0] - avePosition[0]);
410 double arcLenToPlane(0.);
411 double cosAxisToPlaneNormal = axisDirVec.Dot(planeNormal);
413 TVector3 axisPlaneIntersection = wirePos;
414 TVector3 hitPosTVec = wirePos;
416 if (fabs(cosAxisToPlaneNormal) > 0.)
418 TVector3 deltaPos = wirePos - avePosition;
420 arcLenToPlane = deltaPos.Dot(planeNormal) / cosAxisToPlaneNormal;
421 axisPlaneIntersection = avePosition + arcLenToPlane * axisDirVec;
422 docaInPlane = wirePos[0] - axisPlaneIntersection[0];
424 TVector3 axisToInter = axisPlaneIntersection - wirePos;
425 double arcLenToDoca = axisToInter.Dot(wireDirVec);
427 hitPosTVec += arcLenToDoca * wireDirVec;
431 TVector3 wVec = avePosition - wirePos;
434 double a(axisDirVec.Dot(axisDirVec));
435 double b(axisDirVec.Dot(wireDirVec));
436 double c(wireDirVec.Dot(wireDirVec));
437 double d(axisDirVec.Dot(wVec));
438 double e(wireDirVec.Dot(wVec));
440 double den(
a*
c -
b*
b);
447 arcLen1 = (
b*
e -
c*
d) / den;
448 arcLen2 = (
a*
e -
b*
d) / den;
463 TVector3 hitPos = wirePos + arcLen2 * wireDirVec;
464 TVector3 axisPos = avePosition + arcLen1 * axisDirVec;
465 double deltaX = hitPos[0] - axisPos[0];
466 double deltaY = hitPos[1] - axisPos[1];
467 double deltaZ = hitPos[2] - axisPos[2];
468 double doca2 = deltaX*deltaX + deltaY*deltaY + deltaZ*deltaZ;
469 double doca = sqrt(doca2);
473 aveHitDoca += fabs(docaInPlane);
488 hit->setDocaToAxis(fabs(docaInPlane));
489 hit->setArcLenToPoca(arcLenToPlane);
493 if (
hit->getStatusBits() & 0x80)
500 avePosUpdate += hitPosTVec;
502 hitPosVec.push_back(hitPosTVec);
509 avePosUpdate[0] /= double(nHits);
510 avePosUpdate[1] /= double(nHits);
511 avePosUpdate[2] /= double(nHits);
514 aveHitDoca /= double(nHits);
518 avePosition = avePosUpdate;
522 for(
auto& hitPos : hitPosVec)
525 double x = hitPos[0] - avePosition[0];
526 double y = hitPos[1] - avePosition[1];
527 double z = hitPos[2] - avePosition[2];
540 TMatrixD sigma(3, 3);
543 sigma(0,1) = sigma(1,0) = xiyi;
544 sigma(0,2) = sigma(2,0) = xizi;
546 sigma(1,2) = sigma(2,1) = yizi;
550 sigma *= (1./(nHits - 1.));
553 TDecompSVD rootSVD(sigma);
560 svdOk = rootSVD.Decompose();
571 TVectorD eigenVals = rootSVD.GetSig();
572 TMatrixD eigenVecs = rootSVD.GetU();
575 double recobEigenVals[] = {eigenVals[0], eigenVals[1], eigenVals[2]};
579 std::vector<double> tempVec;
582 tempVec.push_back(eigenVecs(0, 0));
583 tempVec.push_back(eigenVecs(1, 0));
584 tempVec.push_back(eigenVecs(2, 0));
585 recobEigenVecs.push_back(tempVec);
589 tempVec.push_back(eigenVecs(0, 1));
590 tempVec.push_back(eigenVecs(1, 1));
591 tempVec.push_back(eigenVecs(2, 1));
592 recobEigenVecs.push_back(tempVec);
596 tempVec.push_back(eigenVecs(0, 2));
597 tempVec.push_back(eigenVecs(1, 2));
598 tempVec.push_back(eigenVecs(2, 2));
599 recobEigenVecs.push_back(tempVec);
602 double avePosToSave[] = {avePosition[0],avePosition[1],avePosition[2]};
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
geo::Geometry * m_geometry
CryostatID_t Cryostat
Index of cryostat.
const Eigen::Vector3f & getAvePosition() const
double m_parallel
means lines are parallel
PlaneID_t Plane
Index of the plane within its TPC.
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Eigen::Matrix3f EigenVectors
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
TPCID_t TPC
Index of the TPC within its cryostat.
const detinfo::DetectorProperties * m_detector
const EigenVectors & getEigenVectors() const
QTextStream & endl(QTextStream &s)
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const