]>
Commit | Line | Data |
---|---|---|
c9dd1c4d | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, 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 | // Yves? | |
18 | // What | |
19 | // is | |
20 | // this | |
21 | // class | |
22 | // supposed | |
23 | // to | |
24 | // do? | |
25 | //__________________________________________________________________ | |
26 | // | |
27 | // --- ROOT system --- | |
28 | #include <TClass.h> | |
29 | #include <TH1F.h> | |
30 | #include <TH1I.h> | |
31 | #include <TIterator.h> | |
32 | #include <TKey.h> | |
33 | #include <TFile.h> | |
6ceca4ef | 34 | #include <iostream> |
1706c710 | 35 | #include <TCanvas.h> |
36 | #include <TPaveText.h> | |
05e5e0c1 | 37 | #include <TStyle.h> |
c9dd1c4d | 38 | |
39 | // --- AliRoot header files --- | |
40 | #include "AliLog.h" | |
4e25ac79 | 41 | #include "AliQAv1.h" |
c9dd1c4d | 42 | #include "AliQAChecker.h" |
43 | #include "AliFMDQAChecker.h" | |
6ceca4ef | 44 | #include "AliRecoParam.h" |
c9dd1c4d | 45 | |
46 | ClassImp(AliFMDQAChecker) | |
47 | #if 0 | |
48 | ; // This is for Emacs! - do not delete | |
49 | #endif | |
05e5e0c1 | 50 | |
51 | //__________________________________________________________________ | |
52 | Double_t | |
53 | AliFMDQAChecker::CheckOne(AliQAv1::ALITASK_t what, | |
54 | AliRecoParam::EventSpecie_t specie, | |
55 | TH1* hist) const | |
56 | { | |
57 | if(what == AliQAv1::kESD) return CheckESD(specie, hist); | |
58 | if(what == AliQAv1::kRAW) return CheckRaw(specie, hist); | |
59 | if(what == AliQAv1::kSIM) return CheckSim(specie, hist); | |
60 | if(what == AliQAv1::kREC) return CheckRec(specie, hist); | |
61 | return 0; | |
62 | } | |
63 | //__________________________________________________________________ | |
64 | Double_t | |
65 | AliFMDQAChecker::CheckESD(AliRecoParam::EventSpecie_t /* specie*/, | |
66 | TH1* hist) const | |
67 | { | |
68 | return (hist->GetMean() > 0 ? 1 : 0); | |
69 | } | |
70 | //__________________________________________________________________ | |
71 | Double_t | |
72 | AliFMDQAChecker::CheckRaw(AliRecoParam::EventSpecie_t /* specie*/, | |
73 | TH1* hist) const | |
74 | { | |
75 | return (hist->GetMean() > 0 ? 1 : 0); | |
76 | } | |
77 | //__________________________________________________________________ | |
78 | Double_t | |
79 | AliFMDQAChecker::CheckSim(AliRecoParam::EventSpecie_t /* specie*/, | |
80 | TH1* hist) const | |
81 | { | |
82 | return (hist->GetMean() > 0 ? 1 : 0); | |
83 | } | |
84 | //__________________________________________________________________ | |
85 | Double_t | |
86 | AliFMDQAChecker::CheckRec(AliRecoParam::EventSpecie_t /* specie*/, | |
87 | TH1* hist) const | |
88 | { | |
89 | return (hist->GetMean() > 0 ? 1 : 0); | |
90 | } | |
91 | ||
c9dd1c4d | 92 | //__________________________________________________________________ |
fa5a224b | 93 | void AliFMDQAChecker::Check(Double_t* rv, |
94 | AliQAv1::ALITASK_t what, | |
95 | TObjArray** list, | |
96 | const AliDetectorRecoParam* /*t*/) | |
97 | { | |
98 | // | |
99 | // Member function called to do the actual checking | |
100 | // | |
101 | // Parameters: | |
102 | // rv Array of return values. | |
103 | // what What to check | |
104 | // list Array of arrays of histograms. There's one arrat for | |
105 | // each 'specie' | |
106 | // t Reconstruction parameters - not used. | |
107 | // | |
6ceca4ef | 108 | |
fa5a224b | 109 | // Double_t* rv = new Double_t[AliRecoParam::kNSpecies] ; |
6ceca4ef | 110 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
83dbc5b8 | 111 | // Int_t count = 0; |
fa5a224b | 112 | rv[specie] = 0.; |
113 | ||
1706c710 | 114 | if (!AliQAv1::Instance()->IsEventSpecieSet(specie) ) |
6ceca4ef | 115 | continue ; |
116 | ||
117 | if(!list[specie]) continue; | |
118 | ||
05e5e0c1 | 119 | TH1* hist = 0; |
584d4c54 | 120 | Int_t nHist = list[specie]->GetEntriesFast(); |
121 | for(Int_t i= 0; i< nHist; i++) { | |
6ceca4ef | 122 | |
05e5e0c1 | 123 | if (!(hist = static_cast<TH1*>(list[specie]->At(i)))) continue; |
6ceca4ef | 124 | |
05e5e0c1 | 125 | rv[specie] += CheckOne(what, AliRecoParam::ConvertIndex(specie), hist); |
fa5a224b | 126 | } // for (int i ...) |
83dbc5b8 | 127 | // if (count != 0) rv[specie] /= count; |
6ceca4ef | 128 | } |
fa5a224b | 129 | // return rv; |
6ceca4ef | 130 | } |
131 | ||
05e5e0c1 | 132 | namespace { |
133 | Int_t CheckForLog(TAxis* axis, | |
134 | TVirtualPad* pad, | |
135 | Int_t xyz) | |
136 | { | |
137 | Int_t ret = 0; | |
138 | TString t(axis->GetTitle()); | |
139 | if (!t.Contains("[log]", TString::kIgnoreCase)) return 0; | |
140 | t.ReplaceAll("[log]", ""); | |
141 | switch (xyz) { | |
142 | case 1: pad->SetLogx(); ret |= 0x1; break; | |
143 | case 2: pad->SetLogy(); ret |= 0x2; break; | |
144 | case 3: pad->SetLogz(); ret |= 0x4; break; | |
145 | } | |
146 | axis->SetTitle(t); | |
147 | return ret; | |
148 | } | |
149 | } | |
6ceca4ef | 150 | |
1706c710 | 151 | //____________________________________________________________________________ |
152 | void | |
153 | AliFMDQAChecker::MakeImage(TObjArray** list, | |
154 | AliQAv1::TASKINDEX_t task, | |
155 | AliQAv1::MODE_t mode) | |
156 | { | |
157 | // makes the QA image for sim and rec | |
158 | // | |
159 | // Parameters: | |
160 | // task What to check | |
161 | // list Array of arrays of histograms. There's one array for | |
162 | // each 'specie' | |
163 | // t Reconstruction parameters - not used. | |
164 | // | |
165 | Int_t nImages = 0 ; | |
166 | Double_t max = 0; | |
167 | Double_t min = 10000; | |
168 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { | |
05e5e0c1 | 169 | AliRecoParam::EventSpecie_t spe = AliRecoParam::ConvertIndex(specie); |
170 | if (!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) | |
171 | ->IsEventSpecieSet(spe)) | |
544ed74f | 172 | continue; |
173 | // if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue ; | |
1706c710 | 174 | |
05e5e0c1 | 175 | if(!list[specie] || list[specie]->GetEntriesFast() == 0) continue; |
1706c710 | 176 | |
05e5e0c1 | 177 | TH1* hist = 0; |
1706c710 | 178 | Int_t nHist = list[specie]->GetEntriesFast(); |
179 | for(Int_t i= 0; i< nHist; i++) { | |
180 | hist = static_cast<TH1F*>(list[specie]->At(i)); | |
ae559def | 181 | if (hist && hist->TestBit(AliQAv1::GetImageBit())) { |
1706c710 | 182 | nImages++; |
05e5e0c1 | 183 | TString name(hist->GetName()); |
184 | if (name.Contains("readouterrors", TString::kIgnoreCase)) continue; | |
185 | Double_t hMax = hist->GetMaximum(); | |
186 | // hist->GetBinContent(hist->GetMaximumBin()); | |
187 | Double_t hMin = hist->GetMinimum(); | |
188 | // hist->GetBinContent(hist->GetMinimumBin()); | |
189 | max = TMath::Max(max, hMax); | |
190 | min = TMath::Min(min, hMin); | |
191 | AliInfo(Form("Histogram %30s min=%f, max=%f (min=%f,max=%f)", | |
192 | name.Data(), hMin, hMax, min, max)); | |
1706c710 | 193 | } |
194 | } | |
195 | break ; | |
196 | } | |
197 | min = TMath::Max(0.1, min); | |
05e5e0c1 | 198 | max = TMath::Max(1.0, max); |
1706c710 | 199 | |
200 | if (nImages == 0) { | |
201 | AliDebug(AliQAv1::GetQADebugLevel(), | |
202 | Form("No histogram will be plotted for %s %s\n", GetName(), | |
203 | AliQAv1::GetTaskName(task).Data())); | |
204 | return; | |
205 | } | |
206 | ||
207 | AliDebug(AliQAv1::GetQADebugLevel(), | |
208 | Form("%d histograms will be plotted for %s %s\n", | |
209 | nImages, GetName(), AliQAv1::GetTaskName(task).Data())); | |
05e5e0c1 | 210 | gStyle->SetOptStat(0); |
1706c710 | 211 | for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { |
05e5e0c1 | 212 | if (!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName())) |
213 | ->IsEventSpecieSet(specie)) continue; | |
1706c710 | 214 | |
05e5e0c1 | 215 | if(!list[specie] || list[specie]->GetEntries() <= 0) continue; |
1706c710 | 216 | |
217 | const Char_t * title = Form("QA_%s_%s_%s", GetName(), | |
218 | AliQAv1::GetTaskName(task).Data(), | |
219 | AliRecoParam::GetEventSpecieName(specie)); | |
05e5e0c1 | 220 | if (!fImage[specie]) |
221 | fImage[specie] = new TCanvas(title, title) ; | |
1706c710 | 222 | fImage[specie]->Clear() ; |
223 | fImage[specie]->SetTitle(title) ; | |
224 | fImage[specie]->cd() ; | |
225 | ||
226 | TPaveText someText(0.015, 0.015, 0.98, 0.98) ; | |
227 | someText.AddText(title) ; | |
228 | someText.Draw() ; | |
05e5e0c1 | 229 | TString outName(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), |
230 | AliQAv1::GetModeName(mode), | |
231 | AliQAChecker::Instance()->GetRunNumber(), | |
232 | AliQAv1::GetImageFileFormat())); | |
233 | fImage[specie]->Print(outName, "ps") ; | |
1706c710 | 234 | fImage[specie]->Clear(); |
235 | ||
dbac3484 | 236 | Int_t nx = int(nImages + .5) / 2; |
1706c710 | 237 | Int_t ny = 2; |
238 | fImage[specie]->Divide(nx, ny, 0, 0); | |
239 | ||
240 | ||
05e5e0c1 | 241 | TH1* hist = 0; |
1706c710 | 242 | Int_t nHist = list[specie]->GetEntriesFast(); |
05e5e0c1 | 243 | // list[specie]->Print(); |
1706c710 | 244 | Int_t j = 0; |
245 | for (Int_t i = 0; i < nHist; i++) { | |
05e5e0c1 | 246 | hist = static_cast<TH1*>(list[specie]->At(i)); |
247 | if (!hist || !hist->TestBit(AliQAv1::GetImageBit())) continue; | |
1706c710 | 248 | |
249 | TVirtualPad* pad = fImage[specie]->cd(++j); | |
05e5e0c1 | 250 | pad->SetRightMargin(0.001); |
251 | Int_t logOpts = 0; | |
252 | logOpts |= CheckForLog(hist->GetXaxis(), pad, 1); | |
253 | logOpts |= CheckForLog(hist->GetYaxis(), pad, 2); | |
254 | logOpts |= CheckForLog(hist->GetZaxis(), pad, 3); | |
255 | if (hist->GetEntries() > 0) | |
256 | AliInfo(Form("Drawing %30s (min=%f, max=%f) in pad %d", | |
257 | hist->GetName(), min, max, j)); | |
258 | ||
259 | TString opt; | |
260 | TString name(hist->GetName()); | |
261 | if (name.Contains("readouterrors", TString::kIgnoreCase)) { | |
262 | pad->SetRightMargin(0.15); | |
263 | pad->SetBottomMargin(0.10); | |
264 | pad->SetTopMargin(0.02); | |
265 | opt="COLZ"; | |
266 | } | |
267 | else { | |
268 | hist->SetMinimum(min); | |
269 | hist->SetMaximum(max); | |
270 | ||
271 | } | |
272 | hist->DrawCopy(opt); | |
273 | ||
274 | if (name.Contains("readouterrors", TString::kIgnoreCase)) | |
275 | continue; | |
276 | ||
277 | TPad* insert = new TPad("insert", "Zoom", | |
278 | .4,.4, .99, .95, 0, 0, 0); | |
279 | insert->SetTopMargin(0); | |
280 | insert->SetRightMargin(0.001); | |
281 | insert->SetFillColor(0); | |
282 | insert->SetBorderSize(1); | |
283 | insert->SetBorderMode(0); | |
284 | insert->Draw(); | |
285 | insert->cd(); | |
286 | if (logOpts & 0x1) insert->SetLogx(); | |
287 | if (logOpts & 0x2) insert->SetLogy(); | |
288 | if (logOpts & 0x4) insert->SetLogz(); | |
289 | hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetXmin(), | |
290 | hist->GetXaxis()->GetXmax()/8); | |
291 | hist->DrawCopy(opt); | |
292 | pad->cd(); | |
1706c710 | 293 | } |
294 | ||
05e5e0c1 | 295 | fImage[specie]->Print(outName, "ps"); |
1706c710 | 296 | } |
297 | } | |
c9dd1c4d | 298 | |
299 | //__________________________________________________________________ | |
300 | // | |
301 | // EOF | |
302 | // |