CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/OnlineDB/CSCCondDB/src/CSCThrTurnOnFcn.cc

Go to the documentation of this file.
00001 #include <OnlineDB/CSCCondDB/interface/CSCThrTurnOnFcn.h>
00002 #include <FWCore/MessageLogger/interface/MessageLogger.h>
00003 #include <cmath>
00004 #include <iostream>
00005 #include <vector>
00006 #include "TMath.h"
00007 
00008 double CSCThrTurnOnFcn::operator()
00009 (const std::vector<double>& par) const {
00010   
00011   double x,y,er,fn;
00012   double N=norm;
00013   double chi2 = 0.;
00014 
00015   int size=xdata.size();
00016   for(int i = 0; i < size; ++i) {
00017     x=xdata[i]; 
00018     y=ydata[i]; 
00019     er=ery[i];
00020 
00021     fn=(x-par[0])/(par[1]*1.4142);
00022     fn=N * (1.- TMath::Erf(fn))/2.;
00023 
00024     double diff = y-fn;
00025     chi2 += diff*diff / (er*er);
00026 
00027     //    std::cout<<"CSC AFEB threshold fit "<<i+1<<" "<<x<<" "<<y<<" "
00028     //                   <<er<<" "<<fn<<" "<<chi2<<" "
00029     //                   <<par[0]<<" "<<par[1]<<"\n";
00030 
00031     LogDebug("CSC")<<" AFEB threshold fit "<<i+1<<" "<<x<<" "<<y<<" "
00032                    <<er<<" "<<fn<<" "<<chi2<<" "
00033                    <<par[0]<<" "<<par[1]<<"\n";
00034   }
00035   //  std::cout<<"Chi2 "<<chi2<<std::endl;
00036   return chi2;
00037 }