1531 double resolution =
hits[0]->GetDetectorInfo()->GetSpatialResolution();
1532 double normalization = 1/(resolution*resolution);
1536 double dx_[12] = { 0.0 };
1537 double l[3] = { 0.0 };
1538 double h[3] = { 0.0 };
1539 for (
size_t i = 0; i <
hits.size(); ++i)
1540 dx_[
hits[i]->GetPlane() - 1] =
hits[i]->GetDetectorInfo()->GetPlaneOffset();
1542 for (
size_t i = 0; i < 3; ++i)
1544 h[i] = dx_[6 + i] == 0 ? dx_[9 + i] : dx_[6 + i];
1545 l[i] = dx_[i] == 0 ? dx_[3 + i] : dx_[i];
1546 dx_[i] = dx_[3 + i] = 0;
1547 dx_[6 + i] = dx_[9 + i] = h[i] - l[i];
1550 for (
size_t i=0; i<
hits.size();i++)
1553 double cosx =
hits[i]->GetDetectorInfo()->GetDetectorRollCos();
1554 double sinx =
hits[i]->GetDetectorInfo()->GetDetectorRollSin();
1555 double cosy =
hits[i]->GetDetectorInfo()->GetDetectorPitchCos();
1556 double siny =
hits[i]->GetDetectorInfo()->GetDetectorPitchSin();
1557 double rcos =
hits[i]->GetDetectorInfo()->GetElementAngleCos();
1558 double rsin =
hits[i]->GetDetectorInfo()->GetElementAngleSin();
1560 double dx = dx_[
hits[i]->GetPlane() - 1];
1562 double wire_off = -0.5 * hits[i]->GetDetectorInfo()->GetElementSpacing()
1563 + hits[i]->GetDetectorInfo()->GetElementOffset();
1564 double hit_pos = hits[i]->GetDriftPosition() + wire_off - dx;
1567 double x0 = hit_pos/rsin;
1568 double y0 = hit_pos/rcos;
1571 if(hits[i]->GetPackage()==1) zRot = -315.9965;
1572 if(hits[i]->GetPackage()==2) zRot = -315.33;
1574 double z0 = hits[i]->GetDetectorInfo()->GetZPosition();
1575 double zD = z0 - zRot;
1584 xR_1 = cosy*x0 +zD*cosx*siny;
1586 zR_1 = zD*cosx*cosy + zRot - siny*x0;
1588 xR_2 = zD*cosx*siny - siny*sinx*y0;
1589 yR_2 = cosx*y0 + zD*sinx;
1590 zR_2 = zD*cosx*cosy + zRot - sinx*cosy*y0;
1592 double xc = hits[i]->GetDetectorInfo()->GetXPosition();
1593 double yc = hits[i]->GetDetectorInfo()->GetYPosition();
1595 double z = (-(fit[1]-xc-zD*cosx*siny)*cosx*siny -
1596 (fit[3]-yc-zD*sinx)*sinx*(cosy*cosy-siny*siny) +
1597 (zRot + zD*cosx*cosy)*cosy*cosx) /
1598 (fit[0]*cosx*siny + fit[2]*sinx*(cosy*cosy-siny*siny) + cosy*cosx);
1600 double x = fit[1] + fit[0] * z;
1601 double y = fit[3] + fit[2] * z;
1607 double diffx = xR_2 - xR_1;
1608 double diffy = yR_2 - yR_1;
1609 double diffz = zR_2 - zR_1;
1611 double numx = -y*diffz + z*diffy + yR_1*zR_2 - yR_2*zR_1;
1612 double numy = x*diffz - z*diffx - xR_1*zR_2 + xR_2*zR_1;
1613 double numz = -x*diffy + y*diffx + xR_1*yR_2 - xR_2*yR_1;
1615 double num = sqrt(numx*numx + numy*numy + numz*numz);
1617 double demx = xR_2 - xR_1;
1618 double demy = yR_2 - yR_1;
1619 double demz = zR_2 - zR_1;
1620 double dem = sqrt(demx*demx + demy*demy + demz*demz);
1622 double residual = num / dem;
1624 chi2 += normalization * residual * residual;
1626 chi2 /= (hits.size() - 4);
std::vector< QwHit * > hits