]>
Commit | Line | Data |
---|---|---|
7cc34f08 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //------------------------------------------------------------------------------ | |
17 | // Implementation of abstract AliPerformanceObject class. It keeps information from | |
18 | // comparison of reconstructed and MC particle tracks. | |
19 | // | |
20 | // Author: J.Otwinowski 14/04/2008 | |
814d192f | 21 | // Changes by M.Knichel 15/10/2010 |
7cc34f08 | 22 | //------------------------------------------------------------------------------ |
23 | ||
24 | #include <iostream> | |
25 | ||
26 | #include "TCanvas.h" | |
27 | #include "TH1.h" | |
28 | #include "TH2.h" | |
28bb9d1f | 29 | #include "TH3.h" |
7cc34f08 | 30 | #include "TAxis.h" |
31 | #include "TPostScript.h" | |
32 | #include "TList.h" | |
33 | #include "TMath.h" | |
34 | ||
35 | #include "AliLog.h" | |
758320f7 | 36 | #include "AliESDVertex.h" |
7cc34f08 | 37 | #include "AliPerformanceObject.h" |
38 | ||
39 | using namespace std; | |
40 | ||
41 | ClassImp(AliPerformanceObject) | |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliPerformanceObject::AliPerformanceObject(): | |
45 | TNamed("AliPerformanceObject","AliPerformanceObject"), | |
46 | fAnalysisMode(-1), | |
814d192f | 47 | fRunNumber(-1), |
e6a60a90 | 48 | fHptGenerator(kFALSE), |
758320f7 | 49 | fTriggerClass(0), |
28bb9d1f | 50 | fUseTrackVertex(kFALSE), |
c1b69b58 | 51 | fHighMultiplicity(kFALSE), |
52 | fUseKinkDaughters(kTRUE) | |
7cc34f08 | 53 | { |
54 | // constructor | |
55 | } | |
56 | ||
57 | //_____________________________________________________________________________ | |
814d192f | 58 | AliPerformanceObject::AliPerformanceObject(const char* name, const char* title, Int_t run): |
7cc34f08 | 59 | TNamed(name,title), |
60 | fAnalysisMode(-1), | |
814d192f | 61 | fRunNumber(run), |
e6a60a90 | 62 | fHptGenerator(kFALSE), |
758320f7 | 63 | fTriggerClass(0), |
28bb9d1f | 64 | fUseTrackVertex(kFALSE), |
c1b69b58 | 65 | fHighMultiplicity(kFALSE), |
66 | fUseKinkDaughters(kTRUE) | |
7cc34f08 | 67 | { |
68 | // constructor | |
69 | } | |
70 | ||
71 | //_____________________________________________________________________________ | |
72 | AliPerformanceObject::~AliPerformanceObject(){ | |
73 | // destructor | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | void AliPerformanceObject::PrintHisto(Bool_t logz, Char_t * outFileName) { | |
78 | // draw all histograms from the folder | |
79 | // and store them in the output *.ps file | |
80 | ||
81 | // use this folder | |
82 | TFolder *folder = this->GetAnalysisFolder(); | |
83 | if (!folder) { | |
84 | AliDebug(AliLog::kError, "folder not available"); | |
85 | return; | |
86 | } | |
87 | ||
88 | TCanvas *can = new TCanvas("can"); | |
89 | can->Divide(2,2); | |
90 | ||
91 | char fname[256]; | |
92 | const char* suffix=".ps"; | |
93 | ||
94 | if(outFileName) sprintf(fname,"%s",outFileName); | |
95 | else sprintf(fname,"%s%s",folder->GetName(),suffix); | |
96 | ||
97 | TPostScript *ps = new TPostScript(fname,112); | |
98 | Printf("Histograms are stored in %s", fname); | |
99 | TIter iter(folder->GetListOfFolders()); | |
100 | ||
101 | TH1 *obj = 0; | |
102 | Int_t count = 0; | |
103 | Int_t pad_count = 0; | |
104 | while ((obj = (TH1*)iter()) !=0) { | |
105 | ||
c1b69b58 | 106 | TString name(obj->ClassName()); |
107 | ||
108 | ||
7cc34f08 | 109 | // 4 figures per page |
110 | if((count%4) == 0) { | |
111 | pad_count = 0; | |
112 | ps->NewPage(); | |
113 | } | |
114 | ||
115 | pad_count++; | |
116 | can->cd(pad_count); | |
117 | ||
118 | if(obj->TestBit(TH1::kLogX)) | |
119 | gPad->SetLogx(1); | |
120 | else | |
121 | gPad->SetLogx(0); | |
122 | ||
123 | if (obj->GetYaxis() && obj->GetZaxis()) { | |
124 | if(logz) gPad->SetLogz(); | |
c1b69b58 | 125 | if ( name.CompareTo("TH3D") ) |
126 | obj->Draw("colz"); | |
7cc34f08 | 127 | } |
128 | else { | |
129 | obj->SetMarkerStyle(24); | |
130 | obj->SetMarkerSize(1.0); | |
c1b69b58 | 131 | if ( name.CompareTo("TH3D") ) |
132 | obj->Draw(); | |
7cc34f08 | 133 | } |
134 | ||
135 | if ((pad_count%4) == 0) { | |
136 | can->Update(); | |
137 | } | |
138 | ||
7cc34f08 | 139 | count++; |
140 | } | |
141 | ps->Close(); | |
142 | } | |
143 | ||
144 | ||
145 | //_____________________________________________________________________________ | |
146 | Double_t * AliPerformanceObject::CreateLogAxis(Int_t nbins, Double_t xmin, Double_t xmax) { | |
147 | // retun pointer to the array with log axis | |
148 | // it is user responsibility to delete the array | |
149 | ||
150 | Double_t logxmin = TMath::Log10(xmin); | |
151 | Double_t logxmax = TMath::Log10(xmax); | |
152 | Double_t binwidth = (logxmax-logxmin)/nbins; | |
153 | ||
154 | Double_t *xbins = new Double_t[nbins+1]; | |
155 | ||
156 | xbins[0] = xmin; | |
157 | for (Int_t i=1;i<=nbins;i++) { | |
158 | xbins[i] = xmin + TMath::Power(10,logxmin+i*binwidth); | |
159 | } | |
160 | ||
161 | return xbins; | |
162 | } | |
28bb9d1f | 163 | |
164 | //_____________________________________________________________________________ | |
165 | void AliPerformanceObject::InitHighMult() { | |
166 | ||
167 | fHighMultiplicity = kTRUE; | |
168 | Init(); | |
169 | ||
170 | } | |
171 | ||
172 | ||
173 | //_____________________________________________________________________________ | |
174 | void AliPerformanceObject::AddProjection(TObjArray* aFolderObj, TString nameSparse, THnSparse* hSparse, Int_t xDim, TString* selString) | |
175 | { | |
176 | TH1 *h1=0; | |
177 | TString name = "h_tpc_" + nameSparse + '_'; | |
178 | if (selString) { name += *selString + '_'; } | |
179 | name.ToLower(); | |
180 | name += xDim; | |
181 | TString title = hSparse->GetAxis(xDim)->GetTitle(); | |
182 | if (selString) { title += " (" + *selString + ")"; } | |
183 | h1 = hSparse->Projection(xDim); | |
184 | h1->SetName(name.Data()); | |
185 | h1->GetXaxis()->SetTitle(hSparse->GetAxis(xDim)->GetTitle()); | |
186 | h1->SetTitle(title.Data()); | |
187 | aFolderObj->Add(h1); | |
188 | } | |
189 | ||
190 | ||
191 | //_____________________________________________________________________________ | |
192 | void AliPerformanceObject::AddProjection(TObjArray* aFolderObj, TString nameSparse, THnSparse *hSparse, Int_t yDim, Int_t xDim, TString* selString) | |
193 | { | |
194 | TH2 *h2=0; | |
195 | TString name = "h_tpc_" + nameSparse + '_'; | |
196 | if (selString) { name += *selString + '_'; } | |
197 | name.ToLower(); | |
198 | name += yDim; | |
199 | name += '_'; | |
200 | name += xDim; | |
201 | TString title = hSparse->GetAxis(yDim)->GetTitle(); | |
202 | title += " vs "; | |
203 | title += hSparse->GetAxis(xDim)->GetTitle(); | |
204 | if (selString) { title += " (" + *selString + ")"; } | |
205 | h2 = hSparse->Projection(yDim,xDim); | |
206 | h2->SetName(name.Data()); | |
207 | h2->GetXaxis()->SetTitle(hSparse->GetAxis(xDim)->GetTitle()); | |
208 | h2->GetYaxis()->SetTitle(hSparse->GetAxis(yDim)->GetTitle()); | |
209 | h2->SetTitle(title.Data()); | |
210 | aFolderObj->Add(h2); | |
211 | } | |
212 | ||
213 | ||
214 | //_____________________________________________________________________________ | |
215 | void AliPerformanceObject::AddProjection(TObjArray* aFolderObj, TString nameSparse, THnSparse *hSparse, Int_t xDim, Int_t yDim, Int_t zDim, TString* selString) | |
216 | { | |
217 | TH3 *h3=0; | |
218 | TString name = "h_tpc_" + nameSparse + '_'; | |
219 | if (selString) { name += *selString + '_'; } | |
220 | name.ToLower(); | |
221 | name += xDim; | |
222 | name += '_'; | |
223 | name += yDim; | |
224 | name += '_'; | |
225 | name += zDim; | |
226 | TString title = hSparse->GetAxis(xDim)->GetTitle(); | |
227 | title += " vs "; | |
228 | title += hSparse->GetAxis(yDim)->GetTitle(); | |
229 | title += " vs "; | |
230 | title += hSparse->GetAxis(zDim)->GetTitle(); | |
231 | if (selString) { title += " (" + *selString + ")"; } | |
232 | h3 = hSparse->Projection(xDim,yDim,zDim); | |
233 | h3->SetName(name.Data()); | |
234 | h3->GetXaxis()->SetTitle(hSparse->GetAxis(xDim)->GetTitle()); | |
235 | h3->GetYaxis()->SetTitle(hSparse->GetAxis(yDim)->GetTitle()); | |
236 | h3->GetZaxis()->SetTitle(hSparse->GetAxis(zDim)->GetTitle()); | |
237 | h3->SetTitle(title.Data()); | |
238 | aFolderObj->Add(h3); | |
239 | } |