17 #include "TDecompSVD.h" 18 #include "TMatrixDfwd.h" 20 #include "TMatrixTUtils.h" 22 #include "TVectorDfwd.h" 31 std::vector<double>& hitX,
32 std::vector<double>& hitXErr,
51 if (hitX.size() < 4)
return;
52 if (hitX.size() != hitWID.size())
return;
53 if (hitX.size() != hitXErr.size())
return;
55 const unsigned int nvars = 4;
56 unsigned int npts = hitX.size();
58 TMatrixD A(npts, nvars);
61 unsigned short ninpl[3] = {0};
62 unsigned short nok = 0;
63 for (std::size_t iht = 0; iht < hitX.size(); ++iht) {
64 auto const& wid = hitWID[iht];
69 double const cw = plane.WireCoordinate(
geo::Point_t{0, 1, 0}) - off;
71 double const sw = plane.WireCoordinate(
geo::Point_t{0, 0, 1}) - off;
72 double const x = hitX[iht] - XOrigin;
74 if (hitXErr[iht] > 0) { wght = 1 / hitXErr[iht]; }
75 A[iht][0] = wght * cw;
76 A[iht][1] = wght *
sw;
77 A[iht][2] = wght * cw *
x;
78 A[iht][3] = wght * sw *
x;
79 w[iht] = wght * (hitWID[iht].Wire - off);
80 unsigned int ipl = wid.Plane;
83 if (ninpl[ipl] == 2) ++nok;
91 TVectorD tVec = svd.Solve(w, ok);
96 if (hitX.size() == 4)
return;
102 unsigned int tpc{-1u}, cstat{-1u};
103 for (std::size_t iht = 0; iht < hitX.size(); ++iht) {
104 auto const& wid = hitWID[iht];
107 cstat = wid.Cryostat;
109 double const cw = plane.WireCoordinate(
geo::Point_t{0, 1, 0}) - off;
110 double const sw = plane.WireCoordinate(
geo::Point_t{0, 0, 1}) - off;
111 double const x = hitX[iht] - XOrigin;
112 double const ypr = tVec[0] + tVec[2] *
x;
113 double const zpr = tVec[1] + tVec[3] *
x;
115 if (hitXErr[iht] > 0) { wght = 1 / hitXErr[iht]; }
117 double const diff = (ypr * cw + zpr * sw - (hitWID[iht].Wire - off)) / wght;
118 ChiDOF += diff * diff;
124 ChiDOF /= (double)(npts - 4);
126 double norm = sqrt(1 + tVec[2] * tVec[2] + tVec[3] * tVec[3]);
128 Dir[1] = tVec[2] /
norm;
129 Dir[2] = tVec[3] /
norm;
void TrkLineFit(std::vector< geo::WireID > &hitWID, std::vector< double > &hitX, std::vector< double > &hitXErr, double XOrigin, TVector3 &Pos, TVector3 &Dir, float &ChiDOF) const
double WireCoordinate(Point_t const &point) const
Returns the coordinate of the point on the plane, in wire units.
Definition of data types for geometry description.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
PlaneGeo const & FirstPlane(TPCID const &tpcid) const
Returns the first plane of the specified TPC.
Encapsulate the construction of a single detector plane .
geo::WireReadoutGeom const * wireReadoutGeom
PlaneGeo const & Plane(TPCID const &tpcid, View_t view) const
Returns the specified wire.
Interface to geometry for wire readouts .