// ------------------------------------------------------
//
-#include <TH3F.h>
-#include <TH2F.h>
+#include <TDirectory.h>
#include <TH1F.h>
+#include <TH2F.h>
+#include <TH3F.h>
#include <TString.h>
+#include <TMath.h>
#include <AliLog.h>
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)
fhGene = (TH3F*)hBinning->Clone("generated");
fhCorr = (TH3F*)hBinning->Clone("correction");
- fhMeas->SetTitle(Form("%s measured",title) );
- fhGene->SetTitle(Form("%s generated",title ));
- fhCorr->SetTitle(Form("%s correction",title));
+ fhMeas->SetTitle(Form("%s measured", GetTitle()));
+ fhGene->SetTitle(Form("%s generated", GetTitle()));
+ fhCorr->SetTitle(Form("%s correction", GetTitle()));
fhMeas->Reset();
fhGene->Reset();
}
//____________________________________________________________________
-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()->SetRange(0, 0);
+ fhMeas->GetYaxis()->SetRange(0, 0);
+ fhMeas->GetZaxis()->SetRange(0, 0);
+
+ 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")) {
Int_t bMin = fhMeas->GetZaxis()->FindBin(aMin);
Int_t bMax = fhMeas->GetZaxis()->FindBin(aMax);
- fhMeas->GetZaxis()->SetRange(bMin, bMax);
+ fhGene->GetZaxis()->SetRange(bMin, bMax);
+ fhMeas->GetZaxis()->SetRange(bMin, bMax);
}
else if (option.Contains("xz") || option.Contains("zx")) {
Int_t bMin = fhMeas->GetYaxis()->FindBin(aMin);
Int_t bMax = fhMeas->GetYaxis()->FindBin(aMax);
- fhMeas->GetYaxis()->SetRange(bMin, bMax);
+ fhGene->GetYaxis()->SetRange(bMin, bMax);
+ fhMeas->GetYaxis()->SetRange(bMin, bMax);
}
else if (option.Contains("yz") || option.Contains("zy")) {
Int_t bMin = fhMeas->GetXaxis()->FindBin(aMin);
Int_t bMax = fhMeas->GetXaxis()->FindBin(aMax);
- fhMeas->GetXaxis()->SetRange(bMin, bMax);
+ fhGene->GetXaxis()->SetRange(bMin, bMax);
+ fhMeas->GetXaxis()->SetRange(bMin, bMax);
}
else {
AliDebug(AliLog::kWarning, Form("WARNING: unknown projection option %s", opt));
return 0;
}
}
+
AliCorrectionMatrix2D* corr2D = new AliCorrectionMatrix2D(Form("%s_%s",GetName(),opt),Form("%s projection %s",GetName(),opt),100,0,100,100,0,100);
- TH2F* meas = (TH2F*) ((TH3F*)fhMeas)->Project3D(opt);
- TH2F* gene = (TH2F*) ((TH3F*)fhGene)->Project3D(opt);
+ 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("corr");
+ TH2F* corr = (TH2F*)gene->Clone(Form("%s_corr", corr2D->GetName()));
corr->Reset();
corr2D->SetGeneratedHistogram(gene);
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;
- if (strcmp(opt,"x")==0) {
- corr2D = Get2DCorrection("xy",aMin1,aMax1);
- return corr2D->Get1DCorrectionHistogram("x",aMin2,aMax2);
+ AliCorrectionMatrix2D* corr2D = 0;
+ if (strcmp(opt,"x")==0) {
+ corr2D = Get2DCorrection("yx",aMin2,aMax2);
+ return corr2D->Get1DCorrectionHistogram("x",aMin1,aMax1);
}
if (strcmp(opt,"y")==0) {
- corr2D = Get2DCorrection("xy",aMin1,aMax1);
- return corr2D->Get1DCorrectionHistogram("y",aMin2,aMax2);
+ corr2D = Get2DCorrection("xy",aMin2,aMax2);
+ return corr2D->Get1DCorrectionHistogram("x",aMin1,aMax1);
}
if (strcmp(opt,"z")==0) {
- corr2D = Get2DCorrection("yz",aMin1,aMax1);
+ 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);
}
//____________________________________________________________________
// counts the number of empty Bins in a given region
//
- TH3F* hist = GetGeneratedHistogram();
+ TH3* hist = GetGeneratedHistogram();
if (!hist)
return -1;
}
//____________________________________________________________________
-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)