]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliBaseCalibViewerGUI.cxx
As part of the efforts of the combined PID subgroup we are continuing to develop...
[u/mrichter/AliRoot.git] / STEER / AliBaseCalibViewerGUI.cxx
1 ///////////////////////////////////////////////////////////////////////////////
2 //                                                                           //
3 //  Base class for the AliTPCCalibViewer and AliTRDCalibViewer               //
4 //  used for the calibration monitor                                         //
5 //                                                                           //
6 //  Authors:     Marian Ivanov (Marian.Ivanov@cern.ch)                       //
7 //               Jens Wiechula (Jens.Wiechula@cern.ch)                       //
8 //               Ionut Arsene  (iarsene@cern.ch)                             //
9 //                                                                           //
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #include <TCanvas.h>
13 #include <TPad.h>
14 #include <TVirtualPad.h>
15 #include <TROOT.h>
16 #include <TObjArray.h>
17 #include <TObjString.h>
18 #include <TVector.h>
19 #include <string.h>
20 #include <TH1.h>
21 #include <TStyle.h>
22 #include <TGFileDialog.h>
23 #include <TGInputDialog.h>
24 #include <TGWidget.h>
25 #include <TGFrame.h>
26 #include <TGButton.h>
27 #include <TGListBox.h>
28 #include <TGComboBox.h>
29 #include <TGNumberEntry.h>
30 #include <TRootEmbeddedCanvas.h>
31 #include <TGSplitter.h>
32 #include <TGButtonGroup.h>
33 #include <TGLabel.h>
34 #include <TGTab.h>
35 #include <TString.h>
36
37 #include "AliBaseCalibViewerGUI.h"
38
39 ClassImp(AliBaseCalibViewerGUI)
40
41 //________________________________________________________________________________________
42 AliBaseCalibViewerGUI::AliBaseCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h)
43   : TGCompositeFrame(p, w, h),
44     fViewer(0),
45     fContTopBottom(0),
46     fContLCR(0),
47     fContLeft(0),
48     ftabLeft(0),
49     ftabLeft0(0),
50     ftabLeft1(0),
51     ftabRight(0),
52     fTabRight0(0),
53     fTabRight1(0),
54     fContRight(0),
55     fContCenter(0),
56     fContPlotOpt(0),
57     fContDrawOpt(0),
58     fContDrawOptSub1D2D(0),
59     fContNormalized(0),
60     fContCustom(0),
61     fContCuts(0),
62     fContAddCuts(0),
63     fContFit(0),
64     fContAddFit(0),
65     fContScaling(0),
66     fContSetMax(0),
67     fContSetMin(0),
68     fContAddDrawOpt(0),
69     fListVariables(0),
70     fBtnDraw(0),
71     fBtnFit(0),
72     fBtnAddFitFunction(0),
73     fBtnGetMinMax(0),
74     fCanvMain(0),
75     fRadioRaw(0),
76     fRadioNormalized(0),
77     fRadioPredefined(0),
78     fRadioCustom(0),
79     fRadio1D(0),
80     fRadio2D(0),
81     fComboAddDrawOpt(0),
82     fChkAuto(0),
83     fChkAutoAppend(0),
84     fComboMethod(0),
85     fListNormalization(0),
86     fComboCustom(0),
87     fLblCustomDraw(0),
88     fChkAddDrawOpt(0),
89     fLblAddCuts(0),
90     fComboAddCuts(0), 
91     fComboCustomFit(0),
92     fChkSetMax(0),
93     fChkSetMin(0),
94     fChkGetMinMaxAuto(0),
95     fTxtSetMax(0),
96     fTxtSetMin(0) ,
97     fContDrawOpt1D(0), 
98     fcontDrawOpt1DSubLR(0),
99     fContDrawOpt1DSubNSC(0), 
100     fRadioNorm(0),
101     fRadioSigma(0),
102     fTxtSigmas(0),
103     fContCumuLR(0),
104     fContCumLeft(0),
105     fContCumRight(0),
106     fLblSigmaMax(0),
107     fTxtSigmaMax(0),
108     fRadioCumulative(0),
109     fCheckCumulativePM(0),
110     fRadioIntegrate(0),
111     fContDrawOpt1DSubMML(0),
112     fChkMean(0),
113     fChkMedian(0),
114     fChkLTM(0),
115     fContStatOpt(0),
116     fChkStatName(0),
117     fChkStatEntries(0),
118     fContStatMean(0),
119     fChkStatMean(0),
120     fChkStatMeanPM(0),
121     fContStatRMS(0),
122     fChkStatRMS(0),
123     fChkStatRMSPM(0),
124     fChkStatUnderflow(0),
125     fChkStatOverflow(0),
126     fChkStatIntegral(0),
127     fContStatSkew(0),
128     fChkStatSkewness(0),
129     fChkStatSkewnessPM(0),
130     fContStatKurt(0),
131     fChkStatKurtosis(0),
132     fChkStatKurtosisPM(0),
133     fBtnUnchekAll(0),
134     fContLabeling(0),
135     fChkLabelTitle(0),
136     fTxtLabelTitle(0),
137     fChkLabelXaxis(0),
138     fTxtLabelXaxis(0),
139     fChkLabelYaxis(0),
140     fTxtLabelYaxis(0),
141     fChkLabelGetAuto(0),
142     fContSave(0),
143     fBtnSave(0),
144     fContAddSaveOpt(0),
145     fChkAddSaveOpt(0),
146     fComboAddSaveOpt(0),
147     fContExport(0),
148     fContAddExport(0),
149     fComboExportName(0),
150     fBtnExport(0),
151     fBtnAddNorm(0), 
152     fContTree(0),
153     fBtnDumpToFile(0),
154     fBtnLoadTree(0),
155     fChkAddAsReference(0),
156     fTxtRefName(0), 
157     fInitialized(0)
158 {
159    //
160    // AliBaseCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing 
161    //
162 }
163
164 //________________________________________________________________________________________
165 void AliBaseCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) {
166    // 
167    // draw the GUI
168    // 
169    // ======================================================================   
170    // ************************* Display everything *************************
171    // ======================================================================
172    
173    SetCleanup(kDeepCleanup);
174    p = p; // to avoid compiler warnings
175
176    // *****************************************************************************
177    // ************************* content of this MainFrame *************************
178    // *****************************************************************************
179    // top level container with horizontal layout
180    fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
181    AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
182    
183    fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
184    fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
185    
186    // ***********************************************************************
187    // ************************* content of fContLCR *************************
188    // ***********************************************************************
189    // left container
190    fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
191    fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
192    
193    // left vertical splitter
194    TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
195    splitLeft->SetFrame(fContLeft, kTRUE);
196    fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
197
198    // right container
199    fContRight = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
200    fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
201    
202    // center container
203    fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
204    fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
205
206    // right vertical splitter
207    TGVSplitter *splitRight = new TGVSplitter(fContLCR);
208    splitRight->SetFrame(fContRight, kFALSE);
209    fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
210    
211    
212    // ========================================================================
213    // ************************* content of fContLeft *************************
214    // ========================================================================
215    // --- draw button and tabLeft ---
216    // draw button
217    fBtnDraw = new TGTextButton(fContLeft, "&Draw");
218    fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
219    //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
220    fBtnDraw->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoDraw()");
221    fBtnDraw->SetToolTipText("Press here to draw according to selections.");
222    
223    // tabs on the left side:
224    ftabLeft = new TGTab(fContLeft);
225    fContLeft->AddFrame(ftabLeft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
226    ftabLeft0 = ftabLeft->AddTab("General");
227    ftabLeft1 = ftabLeft->AddTab("More plot options");
228
229    
230       // **************************** content of tabLeft0 *******************************
231       
232       // draw options container *** fcontDrawOpt ***  " Plot options "
233       fContDrawOpt = new TGGroupFrame(ftabLeft0, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
234       ftabLeft0->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
235       fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
236       fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
237       
238          // ------------------------- content of fContDrawOpt -------------------------
239          // -- radio1D, radio2D, chkAuto
240          // 1D radio button
241          fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30);
242          fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
243          fRadio1D->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
244          fRadio1D->SetToolTipText("1D drawing \nSelect this if you want to have the full control for the custom draw.");
245          
246          // 2D radio button
247          fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31);
248          fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
249          fRadio2D->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
250          fRadio2D->SetToolTipText("2D drawing");
251          
252          // additional draw options container
253          fContAddDrawOpt = new TGCompositeFrame(fContDrawOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
254          fContDrawOpt->AddFrame(fContAddDrawOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
255
256             //  content of --- fContAddDrawOpt ---
257             // addition draw options label
258             fChkAddDrawOpt = new TGCheckButton(fContAddDrawOpt, "Draw options:");
259             //fChkAddDrawOpt->SetTextJustify(kTextLeft);
260             fContAddDrawOpt->AddFrame(fChkAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
261             fChkAddDrawOpt->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
262             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).");
263             
264             // additional draw options combo box
265             fComboAddDrawOpt = new TGComboBox(fContAddDrawOpt);
266             fComboAddDrawOpt->Resize(0, fBtnDraw->GetDefaultHeight());
267             fComboAddDrawOpt->EnableTextInput(kTRUE);
268             fContAddDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
269             fComboAddDrawOpt->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
270             fComboAddDrawOpt->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
271                   
272          // automatic redraw check button
273          fChkAuto = new TGCheckButton(fContDrawOpt, "Auto redraw");
274          fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
275          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'.");
276          
277          // automatic append ending check button
278          fChkAutoAppend = new TGCheckButton(fContDrawOpt, "Auto add appending");
279          fContDrawOpt->AddFrame(fChkAutoAppend, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
280          fChkAutoAppend->SetToolTipText("Tries to repair your custom draw string or custom cut string, if you forgot '~' or '.fElements' \nThis function may be buggy!");
281                
282       
283       // *** predefined radio button ***  " Predefined "
284       fRadioPredefined = new TGRadioButton(ftabLeft0, "Predefined: ", 13);
285       ftabLeft0->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
286       fRadioPredefined->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
287       fRadioPredefined->SetToolTipText("Draw predefined variables according to selection.");
288       
289       // list of variables
290       fListVariables = new TGListBox(ftabLeft0);
291       ftabLeft0->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
292       fListVariables->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
293    
294       
295       // normalization options container *** fContPlotOpt ***
296       //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
297       fContPlotOpt = new TGGroupFrame(ftabLeft0, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight);
298       ftabLeft0->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
299
300          // ------------------------- content of fContPlotOpt -------------------------
301          // raw radio button
302          fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
303          fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
304          fRadioRaw->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
305          fRadioRaw->SetToolTipText("Plot without normalization");
306       
307          // normalized radio button
308          fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
309          fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
310          fRadioNormalized->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
311          fRadioNormalized->SetToolTipText("Normalize data");
312       
313          // normalized options container *** fContNormalized ***
314          fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
315          fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
316       
317             // --- content of fContNormalized ---
318             // --- combo box to select 'subtract' or 'divide', list of normalization variables
319             // method drop down combo box
320             fComboMethod = new TGComboBox(fContNormalized);
321             fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
322             fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
323             fComboMethod->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
324          
325             // list of normalization variables
326             fListNormalization = new TGListBox(fContNormalized);
327             fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
328             fListNormalization->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
329
330       // custom radio button
331       fRadioCustom = new TGRadioButton(ftabLeft0, "Custom: ", 12);
332       ftabLeft0->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
333       fRadioCustom->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
334       fRadioCustom->SetToolTipText("Draw data according to user specific text entry in the 'Custom Draw' line. Remember '~' (= '.fElements')!");
335       // custom options container is located further down
336       
337       // **************************** content of tabLeft1 *******************************
338       
339       // draw options container *** fcontDrawOpt1D ***  " Plot options "
340       fContDrawOpt1D = new TGGroupFrame(ftabLeft1, "1D Plot options", kVerticalFrame | kFitWidth | kFitHeight);
341       ftabLeft1->AddFrame(fContDrawOpt1D, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
342       
343       fcontDrawOpt1DSubLR = new TGCompositeFrame(fContDrawOpt1D, 1, 1, kVerticalFrame | kFitWidth | kFitHeight);
344       fContDrawOpt1D->AddFrame(fcontDrawOpt1DSubLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
345       
346          // ***** content of fContDrawOpt1DSubLR *****
347          fContDrawOpt1DSubNSC = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
348          fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubNSC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
349          
350             // --------------------------- content of fContDrawOpt1DSubNSC -----------------
351             fRadioNorm = new TGRadioButton(fContDrawOpt1DSubNSC, "Normal", 110);
352             fContDrawOpt1DSubNSC->AddFrame(fRadioNorm, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
353             fRadioNorm->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
354             fRadioNorm->SetToolTipText("Produce a normal 1D plot, a histogram of the selected data.");
355                
356             fRadioSigma = new TGRadioButton(fContDrawOpt1DSubNSC, "Sigma", 111);
357             fContDrawOpt1DSubNSC->AddFrame(fRadioSigma, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
358             fRadioSigma->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
359             fRadioSigma->SetToolTipText("Draw a normal histogram, but also lines that indicate the mean/median/LTM \nand sigmas of the selected data.");
360
361             fTxtSigmas = new TGTextEntry(fContDrawOpt1DSubNSC, "2; 4; 6", 111);
362             fContDrawOpt1DSubNSC->AddFrame(fTxtSigmas, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
363             fTxtSigmas->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtons1D(=111)");
364             fTxtSigmas->SetToolTipText("Enter sigma intervals you would like to be indicated by lines. \nExample: '2; 4; 6'");
365                
366             fContCumuLR = new TGCompositeFrame(fContDrawOpt1DSubNSC, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
367             fContDrawOpt1DSubNSC->AddFrame(fContCumuLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
368             
369                fContCumLeft = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
370                fContCumuLR->AddFrame(fContCumLeft, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
371                            
372                   fRadioCumulative = new TGRadioButton(fContCumLeft, "Cumulative", 112);
373                   fContCumLeft->AddFrame(fRadioCumulative, new TGLayoutHints(kLHintsNormal, 0, 10, 0, 0));
374                   fRadioCumulative->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
375                   fRadioCumulative->SetToolTipText("Draw the cumulative (SigmaCut) of the given selection. \nThe data distribution is integrated, starting from the mean/median/LTM.");
376                   
377                   fCheckCumulativePM = new TGCheckButton(fContCumLeft, "Plus/Minus");
378                   fContCumLeft->AddFrame(fCheckCumulativePM, new TGLayoutHints(kLHintsNormal, 10, 15, 0, 0));
379                   fCheckCumulativePM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
380                   fCheckCumulativePM->SetToolTipText("Decide whether you want the cumulative integration for each direction (+/-) \nor only for the absolute distance to the mean/median/LTM value.");
381                   
382                   fRadioIntegrate = new TGRadioButton(fContCumLeft, "Integrate", 113);
383                   fContCumLeft->AddFrame(fRadioIntegrate, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
384                   fRadioIntegrate->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
385                   fRadioIntegrate->SetToolTipText("Draw the integral of the given selection.");
386                   
387                fContCumRight = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
388                fContCumuLR->AddFrame(fContCumRight, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
389                
390                   fLblSigmaMax = new TGLabel(fContCumRight, "SigmaMax:");
391                   fLblSigmaMax->SetTextJustify(kTextLeft);
392                   fContCumRight->AddFrame(fLblSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0));
393
394                   fTxtSigmaMax = new TGTextEntry(fContCumRight, "5", 112);
395                   fContCumRight->AddFrame(fTxtSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
396                   fTxtSigmaMax->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtons1D(=112)");
397                   fTxtSigmaMax->SetToolTipText("Enter up to which multiple of sigma you want to integrate.");
398              
399             
400          fContDrawOpt1DSubMML = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
401          fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubMML, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
402          
403             // -------------- content of fcontDrawOpt1DSubLR
404             fChkMean = new TGCheckButton(fContDrawOpt1DSubMML, "Mean");
405             fContDrawOpt1DSubMML->AddFrame(fChkMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
406             fChkMean->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
407             fChkMean->SetToolTipText("Activate Mean for Sigma/Cumulative/Integrate");
408
409             fChkMedian = new TGCheckButton(fContDrawOpt1DSubMML, "Median");
410             fContDrawOpt1DSubMML->AddFrame(fChkMedian, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
411             fChkMedian->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
412             fChkMedian->SetToolTipText("Activate Median for Sigma/Cumulative/Integrate");
413
414             fChkLTM = new TGCheckButton(fContDrawOpt1DSubMML, "LTM");
415             fContDrawOpt1DSubMML->AddFrame(fChkLTM, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
416             fChkLTM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
417             fChkLTM->SetToolTipText("Activate LTM for Sigma/Cumulative/Integrate");
418             
419       
420       // statistic options container *** fcontStatOpt1D ***  " Statistic options "      
421       fContStatOpt = new TGGroupFrame(ftabLeft1, "Statistic options", kVerticalFrame | kFitWidth | kFitHeight);
422       ftabLeft1->AddFrame(fContStatOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
423       
424          fChkStatName = new TGCheckButton(fContStatOpt, "Name");
425          fContStatOpt->AddFrame(fChkStatName, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
426          fChkStatName->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
427          fChkStatName->SetToolTipText("Display the name in the statistics legend.");
428       
429          fChkStatEntries = new TGCheckButton(fContStatOpt, "Entries");
430          fContStatOpt->AddFrame(fChkStatEntries, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
431          fChkStatEntries->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
432          fChkStatEntries->SetToolTipText("Display the number of entries in the statistics legend.");
433       
434          fContStatMean = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
435          fContStatOpt->AddFrame(fContStatMean, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
436       
437             fChkStatMean = new TGCheckButton(fContStatMean, "Mean");
438             fContStatMean->AddFrame(fChkStatMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
439             fChkStatMean->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
440             fChkStatMean->SetToolTipText("Display the mean value of the data in the statistics legend.");
441             
442             fChkStatMeanPM = new TGCheckButton(fContStatMean, "+- Error");
443             fContStatMean->AddFrame(fChkStatMeanPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
444             fChkStatMeanPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
445             fChkStatMeanPM->SetToolTipText("Display the mean value's error in the statistics legend.");
446
447          fContStatRMS = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
448          fContStatOpt->AddFrame(fContStatRMS, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
449       
450             fChkStatRMS = new TGCheckButton(fContStatRMS, "RMS");
451             fContStatRMS->AddFrame(fChkStatRMS, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
452             fChkStatRMS->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
453             fChkStatRMS->SetToolTipText("Display the RMS value of the data in the statistics legend.");
454             
455             fChkStatRMSPM = new TGCheckButton(fContStatRMS, "+- Error");
456             fContStatRMS->AddFrame(fChkStatRMSPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
457             fChkStatRMSPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
458             fChkStatRMSPM->SetToolTipText("Display the RMS value's error in the statistics legend.");
459
460          fChkStatUnderflow = new TGCheckButton(fContStatOpt, "Underflow");
461          fContStatOpt->AddFrame(fChkStatUnderflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
462          fChkStatUnderflow->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
463          fChkStatUnderflow->SetToolTipText("Display the number of entries in the underflow bin.");
464       
465          fChkStatOverflow = new TGCheckButton(fContStatOpt, "Overflow");
466          fContStatOpt->AddFrame(fChkStatOverflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
467          fChkStatOverflow->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
468          fChkStatOverflow->SetToolTipText("Display the number of entries in the overflow bin.");
469       
470          fChkStatIntegral = new TGCheckButton(fContStatOpt, "Integral");
471          fContStatOpt->AddFrame(fChkStatIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
472          fChkStatIntegral->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
473          fChkStatIntegral->SetToolTipText("Display the integral of the data in the statistics legend.");
474       
475          fContStatSkew = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
476          fContStatOpt->AddFrame(fContStatSkew, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
477       
478             fChkStatSkewness = new TGCheckButton(fContStatSkew, "Skewness");
479             fContStatSkew->AddFrame(fChkStatSkewness, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
480             fChkStatSkewness->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
481             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!");
482             
483             fChkStatSkewnessPM = new TGCheckButton(fContStatSkew, "+- Error");
484             fContStatSkew->AddFrame(fChkStatSkewnessPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
485             fChkStatSkewnessPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
486             fChkStatSkewnessPM->SetToolTipText("Display the skewness' error in the statistics legend.");
487
488          fContStatKurt = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
489          fContStatOpt->AddFrame(fContStatKurt, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
490       
491             fChkStatKurtosis = new TGCheckButton(fContStatKurt, "Kurtosis");
492             fContStatKurt->AddFrame(fChkStatKurtosis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
493             fChkStatKurtosis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
494             fChkStatKurtosis->SetToolTipText("Display the kurtosis of the data in the statistics legend.");
495             
496             fChkStatKurtosisPM = new TGCheckButton(fContStatKurt, "+- Error");
497             fContStatKurt->AddFrame(fChkStatKurtosisPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
498             fChkStatKurtosisPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
499             fChkStatKurtosisPM->SetToolTipText("Display the kurtosis' error in the statistics legend.");
500        
501       fBtnUnchekAll = new TGTextButton(fContStatOpt, "&Uncheck all");
502       fContStatOpt->AddFrame(fBtnUnchekAll, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
503       fBtnUnchekAll->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "UnchekAllStat()");
504       fBtnUnchekAll->SetToolTipText("Disable all statistics legend entries, \nno statistics legend.");
505
506       
507       // custom options container
508       // --- fComboCustom --- the custom draw line on the very low
509       fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
510       fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
511    
512          // ------------------------- content of fContCustom -------------------------
513          fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
514          fLblCustomDraw->SetTextJustify(kTextLeft);
515          fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
516          // text field for custom draw command
517          fComboCustom = new TGComboBox(fContCustom);
518          fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight());
519          fComboCustom->EnableTextInput(kTRUE);
520          fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
521          fComboCustom->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral(=42)");
522          fComboCustom->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
523       
524    
525       // additional cuts container
526       fContAddCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
527       fContTopBottom->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
528       
529          // ------------------------- content of fContAddCuts -------------------------
530          fLblAddCuts = new TGLabel(fContAddCuts, "Custom cuts:  ");
531          fLblAddCuts->SetTextJustify(kTextLeft);
532          fContAddCuts->AddFrame(fLblAddCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
533          // combo text field for additional cuts
534          fComboAddCuts = new TGComboBox(fContAddCuts);
535          fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight());
536          fComboAddCuts->EnableTextInput(kTRUE);
537          fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
538          fComboAddCuts->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
539          
540    // ==========================================================================
541    // ************************* content of fContCenter *************************
542    // ========================================================================
543    // main drawing canvas
544    fCanvMain = new TRootEmbeddedCanvas("Main_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
545    fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
546    
547    fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliBaseCalibViewerGUI", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
548      
549    fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
550    fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
551    
552    
553    // =========================================================================   
554    // ************************* content of fContRight *************************
555    // ========================================================================
556    
557    // tabs on the right side:
558    ftabRight = new TGTab(fContRight);
559    fContRight->AddFrame(ftabRight, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
560    fTabRight0 = ftabRight->AddTab("Basic");
561    fTabRight1 = ftabRight->AddTab("Advanced");
562
563    
564       // **************************** content of tabLeft0 *******************************
565       // cut options container
566  
567       fContCuts = new TGGroupFrame(fTabRight0, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
568       fTabRight0->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
569   
570       // Scaling options container
571       fContScaling = new TGGroupFrame(fTabRight0, "Scaling", kVerticalFrame | kFitWidth | kFitHeight);
572       fTabRight0->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
573    
574          // ************************* content of fContScaling *************************
575          // SetMaximum container
576          fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
577          fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
578          
579             // ------------------------- content of fContSetMax -------------------------
580             // SetMaximum - checkbox
581             fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max.");
582             fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
583             fChkSetMax->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
584             fChkSetMax->SetToolTipText("Set the maximum fixed to the value specified here.");
585             
586             // text field for maximum value
587             fTxtSetMax = new TGTextEntry(fContSetMax, "", 41);
588             fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
589             fTxtSetMax->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
590             fTxtSetMax->SetToolTipText("maximum value for the drawing");
591       
592          // SetMinimum container
593          fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
594          fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
595          
596             // ------------------------- content of fContSetMin -------------------------
597             // SetMinimum - checkbox
598             fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min.");
599             fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
600             fChkSetMin->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
601             fChkSetMin->SetToolTipText("Set the minimum fixed to the value specified here.");
602             
603             // text field for minimum value
604             fTxtSetMin = new TGTextEntry(fContSetMin, "", 40);
605             fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
606             fTxtSetMin->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
607             fTxtSetMin->SetToolTipText("minimum value for the drawing");
608          
609          // get Min & Max from Plot - button
610          fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot");
611          fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
612          fBtnGetMinMax->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "GetMinMax()");
613          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'.");
614          
615          // GetMinMaxAuto - checkbox
616          fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto.");
617          fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
618          fChkGetMinMaxAuto->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
619          fChkGetMinMaxAuto->SetToolTipText("Get minimum and maximum automatically from each new plot. \nDeactivate this, if you want to 'save' your specified minimum and maximum.");
620          
621       // labeling container *** fContLabeling ***  " Labeling "      
622          fContLabeling = new TGGroupFrame(fTabRight0, "Labeling", kVerticalFrame | kFitWidth | kFitHeight);
623          fTabRight0->AddFrame(fContLabeling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
624          
625             fChkLabelTitle = new TGCheckButton(fContLabeling, "Set title:");
626             fContLabeling->AddFrame(fChkLabelTitle, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
627             fChkLabelTitle->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
628             fChkLabelTitle->SetToolTipText("Set the plot title.");
629                
630             fTxtLabelTitle = new TGTextEntry(fContLabeling, "Title", 500);
631             fContLabeling->AddFrame(fTxtLabelTitle, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
632             fTxtLabelTitle->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=50)");
633             fTxtLabelTitle->SetToolTipText("plot title");
634    
635             fChkLabelXaxis = new TGCheckButton(fContLabeling, "Set X-axis label:");
636             fContLabeling->AddFrame(fChkLabelXaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
637             fChkLabelXaxis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
638             fChkLabelXaxis->SetToolTipText("Set the X-axis label.");
639                
640             fTxtLabelXaxis = new TGTextEntry(fContLabeling, "XaxisLabel", 500);
641             fContLabeling->AddFrame(fTxtLabelXaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
642             fTxtLabelXaxis->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=51)");
643             fTxtLabelXaxis->SetToolTipText("X-axis label");
644    
645             fChkLabelYaxis = new TGCheckButton(fContLabeling, "Set Y-axis label:");
646             fContLabeling->AddFrame(fChkLabelYaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
647             fChkLabelYaxis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
648             fChkLabelYaxis->SetToolTipText("Set the Y-axis label.");
649                
650             fTxtLabelYaxis = new TGTextEntry(fContLabeling, "YaxisLabel", 500);
651             fContLabeling->AddFrame(fTxtLabelYaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
652             fTxtLabelYaxis->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=52)");
653             fTxtLabelYaxis->SetToolTipText("Y-axis label");
654    
655             fChkLabelGetAuto = new TGCheckButton(fContLabeling, "Get labels auto.");
656             fContLabeling->AddFrame(fChkLabelGetAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
657             fChkLabelGetAuto->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
658             fChkLabelGetAuto->SetToolTipText("Get labels automatically from each new plot \nDeactivate this, if you want to 'save' your specified labels.");
659
660       
661       // **************************** content of ftabRight1 *******************************
662       // Save container
663       fContSave = new TGGroupFrame(fTabRight1, "Save", kVerticalFrame | kFitWidth | kFitHeight);
664       fTabRight1->AddFrame(fContSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
665          // save button
666          fBtnSave = new TGTextButton(fContSave, "&Save picture");
667          fContSave->AddFrame(fBtnSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
668          fBtnSave->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "SavePicture()");
669          fBtnSave->SetToolTipText("Open a 'Save as...' dialog to save the current plot as picture or macro.");
670
671          // additional save options container
672          fContAddSaveOpt = new TGCompositeFrame(fContSave, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
673          fContSave->AddFrame(fContAddSaveOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
674    
675             //  content of --- fContAddSaveOpt ---
676             // addition save options label
677             fChkAddSaveOpt = new TGCheckButton(fContAddSaveOpt, "Save options:");
678             fContAddSaveOpt->AddFrame(fChkAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
679             fChkAddSaveOpt->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
680             fChkAddSaveOpt->SetToolTipText("Additional save options (see documentation for TPad::Print()).");
681             
682             // additional save options combo box
683             fComboAddSaveOpt = new TGComboBox(fContAddSaveOpt);
684             fContAddSaveOpt->AddFrame(fComboAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
685             fComboAddSaveOpt->Resize(0, fBtnDraw->GetDefaultHeight());
686             fComboAddSaveOpt->EnableTextInput(kTRUE);
687             fComboAddSaveOpt->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "SavePicture()");
688             
689       // calPad export container            
690       fContExport = new TGGroupFrame(fTabRight1, "Export AliTPCCalPad", kVerticalFrame | kFitWidth | kFitHeight);
691       fTabRight1->AddFrame(fContExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
692          // ------------------------- content of fContExport -------------------------
693          // container for export name
694             
695          fContAddExport = new TGCompositeFrame(fContExport, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
696          fContExport->AddFrame(fContAddExport, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
697          
698          fComboExportName = new TGComboBox(fContAddExport);
699          fComboExportName->Resize(0, fBtnDraw->GetDefaultHeight());
700          fContAddExport->AddFrame(fComboExportName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
701          fComboExportName->AddEntry("calPad",  0);  // first default value
702          fComboExportName->Select(0);               // select default value before connecting
703          fComboExportName->EnableTextInput(kTRUE);
704            
705          // export button
706          fBtnExport = new TGTextButton(fContExport, "&Export to CINT");
707          fContExport->AddFrame(fBtnExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
708          fBtnExport->SetToolTipText("Lifeless button :(");
709       
710          // add to normalisation button
711          fBtnAddNorm = new TGTextButton(fContExport, "&Add to normalization");
712          fContExport->AddFrame(fBtnAddNorm, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
713          fBtnAddNorm->SetToolTipText("Lifeless button :(");
714  
715       // Tree container
716       fContTree = new TGGroupFrame(fTabRight1, "Tree", kVerticalFrame | kFitWidth | kFitHeight);
717       fTabRight1->AddFrame(fContTree, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
718             
719          // dump tree to file button
720          fBtnDumpToFile = new TGTextButton(fContTree, "&Dump to File");
721          fContTree->AddFrame(fBtnDumpToFile, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
722          fBtnDumpToFile->SetToolTipText("Lifeless button :(");
723          
724          // dump tree to file button
725          fBtnLoadTree = new TGTextButton(fContTree, "&Load Tree");
726          fContTree->AddFrame(fBtnLoadTree, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
727          fBtnLoadTree->SetToolTipText("Lifeless button :(");
728
729          fChkAddAsReference = new TGCheckButton(fContTree, "as reference:");
730          fContTree->AddFrame(fChkAddAsReference, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
731          fChkAddAsReference->SetToolTipText("Lifeless button :(");            
732
733          fTxtRefName = new TGTextEntry(fContTree, "R", 500);
734          fContTree->AddFrame(fTxtRefName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 15, 0, 0, 0));
735          fTxtRefName->SetToolTipText("Reference Name");
736                         
737       // Fit options container
738       fContFit = new TGGroupFrame(fTabRight1, "Custom fit", kVerticalFrame | kFitWidth | kFitHeight);
739       fTabRight1->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
740         
741          // ------------------------- content of fContFit -------------------------
742          // container for additional fits
743          fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
744          fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
745       
746             // --- content of fContAddFit ---
747             // text field for custom fit
748             fComboCustomFit = new TGComboBox(fContAddFit);
749             fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight());
750             fComboCustomFit->EnableTextInput(kTRUE);
751             fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
752                      
753          // fit button
754          fBtnFit = new TGTextButton(fContAddFit, "&Fit");
755          fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
756          fBtnFit->SetToolTipText("Lifeless button :(");
757 }
758
759 //________________________________________________________________________________________
760 AliBaseCalibViewerGUI::AliBaseCalibViewerGUI(const AliBaseCalibViewerGUI &c)
761    : TGCompositeFrame(c.fParent, c.fWidth, c.fHeight),
762     fViewer(0),
763     fContTopBottom(0),
764     fContLCR(0),
765     fContLeft(0),
766     ftabLeft(0),
767     ftabLeft0(0),
768     ftabLeft1(0),
769     ftabRight(0),
770     fTabRight0(0),
771     fTabRight1(0),
772     fContRight(0),
773     fContCenter(0),
774     fContPlotOpt(0),
775     fContDrawOpt(0),
776     fContDrawOptSub1D2D(0),
777     fContNormalized(0),
778     fContCustom(0),
779     fContCuts(0),
780     fContAddCuts(0),
781     fContFit(0),
782     fContAddFit(0),
783     fContScaling(0),
784     fContSetMax(0),
785     fContSetMin(0),
786     fContAddDrawOpt(0),
787     fListVariables(0),
788     fBtnDraw(0),
789     fBtnFit(0),
790     fBtnAddFitFunction(0),
791     fBtnGetMinMax(0),
792     fCanvMain(0),
793     fRadioRaw(0),
794     fRadioNormalized(0),
795     fRadioPredefined(0),
796     fRadioCustom(0),
797     fRadio1D(0),
798     fRadio2D(0),
799     fComboAddDrawOpt(0),
800     fChkAuto(0),
801     fChkAutoAppend(0),
802     fComboMethod(0),
803     fListNormalization(0),
804     fComboCustom(0),
805     fLblCustomDraw(0),
806     fChkAddDrawOpt(0),
807     fLblAddCuts(0),
808     fComboAddCuts(0), 
809     fComboCustomFit(0),
810     fChkSetMax(0),
811     fChkSetMin(0),
812     fChkGetMinMaxAuto(0),
813     fTxtSetMax(0),
814     fTxtSetMin(0), 
815     fContDrawOpt1D(0),
816     fcontDrawOpt1DSubLR(0),
817     fContDrawOpt1DSubNSC(0), 
818     fRadioNorm(0),
819     fRadioSigma(0),
820     fTxtSigmas(0),
821     fContCumuLR(0),
822     fContCumLeft(0),
823     fContCumRight(0),
824     fLblSigmaMax(0),
825     fTxtSigmaMax(0),
826     fRadioCumulative(0),
827     fCheckCumulativePM(0),
828     fRadioIntegrate(0),
829     fContDrawOpt1DSubMML(0),
830     fChkMean(0),
831     fChkMedian(0),
832     fChkLTM(0), 
833     fContStatOpt(0),
834     fChkStatName(0),
835     fChkStatEntries(0),
836     fContStatMean(0),
837     fChkStatMean(0),
838     fChkStatMeanPM(0),
839     fContStatRMS(0),
840     fChkStatRMS(0),
841     fChkStatRMSPM(0),
842     fChkStatUnderflow(0),
843     fChkStatOverflow(0),
844     fChkStatIntegral(0),
845     fContStatSkew(0),
846     fChkStatSkewness(0),
847     fChkStatSkewnessPM(0),
848     fContStatKurt(0),
849     fChkStatKurtosis(0),
850     fChkStatKurtosisPM(0),
851     fBtnUnchekAll(0),
852     fContLabeling(0),
853     fChkLabelTitle(0),
854     fTxtLabelTitle(0),
855     fChkLabelXaxis(0),
856     fTxtLabelXaxis(0),
857     fChkLabelYaxis(0),
858     fTxtLabelYaxis(0),
859     fChkLabelGetAuto(0),
860     fContSave(0),
861     fBtnSave(0),
862     fContAddSaveOpt(0),
863     fChkAddSaveOpt(0),
864     fComboAddSaveOpt(0),
865     fContExport(0),
866     fContAddExport(0),
867     fComboExportName(0),
868     fBtnExport(0),
869     fBtnAddNorm(0), 
870     fContTree(0),
871     fBtnDumpToFile(0),
872     fBtnLoadTree(0),
873     fChkAddAsReference(0),
874     fTxtRefName(0),
875     fInitialized(0)
876 {
877   //
878   // dummy AliBaseCalibViewerGUI copy constructor
879   //
880 }
881
882 //________________________________________________________________________________________
883 AliBaseCalibViewerGUI & AliBaseCalibViewerGUI::operator =(const AliBaseCalibViewerGUI & /*param*/) {
884    //
885    // dummy assignment operator
886    //
887    return (*this);
888 }
889
890 //________________________________________________________________________________________
891 AliBaseCalibViewerGUI::~AliBaseCalibViewerGUI() {
892    // 
893    // Destructor
894    // 
895   /*
896    if (fCanvMain && fCanvMain->GetCanvas()) {
897       for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
898          if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
899             fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
900       }
901    } 
902 */
903    //   Cleanup();
904 }
905
906 //________________________________________________________________________________________
907 void AliBaseCalibViewerGUI::SetInitialValues() {
908    // 
909    // Set the default button states
910    // 
911    fChkAuto->SetState(kButtonUp);
912    fRadioPredefined->SetState(kButtonDown);
913    fRadioRaw->SetState(kButtonDown);
914    fRadio1D->SetState(kButtonDown);
915    fChkGetMinMaxAuto->SetState(kButtonDown);
916    fChkSetMin->SetState(kButtonUp);
917    fChkSetMax->SetState(kButtonUp);
918    fRadioNorm->SetState(kButtonDown);
919    fRadioSigma->SetState(kButtonUp);
920    fRadioCumulative->SetState(kButtonUp);
921    fChkMean->SetState(kButtonDown);
922    fCheckCumulativePM->SetState(kButtonUp);
923    
924    fChkLabelGetAuto->SetState(kButtonDown);
925
926    Int_t statOpt = gStyle->GetOptStat();
927    if (statOpt == 1) statOpt = 1111;
928    if (statOpt / 200000000 >= 1) {
929       fChkStatKurtosis->SetState(kButtonDown);
930       fChkStatKurtosisPM->SetState(kButtonDown);
931       statOpt -= 200000000;
932    }
933    if (statOpt / 100000000 >= 1) {
934       fChkStatKurtosis->SetState(kButtonDown);
935       statOpt -= 100000000;
936    }
937    if (statOpt / 20000000 >= 1) {
938       fChkStatSkewness->SetState(kButtonDown);
939       fChkStatSkewnessPM->SetState(kButtonDown);
940       statOpt -= 20000000;
941    }
942    if (statOpt / 10000000 >= 1) {
943       fChkStatSkewness->SetState(kButtonDown);
944       statOpt -= 10000000;
945    }
946    if (statOpt / 1000000 >= 1) {
947       fChkStatIntegral->SetState(kButtonDown);
948       statOpt -= 1000000;
949    }
950    if (statOpt / 100000 >= 1) {
951       fChkStatOverflow->SetState(kButtonDown);
952       statOpt -= 100000;
953    }
954    if (statOpt / 10000 >= 1) {
955       fChkStatUnderflow->SetState(kButtonDown);
956       statOpt -= 10000;
957    }
958    if (statOpt / 2000 >= 1) {
959       fChkStatRMS->SetState(kButtonDown);
960       fChkStatRMSPM->SetState(kButtonDown);
961       statOpt -= 2000;
962    }
963    if (statOpt / 1000 >= 1) {
964       fChkStatRMS->SetState(kButtonDown);
965       statOpt -= 1000;
966    }
967    if (statOpt / 200 >= 1) {
968       fChkStatMean->SetState(kButtonDown);
969       fChkStatMeanPM->SetState(kButtonDown);
970       statOpt -= 200;
971    }
972    if (statOpt / 100 >= 1) {
973       fChkStatMean->SetState(kButtonDown);
974       statOpt -= 100;
975    }
976    if (statOpt / 10 >= 1) {
977       fChkStatEntries->SetState(kButtonDown);
978       statOpt -= 10;
979    }
980    if (statOpt / 1 >= 1) {
981       fChkStatName->SetState(kButtonDown);
982       statOpt -= 1;
983    }
984       
985    // fill fComboAddDrawOpt with some additional drawing options
986    fComboAddDrawOpt->AddEntry("same",      0);
987    fComboAddDrawOpt->AddEntry("profbox",   1);
988    fComboAddDrawOpt->AddEntry("profcolz",  2);
989    fComboAddDrawOpt->AddEntry("profcont0", 3);
990    fComboAddDrawOpt->AddEntry("proflego",  4);
991    fComboAddDrawOpt->AddEntry("proflego2", 5);
992    fComboAddDrawOpt->AddEntry("profsurf",  6);
993    fComboAddDrawOpt->AddEntry("profsurf1", 7);
994    fComboAddDrawOpt->AddEntry("profsurf2", 8);
995    fComboAddDrawOpt->AddEntry("box",    9);
996    fComboAddDrawOpt->AddEntry("colz",  10);
997    fComboAddDrawOpt->AddEntry("cont0", 11);
998    fComboAddDrawOpt->AddEntry("lego",  12);
999    fComboAddDrawOpt->AddEntry("lego2", 13);
1000    fComboAddDrawOpt->AddEntry("surf",  14);
1001    fComboAddDrawOpt->AddEntry("surf1", 15);
1002    fComboAddDrawOpt->AddEntry("surf2", 16);
1003
1004    // fill fComboAddSaveOpt with some additional drawing options
1005    fComboAddSaveOpt->AddEntry("Portrait",  0);
1006    fComboAddSaveOpt->AddEntry("Landscape", 1);
1007    fComboAddSaveOpt->AddEntry("Preview",   2);
1008    fComboAddSaveOpt->AddEntry("+50",       3);
1009
1010    // fill fComboMethod
1011    fComboMethod->AddEntry("subtract",  0);
1012    fComboMethod->AddEntry("divide by", 1);
1013    
1014    // fill fComboExportName
1015    fBtnExport->SetEnabled(kFALSE);
1016    fBtnAddNorm->SetEnabled(kFALSE);
1017
1018    // select initial variables
1019    fListVariables->Select(0);
1020    fListNormalization->Select(0);
1021    fComboMethod->Select(0);
1022
1023    fListVariables->IntegralHeight(kFALSE);         // naja
1024    fListNormalization->IntegralHeight(kFALSE);     // naja
1025    fChkAuto->SetState(kButtonDown);
1026 }
1027
1028 //________________________________________________________________________________________
1029 void AliBaseCalibViewerGUI::HandleButtonsGeneral(Int_t id) {
1030    //
1031    // handles mutual radio button exclusions
1032    // for general Tab
1033    //
1034    if (id == -1) {
1035       TGButton *btn = (TGButton *) gTQSender;
1036       id = btn->WidgetId();
1037    }
1038
1039    switch (id) {
1040       case 10:             // fRadioRaw
1041          fRadioNormalized->SetState(kButtonUp);
1042          fRadioPredefined->SetState(kButtonDown);
1043          fRadioCustom->SetState(kButtonUp);
1044          break;
1045       case 11:             // fRadioNormalized
1046          fRadioRaw->SetState(kButtonUp);
1047          fRadioPredefined->SetState(kButtonDown);
1048          fRadioCustom->SetState(kButtonUp);
1049          break;
1050       case 12:             // fRadioCustom
1051          fRadioPredefined->SetState(kButtonUp);
1052          break;
1053       case 14:             // select Draw options fComboAddDrawOpt
1054          fChkAddDrawOpt->SetState(kButtonDown);
1055          break;
1056       case 13:             // fRadioPredefined
1057          fRadioCustom->SetState(kButtonUp);
1058          break;
1059       //--------
1060       case 30:             // fRadio1D
1061          fRadio2D->SetState(kButtonUp);
1062          fBtnExport->SetEnabled(kFALSE);
1063          fBtnAddNorm->SetEnabled(kFALSE);
1064          break;
1065       case 31:             // fRadio2D
1066          fRadio1D->SetState(kButtonUp);
1067          fBtnExport->SetEnabled(kTRUE);
1068          fBtnAddNorm->SetEnabled(kTRUE);
1069          break;
1070       case 42:             // fComboCustom
1071          fRadioCustom->SetState(kButtonDown);
1072          fRadioPredefined->SetState(kButtonUp);
1073          break;
1074    }
1075    DoNewSelection();
1076 }
1077
1078 //________________________________________________________________________________________
1079 void AliBaseCalibViewerGUI::HandleButtons1D(Int_t id) {
1080    //
1081    // handles mutual radio button exclusions
1082    // 1D-Tab buttons
1083    //
1084    
1085    if (id == -1) {
1086       TGButton *btn = (TGButton *) gTQSender;
1087       id = btn->WidgetId();
1088    }
1089    switch (id) {
1090       case 110:            // 1D draw normal
1091          fRadioNorm->SetState(kButtonDown);
1092          fRadioSigma->SetState(kButtonUp);
1093          fRadioCumulative->SetState(kButtonUp);
1094          fRadioIntegrate->SetState(kButtonUp);
1095          break;
1096       case 111:            // 1D draw sigma
1097          fRadioNorm->SetState(kButtonUp);
1098          fRadioSigma->SetState(kButtonDown);
1099          fRadioCumulative->SetState(kButtonUp);
1100          fRadioIntegrate->SetState(kButtonUp);
1101          break;
1102       case 112:            // 1D draw cumulative
1103          fRadioNorm->SetState(kButtonUp);
1104          fRadioSigma->SetState(kButtonUp);
1105          fRadioCumulative->SetState(kButtonDown);
1106          fRadioIntegrate->SetState(kButtonUp);
1107          break;
1108       case 113:            // 1D draw integral
1109          fRadioNorm->SetState(kButtonUp);
1110          fRadioSigma->SetState(kButtonUp);
1111          fRadioCumulative->SetState(kButtonUp);
1112          fRadioIntegrate->SetState(kButtonDown);
1113          break;
1114    }
1115    DoNewSelection();
1116 }
1117
1118 //________________________________________________________________________________________
1119 void AliBaseCalibViewerGUI::HandleButtonsStat(Int_t id) {
1120    // 
1121    // handles statistic check boxes 
1122    // checks each checkbox if checked
1123    // if the checkbox is checked, appends 'n' for name, 'e' for entries, ...
1124    // to a TString, passes this TString to gStyle->SetOptStat(...)
1125    // 
1126    if (id == -1) {
1127       TGButton *btn = (TGButton *) gTQSender;
1128       id = btn->WidgetId();
1129    }
1130    TString statOpt("");
1131    if (fChkStatName->GetState() == kButtonDown) statOpt.Append("n");
1132    if (fChkStatEntries->GetState() == kButtonDown) statOpt.Append("e");
1133    if (fChkStatMean->GetState() == kButtonDown && fChkStatMeanPM->GetState() == kButtonUp) statOpt.Append("m");
1134    if (fChkStatMeanPM->GetState() == kButtonDown) statOpt.Append("M");
1135    if (fChkStatRMS->GetState() == kButtonDown && fChkStatRMSPM->GetState() == kButtonUp) statOpt.Append("r");
1136    if (fChkStatRMSPM->GetState() == kButtonDown) statOpt.Append("R");
1137    if (fChkStatUnderflow->GetState() == kButtonDown) statOpt.Append("u");
1138    if (fChkStatOverflow->GetState() == kButtonDown) statOpt.Append("o");
1139    if (fChkStatIntegral->GetState() == kButtonDown) statOpt.Append("i");
1140    if (fChkStatSkewness->GetState() == kButtonDown && fChkStatSkewnessPM->GetState() == kButtonUp) statOpt.Append("s");
1141    if (fChkStatSkewnessPM->GetState() == kButtonDown) statOpt.Append("S");
1142    if (fChkStatKurtosis->GetState() == kButtonDown && fChkStatKurtosisPM->GetState() == kButtonUp) statOpt.Append("k");
1143    if (fChkStatKurtosisPM->GetState() == kButtonDown) statOpt.Append("K");
1144    
1145    gStyle->SetOptStat(statOpt);
1146    DoNewSelection();
1147 }
1148
1149 //________________________________________________________________________________________
1150 void AliBaseCalibViewerGUI::HandleButtonsNoRedraw(Int_t id) {
1151    //
1152    // handles label & scaling checkboxes 
1153    // without redrawing (not necessary, faster like this)
1154    //
1155     if (id == -1) {
1156       TGButton *btn = (TGButton *) gTQSender;
1157       id = btn->WidgetId();
1158    }
1159
1160    switch (id) {
1161       case 40:             // fTxtSetMin
1162          fChkSetMin->SetState(kButtonDown);
1163          break;
1164       case 41:             // fTxtSetMax
1165          fChkSetMax->SetState(kButtonDown);
1166          break;
1167       case 50:             // fTxtLabelTitle
1168          fChkLabelTitle->SetState(kButtonDown);
1169          break;
1170       case 51:             // fTxtLabelXaxis
1171          fChkLabelXaxis->SetState(kButtonDown);
1172          break;
1173       case 52:             // fTxtLabelXaxis
1174          fChkLabelYaxis->SetState(kButtonDown);
1175          break;
1176    }
1177    SetMinMaxLabel();
1178 }
1179
1180 //________________________________________________________________________________________
1181 void AliBaseCalibViewerGUI::ReplacePlaceHolders(TString &str)
1182 {
1183     //
1184     // replace the defined placeholders in the custom draw string and cut string
1185     //
1186     TString drawPlaceHolder("#draw#");
1187     TString normPlaceHolder("#norm#");
1188
1189     //current draw variable
1190     TString desiredData("");
1191     if (fListVariables->GetSelectedEntry()){
1192       desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
1193       str.ReplaceAll(drawPlaceHolder,desiredData);
1194     }
1195
1196     //current normalisation
1197     TString normalizationData("");
1198     if (fListNormalization->GetSelectedEntry()){
1199       normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
1200       if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
1201         if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData;
1202       if ( fListVariables->FindEntry(normalizationData.Data()) )
1203         normalizationData+="~";
1204       str.ReplaceAll(normPlaceHolder,normalizationData);
1205     }
1206 }
1207
1208 //________________________________________________________________________________________
1209 void AliBaseCalibViewerGUI::DoNewSelection() {
1210    //
1211    // decides whether to redraw if user makes another selection
1212    //
1213    if (fChkAuto->GetState() == kButtonDown) DoDraw();
1214 }
1215
1216 //________________________________________________________________________________________
1217 void AliBaseCalibViewerGUI::SavePicture() {
1218    // 
1219    // saves the current picture
1220    // 
1221    // use the following combination of file type and save options:
1222    // (see also TCanvas::Print)
1223    // 
1224    //       "ps"  - Postscript file is produced (see special cases below)
1225    //    "Portrait" - Postscript file is produced (Portrait)
1226    // "Landscape" - Postscript file is produced (Landscape)
1227    //       "eps" - an Encapsulated Postscript file is produced
1228    //    "Preview" - an Encapsulated Postscript file with preview is produced.
1229    //       "pdf" - a PDF file is produced
1230    //       "svg" - a SVG file is produced
1231    //       "gif" - a GIF file is produced
1232    //       "gif+NN" - an animated GIF file is produced, where NN is delay in 10ms units
1233    //       "xpm" - a XPM file is produced
1234    //       "png" - a PNG file is produced
1235    //       "jpg" - a JPEG file is produced
1236    //       "tiff" - a TIFF file is produced
1237    //       "cxx" - a C++ macro file is produced
1238    //       "xml" - a XML file
1239    //       "root" - a ROOT binary file
1240    
1241    const char *kSaveAsTypes[] = {
1242       "Postscript",  "*.ps",
1243       "Encapsulated Postscript",   "*.eps",
1244       "PDF",   "*.pdf",
1245       "JPEG",   "*.jpg",
1246       "PNG",   "*.png",
1247       "TIFF",   "*.tiff",
1248       "GIF",   "*.gif",
1249       "XPM",   "*.xpm",
1250       "SVG",   "*.svg",
1251       "XML",   "*.xml",
1252       "C++ macro",   "*.cxx",
1253       "Macro file",  "*.C",
1254       "ROOT file",   "*.root",
1255       "All file",    "*",
1256        0,              0
1257    };
1258    TString addSaveOpt("");
1259    if (fChkAddSaveOpt->GetState() == kButtonDown)
1260    addSaveOpt += fComboAddSaveOpt->GetTextEntry()->GetText();
1261    TString dir(".");
1262    TGFileInfo fi;
1263    fi.fFileTypes = kSaveAsTypes;
1264    fi.fOverwrite = kFALSE;
1265    new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
1266    if (fi.fFilename && strlen(fi.fFilename)) {
1267       if (addSaveOpt != "")
1268          fCanvMain->GetCanvas()->Print(fi.fFilename, addSaveOpt.Data());
1269       else 
1270          fCanvMain->GetCanvas()->Print(fi.fFilename);
1271    }
1272 }
1273
1274 //________________________________________________________________________________________
1275 void AliBaseCalibViewerGUI::GetMinMax() {
1276    //
1277    // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
1278    //
1279    if (fChkGetMinMaxAuto->GetState() == kButtonUp) return;
1280    TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
1281    TObject* ptr = 0;
1282    for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
1283       ptr = listOfPrimitives->At(i);
1284       if ( ptr->InheritsFrom("TH1") ) break;
1285    }
1286    if ( !ptr || !ptr->InheritsFrom("TH1") ) return;      // if the loop did not find a TH1
1287    TH1 *hist = (TH1*)ptr;
1288
1289    if (fRadio2D->GetState() == kButtonDown) {
1290       if (fChkSetMax->GetState() == kButtonUp)
1291          fTxtSetMax->SetText(Form("%f", hist->GetMaximum()));
1292       if (fChkSetMin->GetState() == kButtonUp)
1293          fTxtSetMin->SetText(Form("%f", hist->GetMinimum()));
1294    }
1295    else if (fRadio1D->GetState() == kButtonDown) {
1296       if (fChkSetMax->GetState() == kButtonUp)
1297          fTxtSetMax->SetText( Form("%f", hist->GetXaxis()->GetXmax()) );
1298       if (fChkSetMin->GetState() == kButtonUp)
1299          fTxtSetMin->SetText( Form("%f", hist->GetXaxis()->GetXmin()) );
1300    }
1301 }
1302
1303 //________________________________________________________________________________________
1304 void AliBaseCalibViewerGUI::SetMinMaxLabel() {
1305    // 
1306    // Set Minimum, Maximum and labels without redrawing the plot
1307    // (faster)
1308    // 
1309    
1310    // search for histogram
1311    TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
1312    TObject* ptr = 0;
1313    for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
1314       ptr = listOfPrimitives->At(i);
1315       if ( ptr->InheritsFrom("TH1") ) break;
1316    }
1317    if ( ptr == 0 || !ptr->InheritsFrom("TH1") ) {  // if the loop did not find a TH1
1318       fCanvMain->GetCanvas()->Update();
1319       Warning("SetMinMaxLabel","No Histogram found!");
1320       return;
1321       // unable to find histogram, no min and max wil be read out
1322    }
1323    
1324    TH1 *hist = (TH1*)ptr; 
1325    TString minTxt(fTxtSetMin->GetText());
1326    TString maxTxt(fTxtSetMax->GetText());
1327    
1328    // set min and max according to specified values, if checkbox is checked
1329    if (fRadio2D->GetState() == kButtonDown) {
1330       if (fChkSetMax->GetState() == kButtonDown && fChkSetMax->GetState() == kButtonDown &&(maxTxt.IsDigit() || maxTxt.IsFloat()) )
1331          hist->SetMaximum(maxTxt.Atof());
1332       if (fChkSetMax->GetState() == kButtonUp)
1333          hist->SetMaximum(-1111);  // default value, to unzoom
1334       if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) )
1335          hist->SetMinimum(minTxt.Atof());
1336       if (fChkSetMin->GetState() == kButtonUp)
1337          hist->SetMinimum(-1111);  // default value, to unzoom
1338    }
1339    else if (fRadio2D->GetState() == kButtonDown) {
1340       if (fChkSetMin->GetState() == kButtonDown && 
1341           fChkSetMax->GetState() == kButtonDown && hist->GetXaxis())
1342          hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetXmin(), hist->GetXaxis()->GetXmax());
1343       else if (fChkSetMax->GetState() == kButtonDown && hist->GetXaxis())
1344          hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetXmin(), maxTxt.Atof());
1345       else if (fChkSetMin->GetState() == kButtonDown && hist->GetXaxis())
1346          hist->GetXaxis()->SetRangeUser(minTxt.Atof(), hist->GetXaxis()->GetXmax());
1347       hist->SetTitle(hist->GetTitle());  // trick to update the histogram
1348    }
1349    
1350    // get min and max from plot       
1351    GetMinMax();
1352    
1353    // set labels according to specification, if cehckboxes are checked
1354    if (fChkLabelTitle->GetState() == kButtonDown) 
1355       hist->SetTitle(fTxtLabelTitle->GetText());
1356    if (fChkLabelXaxis->GetState() == kButtonDown)
1357       hist->GetXaxis()->SetTitle(fTxtLabelXaxis->GetText());
1358    if (fChkLabelYaxis->GetState() == kButtonDown)
1359       hist->GetYaxis()->SetTitle(fTxtLabelYaxis->GetText());
1360    // get and/or set labels and title
1361    if (fChkLabelGetAuto->GetState() == kButtonDown) {
1362       fTxtLabelTitle->SetText(hist->GetTitle());
1363       fTxtLabelXaxis->SetTitle(hist->GetXaxis()->GetTitle());
1364       fTxtLabelYaxis->SetTitle(hist->GetYaxis()->GetTitle());
1365    }
1366    hist->SetTitle(hist->GetTitle());  // trick to update the histogram
1367    fCanvMain->GetCanvas()->Update();
1368 }
1369
1370 //________________________________________________________________________________________
1371 void AliBaseCalibViewerGUI::UnchekAllStat() {
1372    // 
1373    // Disable all statistical legend entries, no statistical legend.
1374    // 
1375    fChkStatName->SetState(kButtonUp);
1376    fChkStatEntries->SetState(kButtonUp);
1377    fChkStatMean->SetState(kButtonUp);
1378    fChkStatMeanPM->SetState(kButtonUp);
1379    fChkStatRMS->SetState(kButtonUp);
1380    fChkStatRMSPM->SetState(kButtonUp);
1381    fChkStatUnderflow->SetState(kButtonUp);
1382    fChkStatOverflow->SetState(kButtonUp);
1383    fChkStatIntegral->SetState(kButtonUp);
1384    fChkStatSkewness->SetState(kButtonUp);
1385    fChkStatSkewnessPM->SetState(kButtonUp);
1386    fChkStatKurtosis->SetState(kButtonUp);
1387    fChkStatKurtosisPM->SetState(kButtonUp);
1388    
1389    HandleButtonsStat(0);
1390 }