15 #include "TDecompSVD.h" 16 #include "TMatrixDfwd.h" 18 #include "TMatrixTUtils.h" 20 #include "TVectorDfwd.h" 29 std::vector<double>& hitX,
30 std::vector<double>& hitXErr,
49 if (hitX.size() < 4)
return;
50 if (hitX.size() != hitWID.size())
return;
51 if (hitX.size() != hitXErr.size())
return;
53 const unsigned int nvars = 4;
54 unsigned int npts = hitX.size();
56 TMatrixD A(npts, nvars);
59 unsigned short ninpl[3] = {0};
60 unsigned short nok = 0;
61 for (std::size_t iht = 0; iht < hitX.size(); ++iht) {
62 auto const& wid = hitWID[iht];
69 double const x = hitX[iht] - XOrigin;
71 if (hitXErr[iht] > 0) { wght = 1 / hitXErr[iht]; }
72 A[iht][0] = wght * cw;
73 A[iht][1] = wght *
sw;
74 A[iht][2] = wght * cw *
x;
75 A[iht][3] = wght * sw *
x;
76 w[iht] = wght * (hitWID[iht].Wire - off);
77 unsigned int ipl = wid.Plane;
80 if (ninpl[ipl] == 2) ++nok;
88 TVectorD tVec = svd.Solve(w, ok);
93 if (hitX.size() == 4)
return;
99 unsigned int tpc{-1u}, cstat{-1u};
100 for (std::size_t iht = 0; iht < hitX.size(); ++iht) {
101 auto const& wid = hitWID[iht];
103 cstat = wid.Cryostat;
107 double const x = hitX[iht] - XOrigin;
108 double const ypr = tVec[0] + tVec[2] *
x;
109 double const zpr = tVec[1] + tVec[3] *
x;
111 if (hitXErr[iht] > 0) { wght = 1 / hitXErr[iht]; }
113 double const diff = (ypr * cw + zpr * sw - (hitWID[iht].Wire - off)) / wght;
114 ChiDOF += diff * diff;
120 ChiDOF /= (double)(npts - 4);
122 double norm = sqrt(1 + tVec[2] * tVec[2] + tVec[3] * tVec[3]);
124 Dir[1] = tVec[2] /
norm;
125 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
Length_t WireCoordinate(Point_t const &pos, PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
The data type to uniquely identify a Plane.
art::ServiceHandle< geo::Geometry const > geom
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.
Length_t WirePitch(PlaneID const &planeid=plane_zero) const
Returns the distance between two consecutive wires.
art framework interface to geometry description