LCOV - code coverage report
Current view: top level - TPC/TPCbase - AliTPCCalibViewerGUItime.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 2 892 0.2 %
Date: 2016-06-14 17:26:59 Functions: 2 51 3.9 %

          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 AliTPCCalibViewerGUItime
      18             : 
      19             : 
      20             : #include <iostream>
      21             : //Root includes
      22             : #include <TROOT.h>
      23             : #include <TDirectory.h>
      24             : #include <TStyle.h>
      25             : #include <TCanvas.h>
      26             : #include <TPad.h>
      27             : #include <TVirtualPad.h>
      28             : #include <TObject.h>
      29             : #include <TObjArray.h>
      30             : #include <TObjString.h>
      31             : #include <TSystem.h>
      32             : #include <TVector.h>
      33             : #include <TH1.h>
      34             : #include <TCut.h>
      35             : #include <TFile.h>
      36             : #include <TTree.h>
      37             : #include <TChain.h>
      38             : #include <TBranch.h>
      39             : #include <TIterator.h>
      40             : #include <TGraph.h>
      41             : #include <TAxis.h>
      42             : #include <TTimeStamp.h>
      43             : #include <TMath.h>
      44             : #include <TMap.h>
      45             : //
      46             : #include <TGFileDialog.h>
      47             : #include <TGInputDialog.h>
      48             : //
      49             : #include <TGButton.h>
      50             : #include <TGListBox.h>
      51             : #include <TGComboBox.h>
      52             : #include <TGNumberEntry.h>
      53             : #include <TGLayout.h>
      54             : #include <TRootEmbeddedCanvas.h>
      55             : #include <TGSplitter.h>
      56             : #include <TGButtonGroup.h>
      57             : #include <TGLabel.h>
      58             : #include <TGTab.h>
      59             : #include <TGString.h>
      60             : 
      61             : //AliRoot includes
      62             : #include <AliLog.h>
      63             : #include "AliTPCCalibViewerGUI.h"
      64             : #include "AliTPCCalibViewer.h"
      65             : #include "AliTPCcalibDB.h"
      66             : #include "AliTPCcalibDButil.h"
      67             : #include "AliTPCConfigParser.h"
      68             : 
      69             : #include "AliTPCCalibViewerGUItime.h"
      70             : 
      71          24 : ClassImp(AliTPCCalibViewerGUItime)
      72             : 
      73             : AliTPCCalibViewerGUItime::AliTPCCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h) :
      74           0 : TGCompositeFrame(p,w,h),
      75           0 :   fFile(0x0),
      76           0 :   fTree(0x0),
      77           0 :   fCalibViewerGUI(0x0),
      78           0 :   fCalibViewerGUItab(0x0),
      79           0 :   fCurrentHist(0x0),
      80           0 :   fCurrentGraph(0x0),
      81           0 :   fCurrentRunDetails(-1),
      82           0 :   fOutputCacheDir("/tmp"),
      83           0 :   fDrawString(""),
      84           0 :   fConfigFile(""),
      85           0 :   fConfigParser(new AliTPCConfigParser),
      86           0 :   fIsCustomDraw(kFALSE),
      87           0 :   fRunNumbers(10),
      88           0 :   fTimeStamps(10),
      89           0 :   fValuesX(10),
      90           0 :   fValuesY(10),
      91           0 :   fNoGraph(kFALSE),
      92           0 :   fGraphLimitEntries(10000),
      93           0 :   fMapRefTrees(new TMap),
      94             :   //GUI elements
      95             :   //main canvas Top part, bottom part
      96           0 :   fContTopBottom(0x0),
      97             :   //top left, centre, right
      98           0 :   fContLCR(0x0),
      99             :   //content left
     100           0 :   fContLeft(0x0),
     101           0 :   fContDrawOpt(0x0),
     102           0 :   fChkDrawOptSame(0x0),
     103           0 :   fChkDrawOptSparse(0x0),
     104           0 :   fComboAddDrawOpt(0x0),
     105           0 :   fContDrawSel(0x0),
     106           0 :   fContDrawSelSubRunTime(0x0),
     107           0 :   fRadioXhist(0x0),
     108           0 :   fRadioXrun(0x0),
     109           0 :   fRadioXtime(0x0),
     110           0 :   fListVariables(0x0),
     111           0 :   fComboRunType(0x0),
     112           0 :   fLblRunType(0x0),
     113           0 :   fNmbPar(0x0),
     114           0 :   fLblPar(0x0),
     115           0 :   fListCalibType(0x0),
     116           0 :   fContCalibType(0x0),
     117             :   //content centre
     118           0 :   fContCenter(0x0),
     119           0 :   fCanvMain(0x0),
     120             :   //content right
     121           0 :   fContRight(0x0),
     122           0 :   fContValues(0x0),
     123           0 :   fLblRunNumber(0x0),
     124           0 :   fLblRunTime(0x0),
     125           0 :   fLblValueX(0x0),
     126           0 :   fLblValueY(0x0),
     127           0 :   fLblRunNumberVal(0x0),
     128           0 :   fLblRunTimeVal(0x0),
     129           0 :   fLblValueXVal(0x0),
     130           0 :   fLblValueYVal(0x0),
     131           0 :   fBtnDumpRuns(0x0),
     132           0 :   fContAliases(0x0),
     133           0 :   fListAliases(0x0),
     134             :   //content bottom
     135           0 :   fContCustom(0x0),
     136           0 :   fContCustomCuts(0x0),
     137           0 :   fLblCustomDraw(0x0),
     138           0 :   fLblCustomCuts(0x0),
     139           0 :   fComboCustomDraw(0x0),
     140           0 :   fComboCustomCuts(0x0),
     141           0 :   fTrashBox(new TObjArray)
     142           0 : {
     143             :   //
     144             :   // ctor
     145             :   //
     146           0 :   fMapRefTrees->SetOwnerKeyValue();
     147           0 :   fTrashBox->SetOwner();
     148           0 :   DrawGUI(p,w,h);
     149           0 :   gStyle->SetMarkerStyle(20);
     150           0 :   gStyle->SetMarkerSize(0.5);
     151           0 :   SetInitialValues();
     152           0 : }
     153             : //______________________________________________________________________________
     154           0 : AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
     155             :   /// dtor
     156             : 
     157           0 :   delete fConfigParser;
     158           0 :   delete fTrashBox;
     159           0 :   delete fMapRefTrees;
     160           0 : }
     161             : //______________________________________________________________________________
     162             : void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
     163             :    /// draw the GUI
     164             :    ///
     165             :    /// ************************* Display everything *************************
     166             : 
     167           0 :   SetCleanup(kDeepCleanup);
     168             :   
     169             :    // *****************************************************************************
     170             :    // ************************* content of this MainFrame *************************
     171             :    // *****************************************************************************
     172             :    // top level container with horizontal layout
     173           0 :   fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
     174           0 :   AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     175             :   
     176           0 :   fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
     177           0 :   fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     178             :   
     179             :    // ***********************************************************************
     180             :    // ************************* content of fContLCR *************************
     181             :    // ***********************************************************************
     182             :    // left container
     183           0 :   fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
     184           0 :   fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
     185             :   
     186             :    // left vertical splitter
     187           0 :   TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
     188           0 :   splitLeft->SetFrame(fContLeft, kTRUE);
     189           0 :   fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
     190             :   
     191             :    // right container
     192           0 :   fContRight = new TGCompositeFrame(fContLCR, 150, 200, kVerticalFrame | kFixedWidth | kFitHeight);
     193           0 :   fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
     194             :   
     195             :    // center container
     196           0 :   fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
     197           0 :   fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     198             :   
     199             :    // right vertical splitter
     200           0 :   TGVSplitter *splitRight = new TGVSplitter(fContLCR);
     201           0 :   splitRight->SetFrame(fContRight, kFALSE);
     202           0 :   fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
     203             :   
     204             :   
     205             :    // ========================================================================
     206             :    // ************************* content of fContLeft *************************
     207             :    // ========================================================================
     208             :    // --- draw button and tabLeft ---
     209             :   // draw options
     210           0 :   fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
     211           0 :   fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     212             : 
     213           0 :   TGCompositeFrame *cfr = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
     214           0 :   fContDrawOpt->AddFrame(cfr, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
     215             :   
     216           0 :   fChkDrawOptSame = new TGCheckButton(cfr, "Same");
     217           0 :   cfr->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
     218           0 :   fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
     219             : 
     220           0 :   fChkDrawOptSparse = new TGCheckButton(cfr, "Sparse");
     221           0 :   cfr->AddFrame(fChkDrawOptSparse, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
     222           0 :   fChkDrawOptSparse->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
     223           0 :   fChkDrawOptSparse->SetToolTipText("In case of run trending only plot runs with information");
     224             :   
     225             :   // additional draw options combo box
     226           0 :   fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
     227           0 :   fComboAddDrawOpt->Resize(0, 22);
     228           0 :   fComboAddDrawOpt->EnableTextInput(kTRUE);
     229           0 :   fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     230             : //   fComboAddDrawOpt->Connect("ReturnPressed()", "AliTPCCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
     231             : //   fComboAddDrawOpt->Connect("Selected(Int_t)", "AliTPCCalibViewerGUI", this, "DoNewSelection()");
     232           0 :   fComboAddDrawOpt->GetTextEntry()->SetText("",kFALSE);
     233             :   
     234             :   // draw selection group
     235           0 :   fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
     236           0 :   fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
     237             :   //x-axis variables selection, Run of Time
     238           0 :   fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
     239           0 :   fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
     240             :   
     241             :   // ------------------------- content of fContDrawOpt -------------------------
     242             :   // 
     243             :   // Run radio button
     244             :     // Time radio button
     245           0 :   fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
     246           0 :   fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
     247           0 :   fRadioXhist->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
     248           0 :   fRadioXhist->SetToolTipText("Draw the distribution of the variable");
     249             :   
     250           0 :   fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
     251           0 :   fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
     252           0 :   fRadioXrun->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
     253           0 :   fRadioXrun->SetToolTipText("Use run number as x-value");
     254             :   
     255             :   // Time radio button
     256           0 :   fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
     257           0 :   fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
     258           0 :   fRadioXtime->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "HandleButtonsDrawSel()");
     259           0 :   fRadioXtime->SetToolTipText("Use time stamp number as x-value");
     260             :   
     261             :   
     262             :   // list of variables
     263           0 :   fListVariables = new TGListBox(fContDrawSel);
     264           0 :   fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     265           0 :   fListVariables->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelection()");
     266             : 
     267             :   
     268             : //-------------------- run type selection ------------------------
     269             :   // Parameter label
     270           0 :   fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
     271           0 :   fLblRunType->SetTextJustify(kTextLeft);
     272           0 :   fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     273             :   
     274           0 :   fComboRunType = new TGComboBox(fContDrawSel);
     275           0 :   fComboRunType->EnableTextInput(kFALSE);
     276           0 :   fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     277           0 :   fComboRunType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoDraw()");
     278             : //   fComboRunType->SetEnabled(kFALSE);
     279           0 :   fComboRunType->Resize(0, 22);
     280             :   
     281             :   //-------------------- parameter selection ------------------------
     282             :   // Parameter label
     283           0 :   fLblPar = new TGLabel(fContDrawSel, "Parameter:");
     284           0 :   fLblPar->SetTextJustify(kTextLeft);
     285           0 :   fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     286             :   
     287           0 :   fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
     288           0 :   fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     289           0 :   fNmbPar->Connect("ValueSet(Long_t)", "AliTPCCalibViewerGUItime", this, "DoParLimitChange()");
     290           0 :   fNmbPar->SetState(kFALSE);
     291             :   
     292             :   //-------------------- calibration type selection ------------------------
     293             :   // label
     294             :   // draw selection group
     295           0 :   fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
     296           0 :   fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
     297             :     
     298             :     // list of variables
     299           0 :   fListCalibType = new TGListBox(fContCalibType);
     300           0 :   fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
     301           0 :   fListCalibType->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoChangeSelectionList()");
     302           0 :   fListCalibType->Resize(0,88);
     303           0 :   fListCalibType->SetMultipleSelections();
     304             :   
     305             :   
     306             :      // ==========================================================================
     307             :    // ************************* content of fContCenter *************************
     308             :    // ========================================================================
     309             :    // main drawing canvas
     310           0 :   fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
     311           0 :   fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     312           0 :   fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliTPCCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
     313             : //   fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUItime", this, "GetMinMax()");
     314           0 :   fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
     315           0 :   fCanvMain->GetCanvas()->SetRightMargin(0.062);
     316           0 :   fCanvMain->GetCanvas()->SetLeftMargin(0.15);
     317             :   
     318             :    // =========================================================================
     319             :    // ************************* content of fContRight *************************
     320             :    // ========================================================================
     321             :   //group frame for value information
     322           0 :   fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
     323           0 :   fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     324             :   //set layout manager
     325           0 :   fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 5));
     326             :   //value information labels
     327             : 
     328             :   //run number label
     329           0 :   fLblRunNumber = new TGLabel(fContValues, "Run:");
     330           0 :   fLblRunNumber->SetTextJustify(kTextLeft);
     331           0 :   fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
     332             :   //run number
     333           0 :   fLblRunNumberVal = new TGLabel(fContValues, "000000");
     334           0 :   fLblRunNumberVal->SetTextJustify(kTextLeft);
     335           0 :   fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
     336             :   //time stamp label
     337           0 :   fLblRunTime = new TGLabel(fContValues, "Time:");
     338           0 :   fLblRunTime->SetTextJustify(kTextLeft);
     339           0 :   fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
     340             :   //run number
     341           0 :   fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
     342           0 :   fLblRunTimeVal->SetTextJustify(kTextLeft);
     343           0 :   fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
     344             :   //value label x
     345           0 :   fLblValueX = new TGLabel(fContValues, "x-Value:");
     346           0 :   fLblValueX->SetTextJustify(kTextLeft);
     347           0 :   fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
     348             :   //value x
     349           0 :   fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
     350           0 :   fLblValueXVal->SetTextJustify(kTextRight);
     351           0 :   fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     352             :   //value label y
     353           0 :   fLblValueY = new TGLabel(fContValues, "y-Value:");
     354           0 :   fLblValueY->SetTextJustify(kTextLeft);
     355           0 :   fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
     356             :   //value y
     357           0 :   fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
     358           0 :   fLblValueYVal->SetTextJustify(kTextRight);
     359           0 :   fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     360             :    // draw button
     361           0 :   fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
     362           0 :   fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     363           0 :   fBtnDumpRuns->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDumpRuns()");
     364           0 :   fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
     365             :   //group frame for value information
     366           0 :   fContAliases = new TGGroupFrame(fContRight, "Aliases", kVerticalFrame | kFitWidth | kFitHeight);
     367           0 :   fContRight->AddFrame(fContAliases, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
     368             :   // list of aliases
     369           0 :   fListAliases = new TGListBox(fContAliases);
     370           0 :   fContAliases->AddFrame(fListAliases, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
     371           0 :   fListAliases->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoNewSelectionAliases()");
     372             : //   fListAliases->Resize(0,88);
     373             :   //buttons
     374           0 :   TGCompositeFrame *frame1 = new TGCompositeFrame(fContAliases, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
     375           0 :   fContAliases->AddFrame(frame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
     376             :   // add button
     377           0 :   TGTextButton *btnAdd = new TGTextButton(frame1, "&Add");
     378           0 :   frame1->AddFrame(btnAdd, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     379           0 :   btnAdd->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoAddAlias()");
     380           0 :   btnAdd->SetToolTipText("Press to add an alias.");
     381           0 :   btnAdd->Resize(0,22);
     382             :   // del button
     383           0 :   TGTextButton *btnDel = new TGTextButton(frame1, "&Del");
     384           0 :   frame1->AddFrame(btnDel, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     385           0 :   btnDel->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "DoDelAlias()");
     386           0 :   btnDel->SetToolTipText("Press to delete the selected alias.");
     387           0 :   btnDel->Resize(0,22);
     388             :   // update button
     389           0 :   TGTextButton *btnUp = new TGTextButton(frame1, "&Upd");
     390           0 :   frame1->AddFrame(btnUp, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
     391           0 :   btnUp->Connect("Clicked()", "AliTPCCalibViewerGUItime", this, "UpdateAliasList()");
     392           0 :   btnUp->SetToolTipText("Press to update the alias list.");
     393           0 :   btnUp->Resize(0,22);
     394             :   
     395             : 
     396             :   
     397             :    // =========================================================================
     398             :    // ****************** bottom content of fContTopBottom *********************
     399             :    // =========================================================================
     400             :   
     401             :   // custom options container
     402             :   // --- fComboCustom --- the custom draw line on the very low
     403           0 :   fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
     404           0 :   fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
     405             :   
     406             :          // ------------------------- content of fContCustom -------------------------
     407           0 :   fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
     408           0 :   fLblCustomDraw->SetTextJustify(kTextLeft);
     409           0 :   fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
     410             :          // text field for custom draw command
     411           0 :   fComboCustomDraw = new TGComboBox(fContCustom);
     412             : //   fComboCustomDraw->Resize(0, fLblValueY->GetDefaultHeight());
     413           0 :   fComboCustomDraw->Resize(0, 22);
     414           0 :   fComboCustomDraw->EnableTextInput(kTRUE);
     415           0 :   fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     416           0 :   fComboCustomDraw->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
     417           0 :   fComboCustomDraw->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomDraw()");
     418           0 :   fComboCustomDraw->GetTextEntry()->SetText("",kFALSE);
     419             :   
     420             :       // additional cuts container
     421           0 :   fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
     422           0 :   fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
     423             :   
     424             :          // ------------------------- content of fContCustomCuts -------------------------
     425           0 :   fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts:  ");
     426           0 :   fLblCustomCuts->SetTextJustify(kTextLeft);
     427           0 :   fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
     428             :          // combo text field for additional cuts
     429           0 :   fComboCustomCuts = new TGComboBox(fContCustomCuts);
     430             : //   fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
     431           0 :   fComboCustomCuts->Resize(0, 22);
     432           0 :   fComboCustomCuts->EnableTextInput(kTRUE);
     433           0 :   fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
     434           0 :   fComboCustomCuts->Connect("ReturnPressed()", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
     435           0 :   fComboCustomCuts->Connect("Selected(Int_t)", "AliTPCCalibViewerGUItime", this, "DoCustomCutsDraw()");
     436           0 :   fComboCustomCuts->GetTextEntry()->SetText("",kFALSE);
     437             :   
     438           0 :   SetWindowName("AliTPCCalibViewer GUI - Time");
     439           0 :   MapSubwindows();
     440           0 :   Resize(GetDefaultSize());
     441           0 :   MapWindow();
     442           0 : }
     443             : //______________________________________________________________________________
     444             : void AliTPCCalibViewerGUItime::SetInitialValues(){
     445             :   /// Set inital selections of the gui
     446             : 
     447           0 :   fRadioXrun->SetState(kButtonDown);
     448           0 :   fRadioXtime->SetState(kButtonUp);
     449           0 : }
     450             : 
     451             : //______________________________________________________________________________
     452             : void AliTPCCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
     453             :   /// retrieve tree from file
     454             : 
     455             :   TObjArray *arr=0x0;
     456           0 :   TString file(fileName);
     457           0 :   if (file.Contains("://")) {
     458           0 :     if (file.Contains(";")) {
     459           0 :       arr=file.Tokenize(";");
     460           0 :     } else {
     461           0 :       arr=new TObjArray;
     462           0 :       arr->Add(new TObjString(fileName));
     463             :     }
     464             :   } else {
     465           0 :     TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
     466           0 :     arr=s.Tokenize("\n");
     467           0 :   }
     468             : 
     469           0 :   if (!arr) return;
     470           0 :   TIter next(arr);
     471             :   TObject *o=0;
     472           0 :   if (fTree) delete fTree;
     473           0 :   fTree=new TChain(treeName);
     474           0 :   while ( (o=next()) ){
     475           0 :     fTree->AddFile(o->GetName());
     476             :   }
     477           0 :   arr->SetOwner();
     478           0 :   delete arr;
     479           0 :   if (!CheckChain()) return;
     480           0 :   UseConfigFile(fConfigFile.Data());
     481           0 :   Reload();
     482             :   
     483           0 : }
     484             : //______________________________________________________________________________
     485             : void AliTPCCalibViewerGUItime::UseChain(TChain *const chain  = 0)
     486             : {
     487             :   ///
     488             : 
     489           0 :   fTree=chain;
     490           0 :   if (!CheckChain()) return;
     491             :   //set configuration file
     492           0 :   UseConfigFile(fConfigFile.Data());
     493           0 :   Reload();
     494           0 : }
     495             : //______________________________________________________________________________
     496             : Bool_t AliTPCCalibViewerGUItime::CheckChain()
     497             : {
     498             :   /// check whether cahin has entries
     499             :   /// decide whether to draw graphs in 2D
     500             : 
     501           0 :   if (!fTree) return kFALSE;
     502           0 :   fTree->Lookup();
     503           0 :   Long64_t entries=fTree->GetEntries();
     504           0 :   if (entries==0){
     505           0 :     AliError("No entries found in chain");
     506           0 :     return kFALSE;
     507             :   }
     508             :   //check whether to draw graphs
     509           0 :   CheckDrawGraph();
     510           0 :   return kTRUE;
     511           0 : }
     512             : //______________________________________________________________________________
     513             : void AliTPCCalibViewerGUItime::UseConfigFile(const char* file)
     514             : {
     515             :   /// Use 'file' as configuration file
     516             : 
     517           0 :   fConfigFile=file;
     518           0 :   fConfigParser->ParseConfigFileTxt(fConfigFile.Data());
     519           0 :   FillCalibTypes();
     520           0 : }
     521             : //______________________________________________________________________________
     522             : void AliTPCCalibViewerGUItime::FillRunTypes()
     523             : {
     524             :   /// Loop over the tree entries and fill the run types
     525             : 
     526           0 :   if (!fTree) return;
     527             :   Int_t id=0;
     528           0 :   fComboRunType->RemoveAll();
     529           0 :   fComboRunType->AddEntry("ALL",id++);
     530           0 :   fComboRunType->Select(0,kFALSE);
     531           0 :   if (!fTree->GetBranch("runType.")) return;
     532           0 :   TObjString *runType=0x0;
     533           0 :   Int_t nevets=fTree->GetEntries();
     534           0 :   fTree->SetBranchStatus("*",0);
     535           0 :   fTree->SetBranchStatus("runType.*",1);
     536           0 :   fTree->SetBranchAddress("runType.",&runType);
     537           0 :   for (Int_t iev=0;iev<nevets;++iev){
     538           0 :     fTree->GetEntry(iev);
     539           0 :     TString type=runType->String();
     540           0 :     if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
     541           0 :   }
     542           0 :   fTree->ResetBranchAddresses();
     543           0 :   fTree->SetBranchStatus("*",1);
     544           0 : }
     545             : //______________________________________________________________________________
     546             : void AliTPCCalibViewerGUItime::FillCalibTypes()
     547             : {
     548             :   /// loop over configuration and fill calibration types
     549             : 
     550             :   Int_t id=0;
     551           0 :   fListCalibType->RemoveAll();
     552             :   TObject *o=0x0;
     553           0 :   fConfigParser->ResetIter();
     554           0 :   TString type;
     555           0 :   while ( (o=fConfigParser->NextKey()) ){
     556           0 :     type=fConfigParser->GetData(o,kCalibType);
     557             :     //remove whitespcaces
     558           0 :     type.Remove(TString::kBoth,' ');
     559           0 :     type.Remove(TString::kBoth,'\t');
     560           0 :     if (type.IsNull()) type="UNSPECIFIED";
     561             : //     printf("CalibType: '%s'\n",type.Data());
     562           0 :     if (!fListCalibType->FindEntry(type.Data())) {
     563           0 :       fListCalibType->AddEntry(type.Data(),id);
     564           0 :       fListCalibType->Select(id++);
     565             :     }
     566             :   }
     567             :   //add type for unspecified calibration type
     568           0 :   type="UNSPECIFIED";
     569           0 :   if (!fListCalibType->FindEntry(type.Data())) {
     570           0 :     fListCalibType->AddEntry(type.Data(),id);
     571           0 :     fListCalibType->Select(id++);
     572             :   }
     573           0 : }
     574             : //______________________________________________________________________________
     575             : void AliTPCCalibViewerGUItime::CheckDrawGraph()
     576             : {
     577             :   /// Check whether to draw graphs in 2D mode based on the number of entries in the chain
     578             :   /// GetEstimate() returns the maximum size of the arrays stored in GetV1()...
     579             : 
     580           0 :   if (!fTree) return;
     581           0 :   fNoGraph=kTRUE;
     582           0 :   if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
     583           0 : }
     584             : //______________________________________________________________________________
     585             : void AliTPCCalibViewerGUItime::Reload(Int_t first)
     586             : {
     587             :   /// reload the gui contents, this is needed after the input tree has changed
     588             : 
     589           0 :   if ( !fTree ) return;
     590             :   //in case of the first call create run type and calibration type entries
     591           0 :   if (first){
     592           0 :     FillRunTypes();
     593           0 :     FillCalibTypes();
     594           0 :   }
     595             :   //activate all branches
     596           0 :   fTree->SetBranchStatus("*",1);
     597             :   //reset variables list
     598           0 :   fListVariables->RemoveAll();
     599             :   //get selected calibration types
     600           0 :   TList calibTypes;
     601           0 :   fListCalibType->GetSelectedEntries(&calibTypes);
     602             :   
     603           0 :   TObjArray *branchList = fTree->GetListOfBranches();
     604           0 :   if ( !branchList ) return;
     605           0 :   TIter nextBranch(branchList);
     606             :   Int_t idCount=0,id=0;
     607             :   TObject *objBranch=0;
     608           0 :   while ( (objBranch=nextBranch()) ){
     609           0 :     TString branchName(objBranch->GetName());
     610           0 :     TString branchTitle(objBranch->GetName());
     611           0 :     if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
     612             :     Bool_t active=kTRUE;
     613           0 :     TString calibType="UNSPECIFIED";
     614           0 :     if (fConfigParser){
     615           0 :       const TObject *key=(*fConfigParser)(branchName.Data());
     616           0 :       if (key){
     617             :         //test if branch is active
     618           0 :         active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
     619           0 :         id=(*fConfigParser)()->IndexOf(key);
     620             : //         branchTitle=fConfigParser->GetData(key,kBranchTitle);
     621           0 :         calibType=fConfigParser->GetData(key,kCalibType);
     622             :       }
     623             :       else{
     624           0 :         id=1000+idCount;
     625             :       }
     626           0 :     } else {
     627             :       id=idCount;
     628             :     }
     629           0 :     if (calibType.IsNull()) calibType="UNSPECIFIED";
     630             :     //check if branch is in selected calibration types
     631             :     //if not, don't show it in the list and deactivate the branch.
     632             :     Bool_t calibActive=kFALSE;
     633           0 :     TIter nextCalib(&calibTypes);
     634             :     TObject *objCalib=0;
     635           0 :     while ( (objCalib=nextCalib()) )
     636           0 :       if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
     637           0 :     active&=calibActive;
     638           0 :     if (!active){
     639           0 :       TString s=branchName;
     640           0 :       if (branchName.EndsWith(".")) s+="*";
     641             : //       fTree->SetBranchStatus(s.Data(),0);
     642             :       continue;
     643           0 :     }
     644             : //     fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
     645           0 :     fListVariables->AddEntry(branchTitle.Data(),id);
     646           0 :     ++idCount;
     647           0 :   }
     648             :   //trick to display modifications
     649           0 :   fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
     650           0 :   fListVariables->Resize(fListVariables->GetWidth()+1, fListVariables->GetHeight());
     651           0 : }
     652             : //______________________________________________________________________________
     653             : void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
     654             : {
     655             :   /// map of reference trees that should always be attached to the CalibViewerGUI
     656             : 
     657           0 :   fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
     658             : 
     659           0 : }
     660             : //______________________________________________________________________________
     661             : const TString AliTPCCalibViewerGUItime::GetDrawString(){
     662             :   /// create draw string for ttree by combining the user requestsa
     663             : 
     664           0 :   TString selectedVariable="";
     665             :   Int_t id=-1;
     666           0 :   if (!fListVariables->GetSelectedEntry()) return "";
     667           0 :   selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
     668           0 :   id=fListVariables->GetSelectedEntry()->EntryId();
     669             : //   printf("id: %d\n",id);
     670           0 :   TString branchName=selectedVariable;
     671           0 :   if (fConfigParser){
     672           0 :     const TObject *key=(*fConfigParser)(id);
     673           0 :     if (key) branchName=(*fConfigParser)(id)->GetName();
     674           0 :   }
     675             :   //treat case of TVector
     676           0 :   if (branchName.EndsWith(".")){
     677           0 :     Int_t par = (Int_t)(fNmbPar->GetNumber());
     678           0 :     branchName.Append(Form("fElements[%d]",par));
     679           0 :   }
     680             : //   if (fRadioXrun->GetState()==kButtonDown)
     681             : //     selectedVariable.Append(":run");
     682             : //   if (fRadioXtime->GetState()==kButtonDown)
     683             : //     selectedVariable.Append(":time");
     684             :   
     685           0 :   return branchName;
     686           0 : }
     687             : //______________________________________________________________________________
     688             : const TString AliTPCCalibViewerGUItime::GetDrawOptionString(){
     689             :   /// get user selected draw options
     690             : 
     691           0 :   TString drawOpt;
     692           0 :   if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
     693           0 :   if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
     694           0 :     drawOpt+="same";
     695             :   return drawOpt;
     696           0 : }
     697             : //______________________________________________________________________________
     698             : void AliTPCCalibViewerGUItime::GetCutString(TString &cutStr){
     699             :   /// create cut string
     700             : 
     701           0 :   TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
     702           0 :   TString runType="";
     703           0 :   if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
     704           0 :   if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
     705           0 :   cutStr=cuts.GetTitle();
     706           0 : }
     707             : //______________________________________________________________________________
     708             : void AliTPCCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph, const Double_t *xArr)
     709             : {
     710             :   ///
     711             : 
     712           0 :   if (!withGraph){
     713           0 :     fValuesX.ResizeTo(1);
     714           0 :     fValuesY.ResizeTo(1);
     715           0 :     fRunNumbers.ResizeTo(1);
     716           0 :     fTimeStamps.ResizeTo(1);
     717           0 :   } else {
     718           0 :     const Long64_t nrows=fTree->GetSelectedRows();
     719           0 :     fValuesX.ResizeTo(nrows);
     720           0 :     fValuesY.ResizeTo(nrows);
     721           0 :     fRunNumbers.ResizeTo(nrows);
     722           0 :     fTimeStamps.ResizeTo(nrows);
     723           0 :     long long *index=new long long[nrows];
     724             : 
     725             :     //sort data
     726             :     Int_t nTime0=0;
     727           0 :     for (Int_t i=0;i<fTree->GetSelectedRows();++i){
     728           0 :       if (fTree->GetV2()[i]<1) ++nTime0;
     729             :     }
     730             :     
     731           0 :     if (nTime0==fTree->GetSelectedRows()){
     732           0 :         TMath::Sort(nrows,fTree->GetV1(),index,kFALSE);
     733           0 :     } else {
     734           0 :       TMath::Sort(nrows,fTree->GetV2(),index,kFALSE);
     735             :     }
     736             : 
     737             :     Double_t lastRun=-1.;
     738             :     Int_t entries=0;
     739           0 :     const Bool_t drawSparse=(fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown);
     740           0 :     for (Long64_t i=0; i<nrows; ++i){
     741             :       // in case of sparse drawing only use the first entry per run
     742           0 :       Double_t run  = fTree->GetV1()[index[i]];
     743           0 :       Double_t xval = xArr[index[i]];
     744             :       
     745           0 :       if (drawSparse){
     746           0 :         if (TMath::Abs(lastRun-run)<.1) {
     747             :           lastRun=run;
     748           0 :           continue;
     749             :         }
     750           0 :         xval=entries+0.5;
     751           0 :       }
     752           0 :       fValuesX.GetMatrixArray()[entries]=xval;
     753           0 :       fValuesY.GetMatrixArray()[entries]=fTree->GetV3()[index[i]];
     754           0 :       fRunNumbers.GetMatrixArray()[entries]=run;
     755           0 :       fTimeStamps.GetMatrixArray()[entries]=fTree->GetV2()[index[i]];
     756             :       lastRun=run;
     757           0 :       ++entries;
     758           0 :     }
     759             :     
     760           0 :     if (drawSparse){
     761           0 :       fValuesX.ResizeTo(entries);
     762           0 :       fValuesY.ResizeTo(entries);
     763           0 :       fRunNumbers.ResizeTo(entries);
     764           0 :       fTimeStamps.ResizeTo(entries);
     765             :       //      printf("entries: %d\n",entries);
     766           0 :     }
     767             :     
     768           0 :     delete [] index;
     769             :   }
     770           0 : }
     771             : //______________________________________________________________________________
     772             : void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
     773             : {
     774             :   /// Create string for histogram title
     775             : 
     776           0 :   title=fDrawString;
     777           0 :   Int_t pos=title.First(">>");
     778           0 :   if (pos>0) title=title(0,pos);
     779             : //   if (!fIsCustomDraw){
     780           0 :     if (fRadioXrun->GetState()==kButtonDown){
     781           0 :       title+=":Run";
     782           0 :     } else if (fRadioXtime->GetState()==kButtonDown){
     783           0 :       title+=":Date";
     784           0 :     }
     785             : //   }
     786           0 :   TString cuts;
     787           0 :   GetCutString(cuts);
     788           0 :   TObjArray *arr=title.Tokenize(":");
     789             :   TObject *o=0x0;
     790           0 :   title+=" {";
     791           0 :   title+=cuts;
     792           0 :   title+="}";
     793           0 :   TIter next(arr,kIterBackward);
     794           0 :   while ( (o=next()) ){
     795           0 :     TString varName=o->GetName();
     796           0 :     title+=";";
     797             :     //substitue variable names with names in configuration file if available
     798           0 :     if ((*fConfigParser)()->GetEntries()){
     799           0 :       TString branchName=varName;
     800             :       Int_t par=0;
     801           0 :       if (branchName.Contains('.')) branchName=branchName(0,branchName.First('.')+1);
     802             :       //chek if a configuration for that branch is available
     803           0 :       const TObject *oBranch=(*fConfigParser)(branchName.Data());
     804           0 :       if (oBranch){
     805           0 :         TString branchTitle=fConfigParser->GetData(oBranch,kBranchTitle);
     806           0 :         if (!branchTitle.IsNull()){
     807             :           //check for TVectorT type branch
     808             :           //add parameter name if available
     809           0 :           if (varName.Contains("fElements")){
     810           0 :             TString parStr=varName(varName.First('[')+1,varName.Length()-varName.First('[')-2);
     811           0 :             par=parStr.Atoi();
     812           0 :             branchTitle+=": ";
     813           0 :             TString yparname=fConfigParser->GetData(oBranch,par+kParamNames);
     814           0 :             if (!yparname.IsNull()){
     815           0 :               branchTitle+=yparname;
     816             :             } else {
     817           0 :               branchTitle+="[";
     818           0 :               branchTitle+=par;
     819           0 :               branchTitle+="]";
     820             :             }
     821           0 :           }
     822             :         }
     823           0 :         varName=branchTitle;
     824           0 :         SubstituteUnderscores(varName);
     825           0 :       }
     826           0 :     }
     827           0 :     title+=varName;
     828           0 :   }
     829           0 :   delete arr;
     830           0 : }
     831             : //______________________________________________________________________________
     832             : void AliTPCCalibViewerGUItime::AdjustYRange()
     833             : {
     834             :   ///
     835             : 
     836           0 :   TIter nextGraphicObject(fTrashBox);
     837             :   TObject *o=0x0;
     838             :   Float_t min=1,max=0;
     839           0 :   while ( (o=nextGraphicObject()) ){
     840           0 :     if (o->IsA()==TGraph::Class()){
     841           0 :       TGraph *gr=(TGraph*)o;
     842           0 :       if (min>max) {
     843           0 :         min=TMath::MinElement(gr->GetN(),gr->GetY());
     844           0 :         max=TMath::MaxElement(gr->GetN(),gr->GetY());
     845           0 :       } else {
     846           0 :         Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
     847           0 :         Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
     848           0 :         if (currmax>max) max=currmax;
     849           0 :         if (currmin<min) min=currmin;
     850             :       }
     851           0 :     }
     852             :   }
     853           0 :   if (min!=max){
     854           0 :     if (min!=0) min=min-(max-min)/10;
     855           0 :     if (max!=0) max=max+(max-min)/10;
     856           0 :     fCurrentHist->SetMinimum(min);
     857           0 :     fCurrentHist->SetMaximum(max);
     858             :   }
     859           0 : }
     860             : //______________________________________________________________________________
     861             : void AliTPCCalibViewerGUItime::DoDraw() {
     862             :   /// Draw graphics
     863             : 
     864           0 :   TString drawString=fDrawString;
     865           0 :   TString cutString;
     866           0 :   GetCutString(cutString);
     867           0 :   TString optString  = GetDrawOptionString();
     868           0 :   Bool_t graphOutput=!fNoGraph;  //ttree buffer for V1, V2... too small
     869           0 :   graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
     870           0 :   graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
     871             : //   graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
     872             : //   graphOutput&=fDrawString.CountChar(':')<2; //custom draw 1D
     873           0 :   if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
     874           0 :   if (fIsCustomDraw&&fDrawString.Contains(":")) HandleButtonsDrawSel(-kRadioXhist);
     875           0 :   Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
     876             : //   optString+="goff";
     877           0 :   if (graphOutput) {
     878           0 :     drawString.Prepend("run:time:");
     879           0 :     optString="goff";
     880             :   }else{
     881             : //     if (!fIsCustomDraw){
     882           0 :       if (fRadioXrun->GetState()==kButtonDown){
     883           0 :         drawString+=":run";
     884           0 :       } else if (fRadioXtime->GetState()==kButtonDown){
     885           0 :         drawString+=":time";
     886             :       }
     887             : //     }
     888             :   }
     889           0 :   TVirtualPad *padsave=gPad;
     890           0 :   fCanvMain->GetCanvas()->cd();
     891             :   //delete old histograms and graphs
     892           0 :   if (!drawSame){
     893           0 :     fTrashBox->Delete();
     894           0 :     fCurrentGraph=0x0;
     895           0 :     fCurrentHist=0x0;
     896           0 :   }
     897             : //   printf("%s (%s) [%s]\n",drawString.Data(), cutString.Data(), optString.Data());
     898             :   //select data
     899           0 :   fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
     900           0 :   if (fTree->GetSelectedRows()==-1) return;
     901             :   
     902           0 :   TString title;
     903           0 :   GetHistogramTitle(title);
     904             :   Bool_t drawGraph=kFALSE;
     905             :   Double_t *xArr=0;
     906           0 :   if (graphOutput){
     907             :     drawGraph=kTRUE;
     908           0 :     if (fIsCustomDraw&&fDrawString.Contains(":")){
     909             : //       fValuesX.SetElements(fTree->GetV4());
     910           0 :       xArr=fTree->GetV4();
     911           0 :     }else{
     912           0 :       if (fRadioXrun->GetState()==kButtonDown){
     913             : //         fValuesX.SetElements(fTree->GetV1());
     914           0 :         xArr=fTree->GetV1();
     915           0 :       } else if (fRadioXtime->GetState()==kButtonDown){
     916             : //         fValuesX.SetElements(fTree->GetV2());
     917           0 :         xArr=fTree->GetV2();
     918           0 :       } else {
     919             :         drawGraph=kFALSE;
     920             :       }
     921             :     }
     922             :   }
     923           0 :   if (xArr) UpdateValueArrays(graphOutput, xArr);
     924             : //   if (graphOutput){
     925             : //     if (fIsCustomDraw){
     926             : //       if (fDrawString.Contains(":")){
     927             : //         fValuesX.SetElements(fTree->GetV4());
     928             : //         drawGraph=kTRUE;
     929             : //       } else {
     930             : //         drawGraph=kFALSE;
     931             : //       }
     932             : //     }else{
     933             : //       drawGraph=kTRUE;
     934             : //       if (fRadioXrun->GetState()==kButtonDown){
     935             : //         fValuesX.SetElements(fTree->GetV1());
     936             : //       } else if (fRadioXtime->GetState()==kButtonDown){
     937             : //         fValuesX.SetElements(fTree->GetV2());
     938             : //       } else {
     939             : //         drawGraph=kFALSE;
     940             : //       }
     941             : //     }
     942             : //   }
     943             : //create graph according to selection
     944           0 :   if (drawGraph){
     945           0 :     TGraph *graph=new TGraph(fValuesX,fValuesY);
     946             : //     graph->Sort();
     947           0 :     TString grDraw="p";
     948           0 :     if (!drawSame) grDraw+="a";
     949           0 :     if (!fIsCustomDraw) grDraw+="l";
     950             :     // sparse drawing, set bin labels
     951           0 :     if (fRadioXrun->GetState()==kButtonDown && fChkDrawOptSparse->GetState()==kButtonDown){
     952           0 :       Int_t nrows=fValuesX.GetNrows();
     953           0 :       Double_t *newBins = new Double_t[nrows+1];
     954           0 :       for (Int_t ibin=0; ibin<nrows+1; ++ibin) newBins[ibin]=ibin;
     955           0 :       graph->GetXaxis()->Set(nrows,newBins);
     956           0 :       graph->GetXaxis()->LabelsOption("v");
     957           0 :       for (Int_t i=0; i<nrows;++i)
     958           0 :         graph->GetXaxis()->SetBinLabel(i+1,Form("%.0f",fRunNumbers.GetMatrixArray()[i]));
     959           0 :       delete [] newBins;
     960           0 :     }
     961           0 :     graph->Draw(grDraw.Data());
     962           0 :     graph->SetEditable(kFALSE);
     963           0 :     TH1 *hist=graph->GetHistogram();
     964           0 :     hist->SetTitle(title.Data());
     965           0 :     fTrashBox->Add(graph);
     966           0 :     graph->SetLineColor(fTrashBox->GetEntries());
     967           0 :     graph->SetMarkerColor(fTrashBox->GetEntries());
     968           0 :     if (!drawSame) {
     969           0 :       fCurrentGraph=graph;
     970           0 :       fCurrentHist=hist;
     971           0 :     }
     972           0 :   } else {
     973           0 :     TH1 *hist=fTree->GetHistogram();
     974           0 :     hist->SetTitle(title.Data());
     975             : //     hist->Draw(optString.Data());
     976           0 :     fTrashBox->Add(hist);
     977           0 :     hist->SetLineColor(fTrashBox->GetEntries());
     978           0 :     hist->SetMarkerColor(fTrashBox->GetEntries());
     979           0 :     if (!drawSame) fCurrentHist=hist;
     980             :   }
     981             :   
     982             :   //Set time axis if choosen as x-variables
     983             : //   if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
     984           0 :   if (fRadioXtime->GetState()==kButtonDown&&!drawSame){
     985           0 :     TAxis *xaxis=fCurrentHist->GetXaxis();
     986           0 :     xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
     987           0 :     xaxis->SetTimeDisplay(1);
     988           0 :     xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
     989           0 :     xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
     990           0 :   }
     991           0 :   if (!drawSame) {
     992             :   //Set title offset
     993           0 :     fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
     994             :   } else {
     995             :     //adjust y-range
     996           0 :     AdjustYRange();
     997             :   }
     998           0 :   gPad->Modified();
     999           0 :   gPad->Update();
    1000           0 :   padsave->cd();
    1001           0 : }
    1002             : 
    1003             : //______________________________________________________________________________
    1004             : void AliTPCCalibViewerGUItime::DoDumpRuns()
    1005             : {
    1006             :   /// Dump the current run numbers to stdout
    1007             : 
    1008           0 :   Int_t npoints=fRunNumbers.GetNrows();
    1009           0 :   Int_t    *sortIndex = new Int_t[npoints];
    1010           0 :   TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
    1011             :   Int_t run=0, prevRun=-1;
    1012             :   
    1013           0 :   for (Int_t irun=0;irun<npoints;++irun){
    1014           0 :     run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
    1015           0 :     if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
    1016             :     prevRun=run;
    1017             :   }
    1018           0 :   delete [] sortIndex;
    1019           0 : }
    1020             : //______________________________________________________________________________
    1021             : void AliTPCCalibViewerGUItime::DoParLimitChange()
    1022             : {
    1023             :   ///
    1024             : 
    1025           0 :   UpdateParName();
    1026           0 :   DoDraw();
    1027           0 : }
    1028             : //______________________________________________________________________________
    1029             : void AliTPCCalibViewerGUItime::DoNewSelection() {
    1030             :    /// decides whether to redraw if user makes another selection
    1031             : 
    1032           0 :   UpdateParLimits();
    1033           0 :   fDrawString=GetDrawString();
    1034           0 :   fIsCustomDraw=kFALSE;
    1035           0 :   DoDraw();
    1036           0 : }
    1037             : //______________________________________________________________________________
    1038             : void AliTPCCalibViewerGUItime::DoCustomDraw()
    1039             : {
    1040             :   ///
    1041             : 
    1042           0 :   fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
    1043             : //   if (fDrawString.Contains(">>")){
    1044             : //     Warning("DoCustomDraw","Currently no user defined histograms allowed!");
    1045             : //     return;
    1046             : //   }
    1047           0 :   fNmbPar->SetState(kFALSE);
    1048           0 :   fIsCustomDraw=kTRUE;
    1049           0 :   DoDraw();
    1050           0 : }
    1051             : //______________________________________________________________________________
    1052             : void AliTPCCalibViewerGUItime::DoCustomCutsDraw()
    1053             : {
    1054             :   ///
    1055             : 
    1056           0 :   if (fIsCustomDraw) DoCustomDraw();
    1057             :   else {
    1058           0 :     fDrawString=GetDrawString();
    1059           0 :     fIsCustomDraw=kFALSE;
    1060           0 :     DoDraw();
    1061             :   }
    1062           0 : }
    1063             : //______________________________________________________________________________
    1064             : void AliTPCCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
    1065             : {
    1066             :   /// Draw selection button handling (x-variable)
    1067             : 
    1068           0 :   if (id == -1) {
    1069           0 :     TGButton *btn = (TGButton *) gTQSender;
    1070           0 :     id = btn->WidgetId();
    1071           0 :   }
    1072             :   
    1073             :   Bool_t doDraw=kFALSE;
    1074             :   Bool_t noDraw=kFALSE;
    1075           0 :   if (id<-1){
    1076             :     noDraw=kTRUE;
    1077           0 :     id=TMath::Abs(id);
    1078           0 :   }
    1079           0 :   switch (id) {
    1080             :   case (kRadioXhist):
    1081           0 :     doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
    1082           0 :     if (doDraw){
    1083           0 :       fRadioXrun->SetState(kButtonUp);
    1084           0 :       fRadioXtime->SetState(kButtonUp);
    1085           0 :       fRadioXhist->SetState(kButtonDown);
    1086           0 :     }
    1087             :     break;
    1088             :   case (kRadioXrun):
    1089           0 :     doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
    1090           0 :     if (doDraw){
    1091           0 :       fRadioXhist->SetState(kButtonUp);
    1092           0 :       fRadioXtime->SetState(kButtonUp);
    1093           0 :       fRadioXrun->SetState(kButtonDown);
    1094           0 :     }
    1095             :     break;
    1096             :   case (kRadioXtime):
    1097           0 :     doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
    1098           0 :     if (doDraw){
    1099           0 :       fRadioXrun->SetState(kButtonUp);
    1100           0 :       fRadioXhist->SetState(kButtonUp);
    1101           0 :       fRadioXtime->SetState(kButtonDown);
    1102           0 :     }
    1103             :     break;
    1104             :   }
    1105           0 :   if (doDraw&&!noDraw) DoCustomCutsDraw();
    1106           0 : }
    1107             : //______________________________________________________________________________
    1108             : void AliTPCCalibViewerGUItime::UpdateParName()
    1109             : {
    1110             :   /// change parameter name
    1111             : 
    1112           0 :   Int_t par = (Int_t)(fNmbPar->GetNumber());
    1113           0 :   TString parName="";
    1114           0 :   Int_t id=fListVariables->GetSelectedEntry()->EntryId();
    1115           0 :   if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
    1116           0 :   if (parName=="") parName.Form("%d",par);
    1117           0 :   fLblPar->SetText(Form("Parameter: %s",parName.Data()));
    1118           0 :   fDrawString=GetDrawString();
    1119           0 :   fIsCustomDraw=kFALSE;
    1120           0 : }
    1121             : 
    1122             : //______________________________________________________________________________
    1123             : void AliTPCCalibViewerGUItime::UpdateParLimits()
    1124             : {
    1125             :   /// Adjust limits for TVectorT based variables
    1126             : 
    1127           0 :   if (!fTree) return;
    1128           0 :   TString selectedVariableTitle="";
    1129             :   Int_t id=-1;
    1130           0 :   if (!fListVariables->GetSelectedEntry()) return;
    1131           0 :   selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
    1132           0 :   id=fListVariables->GetSelectedEntry()->EntryId();
    1133             : //   printf("id: %d\n",id);
    1134           0 :   TString selectedVariable=selectedVariableTitle;
    1135           0 :   const TObject *key=(*fConfigParser)(id);
    1136           0 :   if (key) selectedVariable=(*fConfigParser)(id)->GetName();
    1137             :   
    1138           0 :   if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
    1139           0 :     fNmbPar->SetState(kFALSE);
    1140           0 :     fLblPar->SetText("Parameter: none");
    1141           0 :     return;
    1142             :   }
    1143           0 :   TVectorD *vD=0x0;
    1144           0 :   TVectorF *vF=0x0;
    1145             :   Int_t maxPar=0;
    1146           0 :   fTree->GetEntry(1);
    1147           0 :   TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
    1148           0 :   TString branchClass=branch->GetClassName();
    1149             :   Int_t event=0;
    1150           0 :   if (branchClass=="TVectorT<double>"){
    1151             : //     branch->SetAddress(&vD);
    1152           0 :     fTree->SetBranchAddress(selectedVariable.Data(),&vD);
    1153           0 :     while (maxPar<2&&event<fTree->GetEntries()){
    1154           0 :       fTree->GetEntry(event++);
    1155           0 :       maxPar=vD->GetNrows();
    1156             :     }
    1157           0 :   } else if (branchClass=="TVectorT<float>"){
    1158             : //     branch->SetAddress(&vF);
    1159           0 :     fTree->SetBranchAddress(selectedVariable.Data(),&vF);
    1160           0 :     while (maxPar<2&&event<fTree->GetEntries()){
    1161           0 :       fTree->GetEntry(event++);
    1162           0 :       maxPar=vF->GetNrows();
    1163             :     }
    1164             :   } else {
    1165             :     //class not known
    1166           0 :     fNmbPar->SetState(kFALSE);
    1167           0 :     return;
    1168             :   }
    1169             : //   branch->ResetAddress();
    1170           0 :   fTree->SetBranchAddress(selectedVariable.Data(),0x0);
    1171           0 :   if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
    1172           0 :   fNmbPar->SetLimitValues(0,maxPar-1);
    1173           0 :   fNmbPar->SetState(kTRUE);
    1174           0 :   UpdateParName();
    1175           0 : }
    1176             : //______________________________________________________________________________
    1177             : void AliTPCCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
    1178             : {
    1179             :   /// handle mouse events in the draw canvas
    1180             : 
    1181           0 :   UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
    1182             :   Double_t valx=0.,valy=0.;
    1183           0 :   if (!fCurrentGraph) {
    1184           0 :     fLblRunNumberVal->SetText(Form("%06u",run));
    1185           0 :     fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
    1186           0 :     fLblValueXVal->SetText(Form("%.3e", valx));
    1187           0 :     fLblValueYVal->SetText(Form("%.3e", valy));
    1188           0 :     return;
    1189             :   }
    1190           0 :   TVirtualPad *padsave=gPad;
    1191           0 :   fCanvMain->GetCanvas()->cd();
    1192           0 :   Int_t n=fValuesY.GetNrows();
    1193             :   Double_t *arr=0x0;
    1194           0 :   arr=fValuesX.GetMatrixArray();
    1195             : 
    1196             :   Int_t minDist=1000000;
    1197             :   Int_t minPoint=-1;
    1198           0 :   for (Int_t i=0;i<n;++i){
    1199           0 :     Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
    1200           0 :     Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
    1201           0 :     Int_t d   = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
    1202           0 :     if (d < minDist) {
    1203             :       minDist  = d;
    1204             :       minPoint = i;
    1205           0 :     }
    1206             :   }
    1207           0 :   if (minDist<2){
    1208           0 :     TTimeStamp t((Int_t)fTimeStamps[minPoint]);
    1209           0 :     t.GetDate(kTRUE,0,&yy,&mm,&dd);
    1210           0 :     t.GetTime(kTRUE,0,&HH,&MM,&SS);
    1211           0 :     run=(UInt_t)fRunNumbers[minPoint];
    1212           0 :     valx=fValuesX[minPoint];
    1213           0 :     valy=fValuesY[minPoint];
    1214           0 :   } else {
    1215           0 :     dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
    1216             :     valx=0.;
    1217             :     valy=0.;
    1218             :   }
    1219           0 :   fLblRunNumberVal->SetText(Form("%06u",run));
    1220           0 :   fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
    1221           0 :   if (fIsCustomDraw){
    1222           0 :     fLblValueXVal->SetText(Form("%.3e", valx));
    1223           0 :   }else{
    1224           0 :     if (fRadioXrun->GetState()==kButtonDown){
    1225           0 :       fLblValueXVal->SetText("Run");
    1226           0 :     } else if (fRadioXtime->GetState()==kButtonDown){
    1227           0 :       fLblValueXVal->SetText("Time");
    1228           0 :     }
    1229             :   }
    1230           0 :   fLblValueYVal->SetText(Form("%.3e", valy));
    1231           0 :   padsave->cd();
    1232           0 :   if (run==0) return;
    1233           0 :   if (event == kButton1Double ){
    1234           0 :     SetGuiTree(run);
    1235           0 :   }
    1236             :   //find closes point of current selection
    1237           0 : }
    1238             : //______________________________________________________________________________
    1239             : void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
    1240             : {
    1241             :   /// create the AliTPCCalibViewerGUI tree for run
    1242             :   /// cache tree in directory fOutputCacheDir
    1243             :   /// retrieve file from this directory if it already exists
    1244             : 
    1245             :   //
    1246             :   //Create and set GUI tree  
    1247             :   //
    1248             :   //try to find file for run in fOutputCacheDir
    1249           0 :   TString fileName=fOutputCacheDir;
    1250           0 :   if (!fileName.EndsWith("/")) fileName+="/";
    1251           0 :   fileName+=Form("guiTreeRun_%d.root",run);
    1252             :   Bool_t load=kTRUE;
    1253           0 :   if (gSystem->AccessPathName(fileName.Data())){
    1254           0 :     load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
    1255           0 :     if (!load){
    1256           0 :       fCalibViewerGUI->Reset();
    1257           0 :       if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
    1258           0 :       return;
    1259             :     }
    1260             :   }
    1261           0 :   fCalibViewerGUI->Initialize(fileName.Data());
    1262           0 :   if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
    1263             :   
    1264             :   //
    1265             :   //Create and set Reference GUI tree
    1266             :   //
    1267           0 :   AliTPCcalibDButil util;
    1268           0 :   util.SetReferenceRun(run);
    1269           0 :   fileName=fOutputCacheDir;
    1270           0 :   if (!fileName.EndsWith("/")) fileName+="/";
    1271           0 :   fileName+=util.GetGUIRefTreeDefaultName();
    1272             :   //only update if file does not exist
    1273           0 :   if (gSystem->AccessPathName(fileName.Data())){
    1274           0 :     util.UpdateRefDataFromOCDB();
    1275           0 :     util.CreateGUIRefTree(fileName.Data());
    1276             :   }
    1277             :   
    1278           0 :   fCalibViewerGUI->GetViewer()->AddReferenceTree(fileName.Data(),"calPads","Ref");
    1279             :   
    1280             :   //
    1281             :   // Process additional reference trees
    1282             :   //
    1283           0 :   TIter nextRefTree(fMapRefTrees);
    1284             :   TObject *o=0x0;
    1285             :   //Set static reference data
    1286           0 :   while ( (o=nextRefTree()) ){
    1287           0 :     fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
    1288             :   }
    1289           0 :   fCalibViewerGUI->Reload();
    1290           0 : }
    1291             : //______________________________________________________________________________
    1292             : void AliTPCCalibViewerGUItime::SubstituteUnderscores(TString &s)
    1293             : {
    1294             :   ///
    1295             : 
    1296           0 :   s.ReplaceAll("_{","|{");
    1297           0 :   s.ReplaceAll("_"," ");
    1298           0 :   s.ReplaceAll("|{","_{");
    1299           0 : }
    1300             : 
    1301             : //______________________________________________________________________________
    1302             : void AliTPCCalibViewerGUItime::DoNewSelectionAliases()
    1303             : {
    1304             :   ///
    1305             : 
    1306           0 :   if (!fTree) return;
    1307           0 :   TList *l=fTree->GetListOfAliases();
    1308           0 :   if (!l) return;
    1309           0 :   TString selectedVariable="";
    1310           0 :   if (!fListAliases->GetSelectedEntry()) return;
    1311           0 :   selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
    1312           0 :   fDrawString=selectedVariable;
    1313           0 :   fIsCustomDraw=kFALSE;
    1314           0 :   DoDraw();
    1315           0 : }
    1316             : //______________________________________________________________________________
    1317             : void AliTPCCalibViewerGUItime::DoAddAlias()
    1318             : {
    1319             :   ///
    1320             : 
    1321           0 :   new AliTPCCalibViewerGUItimeAddAliasFrame(gClient->GetRoot(), fContTopBottom, 400, 200, kVerticalFrame, this);
    1322           0 : }
    1323             : //______________________________________________________________________________
    1324             : void AliTPCCalibViewerGUItime::DoDelAlias()
    1325             : {
    1326             :   ///
    1327             : 
    1328           0 :   if (!fTree) return;
    1329           0 :   TList *l=fTree->GetListOfAliases();
    1330           0 :   if (!l) return;
    1331           0 :   TString selectedVariable="";
    1332           0 :   if (!fListAliases->GetSelectedEntry()) return;
    1333           0 :   selectedVariable = fListAliases->GetSelectedEntry()->GetTitle();
    1334           0 :   l->Remove(l->FindObject(selectedVariable.Data()));
    1335           0 :   UpdateAliasList();
    1336           0 : }
    1337             : 
    1338             : //______________________________________________________________________________
    1339             : void AliTPCCalibViewerGUItime::UpdateAliasList()
    1340             : {
    1341             :   ///
    1342             : 
    1343           0 :   printf("UpdateAliasList\n");
    1344           0 :   if (!fTree) return;
    1345           0 :   TList *l=fTree->GetListOfAliases();
    1346           0 :   if (!l) return;
    1347           0 :   TIter nextAlias(l);
    1348             :   TObject *o;
    1349           0 :   fListAliases->RemoveAll();
    1350             :   Int_t id=0;
    1351           0 :   while( (o=nextAlias()) ){
    1352           0 :     fListAliases->AddEntry(o->GetName(),id++);
    1353             :   }
    1354           0 :   fListAliases->Resize(fListAliases->GetWidth()-1, fListAliases->GetHeight());
    1355           0 :   fListAliases->Resize(fListAliases->GetWidth()+1, fListAliases->GetHeight());
    1356           0 : }
    1357             : //______________________________________________________________________________
    1358             : TObjArray* AliTPCCalibViewerGUItime::ShowGUI(const char* fileName, const char* treeName) {
    1359             :    /// Initialize and show GUI for presentation for demonstration purposes
    1360             :    /// or for fast standalone use
    1361             : 
    1362           0 :   TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
    1363           0 :   frmMain->SetWindowName("AliTPCCalibViewer GUItime");
    1364           0 :   frmMain->SetCleanup(kDeepCleanup);
    1365             :   
    1366           0 :   TGTab* tabMain = new TGTab(frmMain, 1000, 600);
    1367           0 :   frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
    1368             :   
    1369           0 :   TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
    1370           0 :   TGCompositeFrame* tabCont2 = tabMain->AddTab("Detail - XXXXX");
    1371             :   
    1372           0 :   AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
    1373           0 :   tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
    1374           0 :   calibViewerTime->SetConfigFileName("$ALICE_ROOT/TPC/CalibMacros/calibVarDescription.txt");
    1375           0 :   calibViewerTime->UseFile(fileName, treeName);
    1376             :   
    1377           0 :   AliTPCCalibViewerGUI* calibViewer = new AliTPCCalibViewerGUI(tabCont2, 1000, 600, 0);
    1378           0 :   tabCont2->AddFrame(calibViewer, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
    1379           0 :   calibViewerTime->SetCalibViewerGUI(calibViewer);
    1380           0 :   calibViewerTime->SetCalibViewerGUItab(tabMain->GetTabTab(1));
    1381             :   
    1382             :   
    1383           0 :   TObjArray *guiArray = new TObjArray();
    1384           0 :   guiArray->Add(calibViewerTime);
    1385           0 :   guiArray->Add(calibViewer);
    1386             :   
    1387           0 :   frmMain->MapSubwindows();
    1388           0 :   frmMain->Resize();
    1389           0 :   frmMain->MapWindow();
    1390             :   
    1391           0 :   return guiArray;
    1392           0 : }
    1393             : 
    1394             : //______________________________________________________________________________
    1395             : TObjArray* AliTPCCalibViewerGUItime::ShowGUI(TChain *chain) {
    1396             :    /// Initialize and show GUI for presentation for demonstration purposes
    1397             :    /// or for fast standalone use
    1398             : 
    1399           0 :   TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
    1400           0 :   frmMain->SetWindowName("AliTPCCalibViewer GUItime");
    1401           0 :   frmMain->SetCleanup(kDeepCleanup);
    1402             : 
    1403           0 :   TGTab* tabMain = new TGTab(frmMain, 1000, 600);
    1404           0 :   frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
    1405             : 
    1406           0 :   TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
    1407             : 
    1408           0 :   AliTPCCalibViewerGUItime* calibViewerTime = new AliTPCCalibViewerGUItime(tabCont1, 1000, 600);
    1409           0 :   tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
    1410           0 :   calibViewerTime->UseChain(chain);
    1411             : 
    1412           0 :   TObjArray *guiArray = new TObjArray();
    1413           0 :   guiArray->Add(calibViewerTime);
    1414             : 
    1415           0 :   frmMain->MapSubwindows();
    1416           0 :   frmMain->Resize();
    1417           0 :   frmMain->MapWindow();
    1418             : 
    1419           0 :   return guiArray;
    1420           0 : }
    1421             : 
    1422             : 
    1423             : ////////////////////////////////////////////////////////////////////////
    1424             : //
    1425             : //   GUI Alias frame
    1426             : //
    1427             : ////////////////////////////////////////////////////////////////////////
    1428             : 
    1429             : 
    1430             : /// \cond CLASSIMP
    1431          24 : ClassImp(AliTPCCalibViewerGUItimeAddAliasFrame)
    1432             : /// \endcond
    1433             : 
    1434           0 : AliTPCCalibViewerGUItimeAddAliasFrame::AliTPCCalibViewerGUItimeAddAliasFrame(const TGWindow *p, const TGWindow *main,
    1435             :                                                                              UInt_t w, UInt_t h, UInt_t options,
    1436             :                                                                              AliTPCCalibViewerGUItime *gui, TString strAlias) :
    1437           0 :   fMain(0x0),
    1438           0 :   fTxt1(0x0),
    1439           0 :   fTxt2(0x0),
    1440           0 :   fGUI(0x0)
    1441           0 : {
    1442           0 :   fMain = new TGTransientFrame(p, main, w, h, options);
    1443           0 :   fMain->Connect("CloseWindow()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
    1444           0 :   fMain->DontCallClose(); // to avoid double deletions.
    1445             :   
    1446             :    // use hierarchical cleaning
    1447           0 :   fMain->SetCleanup(kDeepCleanup);
    1448             : 
    1449             :   //layout
    1450           0 :   TGLayoutHints *l1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
    1451           0 :   TGLayoutHints *l2 = new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX, 2, 2, 0, 5);
    1452             : //   TGLayoutHints *l3 = new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5);
    1453             :   
    1454             :   //input fields
    1455           0 :   TGCompositeFrame *f1 = new TGCompositeFrame(fMain, 60, 20, kVerticalFrame);
    1456           0 :   fMain->AddFrame(f1, l1);
    1457           0 :   TGCompositeFrame *frameName    = new TGCompositeFrame(f1);
    1458           0 :   TGCompositeFrame *frameFormula = new TGCompositeFrame(f1);
    1459           0 :   f1->AddFrame(frameName,l2);
    1460           0 :   f1->AddFrame(frameFormula,l2);
    1461           0 :   TGLabel *lblTxt1   = new TGLabel(frameName, "Name:");
    1462           0 :   TGLabel *lblTxt2   = new TGLabel(frameFormula, "Formula:");
    1463           0 :   fTxt1 = new TGTextEntry(frameName, new TGTextBuffer(1000));
    1464           0 :   fTxt2 = new TGTextEntry(frameFormula, new TGTextBuffer(1000));
    1465             :   
    1466           0 :   frameName->AddFrame(lblTxt1, l2);
    1467           0 :   frameName->AddFrame(fTxt1, l2);
    1468           0 :   frameFormula->AddFrame(lblTxt2, l2);
    1469           0 :   frameFormula->AddFrame(fTxt2, l2);
    1470             :   
    1471           0 :   fTxt1->Resize(350, fTxt1->GetDefaultHeight());
    1472           0 :   fTxt2->Resize(350, fTxt2->GetDefaultHeight());
    1473             : 
    1474             :   //ok and cancel buttons
    1475           0 :   TGHorizontalFrame *frame = new TGHorizontalFrame(fMain, 60, 20, kFixedWidth);
    1476             :   
    1477           0 :   TGTextButton *okButton = new TGTextButton(frame, "&Ok", 1);
    1478           0 :   okButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoOK()");
    1479           0 :   TGTextButton *cancelButton = new TGTextButton(frame, "&Cancel", 2);
    1480           0 :   cancelButton->Connect("Clicked()", "AliTPCCalibViewerGUItimeAddAliasFrame", this, "DoCancel()");
    1481             :   
    1482             :   
    1483           0 :   frame->AddFrame(okButton, l1);
    1484           0 :   frame->AddFrame(cancelButton, l1);
    1485             :   
    1486           0 :   frame->Resize(150, okButton->GetDefaultHeight());
    1487             :   
    1488           0 :   fMain->AddFrame(frame, new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
    1489             :   
    1490           0 :   fGUI=gui;
    1491           0 :   TString aliasName, alias;
    1492           0 :   if (!strAlias.IsNull()){
    1493           0 :     TChain *c=fGUI->GetChain();
    1494           0 :     if (c){
    1495           0 :       TList *l=c->GetListOfAliases();
    1496           0 :       if (l){
    1497           0 :         TNamed *d=(TNamed*)l->FindObject(strAlias);
    1498           0 :         if (d){
    1499           0 :           aliasName=d->GetName();
    1500           0 :           alias=d->GetTitle();
    1501             :         }
    1502           0 :       }
    1503           0 :     }
    1504           0 :   }else{
    1505           0 :     alias=fGUI->GetCustomDrawString();
    1506             :   }
    1507           0 :   fTxt1->SetText(aliasName.Data(),kFALSE);
    1508           0 :   fTxt2->SetText(alias.Data(),kFALSE);
    1509             : 
    1510           0 :   fMain->MapSubwindows();
    1511           0 :   fMain->Resize();
    1512             :   
    1513             :    // position relative to the parent's window
    1514           0 :   fMain->CenterOnParent();
    1515             :   
    1516           0 :   fMain->SetWindowName("Alias Editor");
    1517             :   
    1518           0 :   fMain->MapWindow();
    1519             :   
    1520           0 : }
    1521             : //______________________________________________________________________________
    1522             : AliTPCCalibViewerGUItimeAddAliasFrame::~AliTPCCalibViewerGUItimeAddAliasFrame()
    1523           0 : {
    1524             :   ///
    1525             : 
    1526           0 :   fMain->DeleteWindow();  // deletes fMain
    1527           0 : }
    1528             : //______________________________________________________________________________
    1529             : void AliTPCCalibViewerGUItimeAddAliasFrame::DoOK()
    1530             : {
    1531             :   ///
    1532             : 
    1533           0 :   TString aliasName=fTxt1->GetText();
    1534           0 :   TString alias=fTxt2->GetText();
    1535           0 :   if (!aliasName.IsNull()&&!alias.IsNull()){
    1536           0 :     TChain *c=fGUI->GetChain();
    1537           0 :     if (c){
    1538           0 :       c->SetAlias(aliasName.Data(),alias.Data());
    1539             :     }
    1540           0 :   }
    1541           0 :   fGUI->UpdateAliasList();
    1542           0 :   delete this;
    1543           0 : }
    1544             : //______________________________________________________________________________
    1545             : void AliTPCCalibViewerGUItimeAddAliasFrame::DoCancel()
    1546             : {
    1547             :   ///
    1548             : 
    1549           0 :   delete this;
    1550           0 : }
    1551             : 

Generated by: LCOV version 1.11