StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
circleFitTest.cc
1 /***************************************************************************
2  *
3  * $Id: circleFitTest.cc,v 1.2 2003/09/02 17:59:37 perev Exp $
4  *
5  * Author: Thomas Ullrich, Dec 1999
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: circleFitTest.cc,v $
13  * Revision 1.2 2003/09/02 17:59:37 perev
14  * gcc 3.2 updates + WarnOff
15  *
16  * Revision 1.1 1999/12/21 16:29:39 ullrich
17  * Initial Revision
18  *
19  **************************************************************************/
20 #include "StFastCircleFitter.hh"
21 #include <Stiostream.h>
22 #include <cstdlib>
23 
24 int main()
25 {
26  cout << "This program tests the StFastCircleFitter class" << endl;
27  cout << "-----------------------------------------------" << endl;
28 
29  StFastCircleFitter fitter;
30 
31  const unsigned int nPoints = 42;
32  const double x0 = 10.23;
33  const double y0 = 0.018;
34  const double r = 19.91;
35  double phi;
36  int i;
37 
38  cout << "Input: x0 = " << x0 << endl;
39  cout << " y0 = " << y0 << endl;
40  cout << " r = " << r << endl;
41  cout << " n = " << nPoints << endl;
42 
43  for (i=0; i<nPoints; i++) {
44  phi = drand48();
45  fitter.addPoint(r*cos(phi)+x0, r*sin(phi)+y0);
46  }
47 
48  fitter.fit();
49  cout << "Fit 1: x0 = " << fitter.xcenter() << endl;
50  cout << " y0 = " << fitter.ycenter() << endl;
51  cout << " r = " << fitter.radius() << endl;
52  cout << " n = " << fitter.numberOfPoints() << endl;
53 
54  fitter.clear();
55 
56  for (i=0; i<nPoints; i++) {
57  phi = drand48();
58  fitter.addPoint(r*cos(phi)+x0, r*sin(phi)+y0);
59  }
60 
61  fitter.fit();
62  cout << "Fit 2: x0 = " << fitter.xcenter() << endl;
63  cout << " y0 = " << fitter.ycenter() << endl;
64  cout << " r = " << fitter.radius() << endl;
65  cout << " n = " << fitter.numberOfPoints() << endl;
66 
67  cout << "done\n" << endl;
68  return 0;
69 }