The charge at cluster maxima used in the dataQA
[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!
9d63ae25 50 fCycle=0;
e9d4890d 51}
52
53
54UIQA::~UIQA()
55{
56}
57
266f8637 58void UIQA::Construct() { // The custom GUI is constructed here. gRootFrame is the container of the custom widgets.
59
e9d4890d 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);
266f8637 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;
266f8637 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";
45af6e68 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 }
7fb2364f 145
266f8637 146 if (!tpcqa) return;
4a294b26 147 //
148 // Over threshold
149 //
150
151 TCanvas *canvas = fEC[0]->GetCanvas();
266f8637 152 if (tpcqa->GetNoThreshold()){
4a294b26 153 canvas->cd(1);
266f8637 154 tpcqa->GetNoThreshold()->MakeHisto1D()->Draw();
4a294b26 155 canvas->cd(2);
266f8637 156 tpcqa->GetNoThreshold()->MakeHisto2D(0)->Draw("colz");
4a294b26 157 canvas->cd(3);
266f8637 158 tpcqa->GetNoThreshold()->MakeHisto2D(1)->Draw("colz");
4a294b26 159 }
160 //
266f8637 161 if (tpcqa->GetNTimeBins()){
4a294b26 162 canvas->cd(4);
266f8637 163 tpcqa->GetNTimeBins()->MakeHisto1D()->Draw();
4a294b26 164 canvas->cd(5);
266f8637 165 tpcqa->GetNTimeBins()->MakeHisto2D(0)->Draw("colz");
4a294b26 166 canvas->cd(6);
266f8637 167 tpcqa->GetNTimeBins()->MakeHisto2D(1)->Draw("colz");
4a294b26 168 }
169
266f8637 170 if (tpcqa->GetNPads()){
4a294b26 171 canvas->cd(7);
266f8637 172 tpcqa->GetNPads()->MakeHisto1D()->Draw();
4a294b26 173 canvas->cd(8);
266f8637 174 tpcqa->GetNPads()->MakeHisto2D(0)->Draw("colz");
4a294b26 175 canvas->cd(9);
266f8637 176 tpcqa->GetNPads()->MakeHisto2D(1)->Draw("colz");
4a294b26 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 }
266f8637 199 if (tpcqa) MakeTree(tpcqa);
25eb8f52 200
e9d4890d 201 // End of access example
266f8637 202
203 //amore::da::AmoreDA amoreDA;
204 // hCalibCE->Dump();
205 // TObject *temp=0;
206 //amoreDA.Receive("CEDA/CE",temp);
207 //temp->Dump();
208
209
e9d4890d 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 //
7fb2364f 227 //
9d63ae25 228 AliTPCPreprocessorOnline * preprocesor = new AliTPCPreprocessorOnline;
7fb2364f 229
266f8637 230 if (ped->GetNLocalMaxima())
231 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetNLocalMaxima())));
232 if (ped->GetMaxCharge())
233 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetMaxCharge())));
234 if (ped->GetMeanCharge())
235 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetMeanCharge())));
236 if (ped->GetNoThreshold())
237 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetNoThreshold())));
238 if (ped->GetNTimeBins())
239 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetNTimeBins())));
240 if (ped->GetNPads())
241 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetNPads())));
242 if (ped->GetTimePosition())
243 preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetTimePosition())));
252b0bbf 244 AliTPCCalPad * noise = GetNoise();
9d63ae25 245 if (noise) preprocesor->AddComponent(new AliTPCCalPad(*noise));
252b0bbf 246 AliTPCCalPad * pedestal = GetPedestal();
9d63ae25 247 if (pedestal) preprocesor->AddComponent(new AliTPCCalPad(*pedestal));
248 char fname[10000];
249 sprintf(fname,"QAtree%d.root",fCycle);
250 preprocesor->DumpToFile(fname);
251 fCycle++;
252b0bbf 252 delete noise;
253 delete pedestal;
266f8637 254 // /*CalibTree
252b0bbf 255 AliTPCCalibViewer *viewer = fViewerGUI->GetViewer();
9d63ae25 256 AliTPCCalibViewer *nviewer = new AliTPCCalibViewer(fname, "calPads");
266f8637 257 fViewerGUI->Initialize(nviewer);
258 //*/
252b0bbf 259 //
260 //
261 //
9d63ae25 262 delete preprocesor;
252b0bbf 263 }
264
265 AliTPCCalPad * UIQA::GetNoise(){
266 //
267 // GetNoise - if not in AmoreDB than from file
268 //
269 //amore::da::AmoreDA amoreDA;
270 // TObject *temp=0;
271 //amoreDA.Receive("PEDESTAL/NOISE",temp);
272 //temp->Dump();
273 // if (temp) return (AliTPCCalPad*) temp;
274 TDirectory * dir = gDirectory;
275 TFile *f = new TFile("$AMORE_SITE/PadNoise.root");
276 AliCDBEntry * entry = (AliCDBEntry*)f->Get("AliCDBEntry");
277 if (entry){
278 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
279 if (pad) {
280 pad->SetName("Noise");
281 pad->Print();
282 return pad;
283 }
284 }
285 f->Close();
286 dir->cd();
287 return 0;
288 }
289
290 AliTPCCalPad * UIQA::GetPedestal(){
291 //
292 //
293 TFile f("$AMORE_SITE/Pedestal.root");
294 AliCDBEntry * entry = (AliCDBEntry*)f.Get("AliCDBEntry");
295 if (entry){
296 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
297 if (pad) {
298 pad->SetName("Pedestals");
299 pad->Print();
300 return pad;
301 }
302 }
303 return 0;
304 }
305 AliTPCCalPad * UIQA::GetTime0(){
306 return 0;
307 }
308
309
310
e9d4890d 311};
312
313};
314
315};