Adding README file + using proper Makefile (Marian)
[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 //
72d0ab7e 21// All functionalities of the AliTPCCalibViewer are here available
22//
a6d2bd0c 23// Example usage: //
39bcd65d 24/*
25 aliroot
72d0ab7e 26 AliTPCCalibViewerGUI::ShowGUI("CalibTree.root")
832bb12c 27
a6d2bd0c 28*/
72d0ab7e 29// //
39bcd65d 30// //
31///////////////////////////////////////////////////////////////////////////////
32
33
34#include "AliTPCCalibViewerGUI.h"
72d0ab7e 35#include <iostream>
39bcd65d 36
37#include <TCanvas.h>
38#include <TPad.h>
39#include <TVirtualPad.h>
40
832bb12c 41#include <TROOT.h>
39bcd65d 42#include <TObjArray.h>
43#include <TObjString.h>
44#include <TVector.h>
a6d2bd0c 45#include <string.h>
46#include <TH1.h>
72d0ab7e 47#include "TStyle.h"
48#include "AliTPCCalibViewer.h"
4f3934a1 49#include "TGFileDialog.h"
50#include "TGFileDialog.h"
72d0ab7e 51
52// #include "TGListBox.h"
53// #include "TGNumberEntry"
54// #include "TGSplitter"
55// #include "TGTab"
56// #include "TGLabel"
57// #include "TGButtonGroup"
58// #include "TGComboBox"
59// #include "TRootEmbeddedCanvas"
60// #include "TGButton"
61// #include "TGRadioButton"
62// #include "GTCheckButton"
63// #include "TGTextEntry"
64
65
a6d2bd0c 66
39bcd65d 67
68ClassImp(AliTPCCalibViewerGUI)
69
70AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h, char* fileName)
a6d2bd0c 71 : TGCompositeFrame(p, w, h),
39bcd65d 72 fViewer(0),
a6d2bd0c 73 fContTopBottom(0),
74 fContLCR(0),
39bcd65d 75 fContLeft(0),
72d0ab7e 76 ftabLeft(0),
77 ftabLeft0(0),
78 ftabLeft1(0),
4f3934a1 79 ftabRight(0),
80 fTabRight0(0),
81 fTabRight1(0),
39bcd65d 82 fContRight(0),
83 fContCenter(0),
84 fContPlotOpt(0),
85 fContDrawOpt(0),
a6d2bd0c 86 fContDrawOptSub1D2D(0),
39bcd65d 87 fContNormalized(0),
88 fContCustom(0),
89 fContCuts(0),
90 fContSector(0),
91 fContAddCuts(0),
a6d2bd0c 92 fContFit(0),
93 fContAddFit(0),
94 fContScaling(0),
95 fContSetMax(0),
96 fContSetMin(0),
72d0ab7e 97 fContAddDrawOpt(0),
39bcd65d 98 fListVariables(0),
99 fBtnDraw(0),
a6d2bd0c 100 fBtnFit(0),
101 fBtnAddFitFunction(0),
102 fBtnGetMinMax(0),
39bcd65d 103 fCanvMain(0),
104 fRadioRaw(0),
105 fRadioNormalized(0),
a6d2bd0c 106 fRadioPredefined(0),
39bcd65d 107 fRadioCustom(0),
108 fRadio1D(0),
109 fRadio2D(0),
110 fRadioTPC(0),
111 fRadioSideA(0),
112 fRadioSideC(0),
113 fRadioSector(0),
72d0ab7e 114 fComboAddDrawOpt(0),
39bcd65d 115 fChkAuto(0),
116 fComboMethod(0),
117 fListNormalization(0),
a6d2bd0c 118 fComboCustom(0),
4f3934a1 119 fLblCustomDraw(0),
72d0ab7e 120 fChkAddDrawOpt(0),
39bcd65d 121 fNmbSector(0),
a6d2bd0c 122 fLblSector(0),
72d0ab7e 123 fChkCutZero(0),
39bcd65d 124 fChkAddCuts(0),
4f3934a1 125 fLblAddCuts(0),
a6d2bd0c 126 fComboAddCuts(0),
127 fComboCustomFit(0),
128 fChkSetMax(0),
129 fChkSetMin(0),
130 fChkGetMinMaxAuto(0),
131 fTxtSetMax(0),
72d0ab7e 132 fTxtSetMin(0) ,
133 fContDrawOpt1D(0),
134 fcontDrawOpt1DSubLR(0),
135 fContDrawOpt1DSubNSC(0),
136 fRadioNorm(0),
137 fRadioSigma(0),
138 fTxtSigmas(0),
139 fContCumuLR(0),
140 fContCumLeft(0),
141 fContCumRight(0),
142 fLblSigmaMax(0),
143 fTxtSigmaMax(0),
144 fRadioCumulative(0),
145 fCheckCumulativePM(0),
146 fRadioIntegrate(0),
147 fContDrawOpt1DSubMML(0),
148 fChkMean(0),
149 fChkMedian(0),
150 fChkLTM(0),
151 fContStatOpt(0),
152 fChkStatName(0),
153 fChkStatEntries(0),
154 fContStatMean(0),
155 fChkStatMean(0),
156 fChkStatMeanPM(0),
157 fContStatRMS(0),
158 fChkStatRMS(0),
159 fChkStatRMSPM(0),
160 fChkStatUnderflow(0),
161 fChkStatOverflow(0),
162 fChkStatIntegral(0),
163 fContStatSkew(0),
164 fChkStatSkewness(0),
165 fChkStatSkewnessPM(0),
166 fContStatKurt(0),
167 fChkStatKurtosis(0),
4f3934a1 168 fChkStatKurtosisPM(0),
832bb12c 169 fBtnUnchekAll(0),
4f3934a1 170 fContLabeling(0),
171 fChkLabelTitle(0),
172 fTxtLabelTitle(0),
173 fChkLabelXaxis(0),
174 fTxtLabelXaxis(0),
175 fChkLabelYaxis(0),
176 fTxtLabelYaxis(0),
177 fChkLabelGetAuto(0),
178 fContSave(0),
179 fBtnSave(0),
180 fContAddSaveOpt(0),
181 fChkAddSaveOpt(0),
832bb12c 182 fComboAddSaveOpt(0),
183 fContExport(0),
184 fContAddExport(0),
185 fComboExportName(0),
186 fBtnExport(0),
187 fBtnAddNorm(0)
39bcd65d 188{
72d0ab7e 189 //
190 // AliTPCCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing
191 //
832bb12c 192
193 // draw the GUI:
194 DrawGUI(p, w, h);
195 // initialize the AliTPCCalibViewer:
196 if (fileName) Initialize(fileName);
197 // set default button states:
198 SetInitialValues();
199 // do first drawing:
200 DoDraw();
201}
202
203
204void AliTPCCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) {
205 //
206 // draw the GUI
207 //
208 // ======================================================================
209 // ************************* Display everything *************************
210 // ======================================================================
39bcd65d 211
832bb12c 212 SetCleanup(kDeepCleanup);
213
72d0ab7e 214 // *****************************************************************************
39bcd65d 215 // ************************* content of this MainFrame *************************
72d0ab7e 216 // *****************************************************************************
39bcd65d 217 // top level container with horizontal layout
a6d2bd0c 218 fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
219 AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
220
221 fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
222 fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
223
72d0ab7e 224 // ***********************************************************************
a6d2bd0c 225 // ************************* content of fContLCR *************************
72d0ab7e 226 // ***********************************************************************
39bcd65d 227 // left container
a6d2bd0c 228 fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
229 fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
39bcd65d 230
231 // left vertical splitter
a6d2bd0c 232 TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
39bcd65d 233 splitLeft->SetFrame(fContLeft, kTRUE);
a6d2bd0c 234 fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 235
236 // right container
a6d2bd0c 237 fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
238 fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
39bcd65d 239
240 // center container
a6d2bd0c 241 fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
242 fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 243
244 // right vertical splitter
a6d2bd0c 245 TGVSplitter *splitRight = new TGVSplitter(fContLCR);
39bcd65d 246 splitRight->SetFrame(fContRight, kFALSE);
a6d2bd0c 247 fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
39bcd65d 248
72d0ab7e 249
250 // ========================================================================
39bcd65d 251 // ************************* content of fContLeft *************************
72d0ab7e 252 // ========================================================================
253 // --- draw button and tabLeft ---
a6d2bd0c 254 // draw button
255 fBtnDraw = new TGTextButton(fContLeft, "&Draw");
256 fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
257 //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
258 fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoDraw()");
832bb12c 259 fBtnDraw->SetToolTipText("Press here to draw according to selections.");
a6d2bd0c 260
4f3934a1 261 // tabs on the left side:
72d0ab7e 262 ftabLeft = new TGTab(fContLeft);
263 fContLeft->AddFrame(ftabLeft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
264 ftabLeft0 = ftabLeft->AddTab("General");
265 ftabLeft1 = ftabLeft->AddTab("More plot options");
266
a6d2bd0c 267
72d0ab7e 268 // **************************** content of tabLeft0 *******************************
269
270 // draw options container *** fcontDrawOpt *** " Plot options "
271 fContDrawOpt = new TGGroupFrame(ftabLeft0, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
272 ftabLeft0->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
273 fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
274 fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
275
276 // ------------------------- content of fContDrawOpt -------------------------
277 // -- radio1D, radio2D, chkAuto
278 // 1D radio button
279 fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30);
280 fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
281 fRadio1D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 282 fRadio1D->SetToolTipText("1D drawing \nSelect this if you want to have the full control for the custom draw.");
72d0ab7e 283
284 // 2D radio button
285 fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31);
286 fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
287 fRadio2D->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 288 fRadio2D->SetToolTipText("2D drawing");
72d0ab7e 289
290 // additional draw options container
291 fContAddDrawOpt = new TGCompositeFrame(fContDrawOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
292 fContDrawOpt->AddFrame(fContAddDrawOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
293
294 // content of --- fContAddDrawOpt ---
295 // addition draw options label
296 fChkAddDrawOpt = new TGCheckButton(fContAddDrawOpt, "Draw options:");
297 //fChkAddDrawOpt->SetTextJustify(kTextLeft);
298 fContAddDrawOpt->AddFrame(fChkAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
299 fChkAddDrawOpt->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
832bb12c 300 fChkAddDrawOpt->SetToolTipText("Enter additional draw options like 'prof' or 'colz' here.\nBe careful with the option 'same' for 2D drawings as it will crash (ROOT feature).");
72d0ab7e 301
302 // additional draw options combo box
303 fComboAddDrawOpt = new TGComboBox(fContAddDrawOpt);
304 fComboAddDrawOpt->Resize(0, fBtnDraw->GetDefaultHeight());
305 fComboAddDrawOpt->EnableTextInput(kTRUE);
306 fContAddDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 307 fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
72d0ab7e 308 fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
309
310 // automatic redraw check button
832bb12c 311 fChkAuto = new TGCheckButton(fContDrawOpt, "Auto redraw");
72d0ab7e 312 fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
832bb12c 313 fChkAuto->SetToolTipText("Decide if you want an automatic redraw on each new selection.\nNot recommended on a slow machine, during remote connection or if your draw option is 'same'.");
72d0ab7e 314
315
316 // *** predefined radio button *** " Predefined "
317 fRadioPredefined = new TGRadioButton(ftabLeft0, "Predefined: ", 13);
318 ftabLeft0->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
319 fRadioPredefined->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 320 fRadioPredefined->SetToolTipText("Draw predefined variables according to selection.");
72d0ab7e 321
322 // list of variables
323 fListVariables = new TGListBox(ftabLeft0);
324 ftabLeft0->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
325 fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
a6d2bd0c 326
72d0ab7e 327
328 // normalization options container *** fContPlotOpt ***
329 //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
330 fContPlotOpt = new TGGroupFrame(ftabLeft0, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight);
331 ftabLeft0->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
332
333 // ------------------------- content of fContPlotOpt -------------------------
334 // raw radio button
335 fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
336 fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
337 fRadioRaw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 338 fRadioRaw->SetToolTipText("Plot without normalization");
72d0ab7e 339
340 // normalized radio button
341 fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
342 fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
343 fRadioNormalized->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 344 fRadioNormalized->SetToolTipText("Normalize data");
72d0ab7e 345
346 // normalized options container *** fContNormalized ***
347 fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
348 fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
349
350 // --- content of fContNormalized ---
351 // --- combo box to select 'subtract' or 'divide', list of normalization variables
352 // method drop down combo box
353 fComboMethod = new TGComboBox(fContNormalized);
354 fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
355 fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
356 fComboMethod->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
357
358 // list of normalization variables
359 fListNormalization = new TGListBox(fContNormalized);
360 fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
361 fListNormalization->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
39bcd65d 362
72d0ab7e 363 // custom radio button
364 fRadioCustom = new TGRadioButton(ftabLeft0, "Custom: ", 12);
365 ftabLeft0->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
366 fRadioCustom->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral()");
832bb12c 367 fRadioCustom->SetToolTipText("Draw data according to user specific text entry in the 'Custom Draw' line. Remember '~' (= '.fElements')!");
4f3934a1 368 // custom options container is located further down
72d0ab7e 369
370 // **************************** content of tabLeft1 *******************************
371
372 // draw options container *** fcontDrawOpt1D *** " Plot options "
373 fContDrawOpt1D = new TGGroupFrame(ftabLeft1, "1D Plot options", kVerticalFrame | kFitWidth | kFitHeight);
374 ftabLeft1->AddFrame(fContDrawOpt1D, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
375
376 fcontDrawOpt1DSubLR = new TGCompositeFrame(fContDrawOpt1D, 1, 1, kVerticalFrame | kFitWidth | kFitHeight);
377 fContDrawOpt1D->AddFrame(fcontDrawOpt1DSubLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
378
379 // ***** content of fContDrawOpt1DSubLR *****
380 fContDrawOpt1DSubNSC = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
381 fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubNSC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
382
383 // --------------------------- content of fContDrawOpt1DSubNSC -----------------
384 fRadioNorm = new TGRadioButton(fContDrawOpt1DSubNSC, "Normal", 110);
385 fContDrawOpt1DSubNSC->AddFrame(fRadioNorm, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
386 fRadioNorm->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 387 fRadioNorm->SetToolTipText("Produce a normal 1D plot, a histogram of the selected data.");
72d0ab7e 388
389 fRadioSigma = new TGRadioButton(fContDrawOpt1DSubNSC, "Sigma", 111);
390 fContDrawOpt1DSubNSC->AddFrame(fRadioSigma, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
391 fRadioSigma->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 392 fRadioSigma->SetToolTipText("Draw a normal histogram, but also lines that indicate the mean/median/LTM \nand sigmas of the selected data.");
72d0ab7e 393
394 fTxtSigmas = new TGTextEntry(fContDrawOpt1DSubNSC, "2; 4; 6", 111);
395 fContDrawOpt1DSubNSC->AddFrame(fTxtSigmas, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
396 fTxtSigmas->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons1D(=111)");
832bb12c 397 fTxtSigmas->SetToolTipText("Enter sigma intervals you would like to be indicated by lines. \nExample: '2; 4; 6'");
72d0ab7e 398
399 fContCumuLR = new TGCompositeFrame(fContDrawOpt1DSubNSC, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
400 fContDrawOpt1DSubNSC->AddFrame(fContCumuLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
401
402 fContCumLeft = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
403 fContCumuLR->AddFrame(fContCumLeft, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
404
405 fRadioCumulative = new TGRadioButton(fContCumLeft, "Cumulative", 112);
406 fContCumLeft->AddFrame(fRadioCumulative, new TGLayoutHints(kLHintsNormal, 0, 10, 0, 0));
407 fRadioCumulative->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 408 fRadioCumulative->SetToolTipText("Draw the cumulative (SigmaCut) of the given selection. \nThe data distribution is integrated, starting from the mean/median/LTM.");
72d0ab7e 409
410 fCheckCumulativePM = new TGCheckButton(fContCumLeft, "Plus/Minus");
411 fContCumLeft->AddFrame(fCheckCumulativePM, new TGLayoutHints(kLHintsNormal, 10, 15, 0, 0));
412 fCheckCumulativePM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 413 fCheckCumulativePM->SetToolTipText("Decide whether you want the cumulative integration for each direction (+/-) \nor only for the absolute distance to the mean/median/LTM value.");
72d0ab7e 414
415 fRadioIntegrate = new TGRadioButton(fContCumLeft, "Integrate", 113);
416 fContCumLeft->AddFrame(fRadioIntegrate, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
417 fRadioIntegrate->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 418 fRadioIntegrate->SetToolTipText("Draw the integral of the given selection.");
72d0ab7e 419
420 fContCumRight = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
421 fContCumuLR->AddFrame(fContCumRight, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
422
423 fLblSigmaMax = new TGLabel(fContCumRight, "SigmaMax:");
424 fLblSigmaMax->SetTextJustify(kTextLeft);
425 fContCumRight->AddFrame(fLblSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0));
426
427 fTxtSigmaMax = new TGTextEntry(fContCumRight, "5", 112);
428 fContCumRight->AddFrame(fTxtSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
429 fTxtSigmaMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtons1D(=112)");
832bb12c 430 fTxtSigmaMax->SetToolTipText("Enter up to which multiple of sigma you want to integrate.");
72d0ab7e 431
432
433 fContDrawOpt1DSubMML = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
434 fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubMML, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
435
436 // -------------- content of fcontDrawOpt1DSubLR
437 fChkMean = new TGCheckButton(fContDrawOpt1DSubMML, "Mean");
438 fContDrawOpt1DSubMML->AddFrame(fChkMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
439 fChkMean->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 440 fChkMean->SetToolTipText("Activate Mean for Sigma/Cumulative/Integrate");
72d0ab7e 441
442 fChkMedian = new TGCheckButton(fContDrawOpt1DSubMML, "Median");
443 fContDrawOpt1DSubMML->AddFrame(fChkMedian, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
444 fChkMedian->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 445 fChkMedian->SetToolTipText("Activate Median for Sigma/Cumulative/Integrate");
72d0ab7e 446
447 fChkLTM = new TGCheckButton(fContDrawOpt1DSubMML, "LTM");
448 fContDrawOpt1DSubMML->AddFrame(fChkLTM, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
449 fChkLTM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtons1D()");
832bb12c 450 fChkLTM->SetToolTipText("Activate LTM for Sigma/Cumulative/Integrate");
72d0ab7e 451
452
453 // statistic options container *** fcontStatOpt1D *** " Statistic options "
454 fContStatOpt = new TGGroupFrame(ftabLeft1, "Statistic options", kVerticalFrame | kFitWidth | kFitHeight);
455 ftabLeft1->AddFrame(fContStatOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
456
457 fChkStatName = new TGCheckButton(fContStatOpt, "Name");
458 fContStatOpt->AddFrame(fChkStatName, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
459 fChkStatName->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 460 fChkStatName->SetToolTipText("Display the name in the statistics legend.");
72d0ab7e 461
462 fChkStatEntries = new TGCheckButton(fContStatOpt, "Entries");
463 fContStatOpt->AddFrame(fChkStatEntries, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
464 fChkStatEntries->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 465 fChkStatEntries->SetToolTipText("Display the number of entries in the statistics legend.");
72d0ab7e 466
467 fContStatMean = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
468 fContStatOpt->AddFrame(fContStatMean, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
469
470 fChkStatMean = new TGCheckButton(fContStatMean, "Mean");
471 fContStatMean->AddFrame(fChkStatMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
472 fChkStatMean->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 473 fChkStatMean->SetToolTipText("Display the mean value of the data in the statistics legend.");
72d0ab7e 474
475 fChkStatMeanPM = new TGCheckButton(fContStatMean, "+- Error");
476 fContStatMean->AddFrame(fChkStatMeanPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
477 fChkStatMeanPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 478 fChkStatMeanPM->SetToolTipText("Display the mean value's error in the statistics legend.");
a6d2bd0c 479
72d0ab7e 480 fContStatRMS = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
481 fContStatOpt->AddFrame(fContStatRMS, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
482
483 fChkStatRMS = new TGCheckButton(fContStatRMS, "RMS");
484 fContStatRMS->AddFrame(fChkStatRMS, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
485 fChkStatRMS->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 486 fChkStatRMS->SetToolTipText("Display the RMS value of the data in the statistics legend.");
72d0ab7e 487
488 fChkStatRMSPM = new TGCheckButton(fContStatRMS, "+- Error");
489 fContStatRMS->AddFrame(fChkStatRMSPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
490 fChkStatRMSPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 491 fChkStatRMSPM->SetToolTipText("Display the RMS value's error in the statistics legend.");
a6d2bd0c 492
72d0ab7e 493 fChkStatUnderflow = new TGCheckButton(fContStatOpt, "Underflow");
494 fContStatOpt->AddFrame(fChkStatUnderflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
495 fChkStatUnderflow->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 496 fChkStatUnderflow->SetToolTipText("Display the number of entries in the underflow bin.");
72d0ab7e 497
498 fChkStatOverflow = new TGCheckButton(fContStatOpt, "Overflow");
499 fContStatOpt->AddFrame(fChkStatOverflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
500 fChkStatOverflow->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 501 fChkStatOverflow->SetToolTipText("Display the number of entries in the overflow bin.");
72d0ab7e 502
503 fChkStatIntegral = new TGCheckButton(fContStatOpt, "Integral");
504 fContStatOpt->AddFrame(fChkStatIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
505 fChkStatIntegral->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 506 fChkStatIntegral->SetToolTipText("Display the integral of the data in the statistics legend.");
72d0ab7e 507
508 fContStatSkew = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
509 fContStatOpt->AddFrame(fContStatSkew, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
510
511 fChkStatSkewness = new TGCheckButton(fContStatSkew, "Skewness");
512 fContStatSkew->AddFrame(fChkStatSkewness, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
513 fChkStatSkewness->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 514 fChkStatSkewness->SetToolTipText("Display the skewness of the data in the statistics legend. \nBe careful! Sometimes the skewness causes a floating point exception that hangs the GUI!");
72d0ab7e 515
516 fChkStatSkewnessPM = new TGCheckButton(fContStatSkew, "+- Error");
517 fContStatSkew->AddFrame(fChkStatSkewnessPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
518 fChkStatSkewnessPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 519 fChkStatSkewnessPM->SetToolTipText("Display the skewness' error in the statistics legend.");
72d0ab7e 520
521 fContStatKurt = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
522 fContStatOpt->AddFrame(fContStatKurt, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
523
524 fChkStatKurtosis = new TGCheckButton(fContStatKurt, "Kurtosis");
525 fContStatKurt->AddFrame(fChkStatKurtosis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
526 fChkStatKurtosis->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 527 fChkStatKurtosis->SetToolTipText("Display the kurtosis of the data in the statistics legend.");
72d0ab7e 528
529 fChkStatKurtosisPM = new TGCheckButton(fContStatKurt, "+- Error");
530 fContStatKurt->AddFrame(fChkStatKurtosisPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
531 fChkStatKurtosisPM->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsStat()");
832bb12c 532 fChkStatKurtosisPM->SetToolTipText("Display the kurtosis' error in the statistics legend.");
533
534 fBtnUnchekAll = new TGTextButton(fContStatOpt, "&Uncheck all");
535 fContStatOpt->AddFrame(fBtnUnchekAll, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
536 //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
537 fBtnUnchekAll->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "UnchekAllStat()");
538 fBtnUnchekAll->SetToolTipText("Disable all statistics legend entries, \nno statistics legend.");
72d0ab7e 539
4f3934a1 540
541 // custom options container
542 // --- fComboCustom --- the custom draw line on the very low
543 fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
544 fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
545
546 // ------------------------- content of fContCustom -------------------------
832bb12c 547 fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
4f3934a1 548 fLblCustomDraw->SetTextJustify(kTextLeft);
549 fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
550 // text field for custom draw command
551 fComboCustom = new TGComboBox(fContCustom);
552 fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight());
553 fComboCustom->EnableTextInput(kTRUE);
554 fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
555 fComboCustom->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=42)");
556 fComboCustom->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
557
558
559 // additional cuts container
560 fContAddCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
561 fContTopBottom->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
562
563 // ------------------------- content of fContAddCuts -------------------------
832bb12c 564 fLblAddCuts = new TGLabel(fContAddCuts, "Custom cuts: ");
4f3934a1 565 fLblAddCuts->SetTextJustify(kTextLeft);
566 fContAddCuts->AddFrame(fLblAddCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
567 // combo text field for additional cuts
568 fComboAddCuts = new TGComboBox(fContAddCuts);
569 fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight());
570 fComboAddCuts->EnableTextInput(kTRUE);
571 fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 572 fComboAddCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts(=31)");
4f3934a1 573 fComboAddCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
72d0ab7e 574
72d0ab7e 575 // ==========================================================================
576 // ************************* content of fContCenter *************************
577 // ========================================================================
578 // main drawing canvas
832bb12c 579 fCanvMain = new TRootEmbeddedCanvas("Main_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
72d0ab7e 580 fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
832bb12c 581 fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUI", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
582 fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
583 fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
72d0ab7e 584
585
586 // =========================================================================
39bcd65d 587 // ************************* content of fContRight *************************
72d0ab7e 588 // ========================================================================
72d0ab7e 589
4f3934a1 590 // tabs on the right side:
591 ftabRight = new TGTab(fContRight);
592 fContRight->AddFrame(ftabRight, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
593 fTabRight0 = ftabRight->AddTab("Basic");
594 fTabRight1 = ftabRight->AddTab("Advanced");
595
72d0ab7e 596
4f3934a1 597 // **************************** content of tabLeft0 *******************************
598 // cut options container
599 fContCuts = new TGGroupFrame(fTabRight0, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
600 fTabRight0->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
72d0ab7e 601
72d0ab7e 602
4f3934a1 603 // ************************* content of fContCuts *************************
604 // TPC radio button
832bb12c 605 fRadioTPC = new TGRadioButton(fContCuts, "Whole TPC", 20);
4f3934a1 606 fContCuts->AddFrame(fRadioTPC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
832bb12c 607 fRadioTPC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
608 fRadioTPC->SetToolTipText("No cuts, use the whole TPC. \nIn 2D mode, A side and C side are superimposed!");
72d0ab7e 609
4f3934a1 610 // side A radio button
832bb12c 611 fRadioSideA = new TGRadioButton(fContCuts, "Side A", 21);
4f3934a1 612 fContCuts->AddFrame(fRadioSideA, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
832bb12c 613 fRadioSideA->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
614 fRadioSideA->SetToolTipText("Use only side A.");
72d0ab7e 615
4f3934a1 616 // side C radio button
832bb12c 617 fRadioSideC = new TGRadioButton(fContCuts, "Side C", 22);
4f3934a1 618 fContCuts->AddFrame(fRadioSideC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
832bb12c 619 fRadioSideC->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
620 fRadioSideC->SetToolTipText("Use only side C.");
72d0ab7e 621
4f3934a1 622 // sector radio button
832bb12c 623 fRadioSector = new TGRadioButton(fContCuts, "ROC", 23);
4f3934a1 624 fContCuts->AddFrame(fRadioSector, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
832bb12c 625 fRadioSector->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsCuts()");
626 fRadioSector->SetToolTipText("Use only one ROC (readout chamber).");
72d0ab7e 627
4f3934a1 628 // sector options container
629 fContSector = new TGCompositeFrame(fContCuts, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
630 fContCuts->AddFrame(fContSector, new TGLayoutHints(kLHintsExpandX, 5, 0, 0, 0));
72d0ab7e 631
4f3934a1 632 // ------------------------- content of fContSector -------------------------
633 // sector number entry
634 fNmbSector = new TGNumberEntry(fContSector, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
635 fContSector->AddFrame(fNmbSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
636 fNmbSector->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUI", this, "ChangeSector()");
637
638 // sector number label
639 fLblSector = new TGLabel(fContSector, "IROC, A");
640 fLblSector->SetTextJustify(kTextLeft);
641 fContSector->AddFrame(fLblSector, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0));
642
643 // cut zeros check button
644 fChkCutZero = new TGCheckButton(fContCuts, "Cut zeros");
645 fContCuts->AddFrame(fChkCutZero, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
646 fChkCutZero->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
832bb12c 647 fChkCutZero->SetToolTipText("Use only values that are not zero. \nWhen doing a custom draw this cut is composed of the draw string\nup to the first ':' or '>>' and the condition that this should not be zero.");
72d0ab7e 648
4f3934a1 649 // additional cuts check button
650 fChkAddCuts = new TGCheckButton(fContCuts, "Custom cuts");
651 fContCuts->AddFrame(fChkAddCuts, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
652 fChkAddCuts->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
832bb12c 653 fChkAddCuts->SetToolTipText("Activate the custom cuts on the bottom. Remember '~' (= '.fElements')!");
4f3934a1 654 // fContAddCuts' content is locaed further op
72d0ab7e 655
72d0ab7e 656
4f3934a1 657 // Scaling options container
658 fContScaling = new TGGroupFrame(fTabRight0, "Scaling", kVerticalFrame | kFitWidth | kFitHeight);
659 fTabRight0->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
39bcd65d 660
4f3934a1 661 // ************************* content of fContScaling *************************
662 // SetMaximum container
663 fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
664 fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
665
666 // ------------------------- content of fContSetMax -------------------------
667 // SetMaximum - checkbox
668 fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max.");
669 fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 670 fChkSetMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
671 fChkSetMax->SetToolTipText("Set the maximum fixed to the value specified here.");
4f3934a1 672
673 // text field for maximum value
674 fTxtSetMax = new TGTextEntry(fContSetMax, "", 41);
675 fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 676 fTxtSetMax->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
677 fTxtSetMax->SetToolTipText("maximum value for the drawing");
4f3934a1 678
679 // SetMinimum container
680 fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
681 fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
682
683 // ------------------------- content of fContSetMin -------------------------
684 // SetMinimum - checkbox
685 fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min.");
686 fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 687 fChkSetMin->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
688 fChkSetMin->SetToolTipText("Set the minimum fixed to the value specified here.");
4f3934a1 689
690 // text field for minimum value
691 fTxtSetMin = new TGTextEntry(fContSetMin, "", 40);
692 fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 693 fTxtSetMin->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
694 fTxtSetMin->SetToolTipText("minimum value for the drawing");
4f3934a1 695
696 // get Min & Max from Plot - button
697 fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot");
698 fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
699 fBtnGetMinMax->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
832bb12c 700 fBtnGetMinMax->SetToolTipText("Get min and max from plot, e.g. after rescaling by dragging the palette. \nObsolete! The button's function will change to 'Unzoom all'.");
4f3934a1 701
702 // GetMinMaxAuto - checkbox
703 fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto.");
704 fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 705 fChkGetMinMaxAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
706 fChkGetMinMaxAuto->SetToolTipText("Get minimum and maximum automatically from each new plot. \nDeactivate this, if you want to 'save' your specified minimum and maximum.");
4f3934a1 707
708 // labeling container *** fContLabeling *** " Labeling "
709 fContLabeling = new TGGroupFrame(fTabRight0, "Labeling", kVerticalFrame | kFitWidth | kFitHeight);
710 fTabRight0->AddFrame(fContLabeling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
711
712 fChkLabelTitle = new TGCheckButton(fContLabeling, "Set title:");
713 fContLabeling->AddFrame(fChkLabelTitle, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 714 fChkLabelTitle->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
715 fChkLabelTitle->SetToolTipText("Set the plot title.");
4f3934a1 716
717 fTxtLabelTitle = new TGTextEntry(fContLabeling, "Title", 500);
718 fContLabeling->AddFrame(fTxtLabelTitle, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 719 fTxtLabelTitle->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw(=50)");
720 fTxtLabelTitle->SetToolTipText("plot title");
4f3934a1 721
722 fChkLabelXaxis = new TGCheckButton(fContLabeling, "Set X-axis label:");
723 fContLabeling->AddFrame(fChkLabelXaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 724 fChkLabelXaxis->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
725 fChkLabelXaxis->SetToolTipText("Set the X-axis label.");
4f3934a1 726
727 fTxtLabelXaxis = new TGTextEntry(fContLabeling, "XaxisLabel", 500);
728 fContLabeling->AddFrame(fTxtLabelXaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 729 fTxtLabelXaxis->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw(=51)");
730 fTxtLabelXaxis->SetToolTipText("X-axis label");
4f3934a1 731
732 fChkLabelYaxis = new TGCheckButton(fContLabeling, "Set Y-axis label:");
733 fContLabeling->AddFrame(fChkLabelYaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 734 fChkLabelYaxis->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
735 fChkLabelYaxis->SetToolTipText("Set the Y-axis label.");
4f3934a1 736
737 fTxtLabelYaxis = new TGTextEntry(fContLabeling, "YaxisLabel", 500);
738 fContLabeling->AddFrame(fTxtLabelYaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
832bb12c 739 fTxtLabelYaxis->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw(=52)");
740 fTxtLabelYaxis->SetToolTipText("Y-axis label");
4f3934a1 741
742 fChkLabelGetAuto = new TGCheckButton(fContLabeling, "Get labels auto.");
743 fContLabeling->AddFrame(fChkLabelGetAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
832bb12c 744 fChkLabelGetAuto->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "HandleButtonsNoRedraw()");
745 fChkLabelGetAuto->SetToolTipText("Get labels automatically from each new plot \nDeactivate this, if you want to 'save' your specified labels.");
4f3934a1 746
72d0ab7e 747
832bb12c 748 // **************************** content of ftabRight1 *******************************
4f3934a1 749 // Save container
750 fContSave = new TGGroupFrame(fTabRight1, "Save", kVerticalFrame | kFitWidth | kFitHeight);
751 fTabRight1->AddFrame(fContSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
752 // save button
832bb12c 753 fBtnSave = new TGTextButton(fContSave, "&Save picture");
4f3934a1 754 fContSave->AddFrame(fBtnSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
755 fBtnSave->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "SavePicture()");
832bb12c 756 fBtnSave->SetToolTipText("Open a 'Save as...' dialog to save the current plot as picture or macro.");
4f3934a1 757
758 // additional save options container
759 fContAddSaveOpt = new TGCompositeFrame(fContSave, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
760 fContSave->AddFrame(fContAddSaveOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
72d0ab7e 761
4f3934a1 762 // content of --- fContAddSaveOpt ---
763 // addition save options label
764 fChkAddSaveOpt = new TGCheckButton(fContAddSaveOpt, "Save options:");
765 fContAddSaveOpt->AddFrame(fChkAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
766 fChkAddSaveOpt->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
832bb12c 767 fChkAddSaveOpt->SetToolTipText("Additional save options (see documentation for TPad::Print()).");
4f3934a1 768
769 // additional save options combo box
770 fComboAddSaveOpt = new TGComboBox(fContAddSaveOpt);
771 fContAddSaveOpt->AddFrame(fComboAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
772 fComboAddSaveOpt->Resize(0, fBtnDraw->GetDefaultHeight());
773 fComboAddSaveOpt->EnableTextInput(kTRUE);
774 fComboAddSaveOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "SavePicture()");
775 // fComboAddSaveOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "SavePicture()");
776
832bb12c 777 // calPad export container
778 fContExport = new TGGroupFrame(fTabRight1, "Export AliTPCCalPad", kVerticalFrame | kFitWidth | kFitHeight);
779 fTabRight1->AddFrame(fContExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
780
781 // ------------------------- content of fContExport -------------------------
782 // container for export name
783 fContAddExport = new TGCompositeFrame(fContExport, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
784 fContExport->AddFrame(fContAddExport, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
785
786 fComboExportName = new TGComboBox(fContAddExport);
787 fComboExportName->Resize(0, fBtnDraw->GetDefaultHeight());
788 fContAddExport->AddFrame(fComboExportName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
789 fComboExportName->AddEntry("calPad", 0); // first default value
790 fComboExportName->Select(0); // select default value before connecting
791 fComboExportName->EnableTextInput(kTRUE);
792 fComboExportName->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoExport()");
793 fComboExportName->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoExport()");
794
795 // export button
796 fBtnExport = new TGTextButton(fContExport, "&Export to CINT");
797 fContExport->AddFrame(fBtnExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
798 fBtnExport->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoExport()");
799 fBtnExport->SetToolTipText("Export the current 2D view as AliTPCCalPad to the CINT command line interpreter, use the specified name. \nThis works only in 2D mode.");
800
801 // export button
802 fBtnAddNorm = new TGTextButton(fContExport, "&Add to normalization");
803 fContExport->AddFrame(fBtnAddNorm, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
804 fBtnAddNorm->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoExportNorm()");
805 fBtnAddNorm->SetToolTipText("Use the current 2D view as normalization variable, use the specified name. \nNot yet working!");
806
807
4f3934a1 808 // Fit options container
832bb12c 809 fContFit = new TGGroupFrame(fTabRight1, "Custom fit", kVerticalFrame | kFitWidth | kFitHeight);
4f3934a1 810 fTabRight1->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
811
812 // ------------------------- content of fContFit -------------------------
813 // container for additional fits
814 fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
815 fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
816
817 // --- content of fContAddFit ---
818 // text field for custom fit
819 fComboCustomFit = new TGComboBox(fContAddFit);
820 fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight());
821 fComboCustomFit->EnableTextInput(kTRUE);
822 fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
823 fComboCustomFit->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "DoFit()");
824 fComboCustomFit->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoFit()");
72d0ab7e 825
4f3934a1 826 // fit button
827 fBtnFit = new TGTextButton(fContAddFit, "&Fit");
828 fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
829 fBtnFit->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoFit()");
832bb12c 830 fBtnFit->SetToolTipText("Fit a whole TPC side, e.g. with gx~ ++ gy~, the result is printed to the console \nNot yet final status.");
4f3934a1 831
832 // add fit function button
833 //fBtnAddFitFunction = new TGTextButton(fContAddFit, "&Add fit function to normalization");
834 //fContAddFit->AddFrame(fBtnAddFitFunction, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
835 //fBtnAddFitFunction->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "AddFitFunction()");
836
832bb12c 837 SetWindowName("AliTPCCalibViewer GUI");
838 MapSubwindows();
839 Resize(GetDefaultSize());
840 MapWindow();
841}
842
843
844void AliTPCCalibViewerGUI::SetInitialValues() {
845 //
846 // Set the default button states
847 //
72d0ab7e 848 fRadioPredefined->SetState(kButtonDown);
849 fRadioRaw->SetState(kButtonDown);
850 fRadioTPC->SetState(kButtonDown);
851 fRadio1D->SetState(kButtonDown);
852 fChkAuto->SetState(kButtonDown);
853 fChkAddCuts->SetState(kButtonUp);
854 fChkGetMinMaxAuto->SetState(kButtonDown);
855 fChkSetMin->SetState(kButtonUp);
856 fChkSetMax->SetState(kButtonUp);
857 fRadioNorm->SetState(kButtonDown);
858 fRadioSigma->SetState(kButtonUp);
859 fRadioCumulative->SetState(kButtonUp);
860 fChkMean->SetState(kButtonDown);
861 fCheckCumulativePM->SetState(kButtonUp);
862
832bb12c 863 fChkLabelGetAuto->SetState(kButtonDown);
864
865 // TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
866 // TODO Set the checkboxes state as it is really TODO
867 // TODO in gStyle TODO
868 // TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO TODO
869// k = 1; kurtosis printed
870// k = 2; kurtosis and kurtosis error printed
871// s = 1; skewness printed
872// s = 2; skewness and skewness error printed
873// i = 1; integral of bins printed
874// o = 1; number of overflows printed
875// u = 1; number of underflows printed
876// r = 1; rms printed
877// r = 2; rms and rms error printed
878// m = 1; mean value printed
879// m = 2; mean and mean error values printed
880// e = 1; number of entries printed
881// n = 1; name of histogram is printed
882// (default = 000001111)
883
884 Int_t statOpt = gStyle->GetOptStat();
885 if (statOpt == 1) statOpt = 1111;
886 if (statOpt / 200000000 >= 1) {
887 fChkStatKurtosis->SetState(kButtonDown);
888 fChkStatKurtosisPM->SetState(kButtonDown);
889 statOpt -= 200000000;
890 }
891 if (statOpt / 100000000 >= 1) {
892 fChkStatKurtosis->SetState(kButtonDown);
893 statOpt -= 100000000;
894 }
895 if (statOpt / 20000000 >= 1) {
896 fChkStatSkewness->SetState(kButtonDown);
897 fChkStatSkewnessPM->SetState(kButtonDown);
898 statOpt -= 20000000;
899 }
900 if (statOpt / 10000000 >= 1) {
901 fChkStatSkewness->SetState(kButtonDown);
902 statOpt -= 10000000;
903 }
904 if (statOpt / 1000000 >= 1) {
905 fChkStatIntegral->SetState(kButtonDown);
906 statOpt -= 1000000;
907 }
908 if (statOpt / 100000 >= 1) {
909 fChkStatOverflow->SetState(kButtonDown);
910 statOpt -= 100000;
911 }
912 if (statOpt / 10000 >= 1) {
913 fChkStatUnderflow->SetState(kButtonDown);
914 statOpt -= 10000;
915 }
916 if (statOpt / 2000 >= 1) {
917 fChkStatRMS->SetState(kButtonDown);
918 fChkStatRMSPM->SetState(kButtonDown);
919 statOpt -= 2000;
920 }
921 if (statOpt / 1000 >= 1) {
922 fChkStatRMS->SetState(kButtonDown);
923 statOpt -= 1000;
924 }
925 if (statOpt / 200 >= 1) {
926 fChkStatMean->SetState(kButtonDown);
927 fChkStatMeanPM->SetState(kButtonDown);
928 statOpt -= 200;
929 }
930 if (statOpt / 100 >= 1) {
931 fChkStatMean->SetState(kButtonDown);
932 statOpt -= 100;
933 }
934 if (statOpt / 10 >= 1) {
935 fChkStatEntries->SetState(kButtonDown);
936 statOpt -= 10;
937 }
938 if (statOpt / 1 >= 1) {
939 fChkStatName->SetState(kButtonDown);
940 statOpt -= 1;
941 }
942
943 /*
72d0ab7e 944 fChkStatName->SetState(kButtonDown);
945 fChkStatEntries->SetState(kButtonDown);
946 fChkStatMean->SetState(kButtonDown);
947 fChkStatRMS->SetState(kButtonDown);
832bb12c 948 */
72d0ab7e 949// fChkStatMeanPM->SetState(kButtonUp);
950// fChkStatRMSPM->SetState(kButtonUp);
951// fChkStatUnderflow->SetState(kButtonUp);
952// fChkStatOverflow->SetState(kButtonUp);
953// fChkStatIntegral->SetState(kButtonUp);
954// fChkStatSkewness->SetState(kButtonUp);
955// fChkStatSkewnessPM->SetState(kButtonUp);
832bb12c 956// fChkStatKurtosis->SetState(kButtonDown);
957// fChkStatKurtosisPM->SetState(kButtonDown);
958
959 // fill fComboAddDrawOpt with some additional drawing options
960 fComboAddDrawOpt->AddEntry("same", 0);
961 fComboAddDrawOpt->AddEntry("profbox", 1);
962 fComboAddDrawOpt->AddEntry("profcolz", 2);
963 fComboAddDrawOpt->AddEntry("profcont0", 3);
964 fComboAddDrawOpt->AddEntry("proflego", 4);
965 fComboAddDrawOpt->AddEntry("proflego2", 5);
966 fComboAddDrawOpt->AddEntry("profsurf", 6);
967 fComboAddDrawOpt->AddEntry("profsurf1", 7);
968 fComboAddDrawOpt->AddEntry("profsurf2", 8);
969 fComboAddDrawOpt->AddEntry("box", 9);
970 fComboAddDrawOpt->AddEntry("colz", 10);
971 fComboAddDrawOpt->AddEntry("cont0", 11);
972 fComboAddDrawOpt->AddEntry("lego", 12);
973 fComboAddDrawOpt->AddEntry("lego2", 13);
974 fComboAddDrawOpt->AddEntry("surf", 14);
975 fComboAddDrawOpt->AddEntry("surf1", 15);
976 fComboAddDrawOpt->AddEntry("surf2", 16);
39bcd65d 977
832bb12c 978 // fill fComboAddSaveOpt with some additional drawing options
979 fComboAddSaveOpt->AddEntry("Portrait", 0);
980 fComboAddSaveOpt->AddEntry("Landscape", 1);
981 fComboAddSaveOpt->AddEntry("Preview", 2);
982 fComboAddSaveOpt->AddEntry("+50", 3);
983
984 // fill fComboMethod
985 fComboMethod->AddEntry("subtract", 0);
986 fComboMethod->AddEntry("divide by", 1);
987
988 // fill fComboExportName
989// fComboExportName->AddEntry("calPad", 0);
990 // fComboExportName->AddEntry("calPad2", 1);
991 fBtnExport->SetEnabled(kFALSE);
992 fBtnAddNorm->SetEnabled(kFALSE);
993
994 // select initial variables
995 fListVariables->Select(0);
996 fListNormalization->Select(0);
997 fComboMethod->Select(0);
998// fComboExportName->Select(0);
999// fComboExportName->EnableTextInput(kTRUE);
1000
1001 //fCanvMain->GetCanvas()->ToggleEventStatus(); // klappt nicht
1002 //fCanvMain->GetCanvas()->GetCanvasImp()->ShowStatusBar(kTRUE); // klappt auch nicht
1003 fListVariables->IntegralHeight(kFALSE); // naja
1004 fListNormalization->IntegralHeight(kFALSE); // naja
1005
1006 // Make first drawing:
1007 // DoDraw();
39bcd65d 1008}
1009
832bb12c 1010
39bcd65d 1011AliTPCCalibViewerGUI::AliTPCCalibViewerGUI(const AliTPCCalibViewerGUI &c)
a6d2bd0c 1012 : TGCompositeFrame(c.fParent, c.fWidth, c.fHeight),
39bcd65d 1013 fViewer(0),
a6d2bd0c 1014 fContTopBottom(0),
1015 fContLCR(0),
39bcd65d 1016 fContLeft(0),
72d0ab7e 1017 ftabLeft(0),
1018 ftabLeft0(0),
1019 ftabLeft1(0),
4f3934a1 1020 ftabRight(0),
1021 fTabRight0(0),
1022 fTabRight1(0),
39bcd65d 1023 fContRight(0),
1024 fContCenter(0),
1025 fContPlotOpt(0),
1026 fContDrawOpt(0),
a6d2bd0c 1027 fContDrawOptSub1D2D(0),
39bcd65d 1028 fContNormalized(0),
1029 fContCustom(0),
1030 fContCuts(0),
1031 fContSector(0),
1032 fContAddCuts(0),
a6d2bd0c 1033 fContFit(0),
1034 fContAddFit(0),
1035 fContScaling(0),
1036 fContSetMax(0),
1037 fContSetMin(0),
72d0ab7e 1038 fContAddDrawOpt(0),
39bcd65d 1039 fListVariables(0),
1040 fBtnDraw(0),
a6d2bd0c 1041 fBtnFit(0),
1042 fBtnAddFitFunction(0),
1043 fBtnGetMinMax(0),
39bcd65d 1044 fCanvMain(0),
1045 fRadioRaw(0),
1046 fRadioNormalized(0),
a6d2bd0c 1047 fRadioPredefined(0),
39bcd65d 1048 fRadioCustom(0),
1049 fRadio1D(0),
1050 fRadio2D(0),
1051 fRadioTPC(0),
1052 fRadioSideA(0),
1053 fRadioSideC(0),
1054 fRadioSector(0),
72d0ab7e 1055 fComboAddDrawOpt(0),
39bcd65d 1056 fChkAuto(0),
1057 fComboMethod(0),
1058 fListNormalization(0),
a6d2bd0c 1059 fComboCustom(0),
4f3934a1 1060 fLblCustomDraw(0),
72d0ab7e 1061 fChkAddDrawOpt(0),
39bcd65d 1062 fNmbSector(0),
a6d2bd0c 1063 fLblSector(0),
72d0ab7e 1064 fChkCutZero(0),
39bcd65d 1065 fChkAddCuts(0),
4f3934a1 1066 fLblAddCuts(0),
a6d2bd0c 1067 fComboAddCuts(0),
1068 fComboCustomFit(0),
1069 fChkSetMax(0),
1070 fChkSetMin(0),
1071 fChkGetMinMaxAuto(0),
1072 fTxtSetMax(0),
72d0ab7e 1073 fTxtSetMin(0),
1074 fContDrawOpt1D(0),
1075 fcontDrawOpt1DSubLR(0),
1076 fContDrawOpt1DSubNSC(0),
1077 fRadioNorm(0),
1078 fRadioSigma(0),
1079 fTxtSigmas(0),
1080 fContCumuLR(0),
1081 fContCumLeft(0),
1082 fContCumRight(0),
1083 fLblSigmaMax(0),
1084 fTxtSigmaMax(0),
1085 fRadioCumulative(0),
1086 fCheckCumulativePM(0),
1087 fRadioIntegrate(0),
1088 fContDrawOpt1DSubMML(0),
1089 fChkMean(0),
1090 fChkMedian(0),
1091 fChkLTM(0),
1092 fContStatOpt(0),
1093 fChkStatName(0),
1094 fChkStatEntries(0),
1095 fContStatMean(0),
1096 fChkStatMean(0),
1097 fChkStatMeanPM(0),
1098 fContStatRMS(0),
1099 fChkStatRMS(0),
1100 fChkStatRMSPM(0),
1101 fChkStatUnderflow(0),
1102 fChkStatOverflow(0),
1103 fChkStatIntegral(0),
1104 fContStatSkew(0),
1105 fChkStatSkewness(0),
1106 fChkStatSkewnessPM(0),
1107 fContStatKurt(0),
1108 fChkStatKurtosis(0),
4f3934a1 1109 fChkStatKurtosisPM(0),
832bb12c 1110 fBtnUnchekAll(0),
4f3934a1 1111 fContLabeling(0),
1112 fChkLabelTitle(0),
1113 fTxtLabelTitle(0),
1114 fChkLabelXaxis(0),
1115 fTxtLabelXaxis(0),
1116 fChkLabelYaxis(0),
1117 fTxtLabelYaxis(0),
1118 fChkLabelGetAuto(0),
1119 fContSave(0),
1120 fBtnSave(0),
1121 fContAddSaveOpt(0),
1122 fChkAddSaveOpt(0),
832bb12c 1123 fComboAddSaveOpt(0),
1124 fContExport(0),
1125 fContAddExport(0),
1126 fComboExportName(0),
1127 fBtnExport(0),
1128 fBtnAddNorm(0)
39bcd65d 1129{
1130 //
1131 // dummy AliTPCCalibViewerGUI copy constructor
1132 //
1133}
1134
832bb12c 1135
39bcd65d 1136AliTPCCalibViewerGUI & AliTPCCalibViewerGUI::operator =(const AliTPCCalibViewerGUI & param) {
1137 //
1138 // dummy assignment operator
1139 //
1140 return (*this);
1141}
1142
832bb12c 1143
39bcd65d 1144AliTPCCalibViewerGUI::~AliTPCCalibViewerGUI() {
72d0ab7e 1145 //
1146 // Destructor
1147 //
a6d2bd0c 1148 if (fCanvMain && fCanvMain->GetCanvas()) {
1149 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
1150 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
1151 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
1152 }
1153 }
39bcd65d 1154 Cleanup();
a6d2bd0c 1155 if (fViewer) fViewer->Delete();
39bcd65d 1156}
1157
832bb12c 1158
a6d2bd0c 1159/*
39bcd65d 1160void AliTPCCalibViewerGUI::CloseWindow() {
1161 DeleteWindow();
1162}
a6d2bd0c 1163*/
39bcd65d 1164
832bb12c 1165
1166void AliTPCCalibViewerGUI::Initialize(char* fileName, char* treeName) {
1167 //
1168 // initialize the GUI with a calibrationTree from fileName
1169 //
39bcd65d 1170
1171 // create AliTPCCalibViewer object, which will be used for generating all drawings
a6d2bd0c 1172 if (fViewer) delete fViewer;
832bb12c 1173 fViewer = new AliTPCCalibViewer(fileName, treeName);
1174 Initialize(fViewer);
1175}
1176
39bcd65d 1177
832bb12c 1178void AliTPCCalibViewerGUI::Initialize(AliTPCCalibViewer *viewer) {
1179 //
1180 // initializes the GUI with default settings and opens tree for drawing
1181 //
1182
1183 fViewer = viewer;
1184 TString selectedVariable("");
1185 TString selectedNormalization("");
1186 Int_t variableId = -1;
1187 Int_t normalizationId = -1;
1188 if (fInitialized) {
1189 // remember the selected entry
1190 if (fListVariables->GetSelectedEntry()) selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
1191 if (fListNormalization->GetSelectedEntry()) selectedNormalization = fListNormalization->GetSelectedEntry()->GetTitle();
1192 }
1193
1194 // fill fListVariables, list of drawable variables:
39bcd65d 1195 TObjArray* arr = fViewer->GetListOfVariables();
1196 TIterator* iter = arr->MakeIterator();
1197 iter->Reset();
1198 TObjString* currentStr = 0;
1199 Int_t id = 0;
832bb12c 1200 fListVariables->RemoveAll();
a6d2bd0c 1201 while ((currentStr = (TObjString*)(iter->Next()))) {
39bcd65d 1202 fListVariables->AddEntry(currentStr->GetString().Data(), id);
832bb12c 1203 if (fInitialized && currentStr->GetString() == selectedVariable) variableId = id;
39bcd65d 1204 id++;
1205 }
1206 delete iter;
1207 arr->Delete();
1208 delete arr;
1209
832bb12c 1210 // fill fListNorm, list of normalization variables:
39bcd65d 1211 arr = fViewer->GetListOfNormalizationVariables();
1212 iter = arr->MakeIterator();
1213 iter->Reset();
1214 currentStr = 0;
1215 id = 0;
832bb12c 1216 fListNormalization->RemoveAll();
a6d2bd0c 1217 while ((currentStr = (TObjString*)(iter->Next()))) {
39bcd65d 1218 fListNormalization->AddEntry(currentStr->GetString().Data(), id);
832bb12c 1219 if (fInitialized && currentStr->GetString() == selectedNormalization) normalizationId = id;
39bcd65d 1220 id++;
1221 }
1222 delete iter;
1223 arr->Delete();
1224 delete arr;
832bb12c 1225
1226 // trick do display the entries corectly after reinitialization
1227 // otherwise all the entries would appear as one kryptic entry
1228 // resizing the listbox somehow fixes the problem...
1229 if (fInitialized) fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
1230 if (fInitialized) fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
1231 if (fInitialized) fListNormalization->Resize(fListNormalization->GetWidth()-1, fListNormalization->GetHeight());
1232 if (fInitialized) fListNormalization->Resize(fListNormalization->GetWidth()+1, fListNormalization->GetHeight());
1233
1234 // select the last selected variable and normalization
1235 if (fInitialized && variableId != -1) fListVariables->Select(variableId);
1236 if (fInitialized && normalizationId != -1)fListVariables->Select(normalizationId);
1237
1238 if (fInitialized) Info("Initialize", "AliTPCCalibViewerGUI new initialized.");
1239 fInitialized = kTRUE;
39bcd65d 1240
39bcd65d 1241}
1242
72d0ab7e 1243
72d0ab7e 1244void AliTPCCalibViewerGUI::HandleButtonsGeneral(Int_t id) {
39bcd65d 1245 //
1246 // handles mutual radio button exclusions
72d0ab7e 1247 // for general Tab
39bcd65d 1248 //
1249 if (id == -1) {
1250 TGButton *btn = (TGButton *) gTQSender;
1251 id = btn->WidgetId();
1252 }
a6d2bd0c 1253
39bcd65d 1254 switch (id) {
1255 case 10: // fRadioRaw
1256 fRadioNormalized->SetState(kButtonUp);
a6d2bd0c 1257 fRadioPredefined->SetState(kButtonDown);
39bcd65d 1258 fRadioCustom->SetState(kButtonUp);
72d0ab7e 1259 // fComboMethod->UnmapWindow();
1260 // fListNormalization->UnmapWindow();
39bcd65d 1261 break;
1262 case 11: // fRadioNormalized
1263 fRadioRaw->SetState(kButtonUp);
a6d2bd0c 1264 fRadioPredefined->SetState(kButtonDown);
39bcd65d 1265 fRadioCustom->SetState(kButtonUp);
1266 break;
1267 case 12: // fRadioCustom
a6d2bd0c 1268 fRadioPredefined->SetState(kButtonUp);
72d0ab7e 1269 // fComboCustom->SetEnabled(kFALSE);
1270 // fRadioNormalized->SetState(kButtonUp);
1271 break;
832bb12c 1272 case 14: // select Draw options fComboAddDrawOpt
1273 fChkAddDrawOpt->SetState(kButtonDown);
a6d2bd0c 1274 break;
1275 case 13: // fRadioPredefined
1276 fRadioCustom->SetState(kButtonUp);
72d0ab7e 1277 // fComboCustom->SetEnabled(kTRUE);
1278 //f RadioNormalized->SetState(kButtonUp);
39bcd65d 1279 break;
1280 //--------
72d0ab7e 1281 case 30: // fRadio1D
1282 fRadio2D->SetState(kButtonUp);
832bb12c 1283 fBtnExport->SetEnabled(kFALSE);
1284 fBtnAddNorm->SetEnabled(kFALSE);
72d0ab7e 1285 break;
1286 case 31: // fRadio2D
1287 fRadio1D->SetState(kButtonUp);
832bb12c 1288 fBtnExport->SetEnabled(kTRUE);
1289 fBtnAddNorm->SetEnabled(kTRUE);
1290 break;
1291 case 42: // fComboCustom
1292 fRadioCustom->SetState(kButtonDown);
1293 fRadioPredefined->SetState(kButtonUp);
72d0ab7e 1294 break;
1295 }
1296 DoNewSelection();
1297}
1298
1299
1300void AliTPCCalibViewerGUI::HandleButtons1D(Int_t id) {
1301 //
1302 // handles mutual radio button exclusions
1303 // 1D-Tab buttons
1304 //
1305
1306 if (id == -1) {
1307 TGButton *btn = (TGButton *) gTQSender;
1308 id = btn->WidgetId();
1309 }
1310 switch (id) {
1311 case 110: // 1D draw normal
1312 fRadioNorm->SetState(kButtonDown);
1313 fRadioSigma->SetState(kButtonUp);
1314 fRadioCumulative->SetState(kButtonUp);
1315 fRadioIntegrate->SetState(kButtonUp);
1316 break;
1317 case 111: // 1D draw sigma
1318 fRadioNorm->SetState(kButtonUp);
1319 fRadioSigma->SetState(kButtonDown);
1320 fRadioCumulative->SetState(kButtonUp);
1321 fRadioIntegrate->SetState(kButtonUp);
1322 break;
1323 case 112: // 1D draw cumulative
1324 fRadioNorm->SetState(kButtonUp);
1325 fRadioSigma->SetState(kButtonUp);
1326 fRadioCumulative->SetState(kButtonDown);
1327 fRadioIntegrate->SetState(kButtonUp);
1328 break;
1329 case 113: // 1D draw integral
1330 fRadioNorm->SetState(kButtonUp);
1331 fRadioSigma->SetState(kButtonUp);
1332 fRadioCumulative->SetState(kButtonUp);
1333 fRadioIntegrate->SetState(kButtonDown);
1334 break;
1335 }
1336 DoNewSelection();
1337}
1338
1339
72d0ab7e 1340void AliTPCCalibViewerGUI::HandleButtonsStat(Int_t id) {
1341 //
1342 // handles statistic check boxes
1343 // checks each checkbox if checked
1344 // if the checkbox is checked, appends 'n' for name, 'e' for entries, ...
1345 // to a TString, passes this TString to gStyle->SetOptStat(...)
1346 //
4f3934a1 1347 if (id == -1) {
1348 TGButton *btn = (TGButton *) gTQSender;
1349 id = btn->WidgetId();
1350 }
72d0ab7e 1351 TString statOpt("");
1352 if (fChkStatName->GetState() == kButtonDown) statOpt.Append("n");
1353 if (fChkStatEntries->GetState() == kButtonDown) statOpt.Append("e");
1354 if (fChkStatMean->GetState() == kButtonDown && fChkStatMeanPM->GetState() == kButtonUp) statOpt.Append("m");
1355 if (fChkStatMeanPM->GetState() == kButtonDown) statOpt.Append("M");
1356 if (fChkStatRMS->GetState() == kButtonDown && fChkStatRMSPM->GetState() == kButtonUp) statOpt.Append("r");
1357 if (fChkStatRMSPM->GetState() == kButtonDown) statOpt.Append("R");
1358 if (fChkStatUnderflow->GetState() == kButtonDown) statOpt.Append("u");
1359 if (fChkStatOverflow->GetState() == kButtonDown) statOpt.Append("o");
1360 if (fChkStatIntegral->GetState() == kButtonDown) statOpt.Append("i");
1361 if (fChkStatSkewness->GetState() == kButtonDown && fChkStatSkewnessPM->GetState() == kButtonUp) statOpt.Append("s");
1362 if (fChkStatSkewnessPM->GetState() == kButtonDown) statOpt.Append("S");
1363 if (fChkStatKurtosis->GetState() == kButtonDown && fChkStatKurtosisPM->GetState() == kButtonUp) statOpt.Append("k");
1364 if (fChkStatKurtosisPM->GetState() == kButtonDown) statOpt.Append("K");
832bb12c 1365
72d0ab7e 1366 gStyle->SetOptStat(statOpt);
1367 DoNewSelection();
1368}
1369
1370
832bb12c 1371void AliTPCCalibViewerGUI::HandleButtonsCuts(Int_t id) {
72d0ab7e 1372 //
1373 // handles mutual radio button exclusions
1374 // right side buttons
1375 //
1376 if (id == -1) {
1377 TGButton *btn = (TGButton *) gTQSender;
1378 id = btn->WidgetId();
1379 }
1380
1381 switch (id) {
39bcd65d 1382 case 20: // fRadioTPC
1383 fRadioSideA->SetState(kButtonUp);
1384 fRadioSideC->SetState(kButtonUp);
1385 fRadioSector->SetState(kButtonUp);
1386 break;
1387 case 21: // fRadioSideA
1388 fRadioTPC->SetState(kButtonUp);
1389 fRadioSideC->SetState(kButtonUp);
1390 fRadioSector->SetState(kButtonUp);
1391 break;
1392 case 22: // fRadioSideC
1393 fRadioTPC->SetState(kButtonUp);
1394 fRadioSideA->SetState(kButtonUp);
1395 fRadioSector->SetState(kButtonUp);
1396 break;
1397 case 23: // fRadioSector
1398 fRadioTPC->SetState(kButtonUp);
1399 fRadioSideA->SetState(kButtonUp);
1400 fRadioSideC->SetState(kButtonUp);
1401 break;
4f3934a1 1402 case 31: // fComboAddCuts
1403 fChkAddCuts->SetState(kButtonDown);
1404 break;
832bb12c 1405 }
1406 DoNewSelection();
1407}
1408
1409
1410void AliTPCCalibViewerGUI::HandleButtonsNoRedraw(Int_t id) {
1411 //
1412 // handles label & scaling checkboxes
1413 // without redrawing (not necessary, faster like this)
1414 //
1415 if (id == -1) {
1416 TGButton *btn = (TGButton *) gTQSender;
1417 id = btn->WidgetId();
1418 }
1419
1420 switch (id) {
a6d2bd0c 1421 case 40: // fTxtSetMin
1422 fChkSetMin->SetState(kButtonDown);
1423 break;
1424 case 41: // fTxtSetMax
1425 fChkSetMax->SetState(kButtonDown);
1426 break;
4f3934a1 1427 case 50: // fTxtLabelTitle
1428 fChkLabelTitle->SetState(kButtonDown);
1429 break;
1430 case 51: // fTxtLabelXaxis
1431 fChkLabelXaxis->SetState(kButtonDown);
1432 break;
1433 case 52: // fTxtLabelXaxis
1434 fChkLabelYaxis->SetState(kButtonDown);
1435 break;
39bcd65d 1436 }
832bb12c 1437 SetMinMaxLabel();
39bcd65d 1438}
1439
72d0ab7e 1440
1441
39bcd65d 1442void AliTPCCalibViewerGUI::DoNewSelection() {
1443 //
1444 // decides whether to redraw if user makes another selection
1445 //
39bcd65d 1446 if (fChkAuto->GetState() == kButtonDown) DoDraw();
1447}
1448
72d0ab7e 1449
832bb12c 1450TString* AliTPCCalibViewerGUI::GetDrawString() {
1451 //
1452 // create the draw string out of selection
1453 //
39bcd65d 1454
1455 // specify data to plot
1456 TString desiredData("");
832bb12c 1457 if (!fListVariables->GetSelectedEntry()) return 0;
39bcd65d 1458 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
832bb12c 1459 desiredData += fViewer->GetAbbreviation();
39bcd65d 1460
1461 // specify normalization
a6d2bd0c 1462 if (fRadioPredefined->GetState() == kButtonDown && fRadioNormalized->GetState() == kButtonDown) {
39bcd65d 1463 TString op("");
1464 switch (fComboMethod->GetSelected()) {
1465 case 0: // subtraction
1466 op += "-";
1467 break;
1468 case 1: // division
1469 op += "/";
1470 break;
1471 }
1472 TString normalizationData("");
832bb12c 1473 if (!fListNormalization->GetSelectedEntry()) return 0;
39bcd65d 1474 normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
a6d2bd0c 1475
1476 if ( normalizationData.BeginsWith("Fit")) {
1477 // create fit formula, evaluate it an replace normalizationData-String
1478 // ********** create cut string **********
1479 TString cutStr("");
1480 if (fRadioTPC->GetState() == kButtonDown)
1481 cutStr += ""; // whole TPC is used for fitting
1482 if (fRadioSideA->GetState() == kButtonDown)
1483 cutStr += "(sector/18)%2==0"; // side A
1484 if (fRadioSideC->GetState() == kButtonDown)
1485 cutStr+= "(sector/18)%2==1"; // side C
1486 if (fRadioSector->GetState() == kButtonDown) {
1487 Int_t sector = (Int_t)(fNmbSector->GetNumber());
1488 cutStr += "sector==";
1489 cutStr += sector;
1490 }
1491 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
1492 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
1493 cutStr += fComboAddCuts->GetTextEntry()->GetText();
1494 }
1495 Double_t chi2 = 0;
1496 TVectorD fitParam(0);
1497 TMatrixD covMatrix(0,0);
1498 TString formulaStr("");
1499 if (normalizationData.CompareTo("FitLinLocal") == 0)
1500 formulaStr = "lx~ ++ ly~";
1501 if (normalizationData.CompareTo("FitLinGlobal") == 0)
1502 formulaStr = "gx~ ++ gy~";
72d0ab7e 1503 if (normalizationData.CompareTo("FitParLocal") == 0)
1504 formulaStr = "lx~ ++ ly~ ++ lx~^2 ++ ly~^2 ++ lx~*ly~";
1505 if (normalizationData.CompareTo("FitParGlobal") == 0)
1506 formulaStr = "gx~ ++ gy~ ++ gx~^2 ++ gy~^2 ++ gx~*gy~";
832bb12c 1507 formulaStr.ReplaceAll("~", fViewer->GetAbbreviation());
a6d2bd0c 1508 normalizationData = *fViewer->Fit(desiredData.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
832bb12c 1509 } // if ( normalizationData.BeginsWith("Fit")
a6d2bd0c 1510
39bcd65d 1511 desiredData += op;
a6d2bd0c 1512 if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
1513 desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
39bcd65d 1514 desiredData += normalizationData;
1515 }
1516 else if (fRadioCustom->GetState() == kButtonDown) {
a6d2bd0c 1517 desiredData = fComboCustom->GetTextEntry()->GetText();
832bb12c 1518 if (desiredData == "") return 0;
39bcd65d 1519 }
832bb12c 1520
1521 return new TString(desiredData.Data());
1522}
1523
1524
1525TString* AliTPCCalibViewerGUI::GetSectorString() {
1526 //
1527 // create the sector string out of selection
1528 //
39bcd65d 1529
39bcd65d 1530 TString sectorStr("");
1531 if (fRadioTPC->GetState() == kButtonDown)
1532 sectorStr += "ALL";
1533 if (fRadioSideA->GetState() == kButtonDown)
1534 sectorStr += "A"; //cuts += "(sector/18)%2==0";
1535 if (fRadioSideC->GetState() == kButtonDown)
1536 sectorStr+= "C"; //cuts += "(sector/18)%2==1";
1537 if (fRadioSector->GetState() == kButtonDown) {
1538 Int_t sector = (Int_t)(fNmbSector->GetNumber());
1539 sectorStr += sector; //cuts += "sector==";
1540 }
832bb12c 1541 return new TString(sectorStr.Data());
1542}
1543
1544
1545 TString* AliTPCCalibViewerGUI::GetCutString() {
1546 //
1547 // create the cut string out of selection
1548 //
1549
39bcd65d 1550 TString cutsStr("");
72d0ab7e 1551 if (fChkCutZero->GetState() == kButtonDown) {
832bb12c 1552 TString cutZerosStr(GetDrawString()->Data());
1553 if (cutZerosStr.Contains(">>")) {
1554 cutZerosStr.Remove(cutZerosStr.First(">>"));
1555 }
1556 if (cutZerosStr.Contains(":")) {
1557 cutZerosStr.Remove(cutZerosStr.First(":"));
1558 }
1559 cutsStr += cutZerosStr.Data();
72d0ab7e 1560 cutsStr += "!=0";
1561 if (fChkAddCuts->GetState() == kButtonDown) cutsStr += " && ";
1562 }
39bcd65d 1563 if (fChkAddCuts->GetState() == kButtonDown)
a6d2bd0c 1564 cutsStr += fComboAddCuts->GetTextEntry()->GetText();
832bb12c 1565 return new TString(cutsStr.Data());
1566}
1567
1568
1569void AliTPCCalibViewerGUI::DoDraw() {
1570 //
1571 // main method for drawing according to user selection
1572 //
1573
1574 // specify data to plot:
1575 TString desiredData(GetDrawString()->Data());
1576 // specify sector:
1577 TString sectorStr(GetSectorString()->Data());
1578 // specify cuts:
1579 TString cutsStr(GetCutString()->Data());
72d0ab7e 1580
1581 TString addDrawOpt("");
1582 if (fChkAddDrawOpt->GetState() == kButtonDown)
1583 addDrawOpt += fComboAddDrawOpt->GetTextEntry()->GetText();
39bcd65d 1584
832bb12c 1585 // remove last picture
1586 if (!addDrawOpt.Contains("same"))
1587 for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
1588 if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
1589 fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
1590 }
a6d2bd0c 1591 //fCanvMain->GetCanvas()->Clear();
39bcd65d 1592 fCanvMain->GetCanvas()->cd();
a6d2bd0c 1593 Int_t entries = -1;
832bb12c 1594 // draw finally
72d0ab7e 1595 if (fRadio1D->GetState() == kButtonDown){
1596 // 1D-Drawing
1597 TString strSigmaMax(fTxtSigmaMax->GetText()); // get sigmaMax from text enty
1598 Double_t sigmaMax = (strSigmaMax.IsFloat()) ? strSigmaMax.Atof() : 5; // convert to double, if not convertable, set to 5
1599 Bool_t plotMean = fChkMean->GetState() == kButtonDown;
1600 Bool_t plotMedian = fChkMedian->GetState() == kButtonDown;
1601 Bool_t plotLTM = fChkLTM->GetState() == kButtonDown;
1602 if (fRadioNorm->GetState() == kButtonDown) // normal 1D drawing
1603 entries = fViewer->EasyDraw1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data());
1604 if (fRadioSigma->GetState() == kButtonDown) // sigma 1D drawing
1605 entries = fViewer->DrawHisto1D(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), //
1606 fTxtSigmas->GetText(), plotMean, plotMedian, plotLTM);
1607 if (fRadioCumulative->GetState() == kButtonDown) // cumulative 1D drawing
1608 entries = fViewer->SigmaCut(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), //
1609 sigmaMax, plotMean, plotMedian, plotLTM, //
1610 fCheckCumulativePM->GetState() == kButtonDown, fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1);
1611 if (fRadioIntegrate->GetState() == kButtonDown) // integral 1D drawing
1612 entries = fViewer->Integrate(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), //
1613 sigmaMax, plotMean, plotMedian, plotLTM, //
1614 fTxtSigmas->GetText(), /* Float_t sigmaStep =*/ -1);
1615 }
1616 else if (fRadio2D->GetState() == kButtonDown) {
1617 // 2D-Drawing
1618 entries = fViewer->EasyDraw(desiredData.Data(), sectorStr.Data(), cutsStr.Data(), addDrawOpt.Data());
1619 }
1620 if (entries == -1) return; // nothing was drawn, there is no histogram to get min and max
1621
832bb12c 1622 SetMinMaxLabel();
39bcd65d 1623 fCanvMain->GetCanvas()->Update();
1624}
a6d2bd0c 1625
1626
1627void AliTPCCalibViewerGUI::DoFit() {
1628 //
1629 // main method for fitting
1630 //
1631
1632 Double_t chi2 = 0;
1633 TVectorD fitParam(0);
1634 TMatrixD covMatrix(0,0);
a6d2bd0c 1635 TString cutStr("");
1636 TString formulaStr("");
1637 TString *returnStr = new TString("");
1638
832bb12c 1639 // specify data to plot:
1640 TString drawStr(GetDrawString()->Data());
1641
a6d2bd0c 1642
1643 // ********** create cut string **********
1644 if (fRadioTPC->GetState() == kButtonDown)
1645 cutStr += ""; // whole TPC is used for fitting
1646 if (fRadioSideA->GetState() == kButtonDown)
1647 cutStr += "(sector/18)%2==0"; // side A
1648 if (fRadioSideC->GetState() == kButtonDown)
1649 cutStr+= "(sector/18)%2==1"; // side C
1650 if (fRadioSector->GetState() == kButtonDown) {
1651 Int_t sector = (Int_t)(fNmbSector->GetNumber());
1652 cutStr += "sector==";
1653 cutStr += sector;
1654 }
1655 if (fChkAddCuts->GetState() == kButtonDown && strcmp(fComboAddCuts->GetTextEntry()->GetText(), "") != 0){
1656 if (fRadioTPC->GetState() != kButtonDown) cutStr += " && ";
1657 cutStr += fComboAddCuts->GetTextEntry()->GetText();
1658 }
1659
1660 // ********** get formula string **********
1661 formulaStr += fComboCustomFit->GetTextEntry()->GetText();
1662
1663 // ********** call AliTPCCalibViewer's fit-function
1664 returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
1665
1666 std::cout << std::endl;
1667 std::cout << "Your fit formula reads as follows:" << std::endl;
1668 std::cout << returnStr->Data() << std::endl;
1669 std::cout << "chi2 = " << chi2 << std::endl;
1670}
1671
832bb12c 1672
1673void AliTPCCalibViewerGUI::DoExport() {
1674 //
1675 // function to export a CalPad to Cint
1676 //
1677 if ( fRadio2D->GetState() != kButtonDown){
1678 Error("ExportCalPad", "Export of AliTPCCalPad to CINT works only in 2D mode.");
1679 return;
1680 }
1681 // specify data to plot:
1682 TString desiredData(GetDrawString()->Data());
1683 // specify cuts:
1684 TString cutsStr(GetCutString()->Data());
1685 // get name for the calPad
1686 const char* calPadName = fComboExportName->GetTextEntry()->GetText();
1687 // create calPad according to drawCommand and cuts
1688 AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)calPadName);
1689 // finally export calPad to Cint:
1690 gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad));
1691 Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName);
1692}
1693
1694
1695void AliTPCCalibViewerGUI::DoExportNorm() {
1696 //
1697 // function to export a CalPad to Cint
1698 //
1699
1700 if ( fRadio2D->GetState() != kButtonDown){
1701 Error("ExportCalPad", "Adding an AliTPCCalPad to the normalization works only in 2D mode.");
1702 return;
1703 }
1704
1705 Error("DoExportNorm", "Not yet implemented.");
1706 return;
1707
1708 // specify data to plot:
1709 TString desiredData(GetDrawString()->Data());
1710 // specify sector:
1711 TString sectorStr(GetSectorString()->Data());
1712 // specify cuts:
1713 TString cutsStr(GetCutString()->Data());
1714
1715 // get name for the calPad
1716 const char* calPadName = fComboExportName->GetTextEntry()->GetText();
1717 // create calPad according to drawCommand and cuts
1718 AliTPCCalPad *calPad = fViewer->GetCalPad(desiredData.Data(), (char*)cutsStr.Data(), (char*)fComboExportName->GetTextEntry()->GetText());
1719 // finally export calPad to Cint:
1720 gROOT->ProcessLine(Form("AliTPCCalPad* %s = (AliTPCCalPad*)0x%lx;", calPadName, calPad));
1721 Info("ExportCalPad", "Current 2D view has been exported to an AliTPCCalPad* with name '%s'", calPadName);
1722}
1723
1724
a6d2bd0c 1725void AliTPCCalibViewerGUI::GetMinMax() {
1726 //
1727 // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
1728 //
832bb12c 1729 if (fChkGetMinMaxAuto->GetState() == kButtonUp) return;
a6d2bd0c 1730 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
1731 TObject* ptr = 0;
1732 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
1733 ptr = listOfPrimitives->At(i);
1734 if ( ptr->InheritsFrom("TH1") ) break;
1735 }
1736 if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return; // if the loop did not find a TH1
1737 TH1 *hist = (TH1*)ptr;
1738 Double_t histMax = hist->GetMaximum();
1739 Double_t histMin = hist->GetMinimum();
1740 fTxtSetMax->SetText(Form("%f",histMax));
1741 fTxtSetMin->SetText(Form("%f",histMin));
1742}
1743
832bb12c 1744
1745void AliTPCCalibViewerGUI::SetMinMaxLabel() {
1746 //
1747 // Set Minimum, Maximum and labels without redrawing the plot
1748 // (faster)
1749 //
1750
1751 // search for histogram
1752 TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
1753 TObject* ptr = 0;
1754 for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
1755 ptr = listOfPrimitives->At(i);
1756 if ( ptr->InheritsFrom("TH1") ) break;
1757 }
1758 if ( ptr == 0 || !ptr->InheritsFrom("TH1") ) { // if the loop did not find a TH1
1759 fCanvMain->GetCanvas()->Update();
1760 Warning("SetMinMaxLabel","No Histogram found!");
1761 return;
1762 // unable to find histogram, no min and max wil be read out
1763 }
1764
1765 TH1 *hist = (TH1*)ptr;
1766 TString minTxt(fTxtSetMin->GetText());
1767 TString maxTxt(fTxtSetMax->GetText());
1768 // set min and max according to specified values, if checkbox is checked
1769 if (fChkSetMax->GetState() == kButtonDown && (maxTxt.IsDigit() || maxTxt.IsFloat()) )
1770 hist->SetMaximum(maxTxt.Atof());
1771 if (fChkSetMax->GetState() == kButtonUp)
1772 hist->SetMaximum(-1111); // default value, to unzoom
1773 if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) )
1774 hist->SetMinimum(minTxt.Atof());
1775 if (fChkSetMin->GetState() == kButtonUp)
1776 hist->SetMinimum(-1111); // default value, to unzoom
1777 // get min and max from plot
1778 if (fChkGetMinMaxAuto->GetState() == kButtonDown) {
1779 // maybe call here GetMinMax ???
1780 if (fChkSetMax->GetState() == kButtonUp)
1781 fTxtSetMax->SetText(Form("%f", hist->GetMaximum()));
1782 if (fChkSetMin->GetState() == kButtonUp)
1783 fTxtSetMin->SetText(Form("%f", hist->GetMinimum()));
1784 }
1785
1786 // set labels according to specification, if cehckboxes are checked
1787 if (fChkLabelTitle->GetState() == kButtonDown)
1788 hist->SetTitle(fTxtLabelTitle->GetText());
1789 if (fChkLabelXaxis->GetState() == kButtonDown)
1790 hist->GetXaxis()->SetTitle(fTxtLabelXaxis->GetText());
1791 if (fChkLabelYaxis->GetState() == kButtonDown)
1792 hist->GetYaxis()->SetTitle(fTxtLabelYaxis->GetText());
1793 // get and/or set labels and title
1794 if (fChkLabelGetAuto->GetState() == kButtonDown) {
1795 fTxtLabelTitle->SetText(hist->GetTitle());
1796 fTxtLabelXaxis->SetTitle(hist->GetXaxis()->GetTitle());
1797 fTxtLabelYaxis->SetTitle(hist->GetYaxis()->GetTitle());
1798 }
1799 hist->SetTitle(hist->GetTitle()); // trick to update the histogram
1800 fCanvMain->GetCanvas()->Update();
1801}
1802
1803
a6d2bd0c 1804void AliTPCCalibViewerGUI::ChangeSector(){
1805 //
1806 // function that is called, when the number of the sector is changed
1807 // to change the sector label
1808 //
1809 Int_t sector = (Int_t)(fNmbSector->GetNumber());
1810 char* secLabel = "";
1811 if (sector >= 0 && sector <= 17) // IROC, Side A
1812 secLabel = "IROC, A";
1813 if (sector >= 18 && sector <= 35) // IROC, Side C
1814 secLabel = "IROC, C";
1815 if (sector >= 36 && sector <= 53) // OROC, Side A
1816 secLabel = "OROC, A";
1817 if (sector >= 54 && sector <= 71) // OROC, Side C
1818 secLabel = "OROC, C";
1819 fLblSector->SetText(secLabel);
1820 DoNewSelection();
1821}
1822
832bb12c 1823
72d0ab7e 1824void AliTPCCalibViewerGUI::AddFitFunction() const {
a6d2bd0c 1825 //
1826 // adds the last fit function to the normalization list
1827 //
1828 std::cout << "Not yet implemented." << std::endl;
1829}
4f3934a1 1830
832bb12c 1831
1832void AliTPCCalibViewerGUI::UnchekAllStat() {
1833 //
1834 // Disable all statistical legend entries, no statistical legend.
1835 //
1836 fChkStatName->SetState(kButtonUp);
1837 fChkStatEntries->SetState(kButtonUp);
1838 fChkStatMean->SetState(kButtonUp);
1839 fChkStatMeanPM->SetState(kButtonUp);
1840 fChkStatRMS->SetState(kButtonUp);
1841 fChkStatRMSPM->SetState(kButtonUp);
1842 fChkStatUnderflow->SetState(kButtonUp);
1843 fChkStatOverflow->SetState(kButtonUp);
1844 fChkStatIntegral->SetState(kButtonUp);
1845 fChkStatSkewness->SetState(kButtonUp);
1846 fChkStatSkewnessPM->SetState(kButtonUp);
1847 fChkStatKurtosis->SetState(kButtonUp);
1848 fChkStatKurtosisPM->SetState(kButtonUp);
1849
1850 HandleButtonsStat(0);
1851}
1852
1853
1854void AliTPCCalibViewerGUI::MouseMove(Int_t event, Int_t x, Int_t y, TObject *selectedObject) {
1855 //
1856 // mouse move
1857 // zoom to sector works ONLY in 2D mode, if one side is specified
1858 //
1859 Double_t pi = TMath::Pi();
1860 if (event != kButton1Double )
1861 return;
1862 if (!selectedObject->InheritsFrom("TH2")) return;
1863 // zoom to sector works ONLY in 2D mode, if one side is specified
1864 if (fRadio2D->GetState() == kButtonUp) return;
1865 if (fRadioSector->GetState() == kButtonDown) { // return to full side view
1866 // return to full side view
1867 Int_t sector = (Int_t)(fNmbSector->GetNumber());
1868 if ( (sector >= 0 && sector <= 17) || (sector >= 36 && sector <= 53) ) {
1869 // A-Side
1870 fRadioSideA->Clicked();
1871 fRadioSideA->SetState(kButtonDown);
1872 DoNewSelection();
1873 }
1874 if ( (sector >= 18 && sector <= 35) || (sector >= 54 && sector <= 71) ) {
1875 // C-Side
1876 fRadioSideC->Clicked();
1877 fRadioSideC->SetState(kButtonDown);
1878 DoNewSelection();
1879 }
1880 return;
1881 }
1882 if (!(fRadioSideA->GetState() == kButtonDown || fRadioSideC->GetState() == kButtonDown)) return;
1883
1884 // Int_t px = gPad->GetEventX();
1885 // Int_t py = gPad->GetEventY();
1886 Float_t upy = gPad->AbsPixeltoY(y);
1887 Float_t upx = gPad->AbsPixeltoX(x);
1888 Float_t gy = gPad->PadtoY(upy);
1889 Float_t gx = gPad->PadtoX(upx);
1890 Int_t quadrant = -1;
1891 if (gx >= 0 && gy >= 0) quadrant = 1;
1892 if (gx < 0 && gy >= 0) quadrant = 2;
1893 if (gx < 0 && gy < 0) quadrant = 3;
1894 if (gx >= 0 && gy < 0) quadrant = 4;
1895 gx = TMath::Abs(gx);
1896 gy = TMath::Abs(gy);
1897 Double_t phi = TMath::ATan(gy/gx); // angle phi is in Pi- units
1898 Double_t r = TMath::Sqrt(gx*gx + gy*gy);
1899 if (quadrant == 2) phi = pi - phi;
1900 if (quadrant == 3) phi = pi + phi;
1901 if (quadrant == 4) phi = 2 * pi - phi;
1902 Double_t phiGrad = phi / pi * 180;
1903 Int_t sector = (Int_t) phiGrad / 20; // one sector coresponds to 20°
1904 // IROC starts at 84.5 cm
1905 // IROC ends at 135.5 cm, OROC begins
1906 // OROC ends at 250 cm
1907 if (r < 84.5 || r > 250) return; // outside TPC
1908 if (r < 135.5) { // IROC
1909 if (fRadioSideC->GetState() == kButtonDown) sector += 18;
1910 }
1911 else {// OROC
1912 sector += 36;
1913 if (fRadioSideC->GetState() == kButtonDown) sector += 18;
1914 }
1915 // printf("r: %f, phi: %f, phiGrad: %f, gy/gx: %f, quadrant: %i, sector: %i \n", r, phi, phiGrad, gy/gx, quadrant, sector);
1916 fNmbSector->SetNumber(sector);
1917 fRadioSector->Clicked();
1918 fRadioSector->SetState(kButtonDown);
1919 ChangeSector();
1920}
1921
1922
4f3934a1 1923void AliTPCCalibViewerGUI::SavePicture() {
1924 //
1925 // saves the current picture
1926 //
1927 // use the following combination of file type and save options:
1928 // (see also TCanvas::Print)
1929 //
1930 // "ps" - Postscript file is produced (see special cases below)
1931 // "Portrait" - Postscript file is produced (Portrait)
1932 // "Landscape" - Postscript file is produced (Landscape)
1933 // "eps" - an Encapsulated Postscript file is produced
1934 // "Preview" - an Encapsulated Postscript file with preview is produced.
1935 // "pdf" - a PDF file is produced
1936 // "svg" - a SVG file is produced
1937 // "gif" - a GIF file is produced
1938 // "gif+NN" - an animated GIF file is produced, where NN is delay in 10ms units
1939 // "xpm" - a XPM file is produced
1940 // "png" - a PNG file is produced
1941 // "jpg" - a JPEG file is produced
1942 // "tiff" - a TIFF file is produced
1943 // "cxx" - a C++ macro file is produced
1944 // "xml" - a XML file
1945 // "root" - a ROOT binary file
1946
4f3934a1 1947 const char *kSaveAsTypes[] = {
1948 "Postscript", "*.ps",
1949 "Encapsulated Postscript", "*.eps",
1950 "PDF", "*.pdf",
1951 "JPEG", "*.jpg",
1952 "PNG", "*.png",
1953 "TIFF", "*.tiff",
1954 "GIF", "*.gif",
1955 "XPM", "*.xpm",
1956 "SVG", "*.svg",
1957 "XML", "*.xml",
1958 "C++ macro", "*.cxx",
1959 "Macro file", "*.C",
1960 "ROOT file", "*.root",
1961 "All file", "*",
1962 0, 0
1963 };
1964 TString addSaveOpt("");
1965 if (fChkAddSaveOpt->GetState() == kButtonDown)
1966 addSaveOpt += fComboAddSaveOpt->GetTextEntry()->GetText();
1967 TString dir(".");
1968 TGFileInfo fi;
1969 fi.fFileTypes = kSaveAsTypes;
1970 // fi.fIniDir = StrDup(dir);
1971 fi.fOverwrite = kFALSE;
1972 new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
1973 if (fi.fFilename && strlen(fi.fFilename)) {
832bb12c 1974 if (addSaveOpt != "")
1975 fCanvMain->GetCanvas()->Print(fi.fFilename, addSaveOpt.Data());
1976 else
1977 fCanvMain->GetCanvas()->Print(fi.fFilename);
4f3934a1 1978 }
1979
1980// TList* fFileNamesList list of selected file names
1981// Int_t fFileTypeIdx selected file type, index in fFileTypes
1982// const char** fFileTypes file types used to filter selectable files
1983// char* fFilename selected file name
1984// char* fIniDir on input: initial directory, on output: new directory
1985// Bool_t fMultipleSelection if true, allow multiple file selection
1986// Bool_t fOverwrite if true overwrite the file with existing name on save
1987
1988}
a6d2bd0c 1989
1990
832bb12c 1991TObjArray* AliTPCCalibViewerGUI::ShowGUI(const char* fileName) {
a6d2bd0c 1992 //
832bb12c 1993 // Initialize and show GUI for presentation for demonstration purposes
1994 // or for fast standalone use
a6d2bd0c 1995 //
1996 TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
1997 frmMain->SetWindowName("AliTPCCalibViewer GUI");
1998 frmMain->SetCleanup(kDeepCleanup);
1999
2000 TGTab* tabMain = new TGTab(frmMain, 1000, 600);
2001 frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
2002
2003 TGCompositeFrame* tabCont1 = tabMain->AddTab("Viewer 1");
2004 TGCompositeFrame* tabCont2 = tabMain->AddTab("Viewer 2");
2005
2006 AliTPCCalibViewerGUI* calibViewer1 = new AliTPCCalibViewerGUI(tabCont1, 1000, 600, (char*)fileName);
2007 tabCont1->AddFrame(calibViewer1, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
2008
2009 AliTPCCalibViewerGUI* calibViewer2 = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, (char*)fileName);
2010 tabCont2->AddFrame(calibViewer2, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
2011
832bb12c 2012 TObjArray *guiArray = new TObjArray();
2013 guiArray->Add(calibViewer1);
2014 guiArray->Add(calibViewer2);
2015
a6d2bd0c 2016 frmMain->MapSubwindows();
2017 frmMain->Resize();
2018 frmMain->MapWindow();
832bb12c 2019
2020 return guiArray;
a6d2bd0c 2021}
2022