CMS 3D CMS Logo

List of all members | Public Member Functions
SaturationFit Class Reference

#include <SaturationFit.h>

Public Member Functions

 SaturationFit (int N, float *charge_ptr, float *adc_ptr, float *u0_ptr, float *u1_ptr, float *u2_ptr, float *u3_ptr)
 
 ~SaturationFit ()
 

Detailed Description

Definition at line 9 of file SaturationFit.h.

Constructor & Destructor Documentation

SaturationFit::SaturationFit ( int  N,
float *  charge_ptr,
float *  adc_ptr,
float *  u0_ptr,
float *  u1_ptr,
float *  u2_ptr,
float *  u3_ptr 
)
inline

Definition at line 13 of file SaturationFit.h.

References gather_cfg::cout, SaturationFcn::set_data(), SaturationFcn::x0start, SaturationFcn::x1start, SaturationFcn::x2start, and SaturationFcn::x3start.

13  {
14  double u[3],sigma[3],chisq;
15  VariableMetricMinimizer* pMinimizer=new VariableMetricMinimizer() ;
16  SaturationFcn* pFcn=new SaturationFcn();
17  pFcn->set_data(N,charge_ptr,adc_ptr);
18  std::vector<double> par(4,0);
19  std::vector<double> err(4,0);
20  //printf(" about to fill pars \n");
21  par[0]=pFcn->x0start;
22  par[1]=pFcn->x1start;
23  par[2]=pFcn->x2start;
24  par[3]=pFcn->x3start;
25  //printf(" pars: %f %f %f %f \n",par[0],par[1],par[2],par[3]);
26  err[0]=20.0;
27  err[1]=0.0001;
28  err[2]=1.0;
29  err[3]=20.0;
30  FunctionMinimum fmin = pMinimizer->Minimize(*pFcn, par, err, 1, 5000, 0.01);
31  if( !fmin.IsValid()){
32  printf(" minuit did not converge \n");
33  } else {
34  std::cout<<"fit succeeded... results: "<<fmin<<std::endl;
35  chisq = fmin.Fval();
36  u[0] = fmin.UserParameters().Value( static_cast<unsigned int>(0) );
37  *u0_ptr=u[0];
38  sigma[0] = fmin.UserParameters().Error( static_cast<unsigned int>(0) );
39  u[1] = fmin.UserParameters().Value( static_cast<unsigned int>(1) );
40  *u1_ptr=u[1];
41  sigma[1] = fmin.UserParameters().Error( static_cast<unsigned int>(1) );
42  u[2] = fmin.UserParameters().Value( static_cast<unsigned int>(2) );
43  *u2_ptr=u[2];
44  sigma[2] = fmin.UserParameters().Error( static_cast<unsigned int>(2) );
45  u[3] = fmin.UserParameters().Value( static_cast<unsigned int>(3) );
46  *u3_ptr=u[3];
47  sigma[3] = fmin.UserParameters().Error( static_cast<unsigned int>(3) );
48  //std::cout<<"fitresults: "<<u[0]<<" "<<u[1]<<" "<<u[2]<<" "<<u[3]<<std::endl;
49 
50  }
51  }
void set_data(int N, float *charge_ptr, float *adc_ptr)
Definition: SaturationFcn.h:16
#define N
Definition: blowfish.cc:9
SaturationFit::~SaturationFit ( )
inline

Definition at line 53 of file SaturationFit.h.

53 {}