1 /**************************************************************************
2 * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 //__________________________________________________________________
25 //__________________________________________________________________
27 // --- ROOT system ---
31 #include <TIterator.h>
36 #include <TPaveText.h>
39 // --- AliRoot header files ---
42 #include "AliQAChecker.h"
43 #include "AliFMDQAChecker.h"
44 #include "AliRecoParam.h"
46 ClassImp(AliFMDQAChecker)
48 ; // This is for Emacs! - do not delete
51 //__________________________________________________________________
53 AliFMDQAChecker::CheckOne(AliQAv1::ALITASK_t what,
54 AliRecoParam::EventSpecie_t specie,
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);
63 //__________________________________________________________________
65 AliFMDQAChecker::CheckESD(AliRecoParam::EventSpecie_t /* specie*/,
68 return (hist->GetMean() > 0 ? 1 : 0);
70 //__________________________________________________________________
72 AliFMDQAChecker::CheckRaw(AliRecoParam::EventSpecie_t /* specie*/,
75 return (hist->GetMean() > 0 ? 1 : 0);
77 //__________________________________________________________________
79 AliFMDQAChecker::CheckSim(AliRecoParam::EventSpecie_t /* specie*/,
82 return (hist->GetMean() > 0 ? 1 : 0);
84 //__________________________________________________________________
86 AliFMDQAChecker::CheckRec(AliRecoParam::EventSpecie_t /* specie*/,
89 return (hist->GetMean() > 0 ? 1 : 0);
92 //__________________________________________________________________
93 void AliFMDQAChecker::Check(Double_t* rv,
94 AliQAv1::ALITASK_t what,
96 const AliDetectorRecoParam* /*t*/)
99 // Member function called to do the actual checking
102 // rv Array of return values.
103 // what What to check
104 // list Array of arrays of histograms. There's one arrat for
106 // t Reconstruction parameters - not used.
109 // Double_t* rv = new Double_t[AliRecoParam::kNSpecies] ;
110 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
114 if (!AliQAv1::Instance()->IsEventSpecieSet(specie) )
117 if(!list[specie]) continue;
120 Int_t nHist = list[specie]->GetEntriesFast();
121 for(Int_t i= 0; i< nHist; i++) {
123 if (!(hist = static_cast<TH1*>(list[specie]->At(i)))) continue;
125 rv[specie] += CheckOne(what, AliRecoParam::ConvertIndex(specie), hist);
127 // if (count != 0) rv[specie] /= count;
133 Int_t CheckForLog(TAxis* axis,
138 TString t(axis->GetTitle());
139 if (!t.Contains("[log]", TString::kIgnoreCase)) return 0;
140 t.ReplaceAll("[log]", "");
142 case 1: pad->SetLogx(); ret |= 0x1; break;
143 case 2: pad->SetLogy(); ret |= 0x2; break;
144 case 3: pad->SetLogz(); ret |= 0x4; break;
151 //____________________________________________________________________________
153 AliFMDQAChecker::MakeImage(TObjArray** list,
154 AliQAv1::TASKINDEX_t task,
155 AliQAv1::MODE_t mode)
157 // makes the QA image for sim and rec
160 // task What to check
161 // list Array of arrays of histograms. There's one array for
163 // t Reconstruction parameters - not used.
167 Double_t min = 10000;
168 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
169 AliRecoParam::EventSpecie_t spe = AliRecoParam::ConvertIndex(specie);
170 if (!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))
171 ->IsEventSpecieSet(spe))
173 // if (!AliQAv1::Instance()->IsEventSpecieSet(specie)) continue ;
175 if(!list[specie] || list[specie]->GetEntriesFast() == 0) continue;
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));
181 if (hist && hist->TestBit(AliQAv1::GetImageBit())) {
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));
197 min = TMath::Max(0.1, min);
198 max = TMath::Max(1.0, max);
201 AliDebug(AliQAv1::GetQADebugLevel(),
202 Form("No histogram will be plotted for %s %s\n", GetName(),
203 AliQAv1::GetTaskName(task).Data()));
207 AliDebug(AliQAv1::GetQADebugLevel(),
208 Form("%d histograms will be plotted for %s %s\n",
209 nImages, GetName(), AliQAv1::GetTaskName(task).Data()));
210 gStyle->SetOptStat(0);
211 for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
212 if (!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))
213 ->IsEventSpecieSet(specie)) continue;
215 if(!list[specie] || list[specie]->GetEntries() <= 0) continue;
217 const Char_t * title = Form("QA_%s_%s_%s", GetName(),
218 AliQAv1::GetTaskName(task).Data(),
219 AliRecoParam::GetEventSpecieName(specie));
221 fImage[specie] = new TCanvas(title, title) ;
222 fImage[specie]->Clear() ;
223 fImage[specie]->SetTitle(title) ;
224 fImage[specie]->cd() ;
226 TPaveText someText(0.015, 0.015, 0.98, 0.98) ;
227 someText.AddText(title) ;
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") ;
234 fImage[specie]->Clear();
236 Int_t nx = int(nImages + .5) / 2;
238 fImage[specie]->Divide(nx, ny, 0, 0);
242 Int_t nHist = list[specie]->GetEntriesFast();
243 // list[specie]->Print();
245 for (Int_t i = 0; i < nHist; i++) {
246 hist = static_cast<TH1*>(list[specie]->At(i));
247 if (!hist || !hist->TestBit(AliQAv1::GetImageBit())) continue;
249 TVirtualPad* pad = fImage[specie]->cd(++j);
250 pad->SetRightMargin(0.001);
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));
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);
268 hist->SetMinimum(min);
269 hist->SetMaximum(max);
274 if (name.Contains("readouterrors", TString::kIgnoreCase))
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);
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);
295 fImage[specie]->Print(outName, "ps");
299 //__________________________________________________________________