CMS 3D CMS Logo

SaturationFcn.h

Go to the documentation of this file.
00001 #ifndef SaturationFcn_h
00002 #define SaturationFcn_h
00003                                                                
00004 #include "Minuit2/FCNBase.h"  
00005 #include <vector>
00006 
00007 using namespace ROOT::Minuit2;
00008 
00009 class SaturationFcn : public FCNBase{ 
00010 
00011  public:
00012 
00013  SaturationFcn(){}
00014 
00015  ~SaturationFcn(){}
00016 
00017 
00018  void set_data(int N,float *charge_ptr,float *adc_ptr){
00019  
00020    float x[20],y[20];
00021 
00022    for(int i=0;i<N;i++){
00023      x[i]=charge_ptr[i];
00024      y[i]=adc_ptr[i];
00025      datx[i]=x[i];
00026      daty[i]=y[i];
00027      //printf("%d  datx daty %f %f \n",i,datx[i],daty[i]);
00028    }
00029 
00030    x3start=(y[4]*x[1]-y[1]*x[4])/(x[1]-x[4]);
00031    x0start=daty[13]-x3start;
00032    x1start=(y[4]-y[1])/(x[4]-x[1])/x0start;
00033    x2start=20.;
00034    //printf(" x0-2start %f %f %f %f\n",x0start,x1start,x2start,x3start);
00035  }
00036  
00037  virtual double Up() const {return 1.;}
00038  
00039  virtual double operator()(const std::vector<double>& x) const {
00040    double chisq = 0.0;  
00041    int N=20;
00042   for(int i=0;i<N;i++){
00043     double val=1.0+pow(x[1]*datx[i],x[2]);
00044     double val2=1.0/x[2];
00045     val=x[0]*x[1]*datx[i]/pow(val,val2);
00046     double tmp=(daty[i]-x[3]-val);
00047     //printf(" dat: %d %f %f %f %f \n",i,datx[i],daty[i]-x[3],val,tmp);
00048     chisq=chisq+tmp*tmp;
00049   }
00050   //printf("x0-3 %f %f %f %f chisq %f \n",x[0],x[1],x[2],x[3],chisq);
00051   return chisq; 
00052  }
00053 
00054  double x0start;
00055  double x1start;
00056  double x2start;
00057  double x3start;
00058  
00059  private:
00060  double datx[20],daty[20];
00061 }; 
00062 
00063 #endif

Generated on Tue Jun 9 17:40:41 2009 for CMSSW by  doxygen 1.5.4