BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
MucRecQuadFit Class Reference

#include <MucRecQuadFit.h>

Public Member Functions

 MucRecQuadFit ()
 Constructor.
 
 ~MucRecQuadFit ()
 Destructor.
 
int QuadFit (float x[], float y[], float w[], int n, float *a, float *b, float *c, int *half, float *chisq, float *siga, float *sigb, float *sigc)
 

Detailed Description

Definition at line 15 of file MucRecQuadFit.h.

Constructor & Destructor Documentation

◆ MucRecQuadFit()

MucRecQuadFit::MucRecQuadFit ( )

Constructor.

Definition at line 21 of file MucRecQuadFit.cxx.

22{
23 // Constructor.
24}

◆ ~MucRecQuadFit()

MucRecQuadFit::~MucRecQuadFit ( )

Destructor.

Definition at line 26 of file MucRecQuadFit.cxx.

27{
28 // Destructor.
29}

Member Function Documentation

◆ QuadFit()

int MucRecQuadFit::QuadFit ( float  x[],
float  y[],
float  w[],
int  n,
float *  a,
float *  b,
float *  c,
int *  half,
float *  chisq,
float *  siga,
float *  sigb,
float *  sigc 
)

Definition at line 67 of file MucRecQuadFit.cxx.

80{
81 double sumx, sumx2, sumx3, sumx4,sumy, sumyx, sumyx2, det;
82 float chi;
83
84 /* The variable "i" is declared 8 bytes long to avoid triggering an
85 apparent alignment bug in optimized code produced by gcc-2.95.3.
86 The bug doesn't seem to be present in gcc-3.2. */
87 long i;
88
89 chi = 99999999.0;
90 *a = 0; *b = 0; *c = 0;
91 *half = 0;
92
93 /* N must be >= 2 for this guy to work */
94 if (n < 3)
95 {
96 //cout << "utiQuadFit-W: Too few points for quad fit \n" << endl;
97 return -1;
98 }
99
100 /* Initialization */
101 sumx = 0.0;
102 sumx2 = 0.0;
103 sumx3 = 0.0;
104 sumx4 = 0.0;
105 sumy = 0.0;
106 sumyx = 0.0;
107 sumyx2 = 0.0;
108
109
110 /* Find sum , sumx ,sumy, sumxx, sumxy */
111 for (i = 0; i < n; i++)
112 {
113 sumx = sumx + w[i] * x[i];
114 sumx2 = sumx2 + w[i] * x[i] * x[i];
115 sumx3 = sumx3 + w[i] * x[i] * x[i] * x[i];
116 sumx4 = sumx4 + w[i] * x[i] * x[i] * x[i] * x[i];
117 sumy = sumy + w[i] * y[i];
118 sumyx = sumyx + w[i] * y[i] * x[i];
119 sumyx2 = sumyx2 + w[i] * y[i] * x[i] * x[i];
120 //cout<<"x : y "<<x[i]<<" "<<y[i]<<endl;
121
122 }
123
124
125
126 /* compute the best fitted parameters A,B,C */
127
128 HepMatrix D(3,3,1);
129 HepMatrix C(3,1), ABC(3,1);
130 D(1,1) = sumx4; D(1,2) = D(2,1) = sumx3; D(1,3) = D(3,1) = D(2,2) = sumx2;
131 D(3,2) = D(2,3) = sumx; D(3,3) = n;
132 C(1,1) = sumyx2; C(2,1) = sumyx; C(3,1) = sumy;
133
134 int ierr;
135 ABC = (D.inverse(ierr))*C;
136
137 *a = ABC(1,1);
138 *b = ABC(2,1);
139 *c = ABC(3,1);
140
141 //judge which half parabola these points belone to
142 float center = *b/(-2*(*a));
143 float mean_x;
144 for(i = 0; i < n; i++){
145 mean_x += x[i]/n;
146 }
147
148 if(mean_x > center) *half = 2;//right half
149 else *half = 1;//left half
150
151 //cout<<"in MucRecQuadFit:: which half= "<<*half<<endl;
152
153 /* calculate chi-square */
154 chi = 0.0;
155 for (i=0; i<n; i++)
156 {
157 chi = chi+(w[i])*((y[i])-*a*(x[i])-*b)*
158 ((y[i])-*a*(x[i])-*b);
159 }
160
161 //*siga = sum/det;
162 //*sigb = sxx/det;
163
164 *chisq = chi;
165 return 1;
166}
const Int_t n
Double_t x[10]
***************************************************************************************Pseudo Class RRes *****************************************************************************************Parameters and physical constants **Maarten sept ************************************************************************DOUBLE PRECISION xsmu **************************************************************************PARTICLE DATA all others are from PDG *Only resonances with known widths into electron pairs are sept ************************************************************************C Declarations C
Definition: RRes.h:29
double y[1000]
const double b
Definition: slope.cxx:9

Referenced by MucRec2DRoad::SimpleFit(), and MucRec2DRoad::SimpleFitNoCurrentGap().


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