]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG0/AliCorrectionMatrix3D.cxx
warning fixes
[u/mrichter/AliRoot.git] / PWG0 / AliCorrectionMatrix3D.cxx
index b953f3b89909cece7c5b4e8edee3de424c8a32b8..f4ee9fceb2afe0d3a5eddc378f0ce63290e23b6f 100644 (file)
@@ -12,6 +12,7 @@
 #include <TH2F.h>
 #include <TH3F.h>
 #include <TString.h>
+#include <TMath.h>
 
 #include <AliLog.h>
 
@@ -100,7 +101,7 @@ AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* t
   delete[] binLimitsY;
 }
 
-AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title, TH3F* hBinning)
+AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title, TH3* hBinning)
   : AliCorrectionMatrix(name, title)
 {
   // constructor with variable bin sizes (uses binning of hBinning)
@@ -162,41 +163,41 @@ AliCorrectionMatrix3D::~AliCorrectionMatrix3D()
 }
 
 //____________________________________________________________________
-TH3F* AliCorrectionMatrix3D::GetGeneratedHistogram()
+TH3* AliCorrectionMatrix3D::GetGeneratedHistogram()
 {
   // return generated histogram casted to correct type
   return dynamic_cast<TH3F*> (fhGene);
 }
 
 //____________________________________________________________________
-TH3F* AliCorrectionMatrix3D::GetMeasuredHistogram()
+TH3* AliCorrectionMatrix3D::GetMeasuredHistogram()
 {
   // return measured histogram casted to correct type
   return dynamic_cast<TH3F*> (fhMeas);
 }
 
 //____________________________________________________________________
-TH3F* AliCorrectionMatrix3D::GetCorrectionHistogram()
+TH3* AliCorrectionMatrix3D::GetCorrectionHistogram()
 {
   // return correction histogram casted to correct type
   return dynamic_cast<TH3F*> (fhCorr);
 }
 
 //____________________________________________________________________
-AliCorrectionMatrix2D* AliCorrectionMatrix3D::Get2DCorrection(Char_t* opt, Float_t aMin, Float_t aMax)
+AliCorrectionMatrix2D* AliCorrectionMatrix3D::Get2DCorrection(Option_t* opt, Float_t aMin, Float_t aMax)
 {
   // returns a 2D projection of this correction
 
   TString option = opt;
 
   // unzoom
-  fhMeas->GetXaxis()->UnZoom();
-  fhMeas->GetYaxis()->UnZoom();
-  fhMeas->GetZaxis()->UnZoom();
+  fhMeas->GetXaxis()->SetRange(0, 0);
+  fhMeas->GetYaxis()->SetRange(0, 0);
+  fhMeas->GetZaxis()->SetRange(0, 0);
 
-  fhGene->GetXaxis()->UnZoom();
-  fhGene->GetYaxis()->UnZoom();
-  fhGene->GetZaxis()->UnZoom();
+  fhGene->GetXaxis()->SetRange(0, 0);
+  fhGene->GetYaxis()->SetRange(0, 0);
+  fhGene->GetZaxis()->SetRange(0, 0);
 
   if (aMin<aMax) {
     if (option.Contains("xy") || option.Contains("yx")) {
@@ -227,6 +228,14 @@ AliCorrectionMatrix2D* AliCorrectionMatrix3D::Get2DCorrection(Char_t* opt, Float
 
   TH2F* meas = (TH2F*) ((TH3F*)fhMeas)->Project3D(option)->Clone(Form("%s_meas", corr2D->GetName()));
   TH2F* gene = (TH2F*) ((TH3F*)fhGene)->Project3D(option)->Clone(Form("%s_gene", corr2D->GetName()));
+  
+  // set errors
+  for (Int_t x = 0; x<=meas->GetNbinsX()+1; x++)
+    for (Int_t y = 0; y<=meas->GetNbinsY()+1; y++)
+    {
+      gene->SetBinError(x, y, TMath::Sqrt(gene->GetBinContent(x, y)));
+      meas->SetBinError(x, y, TMath::Sqrt(meas->GetBinContent(x, y)));
+    }
 
   TH2F* corr = (TH2F*)gene->Clone(Form("%s_corr", corr2D->GetName()));
   corr->Reset();
@@ -238,53 +247,52 @@ AliCorrectionMatrix2D* AliCorrectionMatrix3D::Get2DCorrection(Char_t* opt, Float
   corr2D->Divide();
 
   // unzoom
-  fhMeas->GetXaxis()->UnZoom();
-  fhMeas->GetYaxis()->UnZoom();
-  fhMeas->GetZaxis()->UnZoom();
+  fhMeas->GetXaxis()->SetRange(0, 0);
+  fhMeas->GetYaxis()->SetRange(0, 0);
+  fhMeas->GetZaxis()->SetRange(0, 0);
 
-  fhGene->GetXaxis()->UnZoom();
-  fhGene->GetYaxis()->UnZoom();
-  fhGene->GetZaxis()->UnZoom();
+  fhGene->GetXaxis()->SetRange(0, 0);
+  fhGene->GetYaxis()->SetRange(0, 0);
+  fhGene->GetZaxis()->SetRange(0, 0);
 
   return corr2D;
 }
 
 //____________________________________________________________________
-TH1F* AliCorrectionMatrix3D::Get1DCorrectionHistogram(Char_t* opt, Float_t aMin1, Float_t aMax1, Float_t aMin2, Float_t aMax2)
+TH1* AliCorrectionMatrix3D::Get1DCorrectionHistogram(Option_t* opt, Float_t aMin1, Float_t aMax1, Float_t aMin2, Float_t aMax2)
 {
   // returns a 1D projection of this correction
-  AliDebug(AliLog::kWarning, Form("WARNING: test"));
   
-  AliCorrectionMatrix2D* corr2D;
+  AliCorrectionMatrix2D* corr2D = 0;
   if (strcmp(opt,"x")==0) {
-    corr2D = Get2DCorrection("yx",aMin1,aMax1);
-    return corr2D->Get1DCorrectionHistogram("x",aMin2,aMax2);
+    corr2D = Get2DCorrection("yx",aMin2,aMax2);
+    return corr2D->Get1DCorrectionHistogram("x",aMin1,aMax1);
   }
   if (strcmp(opt,"y")==0) {
-    corr2D = Get2DCorrection("xy",aMin1,aMax1);
-    return corr2D->Get1DCorrectionHistogram("x",aMin2,aMax2);
+    corr2D = Get2DCorrection("xy",aMin2,aMax2);
+    return corr2D->Get1DCorrectionHistogram("x",aMin1,aMax1);
   }  
   if (strcmp(opt,"z")==0) {
     corr2D = Get2DCorrection("yz",aMin1,aMax1);
     return corr2D->Get1DCorrectionHistogram("x",aMin2,aMax2);
   }  
-  AliDebug(AliLog::kWarning, Form("WARNING: unknown projection option %s (should be x,y or z)", opt));  
+  AliDebug(AliLog::kWarning, Form("WARNING: unknown projection option %s (should be x,y or z)", opt));
   
   return 0;
 }
 
 //____________________________________________________________________
-void AliCorrectionMatrix3D::FillMeas(Float_t ax, Float_t ay, Float_t az)
+void AliCorrectionMatrix3D::FillMeas(Float_t ax, Float_t ay, Float_t az, Double_t weight)
 {
   // add value to measured histogram
-  GetMeasuredHistogram()->Fill(ax, ay, az);
+  GetMeasuredHistogram()->Fill(ax, ay, az, weight);
 }
 
 //____________________________________________________________________
-void AliCorrectionMatrix3D::FillGene(Float_t ax, Float_t ay, Float_t az)
+void AliCorrectionMatrix3D::FillGene(Float_t ax, Float_t ay, Float_t az, Double_t weight)
 {
   // add value to generated histogram
-  GetGeneratedHistogram()->Fill(ax, ay, az);
+  GetGeneratedHistogram()->Fill(ax, ay, az, weight);
 }
 
 //____________________________________________________________________
@@ -327,7 +335,7 @@ Int_t AliCorrectionMatrix3D::CheckEmptyBins(Float_t xmin, Float_t xmax, Float_t
   // counts the number of empty Bins in a given region
   //
 
-  TH3F* hist = GetGeneratedHistogram();
+  TH3* hist = GetGeneratedHistogram();
   if (!hist)
     return -1;
 
@@ -346,16 +354,16 @@ Int_t AliCorrectionMatrix3D::CheckEmptyBins(Float_t xmin, Float_t xmax, Float_t
 }
 
 //____________________________________________________________________
-TH1F* AliCorrectionMatrix3D::PlotBinErrors(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
+TH1* AliCorrectionMatrix3D::PlotBinErrors(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
 {
   //
   // makes a 1d plots of the relative bin errors
   //
 
-  TH3F* hist = GetCorrectionHistogram();
+  TH3* hist = GetCorrectionHistogram();
   if (!hist)
     return 0;
-    
+
   TH1F* target = new TH1F("relerrors", "relerrors", 100, 0, 10);
 
   for (Int_t x=hist->GetXaxis()->FindBin(xmin); x<=hist->GetXaxis()->FindBin(xmax); ++x)