15 #include "TDecompSVD.h" 16 #include "TMatrixDfwd.h" 18 #include "TMatrixTUtils.h" 20 #include "TVectorDfwd.h" 29 double XOrigin, TVector3& Pos, TVector3& Dir,
float& ChiDOF)
const 44 if(hitX.size() < 4)
return;
45 if(hitX.size() != hitWID.size())
return;
46 if(hitX.size() != hitXErr.size())
return;
48 const unsigned int nvars = 4;
49 unsigned int npts = hitX.size();
51 TMatrixD
A(npts, nvars);
54 unsigned short ninpl[3] = {0};
55 unsigned short nok = 0;
57 unsigned int ipl, tpc, cstat;
58 double x, cw, sw, off, wght;
59 for(iht = 0; iht < hitX.size(); ++iht) {
60 cstat = hitWID[iht].Cryostat;
61 tpc = hitWID[iht].TPC;
62 ipl = hitWID[iht].Plane;
69 x = hitX[iht] - XOrigin;
70 if(hitXErr[iht] > 0) {
71 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);
82 if(ninpl[ipl] == 2) ++nok;
90 TVectorD tVec = svd.Solve(w, ok);
95 if(hitX.size() == 4)
return;
97 double ypr, zpr, diff;
98 for(iht = 0; iht < hitX.size(); ++iht) {
99 cstat = hitWID[iht].Cryostat;
100 tpc = hitWID[iht].TPC;
101 ipl = hitWID[iht].Plane;
105 x = hitX[iht] - XOrigin;
106 ypr = tVec[0] + tVec[2] *
x;
107 zpr = tVec[1] + tVec[3] *
x;
108 if(hitXErr[iht] > 0) {
109 wght = 1 / hitXErr[iht];
113 if(wght <= 0) wght = 1;
114 diff = (ypr * cw + zpr * sw - (hitWID[iht].Wire - off)) / wght;
115 ChiDOF += diff * diff;
121 ChiDOF /= (double)(npts - 4);
123 double norm = sqrt(1 + tVec[2] * tVec[2] + tVec[3] * tVec[3]);
125 Dir[1] = tVec[2] /
norm;
126 Dir[2] = tVec[3] /
norm;
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
void TrkLineFit(std::vector< geo::WireID > &hitWID, std::vector< double > &hitX, std::vector< double > &hitXErr, double XOrigin, TVector3 &Pos, TVector3 &Dir, float &ChiDOF) const
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
art framework interface to geometry description
art::ServiceHandle< geo::Geometry const > geom
Definition of data types for geometry description.
auto norm(Vector const &v)
Return norm of the specified vector.