--- /dev/null
+/* $Id$ */
+
+// ------------------------------------------------------
+//
+// Class to handle corrections.
+//
+// ------------------------------------------------------
+//
+
+#include <TFile.h>
+#include <TCanvas.h>
+#include <TH2F.h>
+
+#include <AliLog.h>
+#include "AliCorrectionMatrix2D.h"
+#include "AliCorrectionMatrix3D.h"
+
+#include "AliCorrection.h"
+
+//____________________________________________________________________
+ClassImp(AliCorrection)
+
+//____________________________________________________________________
+AliCorrection::AliCorrection() : TNamed(),
+ fEventCorr(0),
+ fTrackCorr(0)
+{
+ // default constructor
+}
+
+//____________________________________________________________________
+AliCorrection::AliCorrection(const Char_t* name, const Char_t* title) : TNamed(name, title),
+ fEventCorr(0),
+ fTrackCorr(0)
+{
+ // constructor initializing tnamed
+
+ Float_t binLimitsPt[] = {0.0, 0.05, 0.1, 0.125, 0.15, 0.175, 0.2, 0.225, 0.25, 0.275, 0.3, 0.325, 0.35, 0.375, 0.4, 0.425, 0.45, 0.475, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.5, 2.0, 5.0, 10.0, 100.0};
+ Float_t binLimitsN[] = {-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 12.5, 14.5, 16.5, 18.5, 20.5, 25.5, 30.5, 40.5, 50.5, 100.5, 300.5};
+ //Float_t binLimitsVtx[] = {-20,-15,-10,-6,-3,0,3,6,10,15,20};
+ Float_t binLimitsVtx[] = {-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
+
+ fEventCorr = new AliCorrectionMatrix2D("EventCorrection", Form("%s EventCorrection", title), 40, binLimitsVtx, 22, binLimitsN);
+ fTrackCorr = new AliCorrectionMatrix3D("TrackCorrection", Form("%s TrackCorrection", title), 40, -20, 20, 20, -2, 2, 28, binLimitsPt);
+
+ fEventCorr->SetAxisTitles("vtx z [cm]", "Ntracks");
+ fTrackCorr->SetAxisTitles("vtx z [cm]", "#eta", "p_{T} [GeV/c]");
+}
+
+//____________________________________________________________________
+AliCorrection::AliCorrection(const AliCorrection& c) : TNamed(c),
+ fEventCorr(0),
+ fTrackCorr(0)
+{
+ // copy constructor
+ ((AliCorrection &)c).Copy(*this);
+}
+
+//____________________________________________________________________
+AliCorrection::~AliCorrection()
+{
+ //
+ // destructor
+ //
+
+ if (fEventCorr)
+ {
+ delete fEventCorr;
+ fEventCorr = 0;
+ }
+
+ if (fTrackCorr)
+ {
+ delete fTrackCorr;
+ fTrackCorr = 0;
+ }
+}
+
+//____________________________________________________________________
+AliCorrection &AliCorrection::operator=(const AliCorrection &c)
+{
+ // assigment operator
+
+ if (this != &c)
+ ((AliCorrection &) c).Copy(*this);
+
+ return *this;
+}
+
+//____________________________________________________________________
+void AliCorrection::Copy(TObject& c) const
+{
+ // copy function
+
+ AliCorrection& target = (AliCorrection &) c;
+
+ if (fEventCorr)
+ target.fEventCorr = dynamic_cast<AliCorrectionMatrix2D*> (fEventCorr->Clone());
+
+ if (fTrackCorr)
+ target.fTrackCorr = dynamic_cast<AliCorrectionMatrix3D*> (fTrackCorr->Clone());
+}
+
+//____________________________________________________________________
+Long64_t AliCorrection::Merge(TCollection* list)
+{
+ // Merge a list of AliCorrection objects with this (needed for
+ // PROOF).
+ // Returns the number of merged objects (including this).
+
+ if (!list)
+ return 0;
+
+ if (list->IsEmpty())
+ return 1;
+
+ TIterator* iter = list->MakeIterator();
+ TObject* obj;
+
+ // collections of measured and generated histograms
+ TList* collectionEvent = new TList;
+ TList* collectionTrack = new TList;
+
+ Int_t count = 0;
+ while ((obj = iter->Next())) {
+
+ AliCorrection* entry = dynamic_cast<AliCorrection*> (obj);
+ if (entry == 0)
+ continue;
+
+ collectionEvent->Add(entry->fEventCorr);
+ collectionTrack->Add(entry->fTrackCorr);
+
+ count++;
+ }
+ fEventCorr->Merge(collectionEvent);
+ fTrackCorr->Merge(collectionTrack);
+
+ delete collectionEvent;
+ delete collectionTrack;
+
+ return count+1;
+}
+
+//____________________________________________________________________
+void AliCorrection::Divide()
+{
+ //
+ // divide the histograms to get the correction
+ //
+
+ if (!fEventCorr || !fTrackCorr)
+ return;
+
+ fEventCorr->Divide();
+ fTrackCorr->Divide();
+
+ Int_t emptyBins = fTrackCorr->CheckEmptyBins(-9.99, 9.99, -0.79, 0.79, 0.3, 9.9);
+ printf("INFO: In the central region the track correction of %s has %d empty bins\n", GetName(), emptyBins);
+}
+
+//____________________________________________________________________
+Bool_t AliCorrection::LoadHistograms(const Char_t* dir)
+{
+ //
+ // loads the histograms from a file
+ // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
+ //
+
+ if (!fEventCorr || !fTrackCorr)
+ return kFALSE;
+
+ if (!dir)
+ dir = GetName();
+
+ if (!gDirectory->cd(dir))
+ return kFALSE;
+
+ Bool_t success = fEventCorr->LoadHistograms();
+ success &= fTrackCorr->LoadHistograms();
+
+ gDirectory->cd("..");
+
+ return success;
+}
+
+//____________________________________________________________________
+void AliCorrection::SaveHistograms()
+{
+ //
+ // saves the histograms in a directory with the name of this object (GetName)
+ //
+
+ gDirectory->mkdir(GetName());
+ gDirectory->cd(GetName());
+
+ if (fEventCorr)
+ fEventCorr->SaveHistograms();
+
+ if (fTrackCorr)
+ fTrackCorr->SaveHistograms();
+
+ gDirectory->cd("..");
+}
+
+//____________________________________________________________________
+void AliCorrection::ReduceInformation()
+{
+ // this function deletes the measured and generated histograms to reduce the amount of data
+ // in memory
+
+ if (!fEventCorr || !fTrackCorr)
+ return;
+
+ fEventCorr->ReduceInformation();
+ fTrackCorr->ReduceInformation();
+}
+
+//____________________________________________________________________
+void AliCorrection::Reset(Option_t* option)
+{
+ // resets the histograms
+
+ if (fEventCorr)
+ fEventCorr->Reset(option);
+
+ if (fTrackCorr)
+ fTrackCorr->Reset(option);
+}
+
+//____________________________________________________________________
+void AliCorrection::DrawHistograms(const Char_t* name)
+{
+ // draws the corrections
+
+ if (!name)
+ name = GetName();
+
+ if (fEventCorr)
+ fEventCorr->DrawHistograms(Form("%s event", name));
+
+ if (fTrackCorr)
+ fTrackCorr->DrawHistograms(Form("%s track", name));
+}
+
+//____________________________________________________________________
+void AliCorrection::SetCorrectionToUnity()
+{
+ // set the corrections to unity
+
+ if (fEventCorr)
+ fEventCorr->SetCorrectionToUnity();
+
+ if (fTrackCorr)
+ fTrackCorr->SetCorrectionToUnity();
+}
+
+//____________________________________________________________________
+void AliCorrection::Multiply()
+{
+ // call Multiply
+
+ if (fEventCorr)
+ {
+ fEventCorr->Multiply();
+ // now we manually copy the overflow bin of the y axis (multiplicity) over. This is important to get the event count correct
+ TH2F* hist = fEventCorr->GetMeasuredHistogram();
+ for (Int_t x = 1; x <= hist->GetNbinsX(); ++x)
+ fEventCorr->GetGeneratedHistogram()->SetBinContent(x, hist->GetNbinsY() + 1, hist->GetBinContent(x, hist->GetNbinsY() + 1));
+ }
+
+ if (fTrackCorr)
+ fTrackCorr->Multiply();
+}
--- /dev/null
+#ifndef ALICORRECTION_H
+#define ALICORRECTION_H
+
+/* $Id$ */
+
+// ------------------------------------------------------
+//
+// This class is used to store the correction for one effect.
+//
+// Most effects have to be correction on track and event level, this class combines
+// two correction matrices. One of the type AliCorrectionMatrix2D and one of
+// the type AliCorrectionMatrix3D
+//
+// ------------------------------------------------------
+
+#include <TNamed.h>
+
+class AliCorrectionMatrix2D;
+class AliCorrectionMatrix3D;
+
+class AliCorrection : public TNamed
+{
+public:
+ AliCorrection();
+ AliCorrection(const Char_t* name, const Char_t* title);
+ AliCorrection(const AliCorrection& c);
+
+ virtual ~AliCorrection();
+ AliCorrection& operator=(const AliCorrection& corr);
+ virtual void Copy(TObject& c) const;
+
+ virtual Long64_t Merge(TCollection* list);
+
+ AliCorrectionMatrix2D* GetEventCorrection() { return fEventCorr; }
+ AliCorrectionMatrix3D* GetTrackCorrection() { return fTrackCorr; }
+
+ void SetEventCorrection(AliCorrectionMatrix2D* corr) { fEventCorr = corr; }
+ void SetTrackCorrection(AliCorrectionMatrix3D* corr) { fTrackCorr = corr; }
+
+ void Divide();
+ void Multiply();
+ void SetCorrectionToUnity();
+
+ virtual Bool_t LoadHistograms(const Char_t* dir = 0);
+ virtual void SaveHistograms();
+ virtual void DrawHistograms(const Char_t* name = 0);
+
+ virtual void ReduceInformation();
+
+ virtual void Reset(Option_t* option = "");
+
+protected:
+ AliCorrectionMatrix2D* fEventCorr; // correction on event level
+ AliCorrectionMatrix3D* fTrackCorr; // correction on track level
+
+ ClassDef(AliCorrection,1)
+};
+
+#endif
+
void AliCorrectionMatrix::Divide()
{
//
- // divide the histograms to get the correction
- //
+ // divides generated by measured to get the correction
+ //
- if (!fhMeas || !fhGene)
+ if (!fhMeas || !fhGene || !fhCorr)
return;
fhCorr->Divide(fhGene, fhMeas, 1, 1, "B");
++emptyBins;
if (emptyBins > 0)
- printf("INFO: In %s we have %d empty bins (of %d) in the correction map\n", GetName(), emptyBins, fhCorr->GetNbinsX() * fhCorr->GetNbinsY() * fhCorr->GetNbinsZ());
+ printf("INFO: In %s we have %d empty bins (of %d) in the correction map\n", GetTitle(), emptyBins, fhCorr->GetNbinsX() * fhCorr->GetNbinsY() * fhCorr->GetNbinsZ());
}
//____________________________________________________________________
-Bool_t AliCorrectionMatrix::LoadHistograms(const Char_t* fileName, const Char_t* dir)
+void AliCorrectionMatrix::Multiply()
+{
+ //
+ // multiplies measured with correction to get the generated
+ //
+
+ if (!fhMeas || !fhGene || !fhCorr)
+ return;
+
+ fhGene->Multiply(fhMeas, fhCorr, 1, 1, "B");
+}
+
+//____________________________________________________________________
+Bool_t AliCorrectionMatrix::LoadHistograms(const Char_t* dir)
{
//
// loads the histograms from a file
+ // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
//
- TFile* fin = TFile::Open(fileName);
+ if (!dir)
+ dir = GetName();
- if(!fin) {
- //Info("LoadHistograms",Form(" %s file does not exist",fileName));
+ if (!gDirectory->cd(dir))
return kFALSE;
+
+ if (fhGene)
+ {
+ delete fhGene;
+ fhGene=0;
}
-
- if(fhGene) {delete fhGene; fhGene=0;}
- if(fhCorr) {delete fhCorr; fhCorr=0;}
- if(fhMeas) {delete fhMeas; fhMeas=0;}
-
- fhMeas = dynamic_cast<TH1*> (fin->Get(Form("%s/meas_%s", dir,GetName())));
- if(!fhMeas) Info("LoadHistograms","No meas. (%s) hist available",Form("%s/meas_%s", dir,GetName()));
- fhGene = dynamic_cast<TH1*> (fin->Get(Form("%s/gene_%s",dir, GetName())));
- if(!fhGene) Info("LoadHistograms","No gene. (%s) hist available",Form("%s/gene_%s",dir, GetName()));
+ if (fhCorr)
+ {
+ delete fhCorr;
+ fhCorr=0;
+ }
- fhCorr = dynamic_cast<TH1*> (fin->Get(Form("%s/corr_%s",dir, GetName())));
- if(!fhCorr) {
- Info("LoadHistograms","No corr.(%s) hist available",Form("%s/corr_%s",dir, GetName()));
- return kFALSE;
+ if (fhMeas)
+ {
+ delete fhMeas;
+ fhMeas=0;
}
-
- return kTRUE;
+
+ fhMeas = dynamic_cast<TH1*> (gDirectory->Get("measured"));
+ if (!fhMeas)
+ Info("LoadHistograms", "No measured hist available");
+
+ fhGene = dynamic_cast<TH1*> (gDirectory->Get("generated"));
+ if (!fhGene)
+ Info("LoadHistograms", "No generated hist available");
+
+ fhCorr = dynamic_cast<TH1*> (gDirectory->Get("correction"));
+
+ Bool_t success = kTRUE;
+ if (!fhCorr)
+ {
+ Info("LoadHistograms", "No correction hist available");
+ success = kFALSE;
+ }
+
+ gDirectory->cd("..");
+
+ return success;
}
//____________________________________________________________________
// saves the histograms
//
+ gDirectory->mkdir(GetName());
+ gDirectory->cd(GetName());
+
if (fhMeas)
fhMeas ->Write();
if (fhCorr)
fhCorr->Write();
+
+ gDirectory->cd("..");
}
//____________________________________________________________________
-void AliCorrectionMatrix::DrawHistograms()
+void AliCorrectionMatrix::DrawHistograms(const Char_t* canvasName)
{
//
- // draws all the four histograms on one TCanvas
+ // draws all histograms on one TCanvas
+ // if canvasName is 0 the name of this object is taken
//
- TCanvas* canvas = new TCanvas(Form("correction_%s",fName.Data()),
- Form("correction_%s",fName.Data()), 800, 800);
- canvas->Divide(2, 2);
+ if (!canvasName)
+ canvasName = Form("%s_canvas", GetName());
+
+ TCanvas* canvas = new TCanvas(canvasName, GetTitle(), 1200, 400);
+ canvas->Divide(3, 1);
canvas->cd(1);
if (fhMeas)
fhMeas->Draw("COLZ");
-
+
canvas->cd(2);
if (fhGene)
+ {
+ // work around ROOT bug #22011
+ if (fhGene->GetEntries() == 0)
+ fhGene->SetEntries(1);
fhGene->Draw("COLZ");
+ }
canvas->cd(3);
if (fhCorr)
fhCorr->Draw("COLZ");
-
- canvas->cd(4);
-
- // add: draw here the stat. errors of the correction histogram
}
//____________________________________________________________________
if (fhCorr)
fhCorr->Reset(option);
}
+
+//____________________________________________________________________
+void AliCorrectionMatrix::SetCorrectionToUnity()
+{
+ // sets the correction matrix to unity
+
+ if (!fhCorr)
+ return;
+
+ for (Int_t x=1; x<=fhCorr->GetNbinsX(); ++x)
+ for (Int_t y=1; y<=fhCorr->GetNbinsY(); ++y)
+ for (Int_t z=1; z<=fhCorr->GetNbinsZ(); ++z)
+ fhCorr->SetBinContent(x, y, z, 1);
+}
TH1* GetGeneratedHistogram() { return fhGene; }
TH1* GetMeasuredHistogram() { return fhMeas; }
+ TH1* GetCorrectionHistogram() { return fhCorr; }
void SetGeneratedHistogram(TH1* agene) { fhGene = agene; }
void SetMeasuredHistogram(TH1* ameas) { fhMeas = ameas; }
+ void SetCorrectionHistogram(TH1* acorr) { fhCorr = acorr; }
void Divide();
+ void Multiply();
+ void SetCorrectionToUnity();
void SetAxisTitles(const Char_t* titleX="", const Char_t* titleY="", const Char_t* titleZ="");
- virtual Bool_t LoadHistograms(const Char_t* fileName, const Char_t* dir = ".");
+ virtual Bool_t LoadHistograms(const Char_t* dir = 0);
virtual void SaveHistograms();
- virtual void DrawHistograms();
+ virtual void DrawHistograms(const Char_t* canvasName = 0);
virtual void ReduceInformation();
// constructor
//
- fhMeas = new TH2F(Form("meas_%s",name), Form("meas_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
- fhGene = new TH2F(Form("gene_%s",name), Form("gene_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
- fhCorr = new TH2F(Form("corr_%s",name), Form("corr_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+ // do not add this hists to the directory
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fhMeas = new TH2F("measured", Form("%s measured",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+ fhGene = new TH2F("generated", Form("%s generated",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+ fhCorr = new TH2F("correction", Form("%s correction",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax);
+
+ TH1::AddDirectory(oldStatus);
fhMeas->Sumw2();
fhGene->Sumw2();
// constructor
//
- fhMeas = new TH2F(Form("meas_%s",name), Form("meas_%s",title), nBinX, X, nBinY, Y);
- fhGene = new TH2F(Form("gene_%s",name), Form("gene_%s",title), nBinX, X, nBinY, Y);
- fhCorr = new TH2F(Form("corr_%s",name), Form("corr_%s",title), nBinX, X, nBinY, Y);
+ // do not add this hists to the directory
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
- fhMeas->Sumw2();
+ fhMeas = new TH2F("measured", Form("%s measured",title), nBinX, X, nBinY, Y);
+ fhGene = new TH2F("generated", Form("%s generated",title), nBinX, X, nBinY, Y);
+ fhCorr = new TH2F("correction", Form("%s correction",title), nBinX, X, nBinY, Y);
+
+ TH1::AddDirectory(oldStatus);
+
+ fhMeas->Sumw2();
fhGene->Sumw2();
fhCorr->Sumw2();
}
TH2F* GetGeneratedHistogram() const;
TH2F* GetMeasuredHistogram() const;
- TH2F* GetCorrectionHistrogram() {return (TH2F*)fhCorr;}
+ TH2F* GetCorrectionHistogram() {return (TH2F*)fhCorr;}
TH1F* Get1DCorrection(Char_t* opt="x", Float_t min=0, Float_t max=0);
void FillMeas(Float_t ax, Float_t ay);
// constructor
//
- fhMeas = new TH3F(Form("meas_%s",name), Form("meas_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
- fhGene = new TH3F(Form("gene_%s",name), Form("gene_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
- fhCorr = new TH3F(Form("corr_%s",name), Form("corr_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
+ // do not add this hists to the directory
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fhMeas = new TH3F("measured", Form("%s measured",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
+ fhGene = new TH3F("generated", Form("%s generated",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
+ fhCorr = new TH3F("correction", Form("%s correction",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
+
+ TH1::AddDirectory(oldStatus);
fhMeas->Sumw2();
fhGene->Sumw2();
for (Int_t i=0; i<=nBinY; ++i)
binLimitsY[i] = Ymin + (Ymax - Ymin) / nBinY * i;
- fhMeas = new TH3F(Form("meas_%s",name), Form("meas_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
- fhGene = new TH3F(Form("gene_%s",name), Form("gene_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
- fhCorr = new TH3F(Form("corr_%s",name), Form("corr_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
+ // do not add this hists to the directory
+ Bool_t oldStatus = TH1::AddDirectoryStatus();
+ TH1::AddDirectory(kFALSE);
+
+ fhMeas = new TH3F("measured", Form("%s measured",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
+ fhGene = new TH3F("generated", Form("%s generated",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
+ fhCorr = new TH3F("correction", Form("%s correction",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
+
+ TH1::AddDirectory(oldStatus);
delete[] binLimitsX;
delete[] binLimitsY;
AliCorrectionMatrix::SaveHistograms();
if (GetGeneratedHistogram() && GetMeasuredHistogram())
- AliPWG0Helper::CreateDividedProjections(GetGeneratedHistogram(), GetMeasuredHistogram());
+ {
+ gDirectory->cd(GetName());
+
+ AliPWG0Helper::CreateDividedProjections(GetGeneratedHistogram(), GetMeasuredHistogram(), 0, kFALSE, kTRUE);
+
+ gDirectory->cd("..");
+ }
}
//____________________________________________________________________
}
//____________________________________________________________________
-void AliPWG0Helper::CreateProjections(TH3* hist)
+void AliPWG0Helper::CreateProjections(TH3* hist, Bool_t save)
{
// create projections of 3d hists to all 2d combinations
// the histograms are not returned, just use them from memory or use this to create them in a file
TH1* proj = hist->Project3D("yx");
proj->SetXTitle(hist->GetXaxis()->GetTitle());
proj->SetYTitle(hist->GetYaxis()->GetTitle());
+ if (save)
+ proj->Write();
proj = hist->Project3D("zx");
proj->SetXTitle(hist->GetXaxis()->GetTitle());
proj->SetYTitle(hist->GetZaxis()->GetTitle());
+ if (save)
+ proj->Write();
proj = hist->Project3D("zy");
proj->SetXTitle(hist->GetYaxis()->GetTitle());
proj->SetYTitle(hist->GetZaxis()->GetTitle());
+ if (save)
+ proj->Write();
}
//____________________________________________________________________
-void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors)
+void AliPWG0Helper::CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis, Bool_t putErrors, Bool_t save)
{
// create projections of the 3d hists divides them
// axis decides to which plane, if axis is 0 to all planes
if (axis == 0)
{
- CreateDividedProjections(hist, hist2, "yx", putErrors);
- CreateDividedProjections(hist, hist2, "zx", putErrors);
- CreateDividedProjections(hist, hist2, "zy", putErrors);
+ CreateDividedProjections(hist, hist2, "yx", putErrors, save);
+ CreateDividedProjections(hist, hist2, "zx", putErrors, save);
+ CreateDividedProjections(hist, hist2, "zy", putErrors, save);
return;
}
proj2->SetXTitle(GetAxisTitle(hist2, axis[0]));
TH1* division = dynamic_cast<TH1*> (proj->Clone(Form("%s_div_%s", proj->GetName(), proj2->GetName())));
+ //printf("doing axis: %s, x axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsX(), proj2->GetNbinsX(), division->GetXaxis()->GetBinLowEdge(1), proj2->GetXaxis()->GetBinLowEdge(1), division->GetXaxis()->GetBinUpEdge(division->GetNbinsX()), proj2->GetXaxis()->GetBinUpEdge(proj2->GetNbinsX()));
+ //printf("doing axis: %s, y axis has %d %d bins, min %f %f max %f %f\n", axis, division->GetNbinsY(), proj2->GetNbinsY(), division->GetYaxis()->GetBinLowEdge(1), proj2->GetYaxis()->GetBinLowEdge(1), division->GetYaxis()->GetBinUpEdge(division->GetNbinsY()), proj2->GetYaxis()->GetBinUpEdge(proj2->GetNbinsY()));
division->Divide(proj2);
+ division->SetTitle(Form("%s divided %s", proj->GetTitle(), proj2->GetTitle()));
if (putErrors)
{
if (division->GetDimension() == 1)
{
Int_t nBins = division->GetNbinsX();
- for (Int_t i = 0; i <= nBins; ++i)
+ for (Int_t i = 1; i <= nBins; ++i)
if (proj2->GetBinContent(i) != 0)
division->SetBinError(i, TMath::Sqrt(proj->GetBinContent(i)) / proj2->GetBinContent(i));
}
{
Int_t nBinsX = division->GetNbinsX();
Int_t nBinsY = division->GetNbinsY();
- for (Int_t i = 0; i <= nBinsX; ++i)
- for (Int_t j = 0; j <= nBinsY; ++j)
+ for (Int_t i = 1; i <= nBinsX; ++i)
+ for (Int_t j = 1; j <= nBinsY; ++j)
if (proj2->GetBinContent(i, j) != 0)
division->SetBinError(i, j, TMath::Sqrt(proj->GetBinContent(i, j)) / proj2->GetBinContent(i, j));
}
}
+
+ if (save)
+ {
+ proj->Write();
+ proj2->Write();
+ division->Write();
+ }
}
//____________________________________________________________________
static Bool_t IsVertexReconstructed(AliESD* aEsd);
static Bool_t IsPrimaryCharged(TParticle* aParticle, Int_t aTotalPrimaries, Bool_t adebug = kFALSE);
- static void CreateProjections(TH3* hist);
- static void CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis = 0, Bool_t putErrors = kFALSE);
+ static void CreateProjections(TH3* hist, Bool_t save = kFALSE);
+ static void CreateDividedProjections(TH3* hist, TH3* hist2, const char* axis = 0, Bool_t putErrors = kFALSE, Bool_t save = kFALSE);
static const char* GetAxisTitle(TH3* hist, const char axis);
protected:
in.close();
if (check)
- outFile.close();
+ outfile.close();
}
if (chainFriend)
#pragma link C++ class AliPWG0Helper+;
+#pragma link C++ class AliCorrection+;
+
#endif
AliCorrectionMatrix.h \
AliCorrectionMatrix2D.h \
AliCorrectionMatrix3D.h \
+ AliCorrection.h \
AliPWG0Helper.h
SRCS = $(HDRS:.h=.cxx)