Line data Source code
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 : // //
18 : // Class to process a tree and create alarms based on thresholds //
19 : // origin: jens wiechula: jens.wiechula@cern.ch //
20 : // //
21 : ///////////////////////////////////////////////////////////////////////////////
22 :
23 : #include <iostream>
24 : #include <TObjArray.h>
25 : #include <TString.h>
26 : #include <TObjString.h>
27 : #include <TStyle.h>
28 : #include <TMarker.h>
29 : #include <TAxis.h>
30 : #include <TLine.h>
31 : #include <TList.h>
32 : #include <TTree.h>
33 : #include <TMath.h>
34 : #include <TGraph.h>
35 : #include <TFrame.h>
36 : #include <TIterator.h>
37 : #include <TPad.h>
38 : #include <TCanvas.h>
39 : #include <TH1.h>
40 : #include <TH2.h>
41 : #include <TStopwatch.h>
42 :
43 : #include <AliLog.h>
44 :
45 : #include "AliTPCCalibQAChecker.h"
46 :
47 : using namespace std;
48 :
49 : AliTPCCalibQAChecker::AliTPCCalibQAChecker() :
50 0 : TNamed("AliTPCCalibQAChecker","AliTPCCalibQAChecker"),
51 0 : fTreePtr(0x0),
52 0 : fHistPtr(0x0),
53 0 : fGraphPtr(0x0),
54 0 : fNumberPtr(0x0),
55 0 : fHist(0x0),
56 0 : fIterSubCheckers(0x0),
57 0 : fArrSubCheckers(0x0),
58 0 : fArrAlarmDescriptions(0x0),
59 0 : fStrDrawRep(""),
60 0 : fStrDrawRepOpt(""),
61 0 : fStrDraw(""),
62 0 : fStrDrawOpt(""),
63 0 : fStrCuts(""),
64 0 : fAlarmType(kMean),
65 0 : fQualityLevel(kINFO),
66 0 : fHistRep(0x0)
67 0 : {
68 : //
69 : // Default ctor
70 : //
71 0 : ResetAlarmThresholds();
72 0 : }
73 : //_________________________________________________________________________
74 : AliTPCCalibQAChecker::AliTPCCalibQAChecker(const char* name, const char *title) :
75 0 : TNamed(name,title),
76 0 : fTreePtr(0x0),
77 0 : fHistPtr(0x0),
78 0 : fGraphPtr(0x0),
79 0 : fNumberPtr(0x0),
80 0 : fHist(0x0),
81 0 : fIterSubCheckers(0x0),
82 0 : fArrSubCheckers(0x0),
83 0 : fArrAlarmDescriptions(0x0),
84 0 : fStrDrawRep(""),
85 0 : fStrDrawRepOpt(""),
86 0 : fStrDraw(""),
87 0 : fStrDrawOpt(""),
88 0 : fStrCuts(""),
89 0 : fAlarmType(kMean),
90 0 : fQualityLevel(kINFO),
91 0 : fHistRep(0x0)
92 0 : {
93 : //
94 : // TNamed ctor
95 : //
96 0 : ResetAlarmThresholds();
97 0 : }
98 : //_________________________________________________________________________
99 : AliTPCCalibQAChecker::~AliTPCCalibQAChecker()
100 0 : {
101 : //
102 : // Default ctor
103 : //
104 0 : if (fHistRep) delete fHistRep;
105 0 : if (fIterSubCheckers) delete fIterSubCheckers;
106 0 : if (fArrAlarmDescriptions) delete fArrAlarmDescriptions;
107 0 : if (fArrSubCheckers) delete fArrSubCheckers;
108 0 : }
109 : //_________________________________________________________________________
110 : void AliTPCCalibQAChecker::AddSubChecker(AliTPCCalibQAChecker *alarm)
111 : {
112 : //
113 : // add a sub checker to this checker
114 : //
115 0 : if (!alarm) return;
116 0 : if (!fArrSubCheckers) {
117 0 : fArrSubCheckers=new TObjArray;
118 0 : fArrSubCheckers->SetOwner();
119 0 : }
120 0 : fArrSubCheckers->Add(alarm);
121 0 : }
122 : //_________________________________________________________________________
123 : void AliTPCCalibQAChecker::Process()
124 : {
125 : //
126 : // Process the alarm thresholds, decide the alarm level, create the representation histogram
127 : //
128 :
129 : //reset quality level
130 0 : fQualityLevel=kINFO;
131 :
132 0 : TStopwatch s;
133 0 : s.Start();
134 : //decide which type of checker to use
135 0 : if (fArrSubCheckers && fArrSubCheckers->GetEntries()>0) ProcessSub();
136 0 : else if (fTreePtr && *fTreePtr) ProcessTree();
137 0 : else if (fHistPtr && *fHistPtr) ProcessHist();
138 0 : else if (fGraphPtr && *fGraphPtr) ProcessGraph();
139 0 : else if (fNumberPtr) ProcessNumber();
140 0 : s.Stop();
141 0 : AliInfo(Form("Processing Time (%s): %fs",GetName(),s.RealTime()));
142 0 : }
143 : //_________________________________________________________________________
144 : void AliTPCCalibQAChecker::ProcessSub()
145 : {
146 : //
147 : // sub checker type checker
148 : //
149 : QualityFlag_t quality=kINFO;
150 0 : if (fArrSubCheckers && fArrSubCheckers->GetEntries()>0){
151 0 : TIter next(fArrSubCheckers);
152 : TObject *o=0x0;
153 0 : while ( (o=next()) ) {
154 0 : AliTPCCalibQAChecker *al=(AliTPCCalibQAChecker*)o;
155 0 : al->Process();
156 0 : QualityFlag_t subQuality=al->GetQuality();
157 0 : if (subQuality>quality) quality=subQuality;
158 : }
159 0 : }
160 0 : fQualityLevel=quality;
161 0 : }
162 : //_________________________________________________________________________
163 : void AliTPCCalibQAChecker::ProcessTree()
164 : {
165 : //
166 : // process tree type checker
167 : //
168 :
169 : //Create Representation Histogram
170 0 : CreateRepresentationHist();
171 : //
172 : // if (!fTree) return;
173 : //chek for the quality
174 :
175 0 : switch (fAlarmType){
176 : case kNentries:
177 0 : ProcessEntries();
178 0 : break;
179 : case kMean:
180 : case kBinAny:
181 : case kBinAll:
182 0 : CreateAlarmHist();
183 0 : ProcessHist();
184 0 : ResetAlarmHist();
185 0 : break;
186 : }
187 :
188 0 : }
189 : //_________________________________________________________________________
190 : void AliTPCCalibQAChecker::ProcessHist()
191 : {
192 : //
193 : // process histogram type checker
194 : //
195 :
196 0 : if (!(fHistPtr && *fHistPtr)) return;
197 :
198 0 : switch (fAlarmType){
199 : case kNentries:
200 : case kMean:
201 0 : ProcessMean();
202 0 : break;
203 : case kBinAny:
204 : case kBinAll:
205 0 : ProcessBin();
206 0 : break;
207 : }
208 :
209 : //create representation histogram if we are not in tree mode
210 0 : if (!fTreePtr){
211 0 : if (!fHistRep) {
212 0 : fHistRep=(*fHistPtr)->Clone();
213 0 : TH1* h=(TH1*)fHistRep;
214 0 : h->SetDirectory(0);
215 0 : h->SetNameTitle(Form("h%s",GetName()),GetTitle());
216 0 : }
217 0 : TH1* h=(TH1*)fHistRep;
218 0 : h->Reset();
219 0 : h->Add(*fHistPtr);
220 0 : if (!fHistRep->InheritsFrom(TH2::Class())) AddQualityLines(h);
221 0 : }
222 0 : }
223 : //_________________________________________________________________________
224 : void AliTPCCalibQAChecker::ProcessGraph()
225 : {
226 : //
227 : // process graph type checker
228 : //
229 0 : if (!(fGraphPtr && *fGraphPtr)) return;
230 0 : Int_t npoints=(*fGraphPtr)->GetN();
231 0 : fQualityLevel=GetQuality(npoints,(*fGraphPtr)->GetY());
232 0 : }
233 : //_________________________________________________________________________
234 : void AliTPCCalibQAChecker::ProcessNumber()
235 : {
236 : //
237 : // process number type checker
238 : //
239 0 : if (!fNumberPtr) return;
240 0 : fQualityLevel=GetQuality(*fNumberPtr);
241 : //create representation histogram
242 0 : if (!fHistRep){
243 0 : TH1* h=new TH1F(Form("h%s",GetName()),GetTitle(),1,0,1);
244 0 : h->GetXaxis()->SetBinLabel(1,"Value");
245 0 : AddQualityLines(h);
246 0 : h->SetDirectory(0);
247 0 : fHistRep=h;
248 0 : }
249 0 : TH1 *h=(TH1*)fHistRep;
250 0 : TMarker *marker=(TMarker*)h->GetListOfFunctions()->FindObject("TMarker");
251 0 : if (!marker) {
252 0 : marker=new TMarker(.5,0,20);
253 0 : h->GetListOfFunctions()->Add(marker);
254 0 : }
255 0 : marker->SetMarkerColor(GetQualityColor());
256 0 : marker->SetY(*fNumberPtr);
257 0 : }
258 : //_________________________________________________________________________
259 : void AliTPCCalibQAChecker::ProcessEntries()
260 : {
261 : //
262 : // Processing function which analyses the number of affected rows of a tree draw
263 : //
264 0 : TString draw=fStrDraw;
265 0 : if (draw.IsNull()) return;
266 :
267 0 : TString cuts=fStrCuts;
268 :
269 0 : TString opt=fStrDrawOpt;
270 0 : opt+="goff";
271 :
272 : //draw and get the histogram
273 0 : Int_t res=(*fTreePtr)->Draw(draw.Data(),cuts.Data(),opt.Data());
274 0 : fQualityLevel=GetQuality(res);
275 0 : }
276 : //_________________________________________________________________________
277 : void AliTPCCalibQAChecker::ProcessMean()
278 : {
279 : //
280 : // Processing function which analyses the mean of the resulting histogram
281 : //
282 :
283 0 : TH1* h=(*fHistPtr);
284 0 : Double_t value=h->GetMean();
285 0 : if (fAlarmType==kNentries) value=h->GetEntries();
286 0 : fQualityLevel=GetQuality(value);
287 0 : }
288 : //_________________________________________________________________________
289 : void AliTPCCalibQAChecker::ProcessBin()
290 : {
291 : //
292 : // Process a histogram bin by bin and check for thresholds
293 : //
294 :
295 : //bin quality counters
296 0 : Int_t nquality[kNQualityFlags];
297 0 : for (Int_t iquality=(Int_t)kINFO; iquality<kNQualityFlags; ++iquality) nquality[iquality]=0;
298 :
299 0 : TH1 *h=(*fHistPtr);
300 :
301 0 : Int_t nbinsX=h->GetNbinsX();
302 0 : Int_t nbinsY=h->GetNbinsY();
303 0 : Int_t nbinsZ=h->GetNbinsZ();
304 0 : Int_t nbinsTotal=nbinsX*nbinsY*nbinsZ;
305 :
306 : //loop over all bins
307 0 : for (Int_t ibinZ=1;ibinZ<nbinsZ+1;++ibinZ){
308 0 : for (Int_t ibinY=1;ibinY<nbinsY+1;++ibinY){
309 0 : for (Int_t ibinX=1;ibinX<nbinsX+1;++ibinX){
310 0 : Double_t value = (*fHistPtr)->GetBinContent(ibinX, ibinY, ibinZ);
311 0 : QualityFlag_t quality=GetQuality(value);
312 0 : nquality[quality]++;
313 : }
314 : }
315 : }
316 :
317 : //loop over Quality levels and set quality
318 0 : for (Int_t iquality=(Int_t)kINFO; iquality<kNQualityFlags; ++iquality){
319 0 : if (fAlarmType==kBinAny){
320 0 : if (nquality[iquality]) fQualityLevel=(QualityFlag_t)iquality;
321 0 : } else if (fAlarmType==kBinAll){
322 0 : if (nquality[iquality]==nbinsTotal) fQualityLevel=(QualityFlag_t)iquality;
323 : }
324 : }
325 0 : }
326 : //_________________________________________________________________________
327 : void AliTPCCalibQAChecker::CreateRepresentationHist()
328 : {
329 : //
330 : // Create the representation histogram which will be shown in the draw function
331 : //
332 0 : ResetRepresentationHist();
333 :
334 0 : TString draw=fStrDrawRep;
335 0 : if (draw.IsNull()) {
336 0 : draw=fStrDraw;
337 0 : fStrDrawRepOpt=fStrDrawOpt;
338 : } else {
339 0 : draw.ReplaceAll("%alarm%",fStrDraw.Data());
340 : }
341 0 : if (draw.IsNull()) return;
342 :
343 0 : TString cuts=fStrCuts;
344 :
345 0 : TString opt=fStrDrawRepOpt;
346 0 : opt+="goff";
347 :
348 0 : Int_t res=(*fTreePtr)->Draw(draw.Data(),cuts.Data(),opt.Data());
349 0 : TH1 *hist=(*fTreePtr)->GetHistogram();
350 0 : if (res<0 || !hist){
351 0 : AliError(Form("Could not create representation histogram of alarm '%s'",GetName()));
352 0 : return;
353 : }
354 0 : fHistRep=hist->Clone();
355 0 : TH1 *h=(TH1*)fHistRep;
356 0 : h->SetDirectory(0);
357 0 : h->SetNameTitle(Form("h%s",GetName()),GetTitle());
358 0 : }
359 : //_________________________________________________________________________
360 : void AliTPCCalibQAChecker::CreateAlarmHist()
361 : {
362 : //
363 : // create alarm histogram from the tree
364 : //
365 :
366 0 : TString draw=fStrDraw;
367 0 : if (draw.IsNull()) return;
368 :
369 0 : TString cuts=fStrCuts;
370 :
371 0 : TString opt=fStrDrawOpt;
372 0 : opt+="goff";
373 :
374 : //draw and get the histogram
375 0 : Int_t res=(*fTreePtr)->Draw(draw.Data(),cuts.Data(),opt.Data());
376 0 : fHist=(*fTreePtr)->GetHistogram();
377 0 : if (res<0 || !fHist){
378 0 : AliError(Form("Could not create alarm histogram of alarm '%s'",GetName()));
379 0 : return;
380 : }
381 0 : fHist->SetDirectory(0);
382 0 : fHistPtr=&fHist;
383 0 : }
384 : //_________________________________________________________________________
385 : void AliTPCCalibQAChecker::ResetAlarmHist()
386 : {
387 : //
388 : // delete the alarm histogram and reset the pointer
389 : //
390 0 : if (fHistPtr){
391 0 : if (*fHistPtr) delete *fHistPtr;
392 0 : fHistPtr=0x0;
393 0 : }
394 0 : }
395 : //_________________________________________________________________________
396 : void AliTPCCalibQAChecker::Draw(Option_t *option)
397 : {
398 : //
399 : // object draw function
400 : // by default the pad backgound color is set to the quality level color
401 : // use 'nobc' to change this
402 : //
403 :
404 : //case of a node with subcheckers and no specific representation histogram
405 0 : if (HasSubCheckers()&&!fHistRep) {DrawSubNodes(option); return;}
406 0 : if (fHistRep) {DrawRepresentationHist(option); return;}
407 0 : }
408 : //_________________________________________________________________________
409 : void AliTPCCalibQAChecker::Print(Option_t * const option) const
410 : {
411 : //
412 : // print the quality status. If we have sub checkers print recursively
413 : //
414 0 : TString sOpt(option);
415 0 : cout << sOpt << GetName() << ": " << GetQualityName() << endl;
416 0 : if (fArrSubCheckers && fArrSubCheckers->GetEntries()>0){
417 0 : sOpt.ReplaceAll("+-"," ");
418 0 : sOpt+="+-";
419 0 : TIter next(fArrSubCheckers);
420 : TObject *o=0x0;
421 0 : while ( (o=next()) ) o->Print(sOpt.Data());
422 0 : }
423 0 : }
424 : //_________________________________________________________________________
425 : void AliTPCCalibQAChecker::SetAlarmThreshold(Double_t min, Double_t max, QualityFlag_t quality)
426 : {
427 : //
428 : //set the alarm thresholds for a specific quality level
429 : //
430 0 : if ((Int_t)quality<(Int_t)kINFO||(Int_t)quality>=kNQualityFlags) return;
431 0 : fThresMin[quality]=min;
432 0 : fThresMax[quality]=max;
433 0 : }
434 : //_________________________________________________________________________
435 : void AliTPCCalibQAChecker::ResetAlarmThreshold(QualityFlag_t quality)
436 : {
437 : //
438 : //set the alarm thresholds for a specific quality level
439 : //
440 0 : if ((Int_t)quality<(Int_t)kINFO||(Int_t)quality>=kNQualityFlags) return;
441 0 : fThresMin[quality]=0;
442 0 : fThresMax[quality]=0;
443 0 : }
444 : //_________________________________________________________________________
445 : void AliTPCCalibQAChecker::ResetAlarmThresholds()
446 : {
447 : //
448 : //reset all the alarm thresholds
449 : //
450 0 : for (Int_t i=0;i<kNQualityFlags;++i){
451 0 : fThresMin[i]=0;
452 0 : fThresMax[i]=0;
453 : }
454 0 : }
455 : //_________________________________________________________________________
456 : void AliTPCCalibQAChecker::SetQualityDescription(const char* text, QualityFlag_t quality)
457 : {
458 : //
459 : // set an description for the quality level
460 : // %min and %max will be replaced by the min and max values of the alarm, when the quality
461 : // description is queried (see QualityDescription)
462 : //
463 :
464 0 : if (quality<kINFO||quality>kFATAL) return;
465 0 : if (! fArrAlarmDescriptions ) fArrAlarmDescriptions=new TObjArray(kNQualityFlags);
466 0 : TObjString *s=(TObjString*)fArrAlarmDescriptions->At(quality);
467 0 : if (!s) fArrAlarmDescriptions->AddAt(s=new TObjString,quality);
468 0 : s->SetString(text);
469 0 : }
470 :
471 : //_________________________________________________________________________
472 : const AliTPCCalibQAChecker* AliTPCCalibQAChecker::GetSubChecker(const char* name, Bool_t recursive) const
473 : {
474 : //
475 : // Return subnode with 'name'
476 : //
477 0 : TString sname(name);
478 0 : if (sname==GetName()) return this;
479 0 : if (!fArrSubCheckers || !fArrSubCheckers->GetEntries()) return 0x0;
480 : const AliTPCCalibQAChecker *al=0x0;
481 0 : if (recursive){
482 0 : TIter next(fArrSubCheckers);
483 : TObject *o=0x0;
484 0 : while ( (o=next()) ){
485 0 : AliTPCCalibQAChecker *sal=(AliTPCCalibQAChecker*)o;
486 0 : al=sal->GetSubChecker(name);
487 0 : if (al) break;
488 0 : }
489 0 : }else{
490 0 : al=dynamic_cast<AliTPCCalibQAChecker*>(fArrSubCheckers->FindObject(name));
491 : }
492 : return al;
493 0 : }
494 : //_________________________________________________________________________
495 : Int_t AliTPCCalibQAChecker::GetNumberOfSubCheckers(Bool_t recursive) const
496 : {
497 : //
498 : // get the number of sub checkers
499 : // if recursive get total number of non subchecker type sub checkers
500 : //
501 : Int_t nsub=0;
502 0 : if (recursive){
503 0 : if (!fArrSubCheckers) return 1;
504 0 : if (!fArrSubCheckers->GetEntries()) return 0;
505 0 : TIter next(fArrSubCheckers);
506 : TObject *o=0x0;
507 0 : while ( (o=next()) ){
508 0 : AliTPCCalibQAChecker *al=(AliTPCCalibQAChecker*)o;
509 0 : nsub+=al->GetNumberOfSubCheckers();
510 : }
511 0 : } else {
512 0 : if (fArrSubCheckers) nsub=fArrSubCheckers->GetEntries();
513 : }
514 0 : return nsub;
515 0 : }
516 : //_________________________________________________________________________
517 : AliTPCCalibQAChecker* AliTPCCalibQAChecker::NextSubChecker()
518 : {
519 : //
520 : // loop over sub checkers
521 : // if recursive, recursively return the pointers of non subchecker type sub checkers
522 : //
523 0 : if (!fArrSubCheckers || !fArrSubCheckers->GetEntries()) return 0;
524 0 : if (!fIterSubCheckers) fIterSubCheckers=fArrSubCheckers->MakeIterator();
525 0 : AliTPCCalibQAChecker *al=(AliTPCCalibQAChecker*)fIterSubCheckers->Next();
526 0 : if (!al){
527 0 : delete fIterSubCheckers;
528 0 : fIterSubCheckers=0x0;
529 0 : }
530 : // if (recursive && al->GetNumberOfSubCheckers(kFALSE)) al=al->NextSubChecker();
531 : return al;
532 0 : }
533 : //_________________________________________________________________________
534 : const char* AliTPCCalibQAChecker::QualityName(AliTPCCalibQAChecker::QualityFlag_t quality)
535 : {
536 : //
537 : // get quality name for quality
538 : //
539 0 : switch (quality){
540 : case kINFO:
541 0 : return "Info";
542 : break;
543 : case kWARNING:
544 0 : return "Warning";
545 : break;
546 : case kERROR:
547 0 : return "Error";
548 : break;
549 : case kFATAL:
550 0 : return "Fatal";
551 : break;
552 : default:
553 0 : return "";
554 : }
555 0 : }
556 : //_________________________________________________________________________
557 : Color_t AliTPCCalibQAChecker::QualityColor(AliTPCCalibQAChecker::QualityFlag_t quality)
558 : {
559 : //
560 : // get quality color for quality
561 : //
562 : Color_t info = kSpring-8;
563 : Color_t warning = kOrange;
564 : Color_t error = kRed;
565 : Color_t fatal = kRed+2;
566 : Color_t none = kWhite;
567 :
568 0 : switch(quality) {
569 : case kINFO :
570 0 : return info;
571 : break;
572 : case kWARNING :
573 0 : return warning;
574 : break;
575 : case kERROR :
576 0 : return error;
577 : break;
578 : case kFATAL :
579 0 : return fatal;
580 : break;
581 : default:
582 0 : return none;
583 : }
584 : return none;
585 :
586 0 : }
587 : //_________________________________________________________________________
588 : const char* AliTPCCalibQAChecker::QualityDescription(QualityFlag_t quality) const
589 : {
590 : //
591 : // return description for quality
592 : //
593 0 : if (!fArrAlarmDescriptions || !fArrAlarmDescriptions->At(quality)) return "";
594 0 : TString s(fArrAlarmDescriptions->At(quality)->GetName());
595 0 : TString min, max;
596 0 : min+=fThresMin[quality];
597 0 : max+=fThresMax[quality];
598 0 : s.ReplaceAll("%min",min);
599 0 : s.ReplaceAll("%max",max);
600 0 : return s.Data();
601 0 : }
602 : //_________________________________________________________________________
603 : Int_t AliTPCCalibQAChecker::DrawInPad(TVirtualPad *pad, Int_t sub)
604 : {
605 : //
606 : // Draw recursively in 'pad'
607 : //
608 :
609 0 : if (fArrSubCheckers){
610 0 : if (fArrSubCheckers->GetEntries()>0){
611 0 : TIter next(fArrSubCheckers);
612 : TObject *o=0x0;
613 0 : while ( (o=next()) ) {
614 0 : AliTPCCalibQAChecker *al=(AliTPCCalibQAChecker*)o;
615 0 : sub=al->DrawInPad(pad,sub);
616 : }
617 0 : }
618 : } else {
619 0 : pad->cd(sub);
620 0 : ++sub;
621 0 : Draw();
622 : }
623 0 : return sub;
624 0 : }
625 : //_________________________________________________________________________
626 : void AliTPCCalibQAChecker::DrawSubNodes(Option_t */*option*/)
627 : {
628 : //
629 : // divide the current pad in sub pads and draw all sub nodes
630 : //
631 0 : if (!gPad) new TCanvas;
632 0 : TPad *mother=(TPad*)gPad;
633 0 : mother->Clear();
634 : //find number of sub pads needed
635 0 : Int_t nPads = GetNumberOfSubCheckers();
636 0 : Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) );
637 0 : Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols );
638 0 : gPad->Divide(nCols,nRows);
639 :
640 0 : DrawInPad(gPad);
641 0 : mother->Update();
642 : TPad *pad=0;
643 : Int_t ipad=1;
644 0 : while ( (pad=(TPad*)mother->GetPad(ipad)) ){
645 0 : TFrame* frame=(TFrame*)pad->GetPrimitive("TFrame");
646 0 : if (frame) frame->SetFillColor(kWhite);
647 0 : else {printf("no frame\n");}
648 0 : pad->Modified();
649 0 : ++ipad;
650 : }
651 0 : mother->Update();
652 0 : }
653 : //_________________________________________________________________________
654 : void AliTPCCalibQAChecker::DrawRepresentationHist(const Option_t *option)
655 : {
656 : //
657 : // Draw the representation histogram
658 : //
659 0 : if (!fHistRep) return;
660 0 : if (!gPad) new TCanvas;
661 : Bool_t withBackColor=kTRUE;
662 :
663 0 : TString opt=option;
664 0 : opt.ToLower();
665 :
666 0 : if (opt.Contains("nobc")) withBackColor=kFALSE;
667 0 : opt.ReplaceAll("nobc","");
668 :
669 0 : if (opt.IsNull()) opt=fStrDrawRepOpt;
670 0 : opt.ToLower();
671 :
672 0 : opt.ReplaceAll("prof","");
673 :
674 0 : fHistRep->Draw(opt.Data());
675 0 : if (withBackColor) {
676 0 : gPad->SetFillColor(GetQualityColor());
677 : }
678 :
679 0 : gPad->Modified();
680 0 : }
681 : //_________________________________________________________________________
682 : void AliTPCCalibQAChecker::AddQualityLines(TH1 *hist)
683 : {
684 : //
685 : // add lines indicating the quality level to hist
686 : //
687 :
688 0 : Double_t xmin=hist->GetXaxis()->GetXmin();
689 0 : Double_t xmax=hist->GetXaxis()->GetXmax();
690 : Double_t min=0;
691 : Double_t max=0;
692 :
693 0 : for (Int_t i=(Int_t)kINFO; i<kNQualityFlags; ++i){
694 0 : if (fThresMin[i]>=fThresMax[i]) continue;
695 : min=fThresMin[i];
696 : max=fThresMax[i];
697 0 : TLine *lmin=new TLine(xmin,min,xmax,min);
698 0 : lmin->SetLineWidth(2);
699 0 : lmin->SetLineColor(QualityColor((QualityFlag_t)i));
700 0 : TLine *lmax=new TLine(xmin,max,xmax,max);
701 0 : lmax->SetLineWidth(2);
702 0 : lmax->SetLineColor(QualityColor((QualityFlag_t)i));
703 0 : hist->GetListOfFunctions()->Add(lmin);
704 0 : hist->GetListOfFunctions()->Add(lmax);
705 0 : }
706 0 : hist->SetAxisRange(min,max,"Y");
707 0 : }
|