Classes for TPC calibration visualization (Marian, Lars, Stefan)
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewerGUI.cxx
CommitLineData
39bcd65d 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17///////////////////////////////////////////////////////////////////////////////
18// //
19// GUI for the AliTPCCalibViewer //
20// used for the calibration monitor
21// Example usage:
22/*
23 aliroot
24
25 AliTPCCalibViewerGUI v(gClient->GetRoot(), 1000, 600, "/u/sgaertne/calibration/localFit/AliTPCCalibViewer/allInOne6.root")
26
27 - Resize windows - (BUG to BE FIXED)
28
29*/ //
30// //
31///////////////////////////////////////////////////////////////////////////////
32
33
34#include "AliTPCCalibViewerGUI.h"
35
36#include <TCanvas.h>
37#include <TPad.h>
38#include <TVirtualPad.h>
39
40#include <TObjArray.h>
41#include <TObjString.h>
42#include <TVector.h>
43
44ClassImp(AliTPCCalibViewerGUI)
45
46AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName)
47 : TGMainFrame(p, w, h),
48 fViewer(0),
49 fContAll(0),
50 fContLeft(0),
51 fContRight(0),
52 fContCenter(0),
53 fContPlotOpt(0),
54 fContDrawOpt(0),
55 fContNormalized(0),
56 fContCustom(0),
57 fContCuts(0),
58 fContSector(0),
59 fContAddCuts(0),
60 fListVariables(0),
61 fBtnDraw(0),
62 fCanvMain(0),
63 fRadioRaw(0),
64 fRadioNormalized(0),
65 fRadioCustom(0),
66 fRadio1D(0),
67 fRadio2D(0),
68 fRadioTPC(0),
69 fRadioSideA(0),
70 fRadioSideC(0),
71 fRadioSector(0),
72 fChkAuto(0),
73 fComboMethod(0),
74 fListNormalization(0),
75 fTxtCustom(0),
76 fNmbSector(0),
77 fChkAddCuts(0),
78 fTxtAddCuts(0)
79//
80// AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing
81//
82{
83 SetCleanup(kDeepCleanup);
84
85 // ************************* content of this MainFrame *************************
86 // top level container with horizontal layout
87 fContAll = new TGCompositeFrame(this, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
88 AddFrame(fContAll, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
89
90 // ************************* content of fContAll *************************
91 // left container
92 fContLeft = new TGCompositeFrame(fContAll, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
93 fContAll->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
94
95 // left vertical splitter
96 TGVSplitter *splitLeft = new TGVSplitter(fContAll);
97 splitLeft->SetFrame(fContLeft, kTRUE);
98 fContAll->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
99
100 // right container
101 fContRight = new TGCompositeFrame(fContAll, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
102 fContAll->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
103
104 // center container
105 fContCenter = new TGCompositeFrame(fContAll, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
106 fContAll->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
107
108 // right vertical splitter
109 TGVSplitter *splitRight = new TGVSplitter(fContAll);
110 splitRight->SetFrame(fContRight, kFALSE);
111 fContAll->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
112
113 // ************************* content of fContLeft *************************
114 // list of variables
115 fListVariables = new TGListBox(fContLeft);
116 fContLeft->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
117 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
118
119 // plot options container
120 //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
121 fContPlotOpt = new TGGroupFrame(fContLeft, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
122 fContLeft->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
123
124 // draw options container
125 fContDrawOpt = new TGCompositeFrame(fContLeft, 200, 20, kHorizontalFrame | kFitWidth | kFixedHeight);
126 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
127
128 // draw button
129 fBtnDraw = new TGTextButton(fContLeft, "&Draw");
130 fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
131 //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
132 fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoDraw()");
133
134 // ************************* content of fContRight *************************
135 // cut options container
136 //fContCuts = new TGCompositeFrame(fContRight, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
137 fContCuts = new TGGroupFrame(fContRight, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
138 fContRight->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
139
140 // ************************* content of fContCenter *************************
141 // main drawing canvas
142 fCanvMain = new TRootEmbeddedCanvas("Main Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
143 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
144
145
146 // ************************* content of fContPlotOpt *************************
147 //TGButtonGroup *fBtngrpPlotOpt = new TGButtonGroup(fContPlotOpt, "Plot options",
148 // raw radio button
149 fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
150 fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
151 fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
152
153 // normalized radio button
154 fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
155 fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
156 fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
157
158 //fContPlotOpt->Show();
159
160 // normalized options container
161 fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
162 fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
163
164 // custom radio button
165 fRadioCustom = new TGRadioButton(fContPlotOpt, "Custom", 12);
166 fContPlotOpt->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
167 fRadioCustom->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
168
169 // custom options container
170 fContCustom = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
171 fContPlotOpt->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 15, 0, 0, 0));
172
173 // ************************* content of fContDrawOpt *************************
174 // 1D radio button
175 fRadio1D = new TGRadioButton(fContDrawOpt, "1D", 30);
176 fContDrawOpt->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
177 fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
178
179 // 2D radio button
180 fRadio2D = new TGRadioButton(fContDrawOpt, "2D", 31);
181 fContDrawOpt->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
182 fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
183
184 // automatic redraw check button
185 fChkAuto = new TGCheckButton(fContDrawOpt, "auto redraw");
186 fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
187
188 // ************************* content of fContCuts *************************
189 // TPC radio button
190 fRadioTPC = new TGRadioButton(fContCuts, "whole TPC", 20);
191 fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
192 fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
193
194 // side A radio button
195 fRadioSideA = new TGRadioButton(fContCuts, "side A", 21);
196 fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
197 fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
198
199 // side C radio button
200 fRadioSideC = new TGRadioButton(fContCuts, "side C", 22);
201 fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
202 fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
203
204 // sector radio button
205 fRadioSector = new TGRadioButton(fContCuts, "sector", 23);
206 fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
207 fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
208
209 // sector options container
210 fContSector = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
211 fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 15, 0, 0, 0));
212
213 // additional cuts check button
214 fChkAddCuts = new TGCheckButton(fContCuts, "additional cuts");
215 fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
216 fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
217
218 // additional cuts container
219 fContAddCuts = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
220 fContCuts->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, 15, 0, 0, 0));
221
222 // ************************* content of fContNormalized *************************
223 // method drop down combo box
224 fComboMethod = new TGComboBox(fContNormalized);
225 fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
226 fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
227 fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
228
229 // list of normalization variables
230 fListNormalization = new TGListBox(fContNormalized);
231 fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
232 fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
233
234 // ************************* content of fContCustom *************************
235 // text field for custom draw command
236 fTxtCustom = new TGTextEntry(fContCustom);
237 fContCustom->AddFrame(fTxtCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
238 fTxtCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
239
240 // ************************* content of fContSector *************************
241 // sector number entry
242 fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
243 fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
244 fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
245
246 // ************************* content of fContAddCuts *************************
247 // text field for additional cuts
248 fTxtAddCuts = new TGTextEntry(fContAddCuts);
249 fContAddCuts->AddFrame(fTxtAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
250 fTxtAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
251
252 // Display everything
253 Initialize(fileName);
254 SetWindowName("AliTPCCalibViewer GUI");
255 MapSubwindows();
256 Resize(GetDefaultSize());
257 MapWindow();
258}
259
260AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c)
261 : TGMainFrame(c.fParent, c.fWidth, c.fHeight),
262 fViewer(0),
263 fContAll(0),
264 fContLeft(0),
265 fContRight(0),
266 fContCenter(0),
267 fContPlotOpt(0),
268 fContDrawOpt(0),
269 fContNormalized(0),
270 fContCustom(0),
271 fContCuts(0),
272 fContSector(0),
273 fContAddCuts(0),
274 fListVariables(0),
275 fBtnDraw(0),
276 fCanvMain(0),
277 fRadioRaw(0),
278 fRadioNormalized(0),
279 fRadioCustom(0),
280 fRadio1D(0),
281 fRadio2D(0),
282 fRadioTPC(0),
283 fRadioSideA(0),
284 fRadioSideC(0),
285 fRadioSector(0),
286 fChkAuto(0),
287 fComboMethod(0),
288 fListNormalization(0),
289 fTxtCustom(0),
290 fNmbSector(0),
291 fChkAddCuts(0),
292 fTxtAddCuts(0)
293{
294 //
295 // dummy AliTPCCalibViewerGUI copy constructor
296 //
297}
298
299AliTPCCalibViewerGUI & AliTPCCalibViewerGUI::operator =(const AliTPCCalibViewerGUI & param) {
300 //
301 // dummy assignment operator
302 //
303 return (*this);
304}
305
306AliTPCCalibViewerGUI::~AliTPCCalibViewerGUI() {
307 Cleanup();
308}
309
310void AliTPCCalibViewerGUI::CloseWindow() {
311 DeleteWindow();
312}
313
314void AliTPCCalibViewerGUI::Initialize(char* fileName) {
315 //
316 // initializes the GUI with default settings and opens tree for drawing
317 //
318
319 // create AliTPCCalibViewer object, which will be used for generating all drawings
320 fViewer = new AliTPCCalibViewer(fileName);
321
322 // fill fListVariables
323 TObjArray* arr = fViewer->GetListOfVariables();
324 TIterator* iter = arr->MakeIterator();
325 iter->Reset();
326 TObjString* currentStr = 0;
327 Int_t id = 0;
328 while (currentStr = (TObjString*)(iter->Next())) {
329 fListVariables->AddEntry(currentStr->GetString().Data(), id);
330 id++;
331 }
332 delete iter;
333 arr->Delete();
334 delete arr;
335
336 // fill fComboMethod
337 fComboMethod->AddEntry("subtract", 0);
338 fComboMethod->AddEntry("divide by", 1);
339
340 // fill fListNorm
341 arr = fViewer->GetListOfNormalizationVariables();
342 iter = arr->MakeIterator();
343 iter->Reset();
344 currentStr = 0;
345 id = 0;
346 while (currentStr = (TObjString*)(iter->Next())) {
347 fListNormalization->AddEntry(currentStr->GetString().Data(), id);
348 id++;
349 }
350 delete iter;
351 arr->Delete();
352 delete arr;
353
354 // set default button states
355 fRadioRaw->SetState(kButtonDown);
356 fRadioTPC->SetState(kButtonDown);
357 //fRadioCustom->SetState(kButtonDisabled);
358 fRadio1D->SetState(kButtonDown);
359 fChkAuto->SetState(kButtonDown);
360 fChkAddCuts->SetState(kButtonUp);
361 fListVariables->Select(0);
362 fListNormalization->Select(0);
363 fComboMethod->Select(0);
364}
365
366void AliTPCCalibViewerGUI::HandleButtons(Int_t id) {
367 //
368 // handles mutual radio button exclusions
369 //
370 if (id == -1) {
371 TGButton *btn = (TGButton *) gTQSender;
372 id = btn->WidgetId();
373 }
374
375 switch (id) {
376 case 10: // fRadioRaw
377 fRadioNormalized->SetState(kButtonUp);
378 fRadioCustom->SetState(kButtonUp);
379 //fComboMethod->UnmapWindow();
380 //fListNormalization->UnmapWindow();
381 break;
382 case 11: // fRadioNormalized
383 fRadioRaw->SetState(kButtonUp);
384 fRadioCustom->SetState(kButtonUp);
385 break;
386 case 12: // fRadioCustom
387 fRadioRaw->SetState(kButtonUp);
388 fRadioNormalized->SetState(kButtonUp);
389 break;
390 //--------
391 case 20: // fRadioTPC
392 fRadioSideA->SetState(kButtonUp);
393 fRadioSideC->SetState(kButtonUp);
394 fRadioSector->SetState(kButtonUp);
395 break;
396 case 21: // fRadioSideA
397 fRadioTPC->SetState(kButtonUp);
398 fRadioSideC->SetState(kButtonUp);
399 fRadioSector->SetState(kButtonUp);
400 break;
401 case 22: // fRadioSideC
402 fRadioTPC->SetState(kButtonUp);
403 fRadioSideA->SetState(kButtonUp);
404 fRadioSector->SetState(kButtonUp);
405 break;
406 case 23: // fRadioSector
407 fRadioTPC->SetState(kButtonUp);
408 fRadioSideA->SetState(kButtonUp);
409 fRadioSideC->SetState(kButtonUp);
410 break;
411 //--------
412 case 30: // fRadio1D
413 fRadio2D->SetState(kButtonUp);
414 break;
415 case 31: // fRadio2D
416 fRadio1D->SetState(kButtonUp);
417 break;
418 }
419 //fRadioCustom->SetState(kButtonDisabled);
420
421 if (fChkAuto->GetState() == kButtonDown) DoDraw();
422}
423
424void AliTPCCalibViewerGUI::DoNewSelection() {
425 //
426 // decides whether to redraw if user makes another selection
427 //
428
429 if (fChkAuto->GetState() == kButtonDown) DoDraw();
430}
431
432void AliTPCCalibViewerGUI::DoDraw() {
433 //
434 // main method for drawing according to user selection
435 //
436
437 // specify data to plot
438 TString desiredData("");
439 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
440 desiredData += ".fElements";
441
442 // specify normalization
443 if (fRadioNormalized->GetState() == kButtonDown) {
444 TString op("");
445 switch (fComboMethod->GetSelected()) {
446 case 0: // subtraction
447 op += "-";
448 break;
449 case 1: // division
450 op += "/";
451 break;
452 }
453 TString normalizationData("");
454 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
455 desiredData += op;
456 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
457 //desiredData += "_";
458 desiredData += normalizationData;
459 }
460 else if (fRadioCustom->GetState() == kButtonDown) {
461 desiredData = fTxtCustom->GetText();
462 if (desiredData == "") return;
463 }
464
465 // specify cuts
466 TString sectorStr("");
467 if (fRadioTPC->GetState() == kButtonDown)
468 sectorStr += "ALL";
469 if (fRadioSideA->GetState() == kButtonDown)
470 sectorStr += "A"; //cuts += "(sector/18)%2==0";
471 if (fRadioSideC->GetState() == kButtonDown)
472 sectorStr+= "C"; //cuts += "(sector/18)%2==1";
473 if (fRadioSector->GetState() == kButtonDown) {
474 Int_t sector = (Int_t)(fNmbSector->GetNumber());
475 sectorStr += sector; //cuts += "sector==";
476 }
477 TString cutsStr("");
478 if (fChkAddCuts->GetState() == kButtonDown)
479 cutsStr += fTxtAddCuts->GetText();
480
481 // draw finally
482 fCanvMain->GetCanvas()->cd();
483 //fViewer->Draw(desiredData.Data(), cuts.Data());
484 if (fRadio1D->GetState() == kButtonDown)
485 fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
486 else if (fRadio2D->GetState() == kButtonDown)
487 fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
488
489 fCanvMain->GetCanvas()->Update();
490}