]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG0/AliCorrectionMatrix3D.cxx
renamed CorrectionMatrix class
[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
16 //____________________________________________________________________
17 ClassImp(AliCorrectionMatrix3D)
18
19 //____________________________________________________________________
20 AliCorrectionMatrix3D::AliCorrectionMatrix3D() :
21   AliCorrectionMatrix()
22 {
23   // default constructor
24 }
25
26 //____________________________________________________________________
27 AliCorrectionMatrix3D::AliCorrectionMatrix3D(const AliCorrectionMatrix3D& c)
28   : AliCorrectionMatrix(c)
29 {
30   // copy constructor
31   ((AliCorrectionMatrix3D &)c).Copy(*this);
32 }
33
34 //____________________________________________________________________
35 AliCorrectionMatrix3D::AliCorrectionMatrix3D(const Char_t* name, const Char_t* title,
36               Int_t nBinX, Float_t Xmin, Float_t Xmax,
37               Int_t nBinY, Float_t Ymin, Float_t Ymax,
38               Int_t nBinZ, Float_t Zmin, Float_t Zmax)
39   : AliCorrectionMatrix(name, title)
40 {
41   //
42   // constructor
43   //
44
45   fhMeas  = new TH3F(Form("meas_%s",name), Form("meas_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
46   fhGene  = new TH3F(Form("gene_%s",name), Form("gene_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
47   fhCorr  = new TH3F(Form("corr_%s",name), Form("corr_%s",title),  nBinX, Xmin, Xmax, nBinY, Ymin, Ymax, nBinZ, Zmin, Zmax);
48
49   fhMeas->Sumw2();
50   fhGene->Sumw2();
51   fhCorr->Sumw2();
52 }
53
54 //____________________________________________________________________
55 AliCorrectionMatrix3D::~AliCorrectionMatrix3D()
56 {
57   //
58   // destructor
59   //
60
61   // histograms already deleted in base class
62 }
63
64 //____________________________________________________________________
65 TH3F* AliCorrectionMatrix3D::GetGeneratedHistogram()
66 {
67   // return generated histogram casted to correct type
68   return dynamic_cast<TH3F*> (fhGene);
69 }
70
71 //____________________________________________________________________
72 TH3F* AliCorrectionMatrix3D::GetMeasuredHistogram()
73 {
74   // return measured histogram casted to correct type
75   return dynamic_cast<TH3F*> (fhMeas);
76 }
77
78 //____________________________________________________________________
79 TH3F* AliCorrectionMatrix3D::GetCorrectionHistogram()
80 {
81   // return correction histogram casted to correct type
82   return dynamic_cast<TH3F*> (fhCorr);
83 }
84
85 //____________________________________________________________________
86 void AliCorrectionMatrix3D::FillMeas(Float_t ax, Float_t ay, Float_t az)
87 {
88   // add value to measured histogram
89   GetMeasuredHistogram()->Fill(ax, ay, az);
90 }
91
92 //____________________________________________________________________
93 void AliCorrectionMatrix3D::FillGene(Float_t ax, Float_t ay, Float_t az)
94 {
95   // add value to generated histogram
96   GetGeneratedHistogram()->Fill(ax, ay, az);
97 }
98
99 //____________________________________________________________________
100 Float_t AliCorrectionMatrix3D::GetCorrection(Float_t ax, Float_t ay, Float_t az) const
101 {
102   // returns a value of the correction map
103   return fhCorr->GetBinContent(fhCorr->FindBin(ax, ay, az));
104 }
105
106 //____________________________________________________________________
107 //void AliCorrectionMatrix3D::RemoveEdges(Float_t cut, Int_t nBinsXedge, Int_t nBinsYedge, Int_t nBinsZedge)
108 void AliCorrectionMatrix3D::RemoveEdges(Float_t, Int_t, Int_t, Int_t)
109 {
110   // so what do we do here...
111 }
112
113 //____________________________________________________________________
114 void AliCorrectionMatrix3D::SaveHistograms()
115 {
116   //
117   // saves the histograms
118   //
119
120   AliCorrectionMatrix::SaveHistograms();
121
122   WriteProjections(GetMeasuredHistogram());
123   WriteProjections(GetGeneratedHistogram());
124
125   if (GetCorrectionHistogram())
126     WriteProjections(GetCorrectionHistogram());
127 }
128
129 //____________________________________________________________________
130 void AliCorrectionMatrix3D::WriteProjections(TH3F* hist)
131 {
132   // write some projections to disk
133
134   TH1* proj = hist->Project3D("yx");
135   proj->SetXTitle(hist->GetXaxis()->GetTitle());
136   proj->SetYTitle(hist->GetYaxis()->GetTitle());
137
138   proj = hist->Project3D("zx");
139   proj->SetXTitle(hist->GetXaxis()->GetTitle());
140   proj->SetYTitle(hist->GetZaxis()->GetTitle());
141
142   proj = hist->Project3D("zy");
143   proj->SetXTitle(hist->GetYaxis()->GetTitle());
144   proj->SetYTitle(hist->GetZaxis()->GetTitle());
145 }