LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCCalibViewerGUI.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1384 0.1 %
Date: 2016-06-14 17:26:59 Functions: 1 40 2.5 %

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

Generated by: LCOV version 1.11