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;
64 off =
geom->WireCoordinate(0, 0, ipl, tpc, cstat);
66 cw =
geom->WireCoordinate(1, 0, ipl, tpc, cstat) - off;
68 sw =
geom->WireCoordinate(0, 1, ipl, tpc, cstat) - off;
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;
102 off =
geom->WireCoordinate(0, 0, ipl, tpc, cstat);
103 cw =
geom->WireCoordinate(1, 0, ipl, tpc, cstat) - off;
104 sw =
geom->WireCoordinate(0, 1, ipl, tpc, cstat) - off;
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;
118 double werr2 =
geom->WirePitch(0, tpc, cstat);
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;
process_name opflash particleana ie x
art::ServiceHandle< geo::Geometry const > geom
auto norm(Vector const &v)
Return norm of the specified vector.