Bug fix for list of cc addresses
[u/mrichter/AliRoot.git] / TPC / amoreTPC-QA / src / ui / UIQA.cxx
CommitLineData
e9d4890d 1/***************************************************************************
2 * Copyright (C) 2007 by Filimon Roukoutakis *
3 * Filimon.Roukoutakis@cern.ch *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20#include "UIQA.h"
45af6e68 21#include <AmoreDA.h>
4a294b26 22#include <TROOT.h>
23#include <TStyle.h>
252b0bbf 24#include "AliTPCCalPad.h"
25#include "AliTPCdataQA.h"
26#include "AliTPCCalibViewer.h"
27#include "AliTPCCalibViewerGUI.h"
28#include "AliTPCPreprocessorOnline.h"
29#include "AliCDBEntry.h"
e9d4890d 30ClassImp(amore::TPC::ui::UIQA)
31
32#include <iostream>
33#include <sstream>
34#include <TCanvas.h>
35
36namespace amore {
37
38namespace TPC {
39
40namespace ui {
41
42using amore::subscriber::Subscribe;
43
45af6e68 44
45
46
e9d4890d 47UIQA::UIQA() {
48
49 Construct(); // Temporary but important!!! Do not forget to put this call in the constructor for the time being!
50
51}
52
53
54UIQA::~UIQA()
55{
56}
57
58void UIQA::Construct() { // The custom GUI is constructed here. gRootFrame is the container of the custom widgets.
59
60 fTab=new TGTab(amore::ui::gRootFrame);
61 amore::ui::gRootFrame->AddFrame(fTab);
4a294b26 62 //
252b0bbf 63 //
64 TGCompositeFrame* tabCont1 =fTab->AddTab("Expert");
65
66 fViewerGUI = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, 0);
67 tabCont1->AddFrame(fViewerGUI , new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
68 //
69 TGCompositeFrame* tempFrame=fTab->AddTab("OverThreshold");
4a294b26 70 fEC[0]=new TRootEmbeddedCanvas("fEC0", tempFrame, 1000, 650);
e9d4890d 71 tempFrame->AddFrame(fEC[0]);
4a294b26 72 fEC[0]->GetCanvas()->Divide(3,3);
73 //
74 //
75 tempFrame=fTab->AddTab("Charge");
76 fEC[1]=new TRootEmbeddedCanvas("fEC1", tempFrame, 1000, 650);
77 tempFrame->AddFrame(fEC[1]);
78 fEC[1]->GetCanvas()->Divide(2,3);
252b0bbf 79 //
80 //
81
82
4a294b26 83
84
e9d4890d 85 amore::ui::gRootFrame->MapSubwindows();
86 amore::ui::gRootFrame->Resize();
87 amore::ui::gRootFrame->MapWindow();
88
4a294b26 89 gROOT->SetStyle("Plain");
90 gStyle->SetFillColor(10);
91 gStyle->SetPadColor(10);
92 gStyle->SetCanvasColor(10);
93 gStyle->SetStatColor(10);
94
95 gStyle->SetPalette(1,0);
96 gStyle->SetNumberContours(30);
97 gStyle->SetOptFit(111);
98
99 gStyle->SetCanvasBorderMode(-1);
100 gStyle->SetCanvasBorderSize(1);
101 gStyle->SetCanvasColor(10);
102
103 gStyle->SetFrameFillColor(10);
104 gStyle->SetFrameBorderSize(1);
105 gStyle->SetFrameBorderMode(-1);
252b0bbf 106 gStyle->SetFrameLineWidth(1.);
e9d4890d 107}
108
109void UIQA::SubscribeMonitorObjects() { // Before using any MonitorObject, a subscription should be made.
110
45af6e68 111 //std::ostringstream stringStream;
112 //amore::core::String_t sourceName="CEDA/", subscription; // The agent name acting as a source could be concatenated with all the objects it contains
113 //subscription=sourceName+"CE";
114 //Subscribe(subscription.c_str()); // Here you put a series of subscriptions where the string corresponds to the object name as published in the Publisher Module. As these names are internal to the QA framework, the recommended way of having consistency between AMORE and QA is to factor-out of QA the function that represents the histogram naming convention as a separate AliRoot class/function and use it from inside QA and AMORE.
e9d4890d 115 //...
25eb8f52 116 amore::core::String_t sourceName="TPCQA/", subscription;
117 subscription=sourceName+"TPCRAW";
118 Subscribe(subscription.c_str());
119 subscription=sourceName+"hist";
120 Subscribe(subscription.c_str());
121
e9d4890d 122}
123
124void UIQA::Update() { // This is executed after getting the updated contents of the subscribed MonitorObjects. Notice that the output of moInt[i] and moString[i] varies with time for a specific i because on the dqmAgent the "quality" check fails or succeeds. This is the essence of automatic data quality checks in AMORE. Try to use the moString[i] on a text widget to alert the shifter, or -depending of the value of moInt[i], 0 or 1- make part of the screen change color...
125 std::ostringstream stringStream;
e9d4890d 126 // Example of accessing a normal TObject. The name is the name of the object in the QA framework
25eb8f52 127
128
129 //amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
130 amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/hist");
131 AliTPCdataQA *tpcqa=0;
132 printf("Pointer - %p\n",ptr);
133 if(ptr) {
134 ptr->Object()->Print();
135 }
136
137 ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
138 tpcqa=0;
139 printf("Pointer - %p\n",ptr);
140 if(ptr) {
141 tpcqa=(AliTPCdataQA*)ptr->Object();
142 printf("Pointertpcqa - %p\n",tpcqa);
143 tpcqa->Print();
144 }
145
4a294b26 146 if (!tpcqa) return;
147 //
148 // Over threshold
149 //
150
151 TCanvas *canvas = fEC[0]->GetCanvas();
152 if (tpcqa->GetOverThreshold5()){
153 canvas->cd(1);
154 tpcqa->GetOverThreshold5()->MakeHisto1D()->Draw();
155 canvas->cd(2);
156 tpcqa->GetOverThreshold5()->MakeHisto2D(0)->Draw("colz");
157 canvas->cd(3);
158 tpcqa->GetOverThreshold5()->MakeHisto2D(1)->Draw("colz");
159 }
160 //
161 if (tpcqa->GetOverThreshold10()){
162 canvas->cd(4);
163 tpcqa->GetOverThreshold10()->MakeHisto1D()->Draw();
164 canvas->cd(5);
165 tpcqa->GetOverThreshold10()->MakeHisto2D(0)->Draw("colz");
166 canvas->cd(6);
167 tpcqa->GetOverThreshold10()->MakeHisto2D(1)->Draw("colz");
168 }
169
170 if (tpcqa->GetOverThreshold20()){
171 canvas->cd(7);
172 tpcqa->GetOverThreshold20()->MakeHisto1D()->Draw();
173 canvas->cd(8);
174 tpcqa->GetOverThreshold20()->MakeHisto2D(0)->Draw("colz");
175 canvas->cd(9);
176 tpcqa->GetOverThreshold20()->MakeHisto2D(1)->Draw("colz");
177 }
178
179 //
180 // Mean charge
181 //
182
183 canvas = fEC[1]->GetCanvas();
184 if (tpcqa->GetMeanCharge()){
185 canvas->cd(1);
186 tpcqa->GetMeanCharge()->MakeHisto1D()->Draw();
187 canvas->cd(3);
188 tpcqa->GetMeanCharge()->MakeHisto2D(0)->Draw("colz");
189 canvas->cd(5);
190 tpcqa->GetMeanCharge()->MakeHisto2D(1)->Draw("colz");
191 //
192 canvas->cd(2);
193 tpcqa->GetMaxCharge()->MakeHisto1D()->Draw();
194 canvas->cd(4);
195 tpcqa->GetMaxCharge()->MakeHisto2D(0)->Draw("colz");
196 canvas->cd(6);
197 tpcqa->GetMaxCharge()->MakeHisto2D(1)->Draw("colz");
198 }
252b0bbf 199 if (tpcqa) MakeTree(tpcqa);
25eb8f52 200
e9d4890d 201 // End of access example
45af6e68 202
25eb8f52 203 //amore::da::AmoreDA amoreDA;
45af6e68 204 // hCalibCE->Dump();
25eb8f52 205 // TObject *temp=0;
206 //amoreDA.Receive("CEDA/CE",temp);
207 //temp->Dump();
45af6e68 208
e9d4890d 209
210}
211
212void UIQA::Process() {
213
214}
215
216void UIQA::StartOfCycle() {
217
218}
219
220void UIQA::EndOfCycle() {
221
222}
223
252b0bbf 224
225 void UIQA::MakeTree(AliTPCdataQA* ped){
226 //
227 //
228 AliTPCPreprocessorOnline preprocesor;
229 if (ped->GetMaxCharge()) preprocesor.AddComponent(ped->GetMaxCharge());
230 if (ped->GetMeanCharge()) preprocesor.AddComponent(ped->GetMeanCharge());
231 if (ped->GetOverThreshold0()) preprocesor.AddComponent(ped->GetOverThreshold0());
232 if (ped->GetOverThreshold5()) preprocesor.AddComponent(ped->GetOverThreshold5());
233 if (ped->GetOverThreshold10()) preprocesor.AddComponent(ped->GetOverThreshold10());
234 if (ped->GetOverThreshold20()) preprocesor.AddComponent(ped->GetOverThreshold20());
235 if (ped->GetOverThreshold30()) preprocesor.AddComponent(ped->GetOverThreshold30());
236 AliTPCCalPad * noise = GetNoise();
237 if (noise) preprocesor.AddComponent(noise);
238 AliTPCCalPad * pedestal = GetPedestal();
239 if (pedestal) preprocesor.AddComponent(pedestal);
240 preprocesor.DumpToFile("CalibTree2.root");
241 delete noise;
242 delete pedestal;
243 // /*CalibTree
244 AliTPCCalibViewer *viewer = fViewerGUI->GetViewer();
245 AliTPCCalibViewer *nviewer = new AliTPCCalibViewer("CalibTree2.root", "calPads");
246 fViewerGUI->Initialize(nviewer);
247 //*/
248 //
249 //
250 //
251
252 }
253
254 AliTPCCalPad * UIQA::GetNoise(){
255 //
256 // GetNoise - if not in AmoreDB than from file
257 //
258 //amore::da::AmoreDA amoreDA;
259 // TObject *temp=0;
260 //amoreDA.Receive("PEDESTAL/NOISE",temp);
261 //temp->Dump();
262 // if (temp) return (AliTPCCalPad*) temp;
263 TDirectory * dir = gDirectory;
264 TFile *f = new TFile("$AMORE_SITE/PadNoise.root");
265 AliCDBEntry * entry = (AliCDBEntry*)f->Get("AliCDBEntry");
266 if (entry){
267 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
268 if (pad) {
269 pad->SetName("Noise");
270 pad->Print();
271 return pad;
272 }
273 }
274 f->Close();
275 dir->cd();
276 return 0;
277 }
278
279 AliTPCCalPad * UIQA::GetPedestal(){
280 //
281 //
282 TFile f("$AMORE_SITE/Pedestal.root");
283 AliCDBEntry * entry = (AliCDBEntry*)f.Get("AliCDBEntry");
284 if (entry){
285 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
286 if (pad) {
287 pad->SetName("Pedestals");
288 pad->Print();
289 return pad;
290 }
291 }
292 return 0;
293 }
294 AliTPCCalPad * UIQA::GetTime0(){
295 return 0;
296 }
297
298
299
e9d4890d 300};
301
302};
303
304};