Updated signature of AliMUONSegFactory
[u/mrichter/AliRoot.git] / PWG0 / AliCorrectionMatrix3D.cxx
CommitLineData
bf21645b 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"
847489f7 15#include "AliPWG0Helper.h"
bf21645b 16
17//____________________________________________________________________
18ClassImp(AliCorrectionMatrix3D)
19
20//____________________________________________________________________
21AliCorrectionMatrix3D::AliCorrectionMatrix3D() :
22 AliCorrectionMatrix()
23{
24 // default constructor
25}
26
27//____________________________________________________________________
28AliCorrectionMatrix3D::AliCorrectionMatrix3D(const AliCorrectionMatrix3D& c)
29 : AliCorrectionMatrix(c)
30{
31 // copy constructor
32 ((AliCorrectionMatrix3D &)c).Copy(*this);
33}
34
61385583 35//____________________________________________________________________
36AliCorrectionMatrix3D &AliCorrectionMatrix3D::operator=(const AliCorrectionMatrix3D &c)
37{
38 // assigment operator
39
40 if (this != &c)
41 ((AliCorrectionMatrix3D &) c).Copy(*this);
42
43 return *this;
44}
45
bf21645b 46//____________________________________________________________________
47AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title,
48 Int_t nBinX, Float_t Xmin, Float_t Xmax,
49 Int_t nBinY, Float_t Ymin, Float_t Ymax,
50 Int_t nBinZ, Float_t Zmin, Float_t Zmax)
51 : AliCorrectionMatrix(name, title)
52{
53 //
54 // constructor
55 //
56
57 fhMeas = new TH3F(Form("meas_%s",name), Form("meas_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
58 fhGene = new TH3F(Form("gene_%s",name), Form("gene_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
59 fhCorr = new TH3F(Form("corr_%s",name), Form("corr_%s",title), nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
60
61 fhMeas->Sumw2();
62 fhGene->Sumw2();
63 fhCorr->Sumw2();
64}
65
1afae8ff 66AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title,
67 Int_t nBinX, Float_t Xmin, Float_t Xmax,
68 Int_t nBinY, Float_t Ymin, Float_t Ymax,
69 Int_t nBinZ, const Float_t* zbins)
70 : AliCorrectionMatrix(name, title)
71{
72 // constructor with variable bin sizes
73
74 Float_t* binLimitsX = new Float_t[nBinX+1];
75 for (Int_t i=0; i<=nBinX; ++i)
76 binLimitsX[i] = Xmin + (Xmax - Xmin) / nBinX * i;
77
78 Float_t* binLimitsY = new Float_t[nBinY+1];
79 for (Int_t i=0; i<=nBinY; ++i)
80 binLimitsY[i] = Ymin + (Ymax - Ymin) / nBinY * i;
81
82 fhMeas = new TH3F(Form("meas_%s",name), Form("meas_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
83 fhGene = new TH3F(Form("gene_%s",name), Form("gene_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
84 fhCorr = new TH3F(Form("corr_%s",name), Form("corr_%s",title), nBinX, binLimitsX, nBinY, binLimitsY, nBinZ, zbins);
85
86 delete[] binLimitsX;
87 delete[] binLimitsY;
88
89 fhMeas->Sumw2();
90 fhGene->Sumw2();
91 fhCorr->Sumw2();
92}
93
bf21645b 94//____________________________________________________________________
95AliCorrectionMatrix3D::~AliCorrectionMatrix3D()
96{
97 //
98 // destructor
99 //
100
101 // histograms already deleted in base class
102}
103
104//____________________________________________________________________
105TH3F* AliCorrectionMatrix3D::GetGeneratedHistogram()
106{
107 // return generated histogram casted to correct type
108 return dynamic_cast<TH3F*> (fhGene);
109}
110
111//____________________________________________________________________
112TH3F* AliCorrectionMatrix3D::GetMeasuredHistogram()
113{
114 // return measured histogram casted to correct type
115 return dynamic_cast<TH3F*> (fhMeas);
116}
117
118//____________________________________________________________________
119TH3F* AliCorrectionMatrix3D::GetCorrectionHistogram()
120{
121 // return correction histogram casted to correct type
122 return dynamic_cast<TH3F*> (fhCorr);
123}
124
125//____________________________________________________________________
126void AliCorrectionMatrix3D::FillMeas(Float_t ax, Float_t ay, Float_t az)
127{
128 // add value to measured histogram
129 GetMeasuredHistogram()->Fill(ax, ay, az);
130}
131
132//____________________________________________________________________
133void AliCorrectionMatrix3D::FillGene(Float_t ax, Float_t ay, Float_t az)
134{
135 // add value to generated histogram
136 GetGeneratedHistogram()->Fill(ax, ay, az);
137}
138
139//____________________________________________________________________
140Float_t AliCorrectionMatrix3D::GetCorrection(Float_t ax, Float_t ay, Float_t az) const
141{
142 // returns a value of the correction map
143 return fhCorr->GetBinContent(fhCorr->FindBin(ax, ay, az));
144}
145
146//____________________________________________________________________
147//void AliCorrectionMatrix3D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge, Int_t nBinsZedge)
148void AliCorrectionMatrix3D::RemoveEdges(Float_t, Int_t, Int_t, Int_t)
149{
150 // so what do we do here...
151}
152
153//____________________________________________________________________
154void AliCorrectionMatrix3D::SaveHistograms()
155{
156 //
157 // saves the histograms
158 //
159
160 AliCorrectionMatrix::SaveHistograms();
161
92d2d8ad 162 if (GetGeneratedHistogram() && GetMeasuredHistogram())
163 AliPWG0Helper::CreateDividedProjections(GetGeneratedHistogram(), GetMeasuredHistogram());
bf21645b 164}