]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - CORRFW/AliCFUnfolding.cxx
suppressed ROOT warnings while building
[u/mrichter/AliRoot.git] / CORRFW / AliCFUnfolding.cxx
index 2665d9d1ee8082fdf0bc9a055b61b59eb09ddd08..fc24e653b6e3c074a7422122a81f8bf818656d32 100644 (file)
@@ -28,7 +28,8 @@
 // At each iteration, an inverse response matrix is calculated, given  //
 // the measured spectrum, the a priori (guessed) spectrum,             //
 // the efficiency spectrum and the response matrix.                    //
-// For each iteration, the unfolded spectrum is calculated using       //
+//                                                                     //
+// Then at each iteration, the unfolded spectrum is calculated using   //
 // the inverse response : the goal is to get an unfolded spectrum      //
 // similar (according to some criterion) to the a priori one.          //
 // If the difference is too big, another iteration is performed :      //
 // If no argument is passed to this function, then the second option   //
 // is used.                                                            //
 //                                                                     //
+// IMPORTANT:                                                          //
+//-----------                                                          //
+// With this approach, the efficiency map must be calculated           //
+// with *simulated* values only, otherwise the method won't work.      //
+//                                                                     //
+// ex: efficiency(bin_pt) = number_rec(bin_pt) / number_sim(bin_pt)    //
+//                                                                     //
+// the pt bin "bin_pt" must always be the same in both the efficiency  //
+// numerator and denominator.                                          //
+// This is why the efficiency map has to be created by a method        //
+// from which both reconstructed and simulated values are accessible   //
+// simultaneously.                                                     //
+//                                                                     //
+//                                                                     //
 //---------------------------------------------------------------------//
 // Author : renaud.vernet@cern.ch                                      //
 //---------------------------------------------------------------------//
@@ -272,12 +287,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 +370,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 +398,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 +482,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;
 }