BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcLine.cxx
Go to the documentation of this file.
1// MdcLine.cc -- simple straight line fitter
2
3#include "MdcTrkRecon/MdcLine.h"
4#include <math.h>
5#include <stdlib.h>
6// End Implementation Dependencies -------------------------------------
7#include <iostream>
8using namespace std; // yzhang debug
9
10int MdcLine::fit( int nUse ) {
11
12 double s1, sx, sy, sxx, sxy; // The various sums.
13 double delinv, denom;
14 double weight = 0.013; // weight for hits, calculated from sigmas.
15 int ihit;
16 if ( nUse > nPoint ) nUse = nPoint;
17 s1 = sx = sy = sxx = sxy = 0.0;
18 chisq = 0.0;
19 for ( ihit = 0; ihit < nUse; ihit++ )
20 {
21
22 if ( sigma[ihit] < 0.0 ) continue;
23 weight = 1. / ( sigma[ihit] * sigma[ihit] ); // NEED sigma of MdcHits
24 s1 += weight;
25 sx += x[ihit] * weight;
26 sy += y[ihit] * weight;
27 sxx += x[ihit] * ( x[ihit] * weight );
28 sxy += y[ihit] * ( x[ihit] * weight );
29
30 // std::cout<<__FILE__<<" "<<__LINE__<< " "<<ihit<<" sigma "<<
31 // sigma[ihit] <<" weight "
32 //<< weight<<" x "
33 //<< x[ihit]<<" y "
34 //<< y[ihit]<< std::endl;
35 }
36
37 /* Calculate parameters. */
38 denom = s1 * sxx - sx * sx;
39 delinv = ( denom == 0.0 ) ? 1.e20 : 1. / denom;
40 intercept = ( sy * sxx - sx * sxy ) * delinv;
41 slope = ( s1 * sxy - sx * sy ) * delinv;
42 errmat[0] = sxx * delinv;
43 errmat[1] = -sx * delinv;
44 errmat[2] = s1 * delinv;
45 // std::cout << " After Fit:" << std::endl;//yzhang debug
46 /* Calculate residuals. */
47 for ( ihit = 0; ihit < nUse; ihit++ )
48 {
49 if ( sigma[ihit] < 0.0 ) continue;
50 resid[ihit] = ( y[ihit] - intercept - slope * x[ihit] );
51 chisq += resid[ihit] * resid[ihit] / ( sigma[ihit] * sigma[ihit] );
52 // std::cout << "resid "<<ihit<<" "<<resid[ihit]<<" sigma "<<sigma[ihit]<<" chisq add
53 // "<<resid[ihit] * resid[ihit] / (sigma[ihit] * sigma[ihit]) << std::endl;//yzhang debug
54 }
55
56 // std::cout<<__FILE__<<" "<<__LINE__
57 //<< " intercept "<<intercept<<" slope "<<slope
58 //<< " chisq "<<chisq<<std::endl;//yzhang debug
59 return 0;
60}
*********Class see also m_nmax DOUBLE PRECISION m_MasPhot DOUBLE PRECISION m_phsu DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_r2 DOUBLE PRECISION m_WtMass INTEGER m_nmax INTEGER m_Nevgen INTEGER m_IsFSR INTEGER m_MarTot *COMMON c_KarFin $ !Output file $ !Event serial number $ !alpha QED at Thomson limit $ !minimum energy at CMS for remooval $ !infrared dimensionless $ !dummy photon IR regulator $ !crude photon multiplicity enhancement factor *EVENT $ !MC crude volume of PhhSpace *Sfactors $ !YFS formfactor IR part only $ !YFS formfactor non IR finite part $ !mass weight
Definition KarFin.h:34
int fit(int nUse)
Definition MdcLine.cxx:10