1 /***************************************************************************
2 * Copyright (C) 2007 by Filimon Roukoutakis *
3 * Filimon.Roukoutakis@cern.ch *
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. *
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. *
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 ***************************************************************************/
24 #include "AliTPCCalPad.h"
25 #include "AliTPCdataQA.h"
26 #include "AliTPCCalibViewer.h"
27 #include "AliTPCCalibViewerGUI.h"
28 #include "AliTPCPreprocessorOnline.h"
29 #include "AliCDBEntry.h"
30 ClassImp(amore::TPC::ui::UIQA)
42 using amore::subscriber::Subscribe;
49 Construct(); // Temporary but important!!! Do not forget to put this call in the constructor for the time being!
58 void UIQA::Construct() {
61 // The custom GUI is constructed here. gRootFrame is the container of the custom widgets.
63 // Expert monitor - AliTPCCalibViewerGUI - fViewerGUI
65 fTab=new TGTab(amore::ui::gRootFrame);
66 amore::ui::gRootFrame->AddFrame(fTab);
70 TGCompositeFrame* tabCont1 =fTab->AddTab("Expert");
72 fViewerGUI = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, 0);
73 tabCont1->AddFrame(fViewerGUI , new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
75 TGCompositeFrame* tempFrame=fTab->AddTab("OverThreshold");
76 fEC[0]=new TRootEmbeddedCanvas("fEC0", tempFrame, 1000, 650);
77 tempFrame->AddFrame(fEC[0]);
78 fEC[0]->GetCanvas()->Divide(3,3);
81 tempFrame=fTab->AddTab("Charge");
82 fEC[1]=new TRootEmbeddedCanvas("fEC1", tempFrame, 1000, 650);
83 tempFrame->AddFrame(fEC[1]);
84 fEC[1]->GetCanvas()->Divide(2,3);
91 amore::ui::gRootFrame->MapSubwindows();
92 amore::ui::gRootFrame->Resize();
93 amore::ui::gRootFrame->MapWindow();
95 gROOT->SetStyle("Plain");
96 gStyle->SetFillColor(10);
97 gStyle->SetPadColor(10);
98 gStyle->SetCanvasColor(10);
99 gStyle->SetStatColor(10);
101 gStyle->SetPalette(1,0);
102 gStyle->SetNumberContours(30);
103 gStyle->SetOptFit(111);
105 gStyle->SetCanvasBorderMode(-1);
106 gStyle->SetCanvasBorderSize(1);
107 gStyle->SetCanvasColor(10);
109 gStyle->SetFrameFillColor(10);
110 gStyle->SetFrameBorderSize(1);
111 gStyle->SetFrameBorderMode(-1);
112 gStyle->SetFrameLineWidth(1.);
115 void UIQA::SubscribeMonitorObjects() { // Before using any MonitorObject, a subscription should be made.
117 //std::ostringstream stringStream;
118 // The agent name acting as a source could be concatenated with all the objects it contains
119 //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.
121 amore::core::String_t sourceName="TPCQA/", subscription;
122 subscription=sourceName+"TPCRAW";
123 Subscribe(subscription.c_str());
124 subscription=sourceName+"hist";
125 Subscribe(subscription.c_str());
129 void 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...
130 std::ostringstream stringStream;
131 // Example of accessing a normal TObject. The name is the name of the object in the QA framework
134 //amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
135 amore::core::MonitorObjectTObject* ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/hist");
136 AliTPCdataQA *tpcqa=0;
137 printf("Pointer - %p\n",ptr);
139 ptr->Object()->Print();
142 ptr=gSubscriber->At<amore::core::MOTObj>("TPCQA/TPCRAW");
144 printf("Pointer - %p\n",ptr);
146 tpcqa=(AliTPCdataQA*)ptr->Object();
147 printf("Pointertpcqa - %p\n",tpcqa);
154 // Expert monitor part
156 if (tpcqa) MakeTree(tpcqa);
163 TCanvas *canvas = fEC[0]->GetCanvas();
164 if (tpcqa->GetOverThreshold5()){
166 tpcqa->GetOverThreshold5()->MakeHisto1D()->Draw();
168 tpcqa->GetOverThreshold5()->MakeHisto2D(0)->Draw("colz");
170 tpcqa->GetOverThreshold5()->MakeHisto2D(1)->Draw("colz");
173 if (tpcqa->GetOverThreshold10()){
175 tpcqa->GetOverThreshold10()->MakeHisto1D()->Draw();
177 tpcqa->GetOverThreshold10()->MakeHisto2D(0)->Draw("colz");
179 tpcqa->GetOverThreshold10()->MakeHisto2D(1)->Draw("colz");
182 if (tpcqa->GetOverThreshold20()){
184 tpcqa->GetOverThreshold20()->MakeHisto1D()->Draw();
186 tpcqa->GetOverThreshold20()->MakeHisto2D(0)->Draw("colz");
188 tpcqa->GetOverThreshold20()->MakeHisto2D(1)->Draw("colz");
195 canvas = fEC[1]->GetCanvas();
196 if (tpcqa->GetMeanCharge()){
198 tpcqa->GetMeanCharge()->MakeHisto1D()->Draw();
200 tpcqa->GetMeanCharge()->MakeHisto2D(0)->Draw("colz");
202 tpcqa->GetMeanCharge()->MakeHisto2D(1)->Draw("colz");
205 tpcqa->GetMaxCharge()->MakeHisto1D()->Draw();
207 tpcqa->GetMaxCharge()->MakeHisto2D(0)->Draw("colz");
209 tpcqa->GetMaxCharge()->MakeHisto2D(1)->Draw("colz");
212 // End of access example
215 void UIQA::Process() {
219 void UIQA::StartOfCycle() {
223 void UIQA::EndOfCycle() {
228 void UIQA::MakeTree(AliTPCdataQA* ped){
230 // Prepare tree for expert monitor
237 AliTPCPreprocessorOnline * preprocesor = new AliTPCPreprocessorOnline;
238 if (ped->GetMaxCharge()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetMaxCharge())));
239 if (ped->GetMeanCharge()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetMeanCharge())));
240 if (ped->GetOverThreshold0()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetOverThreshold0())));
241 if (ped->GetOverThreshold5()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetOverThreshold5())));
242 if (ped->GetOverThreshold10()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetOverThreshold10())));
243 if (ped->GetOverThreshold20()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetOverThreshold20())));
244 if (ped->GetOverThreshold30()) preprocesor->AddComponent(new AliTPCCalPad(*(ped->GetOverThreshold30())));
250 AliTPCCalPad * noise = GetNoise();
251 if (noise) preprocesor->AddComponent(new AliTPCCalPad(*noise));
252 AliTPCCalPad * pedestal = GetPedestal();
253 if (pedestal) preprocesor->AddComponent(new AliTPCCalPad(*pedestal));
259 sprintf(fname,"QAtree%d.root",fCycle);
260 preprocesor->DumpToFile(fname);
269 AliTPCCalibViewer *viewer = fViewerGUI->GetViewer();
270 AliTPCCalibViewer *nviewer = new AliTPCCalibViewer(fname, "calPads");
271 fViewerGUI->Initialize(nviewer);
279 AliTPCCalPad * UIQA::GetNoise(){
281 // Get noise from DAs
282 // For the moment only get calibration param form local file
283 // file is exepected to be in $AMORE_SITE directory
287 // GetNoise - if not in AmoreDB than from file
289 //amore::da::AmoreDA amoreDA;
291 //amoreDA.Receive("PEDESTAL/NOISE",temp);
293 // if (temp) return (AliTPCCalPad*) temp;
296 TDirectory * dir = gDirectory;
297 TFile *f = new TFile("$AMORE_SITE/PadNoise.root");
298 AliCDBEntry * entry = (AliCDBEntry*)f->Get("AliCDBEntry");
300 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
302 pad->SetName("Noise");
312 AliTPCCalPad * UIQA::GetPedestal(){
315 TFile f("$AMORE_SITE/Pedestal.root");
316 AliCDBEntry * entry = (AliCDBEntry*)f.Get("AliCDBEntry");
318 AliTPCCalPad * pad = ((AliTPCCalPad *)entry->GetObject()->Clone());
320 pad->SetName("Pedestals");
327 AliTPCCalPad * UIQA::GetTime0(){