//
#include <TH2F.h>
+#include <TMath.h>
#include <AliLog.h>
// histograms already deleted in base class
}
-TH2F* AliCorrectionMatrix2D::GetGeneratedHistogram() const
+TH2* AliCorrectionMatrix2D::GetGeneratedHistogram() const
{
// return generated histogram casted to correct type
- return dynamic_cast<TH2F*> (fhGene);
+ return dynamic_cast<TH2*> (fhGene);
}
-TH2F* AliCorrectionMatrix2D::GetMeasuredHistogram() const
+TH2* AliCorrectionMatrix2D::GetMeasuredHistogram() const
{
// return measured histogram casted to correct type
- return dynamic_cast<TH2F*> (fhMeas);
+ return dynamic_cast<TH2*> (fhMeas);
}
//____________________________________________________________________
-TH1F* AliCorrectionMatrix2D::Get1DCorrectionHistogram(Char_t* opt, Float_t min, Float_t max)
+TH1* AliCorrectionMatrix2D::Get1DCorrectionHistogram(const Char_t* opt, Float_t min, Float_t max, Bool_t binomialErrors)
{
//
// integrate the correction over one variable
else {
Printf("Getting 1D map. Including y-bins %d to %d", binMin, binMax);
- meas1D = ((TH2F*)fhMeas)->ProjectionX(Form("%s_pm", GetName()),binMin,binMax);
- gene1D = ((TH2F*)fhGene)->ProjectionX(Form("%s_pg", GetName()),binMin,binMax);
+ meas1D = ((TH2F*)fhMeas)->ProjectionX(Form("%s_x_pm", GetName()),binMin,binMax);
+ gene1D = ((TH2F*)fhGene)->ProjectionX(Form("%s_x_pg", GetName()),binMin,binMax);
}
}
- if (strcmp(opt,"y")==0) {
+ else if (strcmp(opt,"y")==0) {
Int_t binMin = fhMeas->GetXaxis()->FindBin(min);
Int_t binMax = fhMeas->GetXaxis()->FindBin(max);
gene1D = ((TH2F*)fhGene)->ProjectionY();
}
else {
- AliDebug(AliLog::kDebug+1, Form("Getting 1D map. Including x-bins %d to %d \n", binMin, binMax));
+ Printf("Getting 1D map. Including x-bins %d to %d \n", binMin, binMax);
- meas1D = ((TH2F*)fhMeas)->ProjectionY(Form("%s_pm", GetName()), binMin, binMax);
- gene1D = ((TH2F*)fhGene)->ProjectionY(Form("%s_pg", GetName()), binMin, binMax);
+ meas1D = ((TH2F*)fhMeas)->ProjectionY(Form("%s_y_pm", GetName()), binMin, binMax);
+ gene1D = ((TH2F*)fhGene)->ProjectionY(Form("%s_y_pg", GetName()), binMin, binMax);
}
}
- gene1D->Sumw2();
+ else {
+ Printf("ERROR: Invalid option");
+ return 0;
+ }
+ if (!binomialErrors)
+ {
+ // set the errors on gene manually, and clear the ones on meas.
+ gene1D->Sumw2();
+ for (Int_t bin=0; bin <= gene1D->GetNbinsX()+1; bin++)
+ {
+ gene1D->SetBinError(bin, TMath::Sqrt(gene1D->GetBinContent(bin)));
+ meas1D->SetBinError(bin, 0);
+ }
+ }
+
gene1D->SetName(Form("corr_1D_%s",fName.Data()));
gene1D->SetTitle(Form("corr_1D_%s",fName.Data()));
+
+ TH1* divided = (TH1*) gene1D->Clone(Form("corr_1D_%s",fName.Data()));
+ divided->Reset();
+
+ divided->Divide(gene1D, meas1D, 1, 1, (binomialErrors) ? "B" : "");
- gene1D->Divide(gene1D, meas1D, 1, 1, "B");
+ Printf("%p %p", gene1D, meas1D);
- return (TH1F*)gene1D;
+ return (TH1F*)divided;
}
//____________________________________________________________________
}
+//____________________________________________________________________
+void AliCorrectionMatrix2D::Rebin(Int_t x, Int_t y)
+{
+ // rebins the histograms, recalculates the correction
+
+ GetGeneratedHistogram()->Rebin2D(x, y);
+ GetMeasuredHistogram()->Rebin2D(x, y);
+ GetCorrectionHistogram()->Rebin2D(x, y);
+ Divide();
+}