QwAnalysis
MyFCN Class Reference

Inherits FCNBase.

Public Member Functions

 MyFCN (std::vector< QwHit * > fhits)
 
double operator() (const double *array) const
 
double operator() (const std::vector< double > &fit) const
 
double Up () const
 

Private Attributes

std::vector< QwHit * > hits
 

Detailed Description

-----------------------------------------------------------------------—*\ Minuit2 Set-up The following is the code that the minuit2 minimizer calls in r2_PartialTrackFit to optimize the fit parameters. It applies rotation parameters defined in the geofile (qweak_HDC.<runrange>.geo) found in the QwAnalysis/Tracking/src/ directory. These rotation parameters (defined by plane) allow the individual planes in Region 2 to be rotated around the center of each chamber. this eventually needs to be corrected to have both chambers in a package rotate around the same point

Definition at line 1517 of file QwTrackingTreeCombine.cc.

Constructor & Destructor Documentation

MyFCN::MyFCN ( std::vector< QwHit * >  fhits)
inline

Definition at line 1521 of file QwTrackingTreeCombine.cc.

1521 : hits(fhits) {}
std::vector< QwHit * > hits

Member Function Documentation

double MyFCN::operator() ( const double *  array) const
inline

Definition at line 1523 of file QwTrackingTreeCombine.cc.

1523  {
1524  const std::vector<double> fit(array, array + 4);
1525  return operator()(fit);
1526  }
double operator()(const double *array) const
double MyFCN::operator() ( const std::vector< double > &  fit) const
inline

Definition at line 1528 of file QwTrackingTreeCombine.cc.

1528  {
1529  double value = 0;
1530  double chi2 = 0;
1531  double resolution = hits[0]->GetDetectorInfo()->GetSpatialResolution();
1532  double normalization = 1/(resolution*resolution);
1533 
1534 
1535  // Calculate the metric matrix
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();
1541 
1542  for (size_t i = 0; i < 3; ++i)
1543  {
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];
1548  }
1549 
1550  for (size_t i=0; i<hits.size();i++)
1551  {
1552 
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();
1559 
1560  double dx = dx_[hits[i]->GetPlane() - 1];
1561 
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;
1565 
1566  // Get end points of the hit wire
1567  double x0 = hit_pos/rsin;
1568  double y0 = hit_pos/rcos;
1569 
1570  double zRot = 1e6;
1571  if(hits[i]->GetPackage()==1) zRot = -315.9965;
1572  if(hits[i]->GetPackage()==2) zRot = -315.33;
1573 
1574  double z0 = hits[i]->GetDetectorInfo()->GetZPosition();
1575  double zD = z0 - zRot;
1576 
1577  double xR_1 = x0;
1578  double yR_1 = 0.0;
1579  double zR_1 = z0;
1580  double xR_2 = 0.0;
1581  double yR_2 = y0;
1582  double zR_2 = z0;
1583 
1584  xR_1 = cosy*x0 +zD*cosx*siny;
1585  yR_1 = zD*sinx;
1586  zR_1 = zD*cosx*cosy + zRot - siny*x0;
1587 
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;
1591 
1592  double xc = hits[i]->GetDetectorInfo()->GetXPosition();
1593  double yc = hits[i]->GetDetectorInfo()->GetYPosition();
1594 
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);
1599 
1600  double x = fit[1] + fit[0] * z;
1601  double y = fit[3] + fit[2] * z;
1602 
1603 
1604  x -= xc;
1605  y -= yc;
1606 
1607  double diffx = xR_2 - xR_1;
1608  double diffy = yR_2 - yR_1;
1609  double diffz = zR_2 - zR_1;
1610 
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;
1614 
1615  double num = sqrt(numx*numx + numy*numy + numz*numz);
1616 
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);
1621 
1622  double residual = num / dem;
1623 
1624  chi2 += normalization * residual * residual;
1625  }
1626  chi2 /= (hits.size() - 4);
1627  return chi2;
1628 
1629 
1630  }
std::vector< QwHit * > hits
double MyFCN::Up ( ) const
inline

Definition at line 1633 of file QwTrackingTreeCombine.cc.

1633 { return 1.; }

Field Documentation

std::vector<QwHit*> MyFCN::hits
private

Definition at line 1639 of file QwTrackingTreeCombine.cc.


The documentation for this class was generated from the following file: