typo
[u/mrichter/AliRoot.git] / test / QA / menuQA.C
CommitLineData
384c0618 1/*
2 * menuQA.C
3 *
4 *
5 * Created by schutz on 01/08/08.
6 * Copyright 2008 CERN. All rights reserved.
7 *fQA
8 */
9gROOT->Reset("a") ;
10
11TControlBar * fQA = NULL ;
12TControlBar * fDet = NULL ;
13TControlBar * fHist = NULL ;
f889de31 14const Int_t fRun = atoi(gSystem->Getenv("RUNNUM")) ;
384c0618 15AliQA * fQAResult = NULL ;
16TCanvas * fCa = NULL ;
17
18void menuQA()
19{
20 cout << AliQA::GetQAResultFileName() << endl ;
21 TFile * qaResultFile = TFile::Open("QA.root") ; //AliQA::GetQAResultFileName() ) ;
22 if ( ! qaResultFile ) {
23 printf("File %s not found in current directory\n", AliQA::GetQAResultFileName() ) ;
24 return ;
25 }
26 fQAResult = (AliQA *)qaResultFile->Get("QA") ;
27 if ( ! fQAResult ) {
28 printf("QA object not found in %s\n", AliQA::GetQAResultFileName() ) ;
29 return ;
30 }
31
32 TFile * qaDataFile = TFile::Open(Form("Merged.QA.%d.root", fRun)) ;
33 if ( ! qaDataFile ) {
34 printf("File Merged.QA.%d.root not found in current directory\n", fRun) ;
35 return ;
36 }
37 if (fQA)
38 delete fQA ;
72b79cf7 39 fQA = new TControlBar("vertical", Form("Active detectors in Run %d", fRun), 40, 20);
40 fQA->SetButtonWidth(400) ;
384c0618 41 fQA->AddButton("Clean Screen", "Cls()", "Clean the screen");
42 // search active detectors
43 TList * listOfDetectors = qaDataFile->GetListOfKeys() ;
44 for (Int_t det = 0 ; det < listOfDetectors->GetEntries() ; det++) {
45 char * detName = listOfDetectors->At(det)->GetName() ;
46 if (fQAResult->IsSetAny(AliQA::GetDetIndex(detName)))
47 char * buttonName = Form("QA SIGNALLED !! : %s", detName) ;
48 else
49 char * buttonName = Form("QA OK : %s", detName) ;
50 fQA->AddButton(buttonName, Form("MakeDetMenu(\"%s\")", detName), Form("Display the QA histograms for %s", detName));
51 }
52 fQA->Show();
53}
54
55void MakeDetMenu(char * detName)
56{
57 if (fDet)
58 delete fDet ;
59 if (fHist)
60 delete fHist ;
61 if (fCa)
62 delete fCa ;
72b79cf7 63 fDet = new TControlBar("vertical", detName, 9000, 8000);
64 fDet->SetButtonWidth(300) ;
384c0618 65 // serach all the QA tasks
66 TDirectory * save = gDirectory ;
67 gDirectory->cd(detName) ;
68 TList * listOfTasks = gDirectory->GetListOfKeys() ;
69 for (Int_t task = 0 ; task < listOfTasks->GetEntries() ; task++) {
f889de31 70 TString taskName = listOfTasks->At(task)->GetName() ;
71 AliQA::ALITASK_t tt = AliQA::kNULLTASK ;
72 if (taskName.Contains(AliQA::GetTaskName(AliQA::kRAWS)) )
73 tt = AliQA::kRAW ;
74 else if (taskName.Contains(AliQA::GetTaskName(AliQA::kRECPOINTS)) ||
1f76df3f 75 taskName.Contains(AliQA::GetTaskName(AliQA::kESDS)) )
f889de31 76 tt = AliQA::kREC ;
77 else if (taskName.Contains(AliQA::GetTaskName(AliQA::kHITS)) ||
78 taskName.Contains(AliQA::GetTaskName(AliQA::kSDIGITS)) ||
79 taskName.Contains(AliQA::GetTaskName(AliQA::kDIGITS)) )
80 tt = AliQA::kSIM ;
81 if (fQAResult->IsSetAny(AliQA::GetDetIndex(detName), tt))
82 char * buttonName = Form("QA SIGNALLED !! : %s", taskName.Data()) ;
384c0618 83 else
f889de31 84 char * buttonName = Form("QA OK : %s", taskName.Data()) ;
85 fDet->AddButton(buttonName, Form("MakeTaskMenu(\"%s\", \"%s\")", detName, taskName.Data()), Form("Display the QA histograms for %s", taskName.Data()));
384c0618 86 }
87 fDet->Show() ;
88 gDirectory = save ;
89}
90
91void MakeTaskMenu(char * detName, char * taskName )
92{
93 if (fHist)
94 delete fHist ;
95 if (fCa)
96 delete fCa ;
72b79cf7 97 fHist = new TControlBar("vertical", Form("QA histos for %s/%s", detName, taskName), 900, 300);
98 fHist->SetButtonWidth(300) ;
384c0618 99 fHist->AddButton("ALL", Form("DisplayAll(\"%s\", \"%s\")", detName, taskName), Form("Display the QA histograms for %s", detName));
100 TDirectory * save = gDirectory ;
101 gDirectory->cd(Form("%s/%s", detName, taskName)) ;
102 TList * listOfHistos = gDirectory->GetListOfKeys() ;
103 for (Int_t h = 0 ; h < listOfHistos->GetEntries() ; h++) {
104 char * hName = listOfHistos->At(h)->GetName() ;
105 fHist->AddButton(hName, Form("Display(\"%s\")", hName), Form("Display the QA histograms %s", hName));
106 }
107 fHist->Show() ;
108 gDirectory = save ;
109}
110
111
112void Display(char * hName)
113{
114 if (fCa)
115 delete fCa ;
116 cout << Display << " " << hName << endl ;
117 fCa = new TCanvas(hName, "test", 800, 600) ;
118 fCa->SetLogy() ;
119 TH1 * hh = dynamic_cast<TH1*>(gDirectory->FindObjectAny(hName));
120 if (hh) {
121 hh->Draw() ;
122 fCa->Modified() ;
123 fCa->Update() ;
124 }
125}
126
127void DisplayAll(char * detName, char * taskName)
128{
129 cout << Display << " " << detName << endl ;
130 TDirectory * save = gDirectory ;
131 gDirectory->cd(Form("%s/%s", detName, taskName)) ;
132 TList * listOfHistos = gDirectory->GetListOfKeys() ;
133 Int_t nHisto = listOfHistos->GetEntries() ;
134 Int_t ny = TMath::Sqrt(nHisto) ;
135 Int_t nx = nHisto / ny + 1 ;
136 if (fCa)
137 delete fCa ;
138 fCa = new TCanvas(Form("QA %s in %s", taskName, detName), Form("QA %s in %s", taskName, detName), nx*300, ny*300) ;
139 fCa->Divide(nx, ny) ;
140 for (Int_t h = 0 ; h < listOfHistos->GetEntries() ; h++) {
141 char * hName = listOfHistos->At(h)->GetName() ;
142 TH1 * hh = dynamic_cast<TH1*>(gDirectory->FindObjectAny(hName));
143 TPad * pad = fCa->cd(h+1) ;
144 pad->SetLogy() ;
145 if (hh) {
146 hh->Draw() ;
147 fCa->Modified() ;
148 fCa->Update() ;
149 }
150 }
151 fCa->Modified() ;
152 fCa->Update() ;
153 gDirectory = save ;
154}
155
156void Cls()
157{
158 if (fDet)
159 delete fDet ;
160 if (fHist)
161 delete fHist ;
162 if (fCa)
163 delete fCa ;
164}