change chi2 calculation + minor changes
authorrvernet <rvernet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 10 Jun 2009 16:17:13 +0000 (16:17 +0000)
committerrvernet <rvernet@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 10 Jun 2009 16:17:13 +0000 (16:17 +0000)
CORRFW/AliCFUnfolding.cxx
CORRFW/AliCFUnfolding.h

index 2665d9d..d783fe8 100644 (file)
@@ -272,12 +272,8 @@ void AliCFUnfolding::CreateEstMeasured() {
 
 
   // clean the measured estimate spectrum
-  for (Long_t i=0; i<fMeasuredEstimate->GetNbins(); i++) {
-    fMeasuredEstimate->GetBinContent(i,fCoordinatesN_M);
-    fMeasuredEstimate->SetBinContent(fCoordinatesN_M,0.);
-    fMeasuredEstimate->SetBinError  (fCoordinatesN_M,0.);
-  }
-  
+  fMeasuredEstimate->Reset();
+
   THnSparse* priorTimesEff = (THnSparse*) fPrior->Clone();
   priorTimesEff->Multiply(fEfficiency);
 
@@ -359,7 +355,7 @@ void AliCFUnfolding::Unfold() {
     CreateInvResponse();
     CreateUnfolded();
     chi2 = GetChi2();
-    AliDebug(1,Form("Chi2 at iteration %d is %e",iIterBayes,chi2));
+    AliDebug(0,Form("Chi2 at iteration %d is %e",iIterBayes,chi2));
     if (fMaxChi2>0. && chi2<fMaxChi2) {
       break;
     }
@@ -387,11 +383,7 @@ void AliCFUnfolding::CreateUnfolded() {
 
 
   // clear the unfolded spectrum
-  for (Long_t i=0; i<fUnfolded->GetNbins(); i++) {
-    fUnfolded->GetBinContent(i,fCoordinatesN_T);
-    fUnfolded->SetBinContent(fCoordinatesN_T,0.);
-    fUnfolded->SetBinError  (fCoordinatesN_T,0.);
-  }
+  fUnfolded->Reset();
   
   for (Long_t iBin=0; iBin<fInverseResponse->GetNbins(); iBin++) {
     Double_t invResponseValue = fInverseResponse->GetBinContent(iBin,fCoordinates2N);
@@ -475,9 +467,9 @@ Double_t AliCFUnfolding::GetChi2() {
 
   Double_t chi2 = 0. ;
   for (Long_t iBin=0; iBin<fPrior->GetNbins(); iBin++) {
-    Double_t priorValue = fPrior->GetBinContent(iBin);
-//     chi2 += (priorValue>0. ? TMath::Power(fUnfolded->GetBinContent(iBin) - priorValue,2) / priorValue : 0.) ;
-    chi2 += (fUnfolded->GetBinError(iBin)>0. ? TMath::Power((fUnfolded->GetBinContent(iBin) - priorValue)/fUnfolded->GetBinError(iBin),2) / priorValue : 0.) ;
+    Double_t priorValue = fPrior->GetBinContent(iBin,fCoordinatesN_T);
+    Double_t error_unf  = fUnfolded->GetBinError(fCoordinatesN_T);
+    chi2 += (error_unf > 0. ? TMath::Power((fUnfolded->GetBinContent(fCoordinatesN_T) - priorValue)/error_unf,2) / priorValue : 0.) ;
   }
   return chi2;
 }
index 5a2a091..1bcbaa6 100644 (file)
@@ -45,6 +45,7 @@ class AliCFUnfolding : public TNamed {
   THnSparse* GetEfficiency()      const {return fEfficiency;}
   THnSparse* GetUnfolded()        const {return fUnfolded;}
   THnSparse* GetEstMeasured()     const {return fMeasuredEstimate;}
+  THnSparse* GetMeasured()        const {return fMeasured;}
   THnSparse* GetConditional()     const {return fConditional;}
   TF1*       GetSmoothFunction()  const {return fSmoothFunction;}