Updated list of framework libraries
[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 //
a6d2bd0c 20// used for the calibration monitor //
21// Example usage: //
39bcd65d 22/*
23 aliroot
a6d2bd0c 24 AliTPCCalibViewerGUI::showGUI("allInOne22.root")
25*/
26// - Resize windows - (BUG to BE FIXED -> ROOT bug) //
39bcd65d 27// //
28///////////////////////////////////////////////////////////////////////////////
29
30
31#include "AliTPCCalibViewerGUI.h"
32
33#include <TCanvas.h>
34#include <TPad.h>
35#include <TVirtualPad.h>
36
37#include <TObjArray.h>
38#include <TObjString.h>
39#include <TVector.h>
a6d2bd0c 40#include <string.h>
41#include <TH1.h>
42
39bcd65d 43
44ClassImp(AliTPCCalibViewerGUI)
45
46AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName)
a6d2bd0c 47 : TGCompositeFrame(p, w, h),
39bcd65d 48 fViewer(0),
a6d2bd0c 49 fContTopBottom(0),
50 fContLCR(0),
39bcd65d 51 fContLeft(0),
52 fContRight(0),
53 fContCenter(0),
54 fContPlotOpt(0),
55 fContDrawOpt(0),
a6d2bd0c 56 fContDrawOptSub1D2D(0),
39bcd65d 57 fContNormalized(0),
58 fContCustom(0),
59 fContCuts(0),
60 fContSector(0),
61 fContAddCuts(0),
a6d2bd0c 62 fContFit(0),
63 fContAddFit(0),
64 fContScaling(0),
65 fContSetMax(0),
66 fContSetMin(0),
39bcd65d 67 fListVariables(0),
68 fBtnDraw(0),
a6d2bd0c 69 fBtnFit(0),
70 fBtnAddFitFunction(0),
71 fBtnGetMinMax(0),
39bcd65d 72 fCanvMain(0),
73 fRadioRaw(0),
74 fRadioNormalized(0),
a6d2bd0c 75 fRadioPredefined(0),
39bcd65d 76 fRadioCustom(0),
77 fRadio1D(0),
78 fRadio2D(0),
79 fRadioTPC(0),
80 fRadioSideA(0),
81 fRadioSideC(0),
82 fRadioSector(0),
83 fChkAuto(0),
84 fComboMethod(0),
85 fListNormalization(0),
a6d2bd0c 86 fComboCustom(0),
39bcd65d 87 fNmbSector(0),
a6d2bd0c 88 fLblSector(0),
39bcd65d 89 fChkAddCuts(0),
a6d2bd0c 90 fComboAddCuts(0),
91 fComboCustomFit(0),
92 fChkSetMax(0),
93 fChkSetMin(0),
94 fChkGetMinMaxAuto(0),
95 fTxtSetMax(0),
96 fTxtSetMin(0)
39bcd65d 97//
98// AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing
99//
100{
101 SetCleanup(kDeepCleanup);
102
103 // ************************* content of this MainFrame *************************
104 // top level container with horizontal layout
a6d2bd0c 105 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
106 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
107
108 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
109 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
110
39bcd65d 111
a6d2bd0c 112 // ************************* content of fContLCR *************************
39bcd65d 113 // left container
a6d2bd0c 114 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
115 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
39bcd65d 116
117 // left vertical splitter
a6d2bd0c 118 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
39bcd65d 119 splitLeft->SetFrame(fContLeft, kTRUE);
a6d2bd0c 120 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 121
122 // right container
a6d2bd0c 123 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
124 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
39bcd65d 125
126 // center container
a6d2bd0c 127 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
128 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 129
130 // right vertical splitter
a6d2bd0c 131 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
39bcd65d 132 splitRight->SetFrame(fContRight, kFALSE);
a6d2bd0c 133 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 134
135 // ************************* content of fContLeft *************************
a6d2bd0c 136 // draw button
137 fBtnDraw = new TGTextButton(fContLeft, "&Draw");
138 fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
139 //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
140 fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoDraw()");
141
142 // draw options container
143 fContDrawOpt = new TGGroupFrame(fContLeft, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
144 fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
145 fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 20, kHorizontalFrame | kFitWidth | kFixedHeight);
146 fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
147
148
149 // predefined radio button
150 fRadioPredefined = new TGRadioButton(fContLeft, "Predefined: ", 13);
151 fContLeft->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
152 fRadioPredefined->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
153
39bcd65d 154 // list of variables
155 fListVariables = new TGListBox(fContLeft);
a6d2bd0c 156 fContLeft->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
39bcd65d 157 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
158
159 // plot options container
160 //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
a6d2bd0c 161 fContPlotOpt = new TGGroupFrame(fContLeft, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight);
162 fContLeft->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
39bcd65d 163
a6d2bd0c 164 // custom radio button
165 fRadioCustom = new TGRadioButton(fContLeft, "Custom: ", 12);
166 fContLeft->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(fContTopBottom, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
171 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
172
39bcd65d 173 // ************************* content of fContRight *************************
174 // cut options container
175 //fContCuts = new TGCompositeFrame(fContRight, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
176 fContCuts = new TGGroupFrame(fContRight, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
177 fContRight->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
178
a6d2bd0c 179 // Fit options container
180 fContFit = new TGGroupFrame(fContRight, "Custom Fit", kVerticalFrame | kFitWidth | kFitHeight);
181 fContRight->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
182
183 // Scaling options container
184 fContScaling = new TGGroupFrame(fContRight, "Scaling", kVerticalFrame | kFitWidth | kFitHeight);
185 fContRight->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
186
39bcd65d 187 // ************************* content of fContCenter *************************
188 // main drawing canvas
189 fCanvMain = new TRootEmbeddedCanvas("Main Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
190 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
191
192
193 // ************************* content of fContPlotOpt *************************
194 //TGButtonGroup *fBtngrpPlotOpt = new TGButtonGroup(fContPlotOpt, "Plot options",
195 // raw radio button
196 fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
197 fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
198 fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
199
200 // normalized radio button
201 fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
202 fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
203 fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
204
205 //fContPlotOpt->Show();
206
207 // normalized options container
208 fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
209 fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
210
39bcd65d 211 // ************************* content of fContDrawOpt *************************
212 // 1D radio button
a6d2bd0c 213 fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30);
214// fContDrawOpt->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
215 fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
39bcd65d 216 fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
217
218 // 2D radio button
a6d2bd0c 219 fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31);
220 fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
39bcd65d 221 fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
222
223 // automatic redraw check button
224 fChkAuto = new TGCheckButton(fContDrawOpt, "auto redraw");
225 fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
226
227 // ************************* content of fContCuts *************************
228 // TPC radio button
229 fRadioTPC = new TGRadioButton(fContCuts, "whole TPC", 20);
230 fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
231 fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
232
233 // side A radio button
234 fRadioSideA = new TGRadioButton(fContCuts, "side A", 21);
235 fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
236 fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
237
238 // side C radio button
239 fRadioSideC = new TGRadioButton(fContCuts, "side C", 22);
240 fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
241 fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
242
243 // sector radio button
244 fRadioSector = new TGRadioButton(fContCuts, "sector", 23);
245 fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
246 fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
247
248 // sector options container
a6d2bd0c 249 fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
250 fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0));
39bcd65d 251
252 // additional cuts check button
253 fChkAddCuts = new TGCheckButton(fContCuts, "additional cuts");
254 fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
255 fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
256
257 // additional cuts container
258 fContAddCuts = new TGCompositeFrame(fContCuts, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
a6d2bd0c 259 fContCuts->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
39bcd65d 260
261 // ************************* content of fContNormalized *************************
262 // method drop down combo box
263 fComboMethod = new TGComboBox(fContNormalized);
264 fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
265 fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
266 fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
267
268 // list of normalization variables
269 fListNormalization = new TGListBox(fContNormalized);
270 fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
271 fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
272
273 // ************************* content of fContCustom *************************
274 // text field for custom draw command
a6d2bd0c 275 fComboCustom = new TGComboBox(fContCustom);
276 fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight());
277 fComboCustom->EnableTextInput(kTRUE);
278 fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
279 fComboCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons(=42)");
280 fComboCustom->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
39bcd65d 281
282 // ************************* content of fContSector *************************
283 // sector number entry
284 fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
285 fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
a6d2bd0c 286 fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "ChangeSector()");
287
288 // sector number label
289 fLblSector = new TGLabel(fContSector, "IROC, A");
290 fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
39bcd65d 291
292 // ************************* content of fContAddCuts *************************
a6d2bd0c 293 // combo text field for additional cuts
294 fComboAddCuts = new TGComboBox(fContAddCuts);
295 fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight());
296 fComboAddCuts->EnableTextInput(kTRUE);
297 fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
298 fComboAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
299 fComboAddCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
300
301 // ************************* content of fContFit *************************
302 // container for additional fits
303 fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
304 fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
305
306 // ************************* content of fContAddFit *************************
307 // text field for custom fit
308 fComboCustomFit = new TGComboBox(fContAddFit);
309 fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight());
310 fComboCustomFit->EnableTextInput(kTRUE);
311 fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
312 fComboCustomFit->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoFit()");
313 fComboCustomFit->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoFit()");
314
315 // fit button
316 fBtnFit = new TGTextButton(fContAddFit, "&Fit");
317 fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
318 fBtnFit->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoFit()");
319
320 // add fit function button
321 //fBtnAddFitFunction = new TGTextButton(fContAddFit, "&Add fit function to normalization");
322 //fContAddFit->AddFrame(fBtnAddFitFunction, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
323 //fBtnAddFitFunction->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "AddFitFunction()");
324
325 // ************************* content of fContScaling *************************
326 // SetMaximum container
327 fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
328 fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
329
330 // SetMinimum container
331 fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
332 fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
333
334 // get Min & Max from Plot - button
335 fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot");
336 fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
337 fBtnGetMinMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
338
339 // GetMinMaxAuto - checkbox
340 fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto.");
341 fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
342 fChkGetMinMaxAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
39bcd65d 343
a6d2bd0c 344
345 // ************************* content of fContSetMax *************************
346 // SetMaximum - checkbox
347 fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max.");
348 fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
349 fChkSetMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
350
351 // text field for maximum value
352 fTxtSetMax = new TGTextEntry(fContSetMax, "", 41);
353 fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
354 fTxtSetMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
355
356 // ************************* content of fContSetMin *************************
357 // SetMinimum - checkbox
358 fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min.");
359 fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
360 fChkSetMin->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
361
362 // text field for minimum value
363 fTxtSetMin = new TGTextEntry(fContSetMin, "", 40);
364 fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
365 fTxtSetMin->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons()");
366
367
39bcd65d 368 // Display everything
369 Initialize(fileName);
370 SetWindowName("AliTPCCalibViewer GUI");
371 MapSubwindows();
372 Resize(GetDefaultSize());
373 MapWindow();
374}
375
376AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c)
a6d2bd0c 377 : TGCompositeFrame(c.fParent, c.fWidth, c.fHeight),
39bcd65d 378 fViewer(0),
a6d2bd0c 379 fContTopBottom(0),
380 fContLCR(0),
39bcd65d 381 fContLeft(0),
382 fContRight(0),
383 fContCenter(0),
384 fContPlotOpt(0),
385 fContDrawOpt(0),
a6d2bd0c 386 fContDrawOptSub1D2D(0),
39bcd65d 387 fContNormalized(0),
388 fContCustom(0),
389 fContCuts(0),
390 fContSector(0),
391 fContAddCuts(0),
a6d2bd0c 392 fContFit(0),
393 fContAddFit(0),
394 fContScaling(0),
395 fContSetMax(0),
396 fContSetMin(0),
39bcd65d 397 fListVariables(0),
398 fBtnDraw(0),
a6d2bd0c 399 fBtnFit(0),
400 fBtnAddFitFunction(0),
401 fBtnGetMinMax(0),
39bcd65d 402 fCanvMain(0),
403 fRadioRaw(0),
404 fRadioNormalized(0),
a6d2bd0c 405 fRadioPredefined(0),
39bcd65d 406 fRadioCustom(0),
407 fRadio1D(0),
408 fRadio2D(0),
409 fRadioTPC(0),
410 fRadioSideA(0),
411 fRadioSideC(0),
412 fRadioSector(0),
413 fChkAuto(0),
414 fComboMethod(0),
415 fListNormalization(0),
a6d2bd0c 416 fComboCustom(0),
39bcd65d 417 fNmbSector(0),
a6d2bd0c 418 fLblSector(0),
39bcd65d 419 fChkAddCuts(0),
a6d2bd0c 420 fComboAddCuts(0),
421 fComboCustomFit(0),
422 fChkSetMax(0),
423 fChkSetMin(0),
424 fChkGetMinMaxAuto(0),
425 fTxtSetMax(0),
426 fTxtSetMin(0)
39bcd65d 427{
428 //
429 // dummy AliTPCCalibViewerGUI copy constructor
430 //
431}
432
433AliTPCCalibViewerGUI & AliTPCCalibViewerGUI::operator =(const AliTPCCalibViewerGUI & param) {
434 //
435 // dummy assignment operator
436 //
437 return (*this);
438}
439
440AliTPCCalibViewerGUI::~AliTPCCalibViewerGUI() {
a6d2bd0c 441 if (fCanvMain && fCanvMain->GetCanvas()) {
442 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
443 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
444 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
445 }
446 }
39bcd65d 447 Cleanup();
a6d2bd0c 448 if (fViewer) fViewer->Delete();
39bcd65d 449}
450
a6d2bd0c 451/*
39bcd65d 452void AliTPCCalibViewerGUI::CloseWindow() {
453 DeleteWindow();
454}
a6d2bd0c 455*/
39bcd65d 456
457void AliTPCCalibViewerGUI::Initialize(char* fileName) {
458 //
459 // initializes the GUI with default settings and opens tree for drawing
460 //
461
462 // create AliTPCCalibViewer object, which will be used for generating all drawings
a6d2bd0c 463 if (fViewer) delete fViewer;
39bcd65d 464 fViewer = new AliTPCCalibViewer(fileName);
465
466 // fill fListVariables
467 TObjArray* arr = fViewer->GetListOfVariables();
468 TIterator* iter = arr->MakeIterator();
469 iter->Reset();
470 TObjString* currentStr = 0;
471 Int_t id = 0;
a6d2bd0c 472 while ((currentStr = (TObjString*)(iter->Next()))) {
39bcd65d 473 fListVariables->AddEntry(currentStr->GetString().Data(), id);
474 id++;
475 }
476 delete iter;
477 arr->Delete();
478 delete arr;
479
480 // fill fComboMethod
481 fComboMethod->AddEntry("subtract", 0);
482 fComboMethod->AddEntry("divide by", 1);
483
484 // fill fListNorm
485 arr = fViewer->GetListOfNormalizationVariables();
486 iter = arr->MakeIterator();
487 iter->Reset();
488 currentStr = 0;
489 id = 0;
a6d2bd0c 490 while ((currentStr = (TObjString*)(iter->Next()))) {
39bcd65d 491 fListNormalization->AddEntry(currentStr->GetString().Data(), id);
492 id++;
493 }
494 delete iter;
495 arr->Delete();
496 delete arr;
497
498 // set default button states
a6d2bd0c 499 fRadioPredefined->SetState(kButtonDown);
39bcd65d 500 fRadioRaw->SetState(kButtonDown);
501 fRadioTPC->SetState(kButtonDown);
39bcd65d 502 fRadio1D->SetState(kButtonDown);
503 fChkAuto->SetState(kButtonDown);
504 fChkAddCuts->SetState(kButtonUp);
505 fListVariables->Select(0);
506 fListNormalization->Select(0);
507 fComboMethod->Select(0);
a6d2bd0c 508 fChkGetMinMaxAuto->SetState(kButtonDown);
509 fChkSetMin->SetState(kButtonUp);
510 fChkSetMax->SetState(kButtonUp);
511
512 //fCanvMain->GetCanvas()->ToggleEventStatus(); // klappt nicht
513 //fCanvMain->GetCanvas()->GetCanvasImp()->ShowStatusBar(kTRUE); // klappt auch nicht
514 fListVariables->IntegralHeight(kFALSE); // naja
515 fListNormalization->IntegralHeight(kFALSE); // naja
516 DoDraw();
39bcd65d 517}
518
519void AliTPCCalibViewerGUI::HandleButtons(Int_t id) {
520 //
521 // handles mutual radio button exclusions
522 //
523 if (id == -1) {
524 TGButton *btn = (TGButton *) gTQSender;
525 id = btn->WidgetId();
526 }
a6d2bd0c 527
39bcd65d 528 switch (id) {
529 case 10: // fRadioRaw
530 fRadioNormalized->SetState(kButtonUp);
a6d2bd0c 531 fRadioPredefined->SetState(kButtonDown);
39bcd65d 532 fRadioCustom->SetState(kButtonUp);
533 //fComboMethod->UnmapWindow();
534 //fListNormalization->UnmapWindow();
535 break;
536 case 11: // fRadioNormalized
537 fRadioRaw->SetState(kButtonUp);
a6d2bd0c 538 fRadioPredefined->SetState(kButtonDown);
39bcd65d 539 fRadioCustom->SetState(kButtonUp);
540 break;
541 case 12: // fRadioCustom
a6d2bd0c 542 fRadioPredefined->SetState(kButtonUp);
543 //fRadioNormalized->SetState(kButtonUp);
544 break;
545 case 13: // fRadioPredefined
546 fRadioCustom->SetState(kButtonUp);
547 //fRadioNormalized->SetState(kButtonUp);
39bcd65d 548 break;
549 //--------
550 case 20: // fRadioTPC
551 fRadioSideA->SetState(kButtonUp);
552 fRadioSideC->SetState(kButtonUp);
553 fRadioSector->SetState(kButtonUp);
554 break;
555 case 21: // fRadioSideA
556 fRadioTPC->SetState(kButtonUp);
557 fRadioSideC->SetState(kButtonUp);
558 fRadioSector->SetState(kButtonUp);
559 break;
560 case 22: // fRadioSideC
561 fRadioTPC->SetState(kButtonUp);
562 fRadioSideA->SetState(kButtonUp);
563 fRadioSector->SetState(kButtonUp);
564 break;
565 case 23: // fRadioSector
566 fRadioTPC->SetState(kButtonUp);
567 fRadioSideA->SetState(kButtonUp);
568 fRadioSideC->SetState(kButtonUp);
569 break;
570 //--------
571 case 30: // fRadio1D
572 fRadio2D->SetState(kButtonUp);
573 break;
574 case 31: // fRadio2D
575 fRadio1D->SetState(kButtonUp);
576 break;
a6d2bd0c 577 //--------
578 case 40: // fTxtSetMin
579 fChkSetMin->SetState(kButtonDown);
580 break;
581 case 41: // fTxtSetMax
582 fChkSetMax->SetState(kButtonDown);
583 break;
584 case 42: // fComboCustom
585 fRadioCustom->SetState(kButtonDown);
586 fRadioPredefined->SetState(kButtonUp);
587 break;
39bcd65d 588 }
a6d2bd0c 589 DoNewSelection();
39bcd65d 590}
591
592void AliTPCCalibViewerGUI::DoNewSelection() {
593 //
594 // decides whether to redraw if user makes another selection
595 //
596
597 if (fChkAuto->GetState() == kButtonDown) DoDraw();
598}
599
600void AliTPCCalibViewerGUI::DoDraw() {
601 //
602 // main method for drawing according to user selection
603 //
604
605 // specify data to plot
606 TString desiredData("");
a6d2bd0c 607 if (!fListVariables->GetSelectedEntry()) return;
39bcd65d 608 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
609 desiredData += ".fElements";
610
611 // specify normalization
a6d2bd0c 612 if (fRadioPredefined->GetState() == kButtonDown && fRadioNormalized->GetState() == kButtonDown) {
39bcd65d 613 TString op("");
614 switch (fComboMethod->GetSelected()) {
615 case 0: // subtraction
616 op += "-";
617 break;
618 case 1: // division
619 op += "/";
620 break;
621 }
622 TString normalizationData("");
a6d2bd0c 623 if (!fListNormalization->GetSelectedEntry()) return;
39bcd65d 624 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
a6d2bd0c 625
626 if ( normalizationData.BeginsWith("Fit")) {
627 // create fit formula, evaluate it an replace normalizationData-String
628 // ********** create cut string **********
629 TString cutStr("");
630 if (fRadioTPC->GetState() == kButtonDown)
631 cutStr += ""; // whole TPC is used for fitting
632 if (fRadioSideA->GetState() == kButtonDown)
633 cutStr += "(sector/18)%2==0"; // side A
634 if (fRadioSideC->GetState() == kButtonDown)
635 cutStr+= "(sector/18)%2==1"; // side C
636 if (fRadioSector->GetState() == kButtonDown) {
637 Int_t sector = (Int_t)(fNmbSector->GetNumber());
638 cutStr += "sector==";
639 cutStr += sector;
640 }
641 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
642 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
643 cutStr += fComboAddCuts->GetTextEntry()->GetText();
644 }
645 Double_t chi2 = 0;
646 TVectorD fitParam(0);
647 TMatrixD covMatrix(0,0);
648 TString formulaStr("");
649 if (normalizationData.CompareTo("FitLinLocal") == 0)
650 formulaStr = "lx~ ++ ly~";
651 if (normalizationData.CompareTo("FitLinGlobal") == 0)
652 formulaStr = "gx~ ++ gy~";
653 normalizationData = *fViewer->Fit(desiredData.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
654 }
655
39bcd65d 656 desiredData += op;
a6d2bd0c 657 if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
658 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
39bcd65d 659 desiredData += normalizationData;
660 }
661 else if (fRadioCustom->GetState() == kButtonDown) {
a6d2bd0c 662 desiredData = fComboCustom->GetTextEntry()->GetText();
39bcd65d 663 if (desiredData == "") return;
664 }
665
666 // specify cuts
667 TString sectorStr("");
668 if (fRadioTPC->GetState() == kButtonDown)
669 sectorStr += "ALL";
670 if (fRadioSideA->GetState() == kButtonDown)
671 sectorStr += "A"; //cuts += "(sector/18)%2==0";
672 if (fRadioSideC->GetState() == kButtonDown)
673 sectorStr+= "C"; //cuts += "(sector/18)%2==1";
674 if (fRadioSector->GetState() == kButtonDown) {
675 Int_t sector = (Int_t)(fNmbSector->GetNumber());
676 sectorStr += sector; //cuts += "sector==";
677 }
678 TString cutsStr("");
679 if (fChkAddCuts->GetState() == kButtonDown)
a6d2bd0c 680 cutsStr += fComboAddCuts->GetTextEntry()->GetText();
39bcd65d 681
682 // draw finally
a6d2bd0c 683 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
684 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
685 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
686 }
687 //fCanvMain->GetCanvas()->Clear();
39bcd65d 688 fCanvMain->GetCanvas()->cd();
a6d2bd0c 689 Int_t entries = -1;
39bcd65d 690 if (fRadio1D->GetState() == kButtonDown)
a6d2bd0c 691 entries = fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
39bcd65d 692 else if (fRadio2D->GetState() == kButtonDown)
a6d2bd0c 693 entries = fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data());
694 if (entries == -1) return;
695
696 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
697 TObject* ptr = 0;
698 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
699 ptr = listOfPrimitives->At(i);
700 if ( ptr->InheritsFrom("TH1") ) break;
701 }
702 if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
703 TH1 *hist = (TH1*)ptr;
704 TString minTxt(fTxtSetMin->GetText());
705 TString maxTxt(fTxtSetMax->GetText());
706 if (fChkSetMax->GetState() == kButtonDown && (maxTxt.IsDigit() || maxTxt.IsFloat()) )
707 hist->SetMaximum(maxTxt.Atof());
708 if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) )
709 hist->SetMinimum(minTxt.Atof());
710
711 if (fChkGetMinMaxAuto->GetState() == kButtonDown) {
712 if (fChkSetMax->GetState() == kButtonUp)
713 fTxtSetMax->SetText(Form("%f", hist->GetMaximum()));
714 if (fChkSetMin->GetState() == kButtonUp)
715 fTxtSetMin->SetText(Form("%f", hist->GetMinimum()));
716 }
39bcd65d 717
718 fCanvMain->GetCanvas()->Update();
719}
a6d2bd0c 720
721
722void AliTPCCalibViewerGUI::DoFit() {
723 //
724 // main method for fitting
725 //
726
727 Double_t chi2 = 0;
728 TVectorD fitParam(0);
729 TMatrixD covMatrix(0,0);
730 TString drawStr("");
731 TString cutStr("");
732 TString formulaStr("");
733 TString *returnStr = new TString("");
734
735
736 // ******** create draw string *********
737 if (fRadioCustom->GetState() == kButtonDown) {
738 // take custom text as draw string
739 drawStr = fComboCustom->GetTextEntry()->GetText();
740 if (drawStr == "") return;
741 }
742 else if (fRadioPredefined->GetState() == kButtonDown) {
743 // create drawStr out of selection
744 drawStr += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
745 drawStr += ".fElements";
746 if (fRadioNormalized->GetState() == kButtonDown) {
747 // normalize data by selection
748 TString op("");
749 switch (fComboMethod->GetSelected()) {
750 case 0: // subtraction
751 op += "-";
752 break;
753 case 1: // division
754 op += "/";
755 break;
756 }
757 TString normalizationData("");
758 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
759 drawStr += op;
760 drawStr += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
761 drawStr += normalizationData;
762 }
763 }
764
765 // ********** create cut string **********
766 if (fRadioTPC->GetState() == kButtonDown)
767 cutStr += ""; // whole TPC is used for fitting
768 if (fRadioSideA->GetState() == kButtonDown)
769 cutStr += "(sector/18)%2==0"; // side A
770 if (fRadioSideC->GetState() == kButtonDown)
771 cutStr+= "(sector/18)%2==1"; // side C
772 if (fRadioSector->GetState() == kButtonDown) {
773 Int_t sector = (Int_t)(fNmbSector->GetNumber());
774 cutStr += "sector==";
775 cutStr += sector;
776 }
777 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
778 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
779 cutStr += fComboAddCuts->GetTextEntry()->GetText();
780 }
781
782 // ********** get formula string **********
783 formulaStr += fComboCustomFit->GetTextEntry()->GetText();
784
785 // ********** call AliTPCCalibViewer's fit-function
786 returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
787
788 std::cout << std::endl;
789 std::cout << "Your fit formula reads as follows:" << std::endl;
790 std::cout << returnStr->Data() << std::endl;
791 std::cout << "chi2 = " << chi2 << std::endl;
792}
793
794void AliTPCCalibViewerGUI::GetMinMax() {
795 //
796 // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
797 //
798 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
799 TObject* ptr = 0;
800 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
801 ptr = listOfPrimitives->At(i);
802 if ( ptr->InheritsFrom("TH1") ) break;
803 }
804 if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
805 TH1 *hist = (TH1*)ptr;
806 Double_t histMax = hist->GetMaximum();
807 Double_t histMin = hist->GetMinimum();
808 fTxtSetMax->SetText(Form("%f",histMax));
809 fTxtSetMin->SetText(Form("%f",histMin));
810}
811
812void AliTPCCalibViewerGUI::ChangeSector(){
813 //
814 // function that is called, when the number of the sector is changed
815 // to change the sector label
816 //
817 Int_t sector = (Int_t)(fNmbSector->GetNumber());
818 char* secLabel = "";
819 if (sector >= 0 && sector <= 17) // IROC, Side A
820 secLabel = "IROC, A";
821 if (sector >= 18 && sector <= 35) // IROC, Side C
822 secLabel = "IROC, C";
823 if (sector >= 36 && sector <= 53) // OROC, Side A
824 secLabel = "OROC, A";
825 if (sector >= 54 && sector <= 71) // OROC, Side C
826 secLabel = "OROC, C";
827 fLblSector->SetText(secLabel);
828 DoNewSelection();
829}
830
831void AliTPCCalibViewerGUI::AddFitFunction(){
832 //
833 // adds the last fit function to the normalization list
834 //
835 std::cout << "Not yet implemented." << std::endl;
836}
837
838
839void AliTPCCalibViewerGUI::ShowGUI(const char* fileName) {
840 //
841 // initialize and show GUI for presentation
842 //
843 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
844 frmMain->SetWindowName("AliTPCCalibViewer GUI");
845 frmMain->SetCleanup(kDeepCleanup);
846
847 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
848 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
849
850 TGCompositeFrame* tabCont1 = tabMain->AddTab("Viewer 1");
851 TGCompositeFrame* tabCont2 = tabMain->AddTab("Viewer 2");
852
853 AliTPCCalibViewerGUI* calibViewer1 = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, (char*)fileName);
854 tabCont1->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
855
856 AliTPCCalibViewerGUI* calibViewer2 = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, (char*)fileName);
857 tabCont2->AddFrame(calibViewer2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
858
859 frmMain->MapSubwindows();
860 frmMain->Resize();
861 frmMain->MapWindow();
862
863}
864