implemented analysis using 3d information (vtx_z, eta, pt)
[u/mrichter/AliRoot.git] / PWG0 / AliCorrectionMatrix3D.cxx
1 /* $Id$ */
2
3 // ------------------------------------------------------
4 //
5 // Class to handle 3d-corrections.
6 //
7 // ------------------------------------------------------
8 //
9
10 #include <TH3F.h>
11
12 #include <AliLog.h>
13
14 #include "AliCorrectionMatrix3D.h"
15 #include "AliPWG0Helper.h"
16
17 //____________________________________________________________________
18 ClassImp(AliCorrectionMatrix3D)
19
20 //____________________________________________________________________
21 AliCorrectionMatrix3D::AliCorrectionMatrix3D() :
22   AliCorrectionMatrix()
23 {
24   // default constructor
25 }
26
27 //____________________________________________________________________
28 AliCorrectionMatrix3D::AliCorrectionMatrix3D(const AliCorrectionMatrix3D& c)
29   : AliCorrectionMatrix(c)
30 {
31   // copy constructor
32   ((AliCorrectionMatrix3D &)c).Copy(*this);
33 }
34
35 //____________________________________________________________________
36 AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title,
37               Int_t nBinX, Float_t Xmin, Float_t Xmax,
38               Int_t nBinY, Float_t Ymin, Float_t Ymax,
39               Int_t nBinZ, Float_t Zmin, Float_t Zmax)
40   : AliCorrectionMatrix(name, title)
41 {
42   //
43   // constructor
44   //
45
46   fhMeas  = new TH3F(Form("meas_%s",name), Form("meas_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
47   fhGene  = new TH3F(Form("gene_%s",name), Form("gene_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
48   fhCorr  = new TH3F(Form("corr_%s",name), Form("corr_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
49
50   fhMeas->Sumw2();
51   fhGene->Sumw2();
52   fhCorr->Sumw2();
53 }
54
55 //____________________________________________________________________
56 AliCorrectionMatrix3D::~AliCorrectionMatrix3D()
57 {
58   //
59   // destructor
60   //
61
62   // histograms already deleted in base class
63 }
64
65 //____________________________________________________________________
66 TH3F* AliCorrectionMatrix3D::GetGeneratedHistogram()
67 {
68   // return generated histogram casted to correct type
69   return dynamic_cast<TH3F*> (fhGene);
70 }
71
72 //____________________________________________________________________
73 TH3F* AliCorrectionMatrix3D::GetMeasuredHistogram()
74 {
75   // return measured histogram casted to correct type
76   return dynamic_cast<TH3F*> (fhMeas);
77 }
78
79 //____________________________________________________________________
80 TH3F* AliCorrectionMatrix3D::GetCorrectionHistogram()
81 {
82   // return correction histogram casted to correct type
83   return dynamic_cast<TH3F*> (fhCorr);
84 }
85
86 //____________________________________________________________________
87 void AliCorrectionMatrix3D::FillMeas(Float_t ax, Float_t ay, Float_t az)
88 {
89   // add value to measured histogram
90   GetMeasuredHistogram()->Fill(ax, ay, az);
91 }
92
93 //____________________________________________________________________
94 void AliCorrectionMatrix3D::FillGene(Float_t ax, Float_t ay, Float_t az)
95 {
96   // add value to generated histogram
97   GetGeneratedHistogram()->Fill(ax, ay, az);
98 }
99
100 //____________________________________________________________________
101 Float_t AliCorrectionMatrix3D::GetCorrection(Float_t ax, Float_t ay, Float_t az) const
102 {
103   // returns a value of the correction map
104   return fhCorr->GetBinContent(fhCorr->FindBin(ax, ay, az));
105 }
106
107 //____________________________________________________________________
108 //void AliCorrectionMatrix3D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge, Int_t nBinsZedge)
109 void AliCorrectionMatrix3D::RemoveEdges(Float_t, Int_t, Int_t, Int_t)
110 {
111   // so what do we do here...
112 }
113
114 //____________________________________________________________________
115 void AliCorrectionMatrix3D::SaveHistograms()
116 {
117   //
118   // saves the histograms
119   //
120
121   AliCorrectionMatrix::SaveHistograms();
122
123   AliPWG0Helper::CreateProjections(GetMeasuredHistogram());
124   AliPWG0Helper::CreateProjections(GetGeneratedHistogram());
125
126   if (GetCorrectionHistogram())
127     AliPWG0Helper::CreateProjections(GetCorrectionHistogram());
128 }