]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added methods for chi2 calculation
authorpavlinov <pavlinov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Apr 2010 03:51:08 +0000 (03:51 +0000)
committerpavlinov <pavlinov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 14 Apr 2010 03:51:08 +0000 (03:51 +0000)
EMCAL/AliEMCALRawUtils.cxx
EMCAL/AliEMCALRawUtils.h

index b06aaab6b7ad0e77615256cb007e17413b45ac8a..9d8b03099e5548c4868eb0f56542127b00e3d369 100644 (file)
@@ -837,6 +837,40 @@ Bool_t AliEMCALRawUtils::RawSampledResponse(const Double_t dtime, const Double_t
   return lowGain ; 
 }
 
+void AliEMCALRawUtils::CalculateChi2(const Double_t* t, const Double_t* y, const Int_t nPoints, 
+const Double_t sig, const Double_t tau, const Double_t amp, const Double_t t0, Double_t &chi2)
+{
+  //   Input:
+  //   t[]   - array of time bins
+  //   y[]   - array of amplitudes after pedestal subtractions;
+  //   nPoints  - number of points 
+  //   sig   - error of amplitude measurement (one value for all channels)
+  //           if sig<0 that mean sig=1.
+  //   tau   - filter time response (in timebin units)
+  //   amp   - amplitude at t0;
+  //   t0    - time of max amplitude; 
+  // Output:
+  //   chi2 - chi2
+  //   ndf = nPoints - 2 when tau fixed 
+  //   ndf = nPoints - 3 when tau free
+  static Double_t par[5]={0.0, 0.0, 0.0, 2.0, 0.0};
+
+  par[0] = amp;
+  par[1] = t0;
+  par[2] = tau;
+  // par[3]=n=2.; par[4]=ped=0.0
+
+  Double_t dy = 0.0, x = 0.0, f=0.0;
+  for(Int_t i=0; i<nPoints; i++){
+    x     = t[i];
+    f     = RawResponseFunction(&x, par);
+    dy    = y[i] - f;
+    chi2 += dy*dy;
+    printf(" AliEMCALRawUtils::CalculateChi2 : %i : y %f -> f %f : dy %f \n", i, y[i], f, dy); 
+  }
+  if(sig>0.0) chi2 /= (sig*sig);
+}
+
 //__________________________________________________________________
 void AliEMCALRawUtils::SetFittingAlgorithm(Int_t fitAlgo)              
 {
index b04a12938f21bf1162cae505a4598db01bf66963..cab4a88eaaacb98ac8eb812831b32d16f003b5f7 100644 (file)
@@ -95,6 +95,8 @@ class AliEMCALRawUtils : public TObject {
   static Double_t RawResponseFunctionLog(Double_t *x, Double_t *par); 
   Bool_t   RawSampledResponse(Double_t dtime, Double_t damp, Int_t * adcH, Int_t * adcL, const Int_t keyErr=0) const;  
 
+  static void CalculateChi2(const Double_t* t,const Double_t* y,const Int_t nPoints, 
+                           const Double_t sig, const Double_t tau, const Double_t amp, const Double_t t0, Double_t &chi2);
 
  private:
   Double_t fHighLowGainFactor ;         // high to low gain factor for the raw RO signal