Adding missing protection if no data - AliTPCCalibViewerGUI.cxx AliTPCCalibViewe...
[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"
4a294b26 21#include "AliTPCCalPad.h"
22#include "AliTPCdataQA.h"
25eb8f52 23#include "AliTPCdataQA.h"
45af6e68 24#include <AmoreDA.h>
4a294b26 25#include <TROOT.h>
26#include <TStyle.h>
e9d4890d 27
28ClassImp(amore::TPC::ui::UIQA)
29
30#include <iostream>
31#include <sstream>
32#include <TCanvas.h>
33
34namespace amore {
35
36namespace TPC {
37
38namespace ui {
39
40using amore::subscriber::Subscribe;
41
45af6e68 42
43
44
e9d4890d 45UIQA::UIQA() {
46
47 Construct(); // Temporary but important!!! Do not forget to put this call in the constructor for the time being!
48
49}
50
51
52UIQA::~UIQA()
53{
54}
55
56void UIQA::Construct() { // The custom GUI is constructed here. gRootFrame is the container of the custom widgets.
57
58 fTab=new TGTab(amore::ui::gRootFrame);
59 amore::ui::gRootFrame->AddFrame(fTab);
4a294b26 60 //
61 TGCompositeFrame* tempFrame=fTab->AddTab("OverThreshold");
62 fEC[0]=new TRootEmbeddedCanvas("fEC0", tempFrame, 1000, 650);
e9d4890d 63 tempFrame->AddFrame(fEC[0]);
4a294b26 64 fEC[0]->GetCanvas()->Divide(3,3);
65 //
66 //
67 tempFrame=fTab->AddTab("Charge");
68 fEC[1]=new TRootEmbeddedCanvas("fEC1", tempFrame, 1000, 650);
69 tempFrame->AddFrame(fEC[1]);
70 fEC[1]->GetCanvas()->Divide(2,3);
71
72
e9d4890d 73 amore::ui::gRootFrame->MapSubwindows();
74 amore::ui::gRootFrame->Resize();
75 amore::ui::gRootFrame->MapWindow();
76
4a294b26 77 gROOT->SetStyle("Plain");
78 gStyle->SetFillColor(10);
79 gStyle->SetPadColor(10);
80 gStyle->SetCanvasColor(10);
81 gStyle->SetStatColor(10);
82
83 gStyle->SetPalette(1,0);
84 gStyle->SetNumberContours(30);
85 gStyle->SetOptFit(111);
86
87 gStyle->SetCanvasBorderMode(-1);
88 gStyle->SetCanvasBorderSize(1);
89 gStyle->SetCanvasColor(10);
90
91 gStyle->SetFrameFillColor(10);
92 gStyle->SetFrameBorderSize(1);
93 gStyle->SetFrameBorderMode(-1);
94 gStyle->SetFrameLineWidth(1.2);
e9d4890d 95}
96
97void UIQA::SubscribeMonitorObjects() { // Before using any MonitorObject, a subscription should be made.
98
45af6e68 99 //std::ostringstream stringStream;
100 //amore::core::String_t sourceName="CEDA/", subscription; // The agent name acting as a source could be concatenated with all the objects it contains
101 //subscription=sourceName+"CE";
102 //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 103 //...
25eb8f52 104 amore::core::String_t sourceName="TPCQA/", subscription;
105 subscription=sourceName+"TPCRAW";
106 Subscribe(subscription.c_str());
107 subscription=sourceName+"hist";
108 Subscribe(subscription.c_str());
109
e9d4890d 110}
111
112void 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...
113 std::ostringstream stringStream;
e9d4890d 114 // Example of accessing a normal TObject. The name is the name of the object in the QA framework
25eb8f52 115
116
117 //amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
118 amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/hist");
119 AliTPCdataQA *tpcqa=0;
120 printf("Pointer - %p\n",ptr);
121 if(ptr) {
122 ptr->Object()->Print();
123 }
124
125 ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
126 tpcqa=0;
127 printf("Pointer - %p\n",ptr);
128 if(ptr) {
129 tpcqa=(AliTPCdataQA*)ptr->Object();
130 printf("Pointertpcqa - %p\n",tpcqa);
131 tpcqa->Print();
132 }
133
4a294b26 134 if (!tpcqa) return;
135 //
136 // Over threshold
137 //
138
139 TCanvas *canvas = fEC[0]->GetCanvas();
140 if (tpcqa->GetOverThreshold5()){
141 canvas->cd(1);
142 tpcqa->GetOverThreshold5()->MakeHisto1D()->Draw();
143 canvas->cd(2);
144 tpcqa->GetOverThreshold5()->MakeHisto2D(0)->Draw("colz");
145 canvas->cd(3);
146 tpcqa->GetOverThreshold5()->MakeHisto2D(1)->Draw("colz");
147 }
148 //
149 if (tpcqa->GetOverThreshold10()){
150 canvas->cd(4);
151 tpcqa->GetOverThreshold10()->MakeHisto1D()->Draw();
152 canvas->cd(5);
153 tpcqa->GetOverThreshold10()->MakeHisto2D(0)->Draw("colz");
154 canvas->cd(6);
155 tpcqa->GetOverThreshold10()->MakeHisto2D(1)->Draw("colz");
156 }
157
158 if (tpcqa->GetOverThreshold20()){
159 canvas->cd(7);
160 tpcqa->GetOverThreshold20()->MakeHisto1D()->Draw();
161 canvas->cd(8);
162 tpcqa->GetOverThreshold20()->MakeHisto2D(0)->Draw("colz");
163 canvas->cd(9);
164 tpcqa->GetOverThreshold20()->MakeHisto2D(1)->Draw("colz");
165 }
166
167 //
168 // Mean charge
169 //
170
171 canvas = fEC[1]->GetCanvas();
172 if (tpcqa->GetMeanCharge()){
173 canvas->cd(1);
174 tpcqa->GetMeanCharge()->MakeHisto1D()->Draw();
175 canvas->cd(3);
176 tpcqa->GetMeanCharge()->MakeHisto2D(0)->Draw("colz");
177 canvas->cd(5);
178 tpcqa->GetMeanCharge()->MakeHisto2D(1)->Draw("colz");
179 //
180 canvas->cd(2);
181 tpcqa->GetMaxCharge()->MakeHisto1D()->Draw();
182 canvas->cd(4);
183 tpcqa->GetMaxCharge()->MakeHisto2D(0)->Draw("colz");
184 canvas->cd(6);
185 tpcqa->GetMaxCharge()->MakeHisto2D(1)->Draw("colz");
186 }
187
25eb8f52 188
e9d4890d 189 // End of access example
45af6e68 190
25eb8f52 191 //amore::da::AmoreDA amoreDA;
45af6e68 192 // hCalibCE->Dump();
25eb8f52 193 // TObject *temp=0;
194 //amoreDA.Receive("CEDA/CE",temp);
195 //temp->Dump();
45af6e68 196
e9d4890d 197
198}
199
200void UIQA::Process() {
201
202}
203
204void UIQA::StartOfCycle() {
205
206}
207
208void UIQA::EndOfCycle() {
209
210}
211
212};
213
214};
215
216};