TPC & TRD calibration viewer GUI, base classes (Ionut)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 May 2010 19:51:20 +0000 (19:51 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 May 2010 19:51:20 +0000 (19:51 +0000)
STEER/AliBaseCalibViewer.cxx [new file with mode: 0644]
STEER/AliBaseCalibViewer.h [new file with mode: 0644]
STEER/AliBaseCalibViewerGUI.cxx [new file with mode: 0644]
STEER/AliBaseCalibViewerGUI.h [new file with mode: 0644]
STEER/AliCalibViewerGUItime.cxx [new file with mode: 0644]
STEER/AliCalibViewerGUItime.h [new file with mode: 0644]
STEER/CDBLinkDef.h
STEER/libCDB.pkg

diff --git a/STEER/AliBaseCalibViewer.cxx b/STEER/AliBaseCalibViewer.cxx
new file mode 100644 (file)
index 0000000..775c7e5
--- /dev/null
@@ -0,0 +1,1002 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Base class for the AliTPCCalibViewer and AliTRDCalibViewer               //
+//  used for the calibration monitor                                         //
+//                                                                           //
+//  Authors:     Marian Ivanov (Marian.Ivanov@cern.ch)                       //
+//               Jens Wiechula (Jens.Wiechula@cern.ch)                       //
+//               Ionut Arsene  (iarsene@cern.ch)                             //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include <iostream>
+#include <fstream>
+#include <TString.h>
+#include <TRandom.h>
+#include <TLegend.h>
+#include <TLine.h>
+//#include <TCanvas.h>
+#include <TROOT.h>
+#include <TStyle.h>
+#include <TH1.h> 
+#include <TH1F.h>
+#include <TMath.h>
+#include <THashTable.h>
+#include <TObjString.h>
+#include <TLinearFitter.h>
+#include <TTreeStream.h>
+#include <TFile.h>
+#include <TKey.h>
+#include <TGraph.h>
+#include <TDirectory.h>
+#include <TFriendElement.h>
+
+#include "AliBaseCalibViewer.h"
+
+ClassImp(AliBaseCalibViewer)
+
+AliBaseCalibViewer::AliBaseCalibViewer()
+                  :TObject(),
+                   fTree(0),
+                   fFile(0),
+                   fListOfObjectsToBeDeleted(0),
+                   fTreeMustBeDeleted(0), 
+                   fAbbreviation(0), 
+                   fAppendString(0)
+{
+  //
+  // Default constructor
+  //
+}
+
+//_____________________________________________________________________________
+AliBaseCalibViewer::AliBaseCalibViewer(const AliBaseCalibViewer &c)
+                  :TObject(c),
+                   fTree(0),
+                   fFile(0),
+                   fListOfObjectsToBeDeleted(0),
+                   fTreeMustBeDeleted(0),
+                   fAbbreviation(0), 
+                   fAppendString(0)
+{
+  //
+  // dummy AliBaseCalibViewer copy constructor
+  // not yet working!!!
+  //
+  fTree = c.fTree;
+  fTreeMustBeDeleted = c.fTreeMustBeDeleted;
+  fListOfObjectsToBeDeleted = c.fListOfObjectsToBeDeleted;
+  fAbbreviation = c.fAbbreviation;
+  fAppendString = c.fAppendString;
+}
+
+//_____________________________________________________________________________
+AliBaseCalibViewer::AliBaseCalibViewer(TTree* tree)
+                  :TObject(),
+                   fTree(0),
+                   fFile(0),
+                   fListOfObjectsToBeDeleted(0),
+                   fTreeMustBeDeleted(0),
+                   fAbbreviation(0), 
+                   fAppendString(0)
+{
+  //
+  // Constructor that initializes the calibration viewer
+  //
+  fTree = tree;
+  fTreeMustBeDeleted = kFALSE;
+  fListOfObjectsToBeDeleted = new TObjArray();
+  fAbbreviation = "~";
+  fAppendString = ".fElements";
+}
+
+//_____________________________________________________________________________
+AliBaseCalibViewer::AliBaseCalibViewer(const Char_t* fileName, const Char_t* treeName)
+                  :TObject(),
+                   fTree(0),
+                   fFile(0),
+                   fListOfObjectsToBeDeleted(0),
+                   fTreeMustBeDeleted(0),
+                   fAbbreviation(0), 
+                   fAppendString(0)
+                   
+{
+   //
+   // Constructor to initialize the calibration viewer
+   // the file 'fileName' contains the tree 'treeName'
+   //
+   fFile = new TFile(fileName, "read");
+   fTree = (TTree*) fFile->Get(treeName);
+   fTreeMustBeDeleted = kTRUE;
+   fListOfObjectsToBeDeleted = new TObjArray();
+   fAbbreviation = "~";
+   fAppendString = ".fElements";
+}
+
+//____________________________________________________________________________
+AliBaseCalibViewer & AliBaseCalibViewer::operator =(const AliBaseCalibViewer & param)
+{
+   //
+   // assignment operator - dummy
+   // not yet working!!!
+   //
+   fTree = param.fTree;
+   fTreeMustBeDeleted = param.fTreeMustBeDeleted;
+   fListOfObjectsToBeDeleted = param.fListOfObjectsToBeDeleted;
+   fAbbreviation = param.fAbbreviation;
+   fAppendString = param.fAppendString;
+   return (*this);
+}
+
+//_____________________________________________________________________________
+AliBaseCalibViewer::~AliBaseCalibViewer()
+{
+   //
+   // AliBaseCalibViewer destructor
+   // all objects will be deleted, the file will be closed, the pictures will disappear
+   //
+   if (fTree && fTreeMustBeDeleted) {
+      fTree->SetCacheSize(0);
+      fTree->Delete();
+   }
+   if (fFile) {
+      fFile->Close();
+      fFile = 0;
+   }
+
+   for (Int_t i = fListOfObjectsToBeDeleted->GetEntriesFast()-1; i >= 0; i--) {
+      delete fListOfObjectsToBeDeleted->At(i);
+   }
+   delete fListOfObjectsToBeDeleted;
+}
+
+//_____________________________________________________________________________
+void AliBaseCalibViewer::Delete(Option_t* option) {
+   //
+   // Should be called from AliBaseCalibViewerGUI class only.
+   // If you use Delete() do not call the destructor.
+   // All objects (except those contained in fListOfObjectsToBeDeleted) will be deleted, the file will be closed.
+   //
+   
+   option = option;  // to avoid warnings on compiling   
+   if (fTree && fTreeMustBeDeleted) {
+      fTree->SetCacheSize(0);
+      fTree->Delete();
+   }
+   if (fFile)
+      delete fFile;
+   delete fListOfObjectsToBeDeleted;
+}
+
+//_____________________________________________________________________________
+void AliBaseCalibViewer::FormatHistoLabels(TH1 *histo) const {
+   // 
+   // formats title and axis labels of histo 
+   // removes '.fElements'
+   // 
+   if (!histo) return;
+   TString replaceString(fAppendString.Data());
+   TString *str = new TString(histo->GetTitle());
+   str->ReplaceAll(replaceString, "");
+   histo->SetTitle(str->Data());
+   delete str;
+   if (histo->GetXaxis()) {
+      str = new TString(histo->GetXaxis()->GetTitle());
+      str->ReplaceAll(replaceString, "");
+      histo->GetXaxis()->SetTitle(str->Data());
+      delete str;
+   }
+   if (histo->GetYaxis()) {
+      str = new TString(histo->GetYaxis()->GetTitle());
+      str->ReplaceAll(replaceString, "");
+      histo->GetYaxis()->SetTitle(str->Data());
+      delete str;
+   }
+   if (histo->GetZaxis()) {
+      str = new TString(histo->GetZaxis()->GetTitle());
+      str->ReplaceAll(replaceString, "");
+      histo->GetZaxis()->SetTitle(str->Data());
+      delete str;
+   }
+}
+
+//_____________________________________________________________________________
+TFriendElement* AliBaseCalibViewer::AddReferenceTree(const Char_t* filename, const Char_t* treename, const Char_t* refname){
+  //
+  // add a reference tree to the current tree
+  // by default the treename is 'tree' and the reference treename is 'R'
+  //
+   TFile *file = new TFile(filename);
+   fListOfObjectsToBeDeleted->Add(file);
+   TTree * tree = (TTree*)file->Get(treename);
+   return AddFriend(tree, refname);
+}
+
+//_____________________________________________________________________________
+TString* AliBaseCalibViewer::Fit(const Char_t* drawCommand, const Char_t* formula, const Char_t* cuts, 
+                                Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix){
+   //
+   // fit an arbitrary function, specified by formula into the data, specified by drawCommand and cuts
+   // returns chi2, fitParam and covMatrix
+   // returns TString with fitted formula
+   //
+   
+   TString formulaStr(formula); 
+   TString drawStr(drawCommand);
+   TString cutStr(cuts);
+   
+   // abbreviations:
+   drawStr.ReplaceAll(fAbbreviation, fAppendString);
+   cutStr.ReplaceAll(fAbbreviation, fAppendString);
+   formulaStr.ReplaceAll(fAbbreviation, fAppendString);
+   
+   formulaStr.ReplaceAll("++", fAbbreviation);
+   TObjArray* formulaTokens = formulaStr.Tokenize(fAbbreviation.Data()); 
+   Int_t dim = formulaTokens->GetEntriesFast();
+   
+   fitParam.ResizeTo(dim);
+   covMatrix.ResizeTo(dim,dim);
+   
+   TLinearFitter* fitter = new TLinearFitter(dim+1, Form("hyp%d",dim));
+   fitter->StoreData(kTRUE);   
+   fitter->ClearPoints();
+   
+   Int_t entries = Draw(drawStr.Data(), cutStr.Data(), "goff");
+   if (entries == -1) return new TString("An ERROR has occured during fitting!");
+   Double_t **values = new Double_t*[dim+1] ; 
+   
+   for (Int_t i = 0; i < dim + 1; i++){
+      Int_t centries = 0;
+      if (i < dim) centries = fTree->Draw(((TObjString*)formulaTokens->At(i))->GetName(), cutStr.Data(), "goff");
+      else  centries = fTree->Draw(drawStr.Data(), cutStr.Data(), "goff");
+      
+      if (entries != centries) return new TString("An ERROR has occured during fitting!");
+      values[i] = new Double_t[entries];
+      memcpy(values[i],  fTree->GetV1(), entries*sizeof(Double_t)); 
+   }
+   
+   // add points to the fitter
+   for (Int_t i = 0; i < entries; i++){
+      Double_t x[1000];
+      for (Int_t j=0; j<dim;j++) x[j]=values[j][i];
+      fitter->AddPoint(x, values[dim][i], 1);
+   }
+
+   fitter->Eval();
+   fitter->GetParameters(fitParam);
+   fitter->GetCovarianceMatrix(covMatrix);
+   chi2 = fitter->GetChisquare();
+   chi2 = chi2;
+   
+   TString *preturnFormula = new TString(Form("( %e+",fitParam[0])), &returnFormula = *preturnFormula;
+   
+   for (Int_t iparam = 0; iparam < dim; iparam++) {
+     returnFormula.Append(Form("%s*(%e)",((TObjString*)formulaTokens->At(iparam))->GetName(),fitParam[iparam+1]));
+     if (iparam < dim-1) returnFormula.Append("+");
+   }
+   returnFormula.Append(" )");
+   delete formulaTokens;
+   delete fitter;
+   delete[] values;
+   return preturnFormula;
+}
+
+//_____________________________________________________________________________
+Double_t AliBaseCalibViewer::GetLTM(Int_t n, Double_t *array, Double_t *sigma, Double_t fraction){
+   //
+   //  returns the LTM and sigma
+   //
+   Double_t *ddata = new Double_t[n];
+   Double_t mean = 0, lsigma = 0;
+   UInt_t nPoints = 0;
+   for (UInt_t i = 0; i < (UInt_t)n; i++) {
+         ddata[nPoints]= array[nPoints];
+         nPoints++;
+   }
+   Int_t hh = TMath::Min(TMath::Nint(fraction * nPoints), Int_t(n));
+   AliMathBase::EvaluateUni(nPoints, ddata, mean, lsigma, hh);
+   if (sigma) *sigma = lsigma;
+   delete [] ddata;
+   return mean;
+}
+
+//_____________________________________________________________________________
+Int_t AliBaseCalibViewer::GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp){
+   // Returns the 'bin' for 'value'
+   // The interval between 'binLow' and 'binUp' is divided into 'nbins' equidistant bins
+   // avoid index out of bounds error: 'if (bin < binLow) bin = binLow' and vice versa
+   /* Begin_Latex
+         GetBin(value) = #frac{nbins - 1}{binUp - binLow} #upoint (value - binLow) +1
+      End_Latex
+   */
+   
+   Int_t bin =  TMath::Nint( (Float_t)(value - binLow) / (Float_t)(binUp - binLow) * (nbins-1) ) + 1;
+   // avoid index out of bounds:   
+   if (value < binLow) bin = 0;
+   if (value > binUp)  bin = nbins + 1;
+   return bin;
+   
+}
+
+//_____________________________________________________________________________
+TH1F* AliBaseCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, 
+                                  Float_t sigmaStep, Bool_t pm) {
+   //
+   // Creates a cumulative histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value
+   // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'histogram'
+   // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and  Begin_Latex #sigma End_Latex of the distribution in 'histogram', to be specified by the user
+   // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex)
+   // sigmaStep: the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used
+   // pm: Decide weather Begin_Latex t > 0 End_Latex (first case) or Begin_Latex t End_Latex arbitrary (secound case)
+   // The actual work is done on the array.
+   /* Begin_Latex 
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #frac{#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx + #int_{#mu}^{#mu - t #sigma} f(x, #mu, #sigma) dx }{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx } ,    for  t > 0    
+         or      
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #frac{#int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx }
+      End_Latex  
+      begin_macro(source)
+      {
+         Float_t mean = 0;
+         Float_t sigma = 1.5;
+         Float_t sigmaMax = 4;
+         gROOT->SetStyle("Plain");
+         TH1F *distribution = new TH1F("Distribution1", "Distribution f(x, #mu, #sigma)", 1000,-5,5);
+         TRandom rand(23);
+         for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma));
+         Float_t *ar = distribution->GetArray();
+         
+         TCanvas* macro_example_canvas = new TCanvas("macro_example_canvas_SigmaCut", "", 350, 350);
+         macro_example_canvas->Divide(0,3);
+         TVirtualPad *pad1 = macro_example_canvas->cd(1);
+         pad1->SetGridy();
+         pad1->SetGridx();
+         distribution->Draw();
+         TVirtualPad *pad2 = macro_example_canvas->cd(2);
+         pad2->SetGridy();
+         pad2->SetGridx();
+         
+         TH1F *shist = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax);
+         shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)");
+         shist->Draw();  
+         TVirtualPad *pad3 = macro_example_canvas->cd(3);
+         pad3->SetGridy();
+         pad3->SetGridx();
+         TH1F *shistPM = AliTPCCalibViewer::SigmaCut(distribution, mean, sigma, sigmaMax, -1, kTRUE);
+         shistPM->Draw();   
+         return macro_example_canvas;
+      }  
+      end_macro
+   */ 
+   
+   Float_t *array = histogram->GetArray();
+   Int_t    nbins = histogram->GetXaxis()->GetNbins();
+   Float_t binLow = histogram->GetXaxis()->GetXmin();
+   Float_t binUp  = histogram->GetXaxis()->GetXmax();
+   return AliBaseCalibViewer::SigmaCut(nbins, array, mean, sigma, nbins, binLow, binUp, sigmaMax, sigmaStep, pm);
+}   
+   
+//_____________________________________________________________________________
+TH1F* AliBaseCalibViewer::SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm){
+   //
+   // Creates a histogram Begin_Latex S(t, #mu, #sigma) End_Latex, where you can see, how much of the data are inside sigma-intervals around the mean value
+   // The data of the distribution Begin_Latex f(x, #mu, #sigma) End_Latex are given in 'array', 'n' specifies the length of the array
+   // 'mean' and 'sigma' are Begin_Latex #mu End_Latex and  Begin_Latex #sigma End_Latex of the distribution in 'array', to be specified by the user
+   // 'nbins': number of bins, 'binLow': first bin, 'binUp': last bin
+   // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma, Begin_Latex t #sigma End_Latex)
+   // sigmaStep: the binsize of the generated histogram
+   // Here the actual work is done.
+   
+   if (TMath::Abs(sigma) < 1.e-10) return 0;
+   Float_t binWidth = (binUp-binLow)/(nbins - 1);
+   if (sigmaStep <= 0) sigmaStep = binWidth;
+   Int_t kbins = (Int_t)(sigmaMax * sigma / sigmaStep) + 1; // + 1  due to overflow bin in histograms
+   if (pm) kbins = 2 * (Int_t)(sigmaMax * sigma / sigmaStep) + 1;
+   Float_t kbinLow = !pm ? 0 : -sigmaMax;
+   Float_t kbinUp  = sigmaMax;
+   TH1F *hist = new TH1F("sigmaCutHisto","Cumulative; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); 
+   hist->SetDirectory(0);
+   hist->Reset();
+   
+   // calculate normalization
+   Double_t normalization = 0;
+   for (Int_t i = 0; i <= n; i++) {
+        normalization += array[i];
+   }
+   
+   // given units: units from given histogram
+   // sigma units: in units of sigma
+   // iDelta: integrate in interval (mean +- iDelta), given units
+   // x:      ofset from mean for integration, given units
+   // hist:   needs 
+   
+   // fill histogram
+   for (Float_t iDelta = 0; iDelta <= sigmaMax * sigma; iDelta += sigmaStep) {
+      // integrate array
+      Double_t valueP = array[GetBin(mean, nbins, binLow, binUp)];
+      Double_t valueM = array[GetBin(mean-binWidth, nbins, binLow, binUp)];
+      // add bin of mean value only once to the histogram
+      for (Float_t x = binWidth; x <= iDelta; x += binWidth) {
+         valueP += (mean + x <= binUp)  ? array[GetBin(mean + x, nbins, binLow, binUp)] : 0;
+         valueM += (mean-binWidth - x >= binLow) ? array[GetBin(mean-binWidth - x, nbins, binLow, binUp)] : 0; 
+      }
+
+      if (valueP / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail  +++ \n", valueP, normalization);
+      if (valueP / normalization > 100) return hist;
+      if (valueM / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail  +++ \n", valueM, normalization);
+      if (valueM / normalization > 100) return hist;
+      valueP = (valueP / normalization);
+      valueM = (valueM / normalization);
+      if (pm) {
+         Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp);
+         hist->SetBinContent(bin, valueP);
+         bin = GetBin(-iDelta/sigma, kbins, kbinLow, kbinUp);
+         hist->SetBinContent(bin, valueM);
+      }
+      else { // if (!pm)
+         Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp);
+         hist->SetBinContent(bin, valueP + valueM);
+      }
+   }
+   if (!pm) hist->SetMaximum(1.2);
+   return hist;
+}
+
+//_____________________________________________________________________________
+TH1F* AliBaseCalibViewer::SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma, Int_t nbins, Double_t *xbins, Double_t sigmaMax){
+   // 
+   // SigmaCut for variable binsize
+   // NOT YET IMPLEMENTED !!!
+   // 
+   printf("SigmaCut with variable binsize, Not yet implemented\n");
+   // avoid compiler warnings:
+   n=n;
+   mean=mean;
+   sigma=sigma;
+   nbins=nbins;
+   sigmaMax=sigmaMax;
+   array=array;
+   xbins=xbins;
+   
+   return 0;
+}
+
+//_____________________________________________________________________________
+Int_t  AliBaseCalibViewer::DrawHisto1D(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts, 
+                                      const Char_t *sigmas, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM) const {
+   // 
+   // Easy drawing of data, in principle the same as EasyDraw1D
+   // Difference: A line for the mean / median / LTM is drawn 
+   // in 'sigmas' you can specify in which distance to the mean/median/LTM you want to see a line in sigma-units, separated by ';'
+   // example: sigmas = "2; 4; 6;"  at Begin_Latex 2 #sigma End_Latex, Begin_Latex 4 #sigma End_Latex and Begin_Latex 6 #sigma End_Latex  a line is drawn.
+   // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see?
+   // 
+   Int_t oldOptStat = gStyle->GetOptStat();
+   gStyle->SetOptStat(0000000);
+   Double_t ltmFraction = 0.8;
+   
+   TObjArray *sigmasTokens = TString(sigmas).Tokenize(";");  
+   TVectorF nsigma(sigmasTokens->GetEntriesFast());
+   for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) {
+      TString str(((TObjString*)sigmasTokens->At(i))->GetString());
+      Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
+      nsigma[i] = sig;
+   }
+   
+   TString drawStr(drawCommand);
+   Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>");
+   if (dangerousToDraw) {
+      Warning("DrawHisto1D", "The draw string must not contain ':' or '>>'.");
+      return -1;
+   }
+   drawStr += " >> tempHist";
+   Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts);
+   TH1F *htemp = (TH1F*)gDirectory->Get("tempHist");
+   // FIXME is this histogram deleted automatically?
+   Double_t *values = fTree->GetV1();  // value is the array containing 'entries' numbers
+   
+   Double_t mean = TMath::Mean(entries, values);
+   Double_t median = TMath::Median(entries, values);
+   Double_t sigma = TMath::RMS(entries, values);
+   Double_t maxY = htemp->GetMaximum();
+   
+   Char_t c[500];
+   TLegend * legend = new TLegend(.7,.7, .99, .99, "Statistical information");
+
+   if (plotMean) {
+      // draw Mean
+      TLine* line = new TLine(mean, 0, mean, maxY);
+      line->SetLineColor(kRed);
+      line->SetLineWidth(2);
+      line->SetLineStyle(1);
+      line->Draw();
+      sprintf(c, "Mean: %f", mean);
+      legend->AddEntry(line, c, "l");
+      // draw sigma lines
+      for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
+         TLine* linePlusSigma = new TLine(mean + nsigma[i] * sigma, 0, mean + nsigma[i] * sigma, maxY);
+         linePlusSigma->SetLineColor(kRed);
+         linePlusSigma->SetLineStyle(2 + i);
+         linePlusSigma->Draw();
+         TLine* lineMinusSigma = new TLine(mean - nsigma[i] * sigma, 0, mean - nsigma[i] * sigma, maxY);
+         lineMinusSigma->SetLineColor(kRed);
+         lineMinusSigma->SetLineStyle(2 + i);
+         lineMinusSigma->Draw();
+         sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma));
+         legend->AddEntry(lineMinusSigma, c, "l");
+      }
+   }
+   if (plotMedian) {
+      // draw median
+      TLine* line = new TLine(median, 0, median, maxY);
+      line->SetLineColor(kBlue);
+      line->SetLineWidth(2);
+      line->SetLineStyle(1);
+      line->Draw();
+      sprintf(c, "Median: %f", median);
+      legend->AddEntry(line, c, "l");
+      // draw sigma lines
+      for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
+         TLine* linePlusSigma = new TLine(median + nsigma[i] * sigma, 0, median + nsigma[i]*sigma, maxY);
+         linePlusSigma->SetLineColor(kBlue);
+         linePlusSigma->SetLineStyle(2 + i);
+         linePlusSigma->Draw();
+         TLine* lineMinusSigma = new TLine(median - nsigma[i] * sigma, 0, median - nsigma[i]*sigma, maxY);
+         lineMinusSigma->SetLineColor(kBlue);
+         lineMinusSigma->SetLineStyle(2 + i);
+         lineMinusSigma->Draw();
+         sprintf(c, "%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma));
+         legend->AddEntry(lineMinusSigma, c, "l");
+      }
+   }
+   if (plotLTM) {
+      // draw LTM
+      Double_t ltmRms = 0;
+      Double_t ltm = GetLTM(entries, values, &ltmRms, ltmFraction);
+      TLine* line = new TLine(ltm, 0, ltm, maxY);
+      //fListOfObjectsToBeDeleted->Add(line);
+      line->SetLineColor(kGreen+2);
+      line->SetLineWidth(2);
+      line->SetLineStyle(1);
+      line->Draw();
+      sprintf(c, "LTM: %f", ltm);
+      legend->AddEntry(line, c, "l");
+      // draw sigma lines
+      for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
+         TLine* linePlusSigma = new TLine(ltm + nsigma[i] * ltmRms, 0, ltm + nsigma[i] * ltmRms, maxY);
+         //fListOfObjectsToBeDeleted->Add(linePlusSigma);
+         linePlusSigma->SetLineColor(kGreen+2);
+         linePlusSigma->SetLineStyle(2+i);
+         linePlusSigma->Draw();
+   
+         TLine* lineMinusSigma = new TLine(ltm - nsigma[i] * ltmRms, 0, ltm - nsigma[i] * ltmRms, maxY);
+         //fListOfObjectsToBeDeleted->Add(lineMinusSigma);
+         lineMinusSigma->SetLineColor(kGreen+2);
+         lineMinusSigma->SetLineStyle(2+i);
+         lineMinusSigma->Draw();
+         sprintf(c, "%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms));
+         legend->AddEntry(lineMinusSigma, c, "l");
+      }
+   }
+   if (!plotMean && !plotMedian && !plotLTM) return -1;
+   legend->Draw();
+   gStyle->SetOptStat(oldOptStat);
+   return 1;
+}
+
+//_____________________________________________________________________________
+Int_t AliBaseCalibViewer::SigmaCut(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts, 
+                                  Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, 
+                                  const Char_t *sigmas, Float_t sigmaStep) const {
+   //
+   // Creates a histogram, where you can see, how much of the data are inside sigma-intervals 
+   // around the mean/median/LTM
+   // with drawCommand, sector and cuts you specify your input data, see EasyDraw
+   // sigmaMax: up to which sigma around the mean/median/LTM the histogram is generated (in units of sigma)
+   // sigmaStep: the binsize of the generated histogram
+   // plotMean/plotMedian/plotLTM: specifies where to put the center
+   //
+  
+   Double_t ltmFraction = 0.8;
+   
+   TString drawStr(drawCommand);
+   Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>");
+   if (dangerousToDraw) {
+      Warning("SigmaCut", "The draw string must not contain ':' or '>>'.");
+      return -1;
+   }
+   drawStr += " >> tempHist";
+   
+   Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff");
+   TH1F *htemp = (TH1F*)gDirectory->Get("tempHist");
+   // FIXME is this histogram deleted automatically?
+   Double_t *values = fTree->GetV1();  // value is the array containing 'entries' numbers
+   
+   Double_t mean = TMath::Mean(entries, values);
+   Double_t median = TMath::Median(entries, values);
+   Double_t sigma = TMath::RMS(entries, values);
+   
+   TLegend * legend = new TLegend(.7,.7, .99, .99, "Cumulative");
+   //fListOfObjectsToBeDeleted->Add(legend);
+   TH1F *cutHistoMean = 0;
+   TH1F *cutHistoMedian = 0;
+   TH1F *cutHistoLTM = 0;
+   
+   TObjArray *sigmasTokens = TString(sigmas).Tokenize(";");  
+   TVectorF nsigma(sigmasTokens->GetEntriesFast());
+   for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) {
+      TString str(((TObjString*)sigmasTokens->At(i))->GetString());
+      Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
+      nsigma[i] = sig;
+   }
+  
+   if (plotMean) {
+      cutHistoMean = SigmaCut(htemp, mean, sigma, sigmaMax, sigmaStep, pm);
+      if (cutHistoMean) {
+         //fListOfObjectsToBeDeleted->Add(cutHistoMean);
+         cutHistoMean->SetLineColor(kRed);
+         legend->AddEntry(cutHistoMean, "Mean", "l");
+         cutHistoMean->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         cutHistoMean->Draw();
+         DrawLines(cutHistoMean, nsigma, legend, kRed, pm);
+      } // if (cutHistoMean)
+       
+   }
+   if (plotMedian) {
+      cutHistoMedian = SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm);
+      if (cutHistoMedian) {
+         //fListOfObjectsToBeDeleted->Add(cutHistoMedian);
+         cutHistoMedian->SetLineColor(kBlue);
+         legend->AddEntry(cutHistoMedian, "Median", "l");
+         cutHistoMedian->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         if (plotMean && cutHistoMean) cutHistoMedian->Draw("same");
+            else cutHistoMedian->Draw();
+         DrawLines(cutHistoMedian, nsigma, legend, kBlue, pm);
+      }  // if (cutHistoMedian)
+   }
+   if (plotLTM) {
+      Double_t ltmRms = 0;
+      Double_t ltm = GetLTM(entries, values, &ltmRms, ltmFraction);
+      cutHistoLTM = SigmaCut(htemp, ltm, ltmRms, sigmaMax, sigmaStep, pm);
+      if (cutHistoLTM) {
+         //fListOfObjectsToBeDeleted->Add(cutHistoLTM);
+         cutHistoLTM->SetLineColor(kGreen+2);
+         legend->AddEntry(cutHistoLTM, "LTM", "l");
+         cutHistoLTM->SetTitle(Form("%s, cumulative; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         if ((plotMean && cutHistoMean) || (plotMedian && cutHistoMedian)) cutHistoLTM->Draw("same");
+            else cutHistoLTM->Draw();
+         DrawLines(cutHistoLTM, nsigma, legend, kGreen+2, pm);
+      }
+   }
+   if (!plotMean && !plotMedian && !plotLTM) return -1;
+   legend->Draw();
+   return 1;
+}
+
+//_____________________________________________________________________________
+Int_t AliBaseCalibViewer::Integrate(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts, 
+                                   Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, 
+                                   const Char_t *sigmas, Float_t sigmaStep) const {
+   //
+   // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram"   
+   // "mean" and "sigma" are Begin_Latex #mu End_Latex and  Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user
+   // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate 
+   // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated
+   // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used
+   // The actual work is done on the array.
+   /* Begin_Latex 
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #frac{#int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx }
+      End_Latex  
+   */
+   
+   Double_t ltmFraction = 0.8;
+   // avoid compiler warnings:
+   sigmaMax = sigmaMax;
+   sigmaStep = sigmaStep;
+   
+   TString drawStr(drawCommand);
+   Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>");
+   if (dangerousToDraw) {
+      Warning("Integrate", "The draw string must not contain ':' or '>>'.");
+      return -1;
+   }
+   drawStr += " >> tempHist";
+   
+   Int_t entries = EasyDraw1D(drawStr.Data(), sector, cuts, "goff");
+   TH1F *htemp = (TH1F*)gDirectory->Get("tempHist");
+   TGraph *integralGraphMean   = 0;
+   TGraph *integralGraphMedian = 0;
+   TGraph *integralGraphLTM    = 0;
+   Double_t *values = fTree->GetV1();  // value is the array containing 'entries' numbers
+   Int_t    *index  = new Int_t[entries];
+   Float_t  *xarray = new Float_t[entries];
+   Float_t  *yarray = new Float_t[entries];
+   TMath::Sort(entries, values, index, kFALSE);
+   
+   Double_t mean = TMath::Mean(entries, values);
+   Double_t median = TMath::Median(entries, values);
+   Double_t sigma = TMath::RMS(entries, values);
+   
+   // parse sigmas string
+   TObjArray *sigmasTokens = TString(sigmas).Tokenize(";");  
+   TVectorF nsigma(sigmasTokens->GetEntriesFast());
+   for (Int_t i = 0; i < sigmasTokens->GetEntriesFast(); i++) {
+      TString str(((TObjString*)sigmasTokens->At(i))->GetString());
+      Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
+      nsigma[i] = sig;
+   }
+  
+   TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram");
+   //fListOfObjectsToBeDeleted->Add(legend);
+  
+   if (plotMean) {
+      for (Int_t i = 0; i < entries; i++) {
+         xarray[i] = (values[index[i]] - mean) / sigma; 
+         yarray[i] = float(i) / float(entries);
+      }
+      integralGraphMean = new TGraph(entries, xarray, yarray);
+      if (integralGraphMean) {
+         //fListOfObjectsToBeDeleted->Add(integralGraphMean);
+         integralGraphMean->SetLineColor(kRed);
+         legend->AddEntry(integralGraphMean, "Mean", "l");
+         integralGraphMean->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         integralGraphMean->Draw("alu");
+         DrawLines(integralGraphMean, nsigma, legend, kRed, kTRUE);
+      }
+   }
+   if (plotMedian) {
+      for (Int_t i = 0; i < entries; i++) {
+         xarray[i] = (values[index[i]] - median) / sigma; 
+         yarray[i] = float(i) / float(entries);
+      }
+      integralGraphMedian = new TGraph(entries, xarray, yarray);
+      if (integralGraphMedian) {
+         //fListOfObjectsToBeDeleted->Add(integralGraphMedian);
+         integralGraphMedian->SetLineColor(kBlue);
+         legend->AddEntry(integralGraphMedian, "Median", "l");
+         integralGraphMedian->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         if (plotMean && integralGraphMean) integralGraphMedian->Draw("samelu");
+            else integralGraphMedian->Draw("alu");
+         DrawLines(integralGraphMedian, nsigma, legend, kBlue, kTRUE);
+      }
+   }
+   if (plotLTM) {
+      Double_t ltmRms = 0;
+      Double_t ltm = GetLTM(entries, values, &ltmRms, ltmFraction);
+      for (Int_t i = 0; i < entries; i++) {
+         xarray[i] = (values[index[i]] - ltm) / ltmRms; 
+         yarray[i] = float(i) / float(entries);
+      }
+      integralGraphLTM = new TGraph(entries, xarray, yarray);
+      if (integralGraphLTM) {
+         //fListOfObjectsToBeDeleted->Add(integralGraphLTM);
+         integralGraphLTM->SetLineColor(kGreen+2);
+         legend->AddEntry(integralGraphLTM, "LTM", "l");
+         integralGraphLTM->SetTitle(Form("%s, integrated; Multiples of #sigma; Fraction of included data", htemp->GetTitle()));
+         if ((plotMean && integralGraphMean) || (plotMedian && integralGraphMedian)) integralGraphLTM->Draw("samelu");
+            else integralGraphLTM->Draw("alu");
+         DrawLines(integralGraphLTM, nsigma, legend, kGreen+2, kTRUE);
+      }
+   }
+   if (!plotMean && !plotMedian && !plotLTM) return -1;
+   legend->Draw();
+   return entries;
+}
+
+//_____________________________________________________________________________
+TH1F* AliBaseCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){
+   //
+   // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram"   
+   // "mean" and "sigma" are Begin_Latex #mu End_Latex and  Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user
+   // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate 
+   // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated
+   // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used
+   // The actual work is done on the array.
+   /* Begin_Latex 
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #frac{#int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx}{ #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx }
+      End_Latex  
+      begin_macro(source)
+      {
+         Float_t mean = 0;
+         Float_t sigma = 1.5;
+         Float_t sigmaMax = 4;
+         gROOT->SetStyle("Plain");
+         TH1F *distribution = new TH1F("Distribution2", "Distribution f(x, #mu, #sigma)", 1000,-5,5);
+         TRandom rand(23);
+         for (Int_t i = 0; i <50000;i++) distribution->Fill(rand.Gaus(mean, sigma));
+         Float_t *ar = distribution->GetArray();
+         
+         TCanvas* macro_example_canvas = new TCanvas("macro_example_canvas_Integrate", "", 350, 350);
+         macro_example_canvas->Divide(0,2);
+         TVirtualPad *pad1 = macro_example_canvas->cd(1);
+         pad1->SetGridy();
+         pad1->SetGridx();
+         distribution->Draw();
+         TVirtualPad *pad2 = macro_example_canvas->cd(2);
+         pad2->SetGridy();
+         pad2->SetGridx();
+         TH1F *shist = AliTPCCalibViewer::Integrate(distribution, mean, sigma, sigmaMax);
+         shist->SetNameTitle("Cumulative","Cumulative S(t, #mu, #sigma)");
+         shist->Draw();  
+         
+         return macro_example_canvas_Integrate;
+      }  
+      end_macro
+   */ 
+
+   
+   Float_t *array = histogram->GetArray();
+   Int_t    nbins = histogram->GetXaxis()->GetNbins();
+   Float_t binLow = histogram->GetXaxis()->GetXmin();
+   Float_t binUp  = histogram->GetXaxis()->GetXmax();
+   return Integrate(nbins, array, nbins, binLow, binUp, mean, sigma, sigmaMax, sigmaStep);
+}
+
+//_____________________________________________________________________________
+TH1F* AliBaseCalibViewer::Integrate(Int_t n, Float_t *array, Int_t nbins, Float_t binLow, Float_t binUp, 
+                                   Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){
+   // Creates an integrated histogram Begin_Latex S(t, #mu, #sigma) End_Latex, out of the input distribution distribution Begin_Latex f(x, #mu, #sigma) End_Latex, given in "histogram"   
+   // "mean" and "sigma" are Begin_Latex #mu End_Latex and  Begin_Latex #sigma End_Latex of the distribution in "histogram", to be specified by the user
+   // sigmaMax: up to which sigma around the mean/median/LTM you want to integrate 
+   // if "igma == 0" and "sigmaMax == 0" the whole histogram is integrated
+   // "sigmaStep": the binsize of the generated histogram, -1 means, that the maximal reasonable stepsize is used
+   // Here the actual work is done.
+      
+   Bool_t givenUnits = kTRUE;
+   if (TMath::Abs(sigma) < 1.e-10 && TMath::Abs(sigmaMax) < 1.e-10) givenUnits = kFALSE;
+   if (givenUnits) {
+      sigma = 1;
+      sigmaMax = (binUp - binLow) / 2.;
+   }
+   
+   Float_t binWidth = (binUp-binLow)/(nbins - 1);
+   if (sigmaStep <= 0) sigmaStep = binWidth;
+   Int_t kbins =  (Int_t)(sigmaMax * sigma / sigmaStep) + 1;  // + 1  due to overflow bin in histograms
+   Float_t kbinLow = givenUnits ? binLow : -sigmaMax;
+   Float_t kbinUp  = givenUnits ? binUp  : sigmaMax;
+   TH1F *hist = 0; 
+   if (givenUnits)  hist = new TH1F("integratedHisto","Integrated Histogram; Given x; Fraction of included data", kbins, kbinLow, kbinUp); 
+   if (!givenUnits) hist = new TH1F("integratedHisto","Integrated Histogram; Multiples of #sigma; Fraction of included data", kbins, kbinLow, kbinUp); 
+   hist->SetDirectory(0);
+   hist->Reset();
+   
+   // calculate normalization
+ //  printf("calculating normalization, integrating from bin 1 to %i \n", n);
+   Double_t normalization = 0;
+   for (Int_t i = 1; i <= n; i++) {
+        normalization += array[i];
+   }
+ //  printf("normalization: %f \n", normalization);
+   
+   // given units: units from given histogram
+   // sigma units: in units of sigma
+   // iDelta: integrate in interval (mean +- iDelta), given units
+   // x:      ofset from mean for integration, given units
+   // hist:   needs 
+   
+   // fill histogram
+   for (Float_t iDelta = mean - sigmaMax * sigma; iDelta <= mean + sigmaMax * sigma; iDelta += sigmaStep) {
+      // integrate array
+      Double_t value = 0;
+      for (Float_t x = mean - sigmaMax * sigma; x <= iDelta; x += binWidth) {
+         value += (x <= binUp && x >= binLow)  ? array[GetBin(x, nbins, binLow, binUp)] : 0;
+      }
+      if (value / normalization > 100) printf("+++ Error, value to big: %f, normalization with %f will fail  +++ \n", value, normalization);
+      if (value / normalization > 100) return hist;
+      Int_t bin = GetBin(iDelta/sigma, kbins, kbinLow, kbinUp);
+    //  printf("first integration bin: %i, last integration bin: %i \n", GetBin(mean - sigmaMax * sigma, nbins, binLow, binUp), GetBin(iDelta, nbins, binLow, binUp));
+    //  printf("value: %f, normalization: %f, normalized value: %f, iDelta: %f, Bin: %i \n", value, normalization, value/normalization, iDelta, bin);
+      value = (value / normalization);
+      hist->SetBinContent(bin, value);
+   }
+   return hist;
+}
+
+//_____________________________________________________________________________
+void AliBaseCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const {
+   // 
+   // Private function for SigmaCut(...) and Integrate(...)
+   // Draws lines into the given histogram, specified by "nsigma", the lines are addeed to the legend
+   // 
+   
+   // start to draw the lines, loop over requested sigmas
+   Char_t c[500];
+   for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
+      if (!pm) { 
+         Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
+         TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineUp);
+         lineUp->SetLineColor(color);
+         lineUp->SetLineStyle(2 + i);
+         lineUp->Draw();
+         TLine* lineLeft = new TLine(nsigma[i], histogram->GetBinContent(bin), 0, histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineLeft);
+         lineLeft->SetLineColor(color);
+         lineLeft->SetLineStyle(2 + i);
+         lineLeft->Draw();
+         sprintf(c, "Fraction(%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin));
+         legend->AddEntry(lineLeft, c, "l");
+      }
+      else { // if (pm)
+         Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
+         TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineUp1);
+         lineUp1->SetLineColor(color);
+         lineUp1->SetLineStyle(2 + i);
+         lineUp1->Draw();
+         TLine* lineLeft1 = new TLine(nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineLeft1);
+         lineLeft1->SetLineColor(color);
+         lineLeft1->SetLineStyle(2 + i);
+         lineLeft1->Draw();
+         sprintf(c, "Fraction(+%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin));
+         legend->AddEntry(lineLeft1, c, "l");
+         bin = histogram->GetXaxis()->FindBin(-nsigma[i]);
+         TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineUp2);
+         lineUp2->SetLineColor(color);
+         lineUp2->SetLineStyle(2 + i);
+         lineUp2->Draw();
+         TLine* lineLeft2 = new TLine(-nsigma[i], histogram->GetBinContent(bin), histogram->GetBinLowEdge(0)+histogram->GetBinWidth(0), histogram->GetBinContent(bin));
+         //fListOfObjectsToBeDeleted->Add(lineLeft2);
+         lineLeft2->SetLineColor(color);
+         lineLeft2->SetLineStyle(2 + i);
+         lineLeft2->Draw();
+         sprintf(c, "Fraction(-%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin));
+         legend->AddEntry(lineLeft2, c, "l");
+      }
+   }  // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)   
+}
+
+//_____________________________________________________________________________
+void AliBaseCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const {
+   // 
+   // Private function for SigmaCut(...) and Integrate(...)
+   // Draws lines into the given histogram, specified by "nsigma", the lines are addeed to the legend
+   // 
+   
+   // start to draw the lines, loop over requested sigmas
+   Char_t c[500];
+   for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
+      if (!pm) { 
+         TLine* lineUp = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineUp);
+         lineUp->SetLineColor(color);
+         lineUp->SetLineStyle(2 + i);
+         lineUp->Draw();
+         TLine* lineLeft = new TLine(nsigma[i], graph->Eval(nsigma[i]), 0, graph->Eval(nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineLeft);
+         lineLeft->SetLineColor(color);
+         lineLeft->SetLineStyle(2 + i);
+         lineLeft->Draw();
+         sprintf(c, "Fraction(%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i]));
+         legend->AddEntry(lineLeft, c, "l");
+      }
+      else { // if (pm)
+         TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineUp1);
+         lineUp1->SetLineColor(color);
+         lineUp1->SetLineStyle(2 + i);
+         lineUp1->Draw();
+         TLine* lineLeft1 = new TLine(nsigma[i], graph->Eval(nsigma[i]), graph->GetHistogram()->GetXaxis()->GetBinLowEdge(0), graph->Eval(nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineLeft1);
+         lineLeft1->SetLineColor(color);
+         lineLeft1->SetLineStyle(2 + i);
+         lineLeft1->Draw();
+         sprintf(c, "Fraction(+%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i]));
+         legend->AddEntry(lineLeft1, c, "l");
+         TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], graph->Eval(-nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineUp2);
+         lineUp2->SetLineColor(color);
+         lineUp2->SetLineStyle(2 + i);
+         lineUp2->Draw();
+         TLine* lineLeft2 = new TLine(-nsigma[i], graph->Eval(-nsigma[i]), graph->GetHistogram()->GetXaxis()->GetBinLowEdge(0), graph->Eval(-nsigma[i]));
+         //fListOfObjectsToBeDeleted->Add(lineLeft2);
+         lineLeft2->SetLineColor(color);
+         lineLeft2->SetLineStyle(2 + i);
+         lineLeft2->Draw();
+         sprintf(c, "Fraction(-%f #sigma) = %f",nsigma[i], graph->Eval(-nsigma[i]));
+         legend->AddEntry(lineLeft2, c, "l");
+      }
+   }  // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)   
+}
diff --git a/STEER/AliBaseCalibViewer.h b/STEER/AliBaseCalibViewer.h
new file mode 100644 (file)
index 0000000..ac44dd0
--- /dev/null
@@ -0,0 +1,120 @@
+#ifndef ALIBASECALIBVIEWER_H
+#define ALIBASECALIBVIEWER_H
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Base class for the AliTPCCalibViewer and AliTRDCalibViewer               //
+//  used for the calibration monitor                                         //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+#include <TTree.h>
+#include <TFile.h>
+#include "TFriendElement.h"
+
+#include "AliMathBase.h"
+
+class TLegend;
+
+class AliBaseCalibViewer : public TObject {
+ public:
+   AliBaseCalibViewer();
+   AliBaseCalibViewer(const AliBaseCalibViewer &c);
+   AliBaseCalibViewer(TTree* tree);
+   AliBaseCalibViewer(const Char_t* fileName, const Char_t* treeName = "tree");
+   AliBaseCalibViewer &operator = (const AliBaseCalibViewer & param);
+   virtual ~AliBaseCalibViewer();
+   virtual void Delete(Option_t* option = "");
+
+   TString& GetAbbreviation()  { return fAbbreviation;  }
+   TString& GetAppendString()  { return fAppendString; }
+   void SetAbbreviation(const Char_t* abr) { fAbbreviation = abr; }
+   void SetAppendString(const Char_t* str) { fAppendString = str; }
+
+   //virtual void GetTimeInfoOCDB(const Char_t* runList, const Char_t* outFile,
+                                //Int_t firstRun, Int_t lastRun, UInt_t infoFlags,
+                                //const Char_t* ocdbStorage) = 0;
+
+   virtual void     Draw(Option_t* opt="") { fTree->Draw(opt); }
+   virtual Long64_t Draw(const Char_t* varexp, const TCut& selection, Option_t* option = "", 
+                        Long64_t nentries = 1000000000, Long64_t firstentry = 0) { 
+     return fTree->Draw(varexp, selection, option, nentries, firstentry); 
+   };
+   virtual Long64_t Draw(const Char_t* varexp, const Char_t* selection, Option_t* option = "", 
+                        Long64_t nentries = 1000000000, Long64_t firstentry = 0) { 
+     return fTree->Draw(varexp, selection, option, nentries, firstentry); 
+   };
+
+   virtual const char* AddAbbreviations(Char_t* c, Bool_t printDrawCommand = kFALSE) = 0;
+   // easy drawing of data, use '~' for abbreviation of '.fElements'
+   virtual Int_t EasyDraw(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0, 
+                         const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;   
+   // easy drawing of data, use '~' for abbreviation of '.fElements'
+   virtual Int_t EasyDraw(const Char_t* drawCommand, Int_t sector, const Char_t* cuts = 0, 
+                         const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;   
+   // easy drawing of data, use '~' for abbreviation of '.fElements'
+   virtual Int_t EasyDraw1D(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0, 
+                           const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;   
+   // easy drawing of data, use '~' for abbreviation of '.fElements'
+   virtual Int_t EasyDraw1D(const Char_t* drawCommand, Int_t sector, const Char_t* cuts = 0, 
+                           const Char_t* drawOptions = 0, Bool_t writeDrawCommand = kFALSE) const = 0;   
+   // formats title and axis labels of histo, removes '.fElements'
+   void FormatHistoLabels(TH1 *histo) const;   
+   // draws 1d histograms and superimposes mean, median, ltm and several sigma cuts
+   Int_t  DrawHisto1D(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0, 
+                     const Char_t *sigmas = "2;4;6", Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, 
+                     Bool_t plotLTM = kTRUE) const; 
+   // draws fraction of used pads over different sigma cuts
+   Int_t     SigmaCut(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0, 
+                     Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, 
+                     Bool_t plotLTM = kTRUE, Bool_t pm = kFALSE, const Char_t *sigmas = "", 
+                     Float_t sigmaStep = -1) const;    
+   // draws an integrated histogram
+   Int_t    Integrate(const Char_t* drawCommand, const Char_t* sector, const Char_t* cuts = 0, 
+                     Float_t sigmaMax = 5, Bool_t plotMean = kTRUE, Bool_t plotMedian = kTRUE, 
+                     Bool_t plotLTM = kTRUE, const Char_t *sigmas = "", Float_t sigmaStep = -1) const;    
+
+   virtual TObjArray* GetListOfVariables(Bool_t printList = kFALSE) = 0;
+   virtual TObjArray* GetListOfNormalizationVariables(Bool_t printList = kFALSE) const = 0;
+
+   TFriendElement* AddReferenceTree(const Char_t* filename, const Char_t* treename = "tree", const Char_t* refname = "R");
+   TFriendElement* AddFriend(const Char_t* treename, const Char_t* filename) 
+   {return fTree->AddFriend(treename, filename);};
+   TFriendElement* AddFriend(TTree* tree, const Char_t* alias, Bool_t warn=kFALSE) 
+   {return fTree->AddFriend(tree, alias, warn);};
+   TFriendElement* AddFriend(const Char_t* treename, TFile* file) 
+   {return fTree->AddFriend(treename, file);};
+   TTree * GetTree() const { return fTree;}
+
+   TString* Fit(const Char_t* drawCommand, const Char_t* formula, const Char_t* cuts, 
+               Double_t & chi2, TVectorD &fitParam, TMatrixD &covMatrix);
+   static Double_t GetLTM(Int_t n, Double_t *array, Double_t *sigma = 0, Double_t fraction = 0.9);
+   static Int_t GetBin(Float_t value, Int_t nbins, Double_t binLow, Double_t binUp);
+   static TH1F* SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t sigma, Int_t nbins, 
+                        Float_t binLow, Float_t binUp, Float_t sigmaMax, Float_t sigmaStep = -1, Bool_t pm = kFALSE);
+   static TH1F* SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, 
+                        Float_t sigmaStep = -1, Bool_t pm = kFALSE);
+   static TH1F* Integrate(TH1F *histogram, Float_t mean = 0, Float_t sigma = 0, 
+                         Float_t sigmaMax = 0, Float_t sigmaStep = -1);
+   static TH1F* Integrate(Int_t n, Float_t *array, Int_t nbins, Float_t binLow, Float_t binUp, 
+                         Float_t mean = 0, Float_t sigma = 0, Float_t sigmaMax = 0, Float_t sigmaStep = -1);
+   static TH1F* SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma, 
+                        Int_t nbins, Double_t *xbins, Double_t sigmaMax);
+
+ protected:
+   TTree* fTree;     // tree containing visualization data (e.g. written by AliTPCCalPad::MakeTree(...)
+   TFile* fFile;     // file that contains a calPads tree (e.g. written by AliTPCCalPad::MakeTree(...)
+   TObjArray* fListOfObjectsToBeDeleted;  //Objects, that will be deleted when the destructor ist called
+   Bool_t fTreeMustBeDeleted;  // decides weather the tree must be deleted in destructor or not 
+   TString fAbbreviation;       // the abreviation for '.fElements'
+   TString fAppendString;      // '.fElements', stored in a TStrig
+   
+   void DrawLines(TH1F *cutHistoMean, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
+   void DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legend, Int_t color, Bool_t pm) const;
+   
+   
+   ClassDef(AliBaseCalibViewer,1)    //  Base calibration viewer class
+};
+
+#endif
diff --git a/STEER/AliBaseCalibViewerGUI.cxx b/STEER/AliBaseCalibViewerGUI.cxx
new file mode 100644 (file)
index 0000000..f0d75d2
--- /dev/null
@@ -0,0 +1,1390 @@
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Base class for the AliTPCCalibViewer and AliTRDCalibViewer               //
+//  used for the calibration monitor                                         //
+//                                                                           //
+//  Authors:     Marian Ivanov (Marian.Ivanov@cern.ch)                       //
+//               Jens Wiechula (Jens.Wiechula@cern.ch)                       //
+//               Ionut Arsene  (iarsene@cern.ch)                             //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TROOT.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TVector.h>
+#include <string.h>
+#include <TH1.h>
+#include <TStyle.h>
+#include <TGFileDialog.h>
+#include <TGInputDialog.h>
+#include <TGWidget.h>
+#include <TGFrame.h>
+#include <TGButton.h>
+#include <TGListBox.h>
+#include <TGComboBox.h>
+#include <TGNumberEntry.h>
+#include <TRootEmbeddedCanvas.h>
+#include <TGSplitter.h>
+#include <TGButtonGroup.h>
+#include <TGLabel.h>
+#include <TGTab.h>
+#include <TString.h>
+
+#include "AliBaseCalibViewerGUI.h"
+
+ClassImp(AliBaseCalibViewerGUI)
+
+//________________________________________________________________________________________
+AliBaseCalibViewerGUI::AliBaseCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h)
+  : TGCompositeFrame(p, w, h),
+    fViewer(0),
+    fContTopBottom(0),
+    fContLCR(0),
+    fContLeft(0),
+    ftabLeft(0),
+    ftabLeft0(0),
+    ftabLeft1(0),
+    ftabRight(0),
+    fTabRight0(0),
+    fTabRight1(0),
+    fContRight(0),
+    fContCenter(0),
+    fContPlotOpt(0),
+    fContDrawOpt(0),
+    fContDrawOptSub1D2D(0),
+    fContNormalized(0),
+    fContCustom(0),
+    fContCuts(0),
+    fContAddCuts(0),
+    fContFit(0),
+    fContAddFit(0),
+    fContScaling(0),
+    fContSetMax(0),
+    fContSetMin(0),
+    fContAddDrawOpt(0),
+    fListVariables(0),
+    fBtnDraw(0),
+    fBtnFit(0),
+    fBtnAddFitFunction(0),
+    fBtnGetMinMax(0),
+    fCanvMain(0),
+    fRadioRaw(0),
+    fRadioNormalized(0),
+    fRadioPredefined(0),
+    fRadioCustom(0),
+    fRadio1D(0),
+    fRadio2D(0),
+    fComboAddDrawOpt(0),
+    fChkAuto(0),
+    fChkAutoAppend(0),
+    fComboMethod(0),
+    fListNormalization(0),
+    fComboCustom(0),
+    fLblCustomDraw(0),
+    fChkAddDrawOpt(0),
+    fLblAddCuts(0),
+    fComboAddCuts(0), 
+    fComboCustomFit(0),
+    fChkSetMax(0),
+    fChkSetMin(0),
+    fChkGetMinMaxAuto(0),
+    fTxtSetMax(0),
+    fTxtSetMin(0) ,
+    fContDrawOpt1D(0), 
+    fcontDrawOpt1DSubLR(0),
+    fContDrawOpt1DSubNSC(0), 
+    fRadioNorm(0),
+    fRadioSigma(0),
+    fTxtSigmas(0),
+    fContCumuLR(0),
+    fContCumLeft(0),
+    fContCumRight(0),
+    fLblSigmaMax(0),
+    fTxtSigmaMax(0),
+    fRadioCumulative(0),
+    fCheckCumulativePM(0),
+    fRadioIntegrate(0),
+    fContDrawOpt1DSubMML(0),
+    fChkMean(0),
+    fChkMedian(0),
+    fChkLTM(0),
+    fContStatOpt(0),
+    fChkStatName(0),
+    fChkStatEntries(0),
+    fContStatMean(0),
+    fChkStatMean(0),
+    fChkStatMeanPM(0),
+    fContStatRMS(0),
+    fChkStatRMS(0),
+    fChkStatRMSPM(0),
+    fChkStatUnderflow(0),
+    fChkStatOverflow(0),
+    fChkStatIntegral(0),
+    fContStatSkew(0),
+    fChkStatSkewness(0),
+    fChkStatSkewnessPM(0),
+    fContStatKurt(0),
+    fChkStatKurtosis(0),
+    fChkStatKurtosisPM(0),
+    fBtnUnchekAll(0),
+    fContLabeling(0),
+    fChkLabelTitle(0),
+    fTxtLabelTitle(0),
+    fChkLabelXaxis(0),
+    fTxtLabelXaxis(0),
+    fChkLabelYaxis(0),
+    fTxtLabelYaxis(0),
+    fChkLabelGetAuto(0),
+    fContSave(0),
+    fBtnSave(0),
+    fContAddSaveOpt(0),
+    fChkAddSaveOpt(0),
+    fComboAddSaveOpt(0),
+    fContExport(0),
+    fContAddExport(0),
+    fComboExportName(0),
+    fBtnExport(0),
+    fBtnAddNorm(0), 
+    fContTree(0),
+    fBtnDumpToFile(0),
+    fBtnLoadTree(0),
+    fChkAddAsReference(0),
+    fTxtRefName(0), 
+    fInitialized(0)
+{
+   //
+   // AliBaseCalibViewerGUI constructor; fileName specifies the ROOT tree used for drawing 
+   //
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::DrawGUI(const TGWindow *p, UInt_t w, UInt_t h) {
+   // 
+   // draw the GUI
+   // 
+   // ======================================================================   
+   // ************************* Display everything *************************
+   // ======================================================================
+   
+   SetCleanup(kDeepCleanup);
+   p = p; // to avoid compiler warnings
+
+   // *****************************************************************************
+   // ************************* content of this MainFrame *************************
+   // *****************************************************************************
+   // top level container with horizontal layout
+   fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
+   AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+   
+   fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
+   fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+   
+   // ***********************************************************************
+   // ************************* content of fContLCR *************************
+   // ***********************************************************************
+   // left container
+   fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+   fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
+   
+   // left vertical splitter
+   TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
+   splitLeft->SetFrame(fContLeft, kTRUE);
+   fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
+
+   // right container
+   fContRight = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+   fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
+   
+   // center container
+   fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+   fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+
+   // right vertical splitter
+   TGVSplitter *splitRight = new TGVSplitter(fContLCR);
+   splitRight->SetFrame(fContRight, kFALSE);
+   fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
+   
+   
+   // ========================================================================
+   // ************************* content of fContLeft *************************
+   // ========================================================================
+   // --- draw button and tabLeft ---
+   // draw button
+   fBtnDraw = new TGTextButton(fContLeft, "&Draw");
+   fContLeft->AddFrame(fBtnDraw, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
+   //fBtnDraw->Connect("Clicked()", "AliTPCCalibViewerGUI", this, "DoTest(=\"fBtnDraw clicked\")");
+   fBtnDraw->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoDraw()");
+   fBtnDraw->SetToolTipText("Press here to draw according to selections.");
+   
+   // tabs on the left side:
+   ftabLeft = new TGTab(fContLeft);
+   fContLeft->AddFrame(ftabLeft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
+   ftabLeft0 = ftabLeft->AddTab("General");
+   ftabLeft1 = ftabLeft->AddTab("More plot options");
+
+   
+      // **************************** content of tabLeft0 *******************************
+      
+      // draw options container *** fcontDrawOpt ***  " Plot options "
+      fContDrawOpt = new TGGroupFrame(ftabLeft0, "Plot options", kVerticalFrame | kFitWidth | kFitHeight);
+      ftabLeft0->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+      fContDrawOptSub1D2D = new TGCompositeFrame(fContDrawOpt, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
+      fContDrawOpt->AddFrame(fContDrawOptSub1D2D, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+         // ------------------------- content of fContDrawOpt -------------------------
+         // -- radio1D, radio2D, chkAuto
+         // 1D radio button
+         fRadio1D = new TGRadioButton(fContDrawOptSub1D2D, "1D", 30);
+         fContDrawOptSub1D2D->AddFrame(fRadio1D, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
+         fRadio1D->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+         fRadio1D->SetToolTipText("1D drawing \nSelect this if you want to have the full control for the custom draw.");
+         
+         // 2D radio button
+         fRadio2D = new TGRadioButton(fContDrawOptSub1D2D, "2D", 31);
+         fContDrawOptSub1D2D->AddFrame(fRadio2D, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
+         fRadio2D->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+         fRadio2D->SetToolTipText("2D drawing");
+         
+         // additional draw options container
+         fContAddDrawOpt = new TGCompositeFrame(fContDrawOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContDrawOpt->AddFrame(fContAddDrawOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+
+            //  content of --- fContAddDrawOpt ---
+            // addition draw options label
+            fChkAddDrawOpt = new TGCheckButton(fContAddDrawOpt, "Draw options:");
+            //fChkAddDrawOpt->SetTextJustify(kTextLeft);
+            fContAddDrawOpt->AddFrame(fChkAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
+            fChkAddDrawOpt->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+            fChkAddDrawOpt->SetToolTipText("Enter additional draw options like 'prof' or 'colz' here.\nBe careful with the option 'same' for 2D drawings as it will crash (ROOT feature).");
+            
+            // additional draw options combo box
+            fComboAddDrawOpt = new TGComboBox(fContAddDrawOpt);
+            fComboAddDrawOpt->Resize(0, fBtnDraw->GetDefaultHeight());
+            fComboAddDrawOpt->EnableTextInput(kTRUE);
+            fContAddDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fComboAddDrawOpt->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral(=14)");
+            fComboAddDrawOpt->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+                  
+         // automatic redraw check button
+         fChkAuto = new TGCheckButton(fContDrawOpt, "Auto redraw");
+         fContDrawOpt->AddFrame(fChkAuto, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
+         fChkAuto->SetToolTipText("Decide if you want an automatic redraw on each new selection.\nNot recommended on a slow machine, during remote connection or if your draw option is 'same'.");
+         
+         // automatic append ending check button
+         fChkAutoAppend = new TGCheckButton(fContDrawOpt, "Auto add appending");
+         fContDrawOpt->AddFrame(fChkAutoAppend, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
+         fChkAutoAppend->SetToolTipText("Tries to repair your custom draw string or custom cut string, if you forgot '~' or '.fElements' \nThis function may be buggy!");
+               
+      
+      // *** predefined radio button ***  " Predefined "
+      fRadioPredefined = new TGRadioButton(ftabLeft0, "Predefined: ", 13);
+      ftabLeft0->AddFrame(fRadioPredefined, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      fRadioPredefined->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+      fRadioPredefined->SetToolTipText("Draw predefined variables according to selection.");
+      
+      // list of variables
+      fListVariables = new TGListBox(ftabLeft0);
+      ftabLeft0->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
+      fListVariables->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+   
+      
+      // normalization options container *** fContPlotOpt ***
+      //fContPlotOpt = new TGCompositeFrame(fContLeft, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+      fContPlotOpt = new TGGroupFrame(ftabLeft0, "Normalization options", kVerticalFrame | kFitWidth | kFitHeight);
+      ftabLeft0->AddFrame(fContPlotOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 10, 0, 0, 0));
+
+         // ------------------------- content of fContPlotOpt -------------------------
+         // raw radio button
+         fRadioRaw = new TGRadioButton(fContPlotOpt, "Raw", 10);
+         fContPlotOpt->AddFrame(fRadioRaw, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         fRadioRaw->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+         fRadioRaw->SetToolTipText("Plot without normalization");
+      
+         // normalized radio button
+         fRadioNormalized = new TGRadioButton(fContPlotOpt, "Normalized", 11);
+         fContPlotOpt->AddFrame(fRadioNormalized, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         fRadioNormalized->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+         fRadioNormalized->SetToolTipText("Normalize data");
+      
+         // normalized options container *** fContNormalized ***
+         fContNormalized = new TGCompositeFrame(fContPlotOpt, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContPlotOpt->AddFrame(fContNormalized, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 15, 0, 0, 0));
+      
+            // --- content of fContNormalized ---
+            // --- combo box to select 'subtract' or 'divide', list of normalization variables
+            // method drop down combo box
+            fComboMethod = new TGComboBox(fContNormalized);
+            fComboMethod->Resize(0, fBtnDraw->GetDefaultHeight());
+            fContNormalized->AddFrame(fComboMethod, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fComboMethod->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+         
+            // list of normalization variables
+            fListNormalization = new TGListBox(fContNormalized);
+            fContNormalized->AddFrame(fListNormalization, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+            fListNormalization->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+
+      // custom radio button
+      fRadioCustom = new TGRadioButton(ftabLeft0, "Custom: ", 12);
+      ftabLeft0->AddFrame(fRadioCustom, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      fRadioCustom->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral()");
+      fRadioCustom->SetToolTipText("Draw data according to user specific text entry in the 'Custom Draw' line. Remember '~' (= '.fElements')!");
+      // custom options container is located further down
+      
+      // **************************** content of tabLeft1 *******************************
+      
+      // draw options container *** fcontDrawOpt1D ***  " Plot options "
+      fContDrawOpt1D = new TGGroupFrame(ftabLeft1, "1D Plot options", kVerticalFrame | kFitWidth | kFitHeight);
+      ftabLeft1->AddFrame(fContDrawOpt1D, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+      
+      fcontDrawOpt1DSubLR = new TGCompositeFrame(fContDrawOpt1D, 1, 1, kVerticalFrame | kFitWidth | kFitHeight);
+      fContDrawOpt1D->AddFrame(fcontDrawOpt1DSubLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+         // ***** content of fContDrawOpt1DSubLR *****
+         fContDrawOpt1DSubNSC = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
+         fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubNSC, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         
+            // --------------------------- content of fContDrawOpt1DSubNSC -----------------
+            fRadioNorm = new TGRadioButton(fContDrawOpt1DSubNSC, "Normal", 110);
+            fContDrawOpt1DSubNSC->AddFrame(fRadioNorm, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fRadioNorm->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+            fRadioNorm->SetToolTipText("Produce a normal 1D plot, a histogram of the selected data.");
+               
+            fRadioSigma = new TGRadioButton(fContDrawOpt1DSubNSC, "Sigma", 111);
+            fContDrawOpt1DSubNSC->AddFrame(fRadioSigma, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
+            fRadioSigma->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+            fRadioSigma->SetToolTipText("Draw a normal histogram, but also lines that indicate the mean/median/LTM \nand sigmas of the selected data.");
+
+            fTxtSigmas = new TGTextEntry(fContDrawOpt1DSubNSC, "2; 4; 6", 111);
+            fContDrawOpt1DSubNSC->AddFrame(fTxtSigmas, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
+            fTxtSigmas->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtons1D(=111)");
+            fTxtSigmas->SetToolTipText("Enter sigma intervals you would like to be indicated by lines. \nExample: '2; 4; 6'");
+               
+            fContCumuLR = new TGCompositeFrame(fContDrawOpt1DSubNSC, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
+            fContDrawOpt1DSubNSC->AddFrame(fContCumuLR, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
+            
+               fContCumLeft = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
+               fContCumuLR->AddFrame(fContCumLeft, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+                           
+                  fRadioCumulative = new TGRadioButton(fContCumLeft, "Cumulative", 112);
+                  fContCumLeft->AddFrame(fRadioCumulative, new TGLayoutHints(kLHintsNormal, 0, 10, 0, 0));
+                  fRadioCumulative->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+                  fRadioCumulative->SetToolTipText("Draw the cumulative (SigmaCut) of the given selection. \nThe data distribution is integrated, starting from the mean/median/LTM.");
+                  
+                  fCheckCumulativePM = new TGCheckButton(fContCumLeft, "Plus/Minus");
+                  fContCumLeft->AddFrame(fCheckCumulativePM, new TGLayoutHints(kLHintsNormal, 10, 15, 0, 0));
+                  fCheckCumulativePM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+                  fCheckCumulativePM->SetToolTipText("Decide whether you want the cumulative integration for each direction (+/-) \nor only for the absolute distance to the mean/median/LTM value.");
+                  
+                  fRadioIntegrate = new TGRadioButton(fContCumLeft, "Integrate", 113);
+                  fContCumLeft->AddFrame(fRadioIntegrate, new TGLayoutHints(kLHintsNormal, 0, 0, 5, 0));
+                  fRadioIntegrate->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+                  fRadioIntegrate->SetToolTipText("Draw the integral of the given selection.");
+                  
+               fContCumRight = new TGCompositeFrame(fContCumuLR, 200, 23, kVerticalFrame | kFitWidth | kFitHeight);
+               fContCumuLR->AddFrame(fContCumRight, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+               
+                  fLblSigmaMax = new TGLabel(fContCumRight, "SigmaMax:");
+                  fLblSigmaMax->SetTextJustify(kTextLeft);
+                  fContCumRight->AddFrame(fLblSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 5, 0, 0, 0));
+
+                  fTxtSigmaMax = new TGTextEntry(fContCumRight, "5", 112);
+                  fContCumRight->AddFrame(fTxtSigmaMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 10, 15, 0, 0));
+                  fTxtSigmaMax->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtons1D(=112)");
+                  fTxtSigmaMax->SetToolTipText("Enter up to which multiple of sigma you want to integrate.");
+             
+            
+         fContDrawOpt1DSubMML = new TGCompositeFrame(fcontDrawOpt1DSubLR, 200, 23, kHorizontalFrame | kFitWidth | kFitHeight);
+         fcontDrawOpt1DSubLR->AddFrame(fContDrawOpt1DSubMML, new TGLayoutHints(kLHintsExpandX, 0, 0, 5, 0));
+         
+            // -------------- content of fcontDrawOpt1DSubLR
+            fChkMean = new TGCheckButton(fContDrawOpt1DSubMML, "Mean");
+            fContDrawOpt1DSubMML->AddFrame(fChkMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkMean->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+            fChkMean->SetToolTipText("Activate Mean for Sigma/Cumulative/Integrate");
+
+            fChkMedian = new TGCheckButton(fContDrawOpt1DSubMML, "Median");
+            fContDrawOpt1DSubMML->AddFrame(fChkMedian, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkMedian->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+            fChkMedian->SetToolTipText("Activate Median for Sigma/Cumulative/Integrate");
+
+            fChkLTM = new TGCheckButton(fContDrawOpt1DSubMML, "LTM");
+            fContDrawOpt1DSubMML->AddFrame(fChkLTM, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkLTM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtons1D()");
+            fChkLTM->SetToolTipText("Activate LTM for Sigma/Cumulative/Integrate");
+            
+      
+      // statistic options container *** fcontStatOpt1D ***  " Statistic options "      
+      fContStatOpt = new TGGroupFrame(ftabLeft1, "Statistic options", kVerticalFrame | kFitWidth | kFitHeight);
+      ftabLeft1->AddFrame(fContStatOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+      
+         fChkStatName = new TGCheckButton(fContStatOpt, "Name");
+         fContStatOpt->AddFrame(fChkStatName, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkStatName->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+         fChkStatName->SetToolTipText("Display the name in the statistics legend.");
+      
+         fChkStatEntries = new TGCheckButton(fContStatOpt, "Entries");
+         fContStatOpt->AddFrame(fChkStatEntries, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkStatEntries->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+         fChkStatEntries->SetToolTipText("Display the number of entries in the statistics legend.");
+      
+         fContStatMean = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
+         fContStatOpt->AddFrame(fContStatMean, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+            fChkStatMean = new TGCheckButton(fContStatMean, "Mean");
+            fContStatMean->AddFrame(fChkStatMean, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkStatMean->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatMean->SetToolTipText("Display the mean value of the data in the statistics legend.");
+            
+            fChkStatMeanPM = new TGCheckButton(fContStatMean, "+- Error");
+            fContStatMean->AddFrame(fChkStatMeanPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
+            fChkStatMeanPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatMeanPM->SetToolTipText("Display the mean value's error in the statistics legend.");
+
+         fContStatRMS = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
+         fContStatOpt->AddFrame(fContStatRMS, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+            fChkStatRMS = new TGCheckButton(fContStatRMS, "RMS");
+            fContStatRMS->AddFrame(fChkStatRMS, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkStatRMS->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatRMS->SetToolTipText("Display the RMS value of the data in the statistics legend.");
+            
+            fChkStatRMSPM = new TGCheckButton(fContStatRMS, "+- Error");
+            fContStatRMS->AddFrame(fChkStatRMSPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
+            fChkStatRMSPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatRMSPM->SetToolTipText("Display the RMS value's error in the statistics legend.");
+
+         fChkStatUnderflow = new TGCheckButton(fContStatOpt, "Underflow");
+         fContStatOpt->AddFrame(fChkStatUnderflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkStatUnderflow->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+         fChkStatUnderflow->SetToolTipText("Display the number of entries in the underflow bin.");
+      
+         fChkStatOverflow = new TGCheckButton(fContStatOpt, "Overflow");
+         fContStatOpt->AddFrame(fChkStatOverflow, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkStatOverflow->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+         fChkStatOverflow->SetToolTipText("Display the number of entries in the overflow bin.");
+      
+         fChkStatIntegral = new TGCheckButton(fContStatOpt, "Integral");
+         fContStatOpt->AddFrame(fChkStatIntegral, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkStatIntegral->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+         fChkStatIntegral->SetToolTipText("Display the integral of the data in the statistics legend.");
+      
+         fContStatSkew = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
+         fContStatOpt->AddFrame(fContStatSkew, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+            fChkStatSkewness = new TGCheckButton(fContStatSkew, "Skewness");
+            fContStatSkew->AddFrame(fChkStatSkewness, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkStatSkewness->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatSkewness->SetToolTipText("Display the skewness of the data in the statistics legend. \nBe careful! Sometimes the skewness causes a floating point exception that hangs the GUI!");
+            
+            fChkStatSkewnessPM = new TGCheckButton(fContStatSkew, "+- Error");
+            fContStatSkew->AddFrame(fChkStatSkewnessPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
+            fChkStatSkewnessPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatSkewnessPM->SetToolTipText("Display the skewness' error in the statistics legend.");
+
+         fContStatKurt = new TGCompositeFrame(fContStatOpt, 1, 1, kHorizontalFrame | kFitWidth | kFitHeight);
+         fContStatOpt->AddFrame(fContStatKurt, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+      
+            fChkStatKurtosis = new TGCheckButton(fContStatKurt, "Kurtosis");
+            fContStatKurt->AddFrame(fChkStatKurtosis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkStatKurtosis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatKurtosis->SetToolTipText("Display the kurtosis of the data in the statistics legend.");
+            
+            fChkStatKurtosisPM = new TGCheckButton(fContStatKurt, "+- Error");
+            fContStatKurt->AddFrame(fChkStatKurtosisPM, new TGLayoutHints(kLHintsNormal, 10, 0, 0, 0));
+            fChkStatKurtosisPM->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsStat()");
+            fChkStatKurtosisPM->SetToolTipText("Display the kurtosis' error in the statistics legend.");
+       
+      fBtnUnchekAll = new TGTextButton(fContStatOpt, "&Uncheck all");
+      fContStatOpt->AddFrame(fBtnUnchekAll, new TGLayoutHints(kLHintsExpandX, 10, 10, 0, 0));
+      fBtnUnchekAll->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "UnchekAllStat()");
+      fBtnUnchekAll->SetToolTipText("Disable all statistics legend entries, \nno statistics legend.");
+
+      
+      // custom options container
+      // --- fComboCustom --- the custom draw line on the very low
+      fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+      fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
+   
+         // ------------------------- content of fContCustom -------------------------
+         fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
+         fLblCustomDraw->SetTextJustify(kTextLeft);
+         fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
+         // text field for custom draw command
+         fComboCustom = new TGComboBox(fContCustom);
+         fComboCustom->Resize(0, fBtnDraw->GetDefaultHeight());
+         fComboCustom->EnableTextInput(kTRUE);
+         fContCustom->AddFrame(fComboCustom, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+         fComboCustom->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsGeneral(=42)");
+         fComboCustom->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+      
+   
+      // additional cuts container
+      fContAddCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+      fContTopBottom->AddFrame(fContAddCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
+      
+         // ------------------------- content of fContAddCuts -------------------------
+         fLblAddCuts = new TGLabel(fContAddCuts, "Custom cuts:  ");
+         fLblAddCuts->SetTextJustify(kTextLeft);
+         fContAddCuts->AddFrame(fLblAddCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
+         // combo text field for additional cuts
+         fComboAddCuts = new TGComboBox(fContAddCuts);
+         fComboAddCuts->Resize(0, fBtnDraw->GetDefaultHeight());
+         fComboAddCuts->EnableTextInput(kTRUE);
+         fContAddCuts->AddFrame(fComboAddCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+         fComboAddCuts->Connect("Selected(Int_t)", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+         
+   // ==========================================================================
+   // ************************* content of fContCenter *************************
+   // ========================================================================
+   // main drawing canvas
+   fCanvMain = new TRootEmbeddedCanvas("Main_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
+   fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+   
+   fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliBaseCalibViewerGUI", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
+     
+   fCanvMain->GetCanvas()->Connect("RangeAxisChanged()", "AliTPCCalibViewerGUI", this, "GetMinMax()");
+   fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
+   
+   
+   // =========================================================================   
+   // ************************* content of fContRight *************************
+   // ========================================================================
+   
+   // tabs on the right side:
+   ftabRight = new TGTab(fContRight);
+   fContRight->AddFrame(ftabRight, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 8, 0));
+   fTabRight0 = ftabRight->AddTab("Basic");
+   fTabRight1 = ftabRight->AddTab("Advanced");
+
+   
+      // **************************** content of tabLeft0 *******************************
+      // cut options container
+      fContCuts = new TGGroupFrame(fTabRight0, "Cuts", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight0->AddFrame(fContCuts, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+  
+      // Scaling options container
+      fContScaling = new TGGroupFrame(fTabRight0, "Scaling", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight0->AddFrame(fContScaling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+   
+         // ************************* content of fContScaling *************************
+         // SetMaximum container
+         fContSetMax = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContScaling->AddFrame(fContSetMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         
+            // ------------------------- content of fContSetMax -------------------------
+            // SetMaximum - checkbox
+            fChkSetMax = new TGCheckButton(fContSetMax, "Set fixed max.");
+            fContSetMax->AddFrame(fChkSetMax, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkSetMax->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkSetMax->SetToolTipText("Set the maximum fixed to the value specified here.");
+            
+            // text field for maximum value
+            fTxtSetMax = new TGTextEntry(fContSetMax, "", 41);
+            fContSetMax->AddFrame(fTxtSetMax, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fTxtSetMax->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fTxtSetMax->SetToolTipText("maximum value for the drawing");
+      
+         // SetMinimum container
+         fContSetMin = new TGCompositeFrame(fContScaling, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContScaling->AddFrame(fContSetMin, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         
+            // ------------------------- content of fContSetMin -------------------------
+            // SetMinimum - checkbox
+            fChkSetMin = new TGCheckButton(fContSetMin, "Set fixed min.");
+            fContSetMin->AddFrame(fChkSetMin, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkSetMin->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkSetMin->SetToolTipText("Set the minimum fixed to the value specified here.");
+            
+            // text field for minimum value
+            fTxtSetMin = new TGTextEntry(fContSetMin, "", 40);
+            fContSetMin->AddFrame(fTxtSetMin, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fTxtSetMin->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fTxtSetMin->SetToolTipText("minimum value for the drawing");
+         
+         // get Min & Max from Plot - button
+         fBtnGetMinMax = new TGTextButton(fContScaling, "&Get scale from plot");
+         fContScaling->AddFrame(fBtnGetMinMax, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         fBtnGetMinMax->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "GetMinMax()");
+         fBtnGetMinMax->SetToolTipText("Get min and max from plot, e.g. after rescaling by dragging the palette. \nObsolete! The button's function will change to 'Unzoom all'.");
+         
+         // GetMinMaxAuto - checkbox
+         fChkGetMinMaxAuto = new TGCheckButton(fContScaling, "Get Min + Max auto.");
+         fContScaling->AddFrame(fChkGetMinMaxAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+         fChkGetMinMaxAuto->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+         fChkGetMinMaxAuto->SetToolTipText("Get minimum and maximum automatically from each new plot. \nDeactivate this, if you want to 'save' your specified minimum and maximum.");
+         
+      // labeling container *** fContLabeling ***  " Labeling "      
+         fContLabeling = new TGGroupFrame(fTabRight0, "Labeling", kVerticalFrame | kFitWidth | kFitHeight);
+         fTabRight0->AddFrame(fContLabeling, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         
+            fChkLabelTitle = new TGCheckButton(fContLabeling, "Set title:");
+            fContLabeling->AddFrame(fChkLabelTitle, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkLabelTitle->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkLabelTitle->SetToolTipText("Set the plot title.");
+               
+            fTxtLabelTitle = new TGTextEntry(fContLabeling, "Title", 500);
+            fContLabeling->AddFrame(fTxtLabelTitle, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fTxtLabelTitle->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=50)");
+            fTxtLabelTitle->SetToolTipText("plot title");
+   
+            fChkLabelXaxis = new TGCheckButton(fContLabeling, "Set X-axis label:");
+            fContLabeling->AddFrame(fChkLabelXaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkLabelXaxis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkLabelXaxis->SetToolTipText("Set the X-axis label.");
+               
+            fTxtLabelXaxis = new TGTextEntry(fContLabeling, "XaxisLabel", 500);
+            fContLabeling->AddFrame(fTxtLabelXaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fTxtLabelXaxis->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=51)");
+            fTxtLabelXaxis->SetToolTipText("X-axis label");
+   
+            fChkLabelYaxis = new TGCheckButton(fContLabeling, "Set Y-axis label:");
+            fContLabeling->AddFrame(fChkLabelYaxis, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkLabelYaxis->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkLabelYaxis->SetToolTipText("Set the Y-axis label.");
+               
+            fTxtLabelYaxis = new TGTextEntry(fContLabeling, "YaxisLabel", 500);
+            fContLabeling->AddFrame(fTxtLabelYaxis, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fTxtLabelYaxis->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw(=52)");
+            fTxtLabelYaxis->SetToolTipText("Y-axis label");
+   
+            fChkLabelGetAuto = new TGCheckButton(fContLabeling, "Get labels auto.");
+            fContLabeling->AddFrame(fChkLabelGetAuto, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+            fChkLabelGetAuto->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "HandleButtonsNoRedraw()");
+            fChkLabelGetAuto->SetToolTipText("Get labels automatically from each new plot \nDeactivate this, if you want to 'save' your specified labels.");
+
+      
+      // **************************** content of ftabRight1 *******************************
+      // Save container
+      fContSave = new TGGroupFrame(fTabRight1, "Save", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight1->AddFrame(fContSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         // save button
+         fBtnSave = new TGTextButton(fContSave, "&Save picture");
+         fContSave->AddFrame(fBtnSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         fBtnSave->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "SavePicture()");
+         fBtnSave->SetToolTipText("Open a 'Save as...' dialog to save the current plot as picture or macro.");
+
+         // additional save options container
+         fContAddSaveOpt = new TGCompositeFrame(fContSave, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContSave->AddFrame(fContAddSaveOpt, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+   
+            //  content of --- fContAddSaveOpt ---
+            // addition save options label
+            fChkAddSaveOpt = new TGCheckButton(fContAddSaveOpt, "Save options:");
+            fContAddSaveOpt->AddFrame(fChkAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
+            fChkAddSaveOpt->Connect("Clicked()", "AliBaseCalibViewerGUI", this, "DoNewSelection()");
+            fChkAddSaveOpt->SetToolTipText("Additional save options (see documentation for TPad::Print()).");
+            
+            // additional save options combo box
+            fComboAddSaveOpt = new TGComboBox(fContAddSaveOpt);
+            fContAddSaveOpt->AddFrame(fComboAddSaveOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+            fComboAddSaveOpt->Resize(0, fBtnDraw->GetDefaultHeight());
+            fComboAddSaveOpt->EnableTextInput(kTRUE);
+            fComboAddSaveOpt->Connect("ReturnPressed()", "AliBaseCalibViewerGUI", this, "SavePicture()");
+            
+      // calPad export container           
+      fContExport = new TGGroupFrame(fTabRight1, "Export AliTPCCalPad", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight1->AddFrame(fContExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+         // ------------------------- content of fContExport -------------------------
+         // container for export name
+           
+         fContAddExport = new TGCompositeFrame(fContExport, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContExport->AddFrame(fContAddExport, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
+         
+         fComboExportName = new TGComboBox(fContAddExport);
+         fComboExportName->Resize(0, fBtnDraw->GetDefaultHeight());
+         fContAddExport->AddFrame(fComboExportName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+         fComboExportName->AddEntry("calPad",  0);  // first default value
+         fComboExportName->Select(0);               // select default value before connecting
+         fComboExportName->EnableTextInput(kTRUE);
+          
+         // export button
+         fBtnExport = new TGTextButton(fContExport, "&Export to CINT");
+         fContExport->AddFrame(fBtnExport, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+        fBtnExport->SetToolTipText("Lifeless button :(");
+      
+         // add to normalisation button
+         fBtnAddNorm = new TGTextButton(fContExport, "&Add to normalization");
+         fContExport->AddFrame(fBtnAddNorm, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+        fBtnAddNorm->SetToolTipText("Lifeless button :(");
+      // Tree container
+      fContTree = new TGGroupFrame(fTabRight1, "Tree", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight1->AddFrame(fContTree, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+           
+         // dump tree to file button
+         fBtnDumpToFile = new TGTextButton(fContTree, "&Dump to File");
+         fContTree->AddFrame(fBtnDumpToFile, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+        fBtnDumpToFile->SetToolTipText("Lifeless button :(");
+        
+         // dump tree to file button
+         fBtnLoadTree = new TGTextButton(fContTree, "&Load Tree");
+         fContTree->AddFrame(fBtnLoadTree, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+        fBtnLoadTree->SetToolTipText("Lifeless button :(");
+
+         fChkAddAsReference = new TGCheckButton(fContTree, "as reference:");
+         fContTree->AddFrame(fChkAddAsReference, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
+        fChkAddAsReference->SetToolTipText("Lifeless button :(");            
+
+         fTxtRefName = new TGTextEntry(fContTree, "R", 500);
+         fContTree->AddFrame(fTxtRefName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 15, 0, 0, 0));
+        fTxtRefName->SetToolTipText("Reference Name");
+                       
+      // Fit options container
+      fContFit = new TGGroupFrame(fTabRight1, "Custom fit", kVerticalFrame | kFitWidth | kFitHeight);
+      fTabRight1->AddFrame(fContFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+       
+         // ------------------------- content of fContFit -------------------------
+         // container for additional fits
+         fContAddFit = new TGCompositeFrame(fContFit, 200, 200, kVerticalFrame | kFitWidth | kFitHeight);
+         fContFit->AddFrame(fContAddFit, new TGLayoutHints(kLHintsExpandX, -5, -5, 0, 0));
+      
+            // --- content of fContAddFit ---
+            // text field for custom fit
+            fComboCustomFit = new TGComboBox(fContAddFit);
+            fComboCustomFit->Resize(0, fBtnDraw->GetDefaultHeight());
+            fComboCustomFit->EnableTextInput(kTRUE);
+            fContAddFit->AddFrame(fComboCustomFit, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+                    
+         // fit button
+         fBtnFit = new TGTextButton(fContAddFit, "&Fit");
+         fContAddFit->AddFrame(fBtnFit, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+        fBtnFit->SetToolTipText("Lifeless button :(");
+}
+
+//________________________________________________________________________________________
+AliBaseCalibViewerGUI::AliBaseCalibViewerGUI(const AliBaseCalibViewerGUI &c)
+   : TGCompositeFrame(c.fParent, c.fWidth, c.fHeight),
+    fViewer(0),
+    fContTopBottom(0),
+    fContLCR(0),
+    fContLeft(0),
+    ftabLeft(0),
+    ftabLeft0(0),
+    ftabLeft1(0),
+    ftabRight(0),
+    fTabRight0(0),
+    fTabRight1(0),
+    fContRight(0),
+    fContCenter(0),
+    fContPlotOpt(0),
+    fContDrawOpt(0),
+    fContDrawOptSub1D2D(0),
+    fContNormalized(0),
+    fContCustom(0),
+    fContCuts(0),
+    fContAddCuts(0),
+    fContFit(0),
+    fContAddFit(0),
+    fContScaling(0),
+    fContSetMax(0),
+    fContSetMin(0),
+    fContAddDrawOpt(0),
+    fListVariables(0),
+    fBtnDraw(0),
+    fBtnFit(0),
+    fBtnAddFitFunction(0),
+    fBtnGetMinMax(0),
+    fCanvMain(0),
+    fRadioRaw(0),
+    fRadioNormalized(0),
+    fRadioPredefined(0),
+    fRadioCustom(0),
+    fRadio1D(0),
+    fRadio2D(0),
+    fComboAddDrawOpt(0),
+    fChkAuto(0),
+    fChkAutoAppend(0),
+    fComboMethod(0),
+    fListNormalization(0),
+    fComboCustom(0),
+    fLblCustomDraw(0),
+    fChkAddDrawOpt(0),
+    fLblAddCuts(0),
+    fComboAddCuts(0), 
+    fComboCustomFit(0),
+    fChkSetMax(0),
+    fChkSetMin(0),
+    fChkGetMinMaxAuto(0),
+    fTxtSetMax(0),
+    fTxtSetMin(0), 
+    fContDrawOpt1D(0),
+    fcontDrawOpt1DSubLR(0),
+    fContDrawOpt1DSubNSC(0), 
+    fRadioNorm(0),
+    fRadioSigma(0),
+    fTxtSigmas(0),
+    fContCumuLR(0),
+    fContCumLeft(0),
+    fContCumRight(0),
+    fLblSigmaMax(0),
+    fTxtSigmaMax(0),
+    fRadioCumulative(0),
+    fCheckCumulativePM(0),
+    fRadioIntegrate(0),
+    fContDrawOpt1DSubMML(0),
+    fChkMean(0),
+    fChkMedian(0),
+    fChkLTM(0), 
+    fContStatOpt(0),
+    fChkStatName(0),
+    fChkStatEntries(0),
+    fContStatMean(0),
+    fChkStatMean(0),
+    fChkStatMeanPM(0),
+    fContStatRMS(0),
+    fChkStatRMS(0),
+    fChkStatRMSPM(0),
+    fChkStatUnderflow(0),
+    fChkStatOverflow(0),
+    fChkStatIntegral(0),
+    fContStatSkew(0),
+    fChkStatSkewness(0),
+    fChkStatSkewnessPM(0),
+    fContStatKurt(0),
+    fChkStatKurtosis(0),
+    fChkStatKurtosisPM(0),
+    fBtnUnchekAll(0),
+    fContLabeling(0),
+    fChkLabelTitle(0),
+    fTxtLabelTitle(0),
+    fChkLabelXaxis(0),
+    fTxtLabelXaxis(0),
+    fChkLabelYaxis(0),
+    fTxtLabelYaxis(0),
+    fChkLabelGetAuto(0),
+    fContSave(0),
+    fBtnSave(0),
+    fContAddSaveOpt(0),
+    fChkAddSaveOpt(0),
+    fComboAddSaveOpt(0),
+    fContExport(0),
+    fContAddExport(0),
+    fComboExportName(0),
+    fBtnExport(0),
+    fBtnAddNorm(0), 
+    fContTree(0),
+    fBtnDumpToFile(0),
+    fBtnLoadTree(0),
+    fChkAddAsReference(0),
+    fTxtRefName(0),
+    fInitialized(0)
+{
+  //
+  // dummy AliBaseCalibViewerGUI copy constructor
+  //
+}
+
+//________________________________________________________________________________________
+AliBaseCalibViewerGUI & AliBaseCalibViewerGUI::operator =(const AliBaseCalibViewerGUI & /*param*/) {
+   //
+   // dummy assignment operator
+   //
+   return (*this);
+}
+
+//________________________________________________________________________________________
+AliBaseCalibViewerGUI::~AliBaseCalibViewerGUI() {
+   // 
+   // Destructor
+   // 
+  /*
+   if (fCanvMain && fCanvMain->GetCanvas()) {
+      for (Int_t i = 0; i < fCanvMain->GetCanvas()->GetListOfPrimitives()->GetEntries(); i++) {
+         if (strcmp(fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->ClassName(), "TFrame") != 0)
+            fCanvMain->GetCanvas()->GetListOfPrimitives()->At(i)->Delete();
+      }
+   } 
+*/
+   //   Cleanup();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::SetInitialValues() {
+   // 
+   // Set the default button states
+   // 
+   fChkAuto->SetState(kButtonUp);
+   fRadioPredefined->SetState(kButtonDown);
+   fRadioRaw->SetState(kButtonDown);
+   fRadio1D->SetState(kButtonDown);
+   fChkGetMinMaxAuto->SetState(kButtonDown);
+   fChkSetMin->SetState(kButtonUp);
+   fChkSetMax->SetState(kButtonUp);
+   fRadioNorm->SetState(kButtonDown);
+   fRadioSigma->SetState(kButtonUp);
+   fRadioCumulative->SetState(kButtonUp);
+   fChkMean->SetState(kButtonDown);
+   fCheckCumulativePM->SetState(kButtonUp);
+   
+   fChkLabelGetAuto->SetState(kButtonDown);
+
+   Int_t statOpt = gStyle->GetOptStat();
+   if (statOpt == 1) statOpt = 1111;
+   if (statOpt / 200000000 >= 1) {
+      fChkStatKurtosis->SetState(kButtonDown);
+      fChkStatKurtosisPM->SetState(kButtonDown);
+      statOpt -= 200000000;
+   }
+   if (statOpt / 100000000 >= 1) {
+      fChkStatKurtosis->SetState(kButtonDown);
+      statOpt -= 100000000;
+   }
+   if (statOpt / 20000000 >= 1) {
+      fChkStatSkewness->SetState(kButtonDown);
+      fChkStatSkewnessPM->SetState(kButtonDown);
+      statOpt -= 20000000;
+   }
+   if (statOpt / 10000000 >= 1) {
+      fChkStatSkewness->SetState(kButtonDown);
+      statOpt -= 10000000;
+   }
+   if (statOpt / 1000000 >= 1) {
+      fChkStatIntegral->SetState(kButtonDown);
+      statOpt -= 1000000;
+   }
+   if (statOpt / 100000 >= 1) {
+      fChkStatOverflow->SetState(kButtonDown);
+      statOpt -= 100000;
+   }
+   if (statOpt / 10000 >= 1) {
+      fChkStatUnderflow->SetState(kButtonDown);
+      statOpt -= 10000;
+   }
+   if (statOpt / 2000 >= 1) {
+      fChkStatRMS->SetState(kButtonDown);
+      fChkStatRMSPM->SetState(kButtonDown);
+      statOpt -= 2000;
+   }
+   if (statOpt / 1000 >= 1) {
+      fChkStatRMS->SetState(kButtonDown);
+      statOpt -= 1000;
+   }
+   if (statOpt / 200 >= 1) {
+      fChkStatMean->SetState(kButtonDown);
+      fChkStatMeanPM->SetState(kButtonDown);
+      statOpt -= 200;
+   }
+   if (statOpt / 100 >= 1) {
+      fChkStatMean->SetState(kButtonDown);
+      statOpt -= 100;
+   }
+   if (statOpt / 10 >= 1) {
+      fChkStatEntries->SetState(kButtonDown);
+      statOpt -= 10;
+   }
+   if (statOpt / 1 >= 1) {
+      fChkStatName->SetState(kButtonDown);
+      statOpt -= 1;
+   }
+      
+   // fill fComboAddDrawOpt with some additional drawing options
+   fComboAddDrawOpt->AddEntry("same",      0);
+   fComboAddDrawOpt->AddEntry("profbox",   1);
+   fComboAddDrawOpt->AddEntry("profcolz",  2);
+   fComboAddDrawOpt->AddEntry("profcont0", 3);
+   fComboAddDrawOpt->AddEntry("proflego",  4);
+   fComboAddDrawOpt->AddEntry("proflego2", 5);
+   fComboAddDrawOpt->AddEntry("profsurf",  6);
+   fComboAddDrawOpt->AddEntry("profsurf1", 7);
+   fComboAddDrawOpt->AddEntry("profsurf2", 8);
+   fComboAddDrawOpt->AddEntry("box",    9);
+   fComboAddDrawOpt->AddEntry("colz",  10);
+   fComboAddDrawOpt->AddEntry("cont0", 11);
+   fComboAddDrawOpt->AddEntry("lego",  12);
+   fComboAddDrawOpt->AddEntry("lego2", 13);
+   fComboAddDrawOpt->AddEntry("surf",  14);
+   fComboAddDrawOpt->AddEntry("surf1", 15);
+   fComboAddDrawOpt->AddEntry("surf2", 16);
+
+   // fill fComboAddSaveOpt with some additional drawing options
+   fComboAddSaveOpt->AddEntry("Portrait",  0);
+   fComboAddSaveOpt->AddEntry("Landscape", 1);
+   fComboAddSaveOpt->AddEntry("Preview",   2);
+   fComboAddSaveOpt->AddEntry("+50",       3);
+
+   // fill fComboMethod
+   fComboMethod->AddEntry("subtract",  0);
+   fComboMethod->AddEntry("divide by", 1);
+   
+   // fill fComboExportName
+   fBtnExport->SetEnabled(kFALSE);
+   fBtnAddNorm->SetEnabled(kFALSE);
+
+   // select initial variables
+   fListVariables->Select(0);
+   fListNormalization->Select(0);
+   fComboMethod->Select(0);
+
+   fListVariables->IntegralHeight(kFALSE);         // naja
+   fListNormalization->IntegralHeight(kFALSE);     // naja
+   fChkAuto->SetState(kButtonDown);
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::HandleButtonsGeneral(Int_t id) {
+   //
+   // handles mutual radio button exclusions
+   // for general Tab
+   //
+   if (id == -1) {
+      TGButton *btn = (TGButton *) gTQSender;
+      id = btn->WidgetId();
+   }
+
+   switch (id) {
+      case 10:             // fRadioRaw
+         fRadioNormalized->SetState(kButtonUp);
+         fRadioPredefined->SetState(kButtonDown);
+         fRadioCustom->SetState(kButtonUp);
+        break;
+      case 11:             // fRadioNormalized
+         fRadioRaw->SetState(kButtonUp);
+         fRadioPredefined->SetState(kButtonDown);
+         fRadioCustom->SetState(kButtonUp);
+         break;
+      case 12:             // fRadioCustom
+         fRadioPredefined->SetState(kButtonUp);
+        break;
+      case 14:             // select Draw options fComboAddDrawOpt
+         fChkAddDrawOpt->SetState(kButtonDown);
+         break;
+      case 13:             // fRadioPredefined
+         fRadioCustom->SetState(kButtonUp);
+        break;
+      //--------
+      case 30:             // fRadio1D
+         fRadio2D->SetState(kButtonUp);
+        fBtnExport->SetEnabled(kFALSE);
+        fBtnAddNorm->SetEnabled(kFALSE);
+         break;
+      case 31:             // fRadio2D
+         fRadio1D->SetState(kButtonUp);
+        fBtnExport->SetEnabled(kTRUE);
+        fBtnAddNorm->SetEnabled(kTRUE);
+         break;
+      case 42:             // fComboCustom
+         fRadioCustom->SetState(kButtonDown);
+         fRadioPredefined->SetState(kButtonUp);
+         break;
+   }
+   DoNewSelection();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::HandleButtons1D(Int_t id) {
+   //
+   // handles mutual radio button exclusions
+   // 1D-Tab buttons
+   //
+   
+   if (id == -1) {
+      TGButton *btn = (TGButton *) gTQSender;
+      id = btn->WidgetId();
+   }
+   switch (id) {
+      case 110:            // 1D draw normal
+         fRadioNorm->SetState(kButtonDown);
+         fRadioSigma->SetState(kButtonUp);
+         fRadioCumulative->SetState(kButtonUp);
+         fRadioIntegrate->SetState(kButtonUp);
+         break;
+      case 111:            // 1D draw sigma
+         fRadioNorm->SetState(kButtonUp);
+         fRadioSigma->SetState(kButtonDown);
+         fRadioCumulative->SetState(kButtonUp);
+         fRadioIntegrate->SetState(kButtonUp);
+         break;
+      case 112:            // 1D draw cumulative
+         fRadioNorm->SetState(kButtonUp);
+         fRadioSigma->SetState(kButtonUp);
+         fRadioCumulative->SetState(kButtonDown);
+         fRadioIntegrate->SetState(kButtonUp);
+         break;
+      case 113:            // 1D draw integral
+         fRadioNorm->SetState(kButtonUp);
+         fRadioSigma->SetState(kButtonUp);
+         fRadioCumulative->SetState(kButtonUp);
+         fRadioIntegrate->SetState(kButtonDown);
+         break;
+   }
+   DoNewSelection();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::HandleButtonsStat(Int_t id) {
+   // 
+   // handles statistic check boxes 
+   // checks each checkbox if checked
+   // if the checkbox is checked, appends 'n' for name, 'e' for entries, ...
+   // to a TString, passes this TString to gStyle->SetOptStat(...)
+   // 
+   if (id == -1) {
+      TGButton *btn = (TGButton *) gTQSender;
+      id = btn->WidgetId();
+   }
+   TString statOpt("");
+   if (fChkStatName->GetState() == kButtonDown) statOpt.Append("n");
+   if (fChkStatEntries->GetState() == kButtonDown) statOpt.Append("e");
+   if (fChkStatMean->GetState() == kButtonDown && fChkStatMeanPM->GetState() == kButtonUp) statOpt.Append("m");
+   if (fChkStatMeanPM->GetState() == kButtonDown) statOpt.Append("M");
+   if (fChkStatRMS->GetState() == kButtonDown && fChkStatRMSPM->GetState() == kButtonUp) statOpt.Append("r");
+   if (fChkStatRMSPM->GetState() == kButtonDown) statOpt.Append("R");
+   if (fChkStatUnderflow->GetState() == kButtonDown) statOpt.Append("u");
+   if (fChkStatOverflow->GetState() == kButtonDown) statOpt.Append("o");
+   if (fChkStatIntegral->GetState() == kButtonDown) statOpt.Append("i");
+   if (fChkStatSkewness->GetState() == kButtonDown && fChkStatSkewnessPM->GetState() == kButtonUp) statOpt.Append("s");
+   if (fChkStatSkewnessPM->GetState() == kButtonDown) statOpt.Append("S");
+   if (fChkStatKurtosis->GetState() == kButtonDown && fChkStatKurtosisPM->GetState() == kButtonUp) statOpt.Append("k");
+   if (fChkStatKurtosisPM->GetState() == kButtonDown) statOpt.Append("K");
+   
+   gStyle->SetOptStat(statOpt);
+   DoNewSelection();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::HandleButtonsNoRedraw(Int_t id) {
+   //
+   // handles label & scaling checkboxes 
+   // without redrawing (not necessary, faster like this)
+   //
+    if (id == -1) {
+      TGButton *btn = (TGButton *) gTQSender;
+      id = btn->WidgetId();
+   }
+
+   switch (id) {
+      case 40:             // fTxtSetMin
+         fChkSetMin->SetState(kButtonDown);
+         break;
+      case 41:             // fTxtSetMax
+         fChkSetMax->SetState(kButtonDown);
+         break;
+      case 50:             // fTxtLabelTitle
+         fChkLabelTitle->SetState(kButtonDown);
+         break;
+      case 51:             // fTxtLabelXaxis
+         fChkLabelXaxis->SetState(kButtonDown);
+         break;
+      case 52:             // fTxtLabelXaxis
+         fChkLabelYaxis->SetState(kButtonDown);
+         break;
+   }
+   SetMinMaxLabel();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::ReplacePlaceHolders(TString &str)
+{
+    //
+    // replace the defined placeholders in the custom draw string and cut string
+    //
+    TString drawPlaceHolder("#draw#");
+    TString normPlaceHolder("#norm#");
+
+    //current draw variable
+    TString desiredData("");
+    if (fListVariables->GetSelectedEntry()){
+      desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+      str.ReplaceAll(drawPlaceHolder,desiredData);
+    }
+
+    //current normalisation
+    TString normalizationData("");
+    if (fListNormalization->GetSelectedEntry()){
+      normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
+      if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
+        if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData;
+      if ( fListVariables->FindEntry(normalizationData.Data()) )
+        normalizationData+="~";
+      str.ReplaceAll(normPlaceHolder,normalizationData);
+    }
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::DoNewSelection() {
+   //
+   // decides whether to redraw if user makes another selection
+   //
+   if (fChkAuto->GetState() == kButtonDown) DoDraw();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::SavePicture() {
+   // 
+   // saves the current picture
+   // 
+   // use the following combination of file type and save options:
+   // (see also TCanvas::Print)
+   // 
+   //       "ps"  - Postscript file is produced (see special cases below)
+   //    "Portrait" - Postscript file is produced (Portrait)
+   // "Landscape" - Postscript file is produced (Landscape)
+   //       "eps" - an Encapsulated Postscript file is produced
+   //    "Preview" - an Encapsulated Postscript file with preview is produced.
+   //       "pdf" - a PDF file is produced
+   //       "svg" - a SVG file is produced
+   //       "gif" - a GIF file is produced
+   //       "gif+NN" - an animated GIF file is produced, where NN is delay in 10ms units
+   //       "xpm" - a XPM file is produced
+   //       "png" - a PNG file is produced
+   //       "jpg" - a JPEG file is produced
+   //       "tiff" - a TIFF file is produced
+   //       "cxx" - a C++ macro file is produced
+   //       "xml" - a XML file
+   //       "root" - a ROOT binary file
+   
+   const char *kSaveAsTypes[] = {
+      "Postscript",  "*.ps",
+      "Encapsulated Postscript",   "*.eps",
+      "PDF",   "*.pdf",
+      "JPEG",   "*.jpg",
+      "PNG",   "*.png",
+      "TIFF",   "*.tiff",
+      "GIF",   "*.gif",
+      "XPM",   "*.xpm",
+      "SVG",   "*.svg",
+      "XML",   "*.xml",
+      "C++ macro",   "*.cxx",
+      "Macro file",  "*.C",
+      "ROOT file",   "*.root",
+      "All file",    "*",
+       0,              0
+   };
+   TString addSaveOpt("");
+   if (fChkAddSaveOpt->GetState() == kButtonDown)
+   addSaveOpt += fComboAddSaveOpt->GetTextEntry()->GetText();
+   TString dir(".");
+   TGFileInfo fi;
+   fi.fFileTypes = kSaveAsTypes;
+   fi.fOverwrite = kFALSE;
+   new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
+   if (fi.fFilename && strlen(fi.fFilename)) {
+      if (addSaveOpt != "")
+         fCanvMain->GetCanvas()->Print(fi.fFilename, addSaveOpt.Data());
+      else 
+         fCanvMain->GetCanvas()->Print(fi.fFilename);
+   }
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::GetMinMax() {
+   //
+   // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
+   //
+   if (fChkGetMinMaxAuto->GetState() == kButtonUp) return;
+   TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
+   TObject* ptr = 0;
+   for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
+      ptr = listOfPrimitives->At(i);
+      if ( ptr->InheritsFrom("TH1") ) break;
+   }
+   if ( ptr != 0 && !ptr->InheritsFrom("TH1") ) return;      // if the loop did not find a TH1
+   TH1 *hist = (TH1*)ptr;
+
+   if (fRadio2D->GetState() == kButtonDown) {
+      if (fChkSetMax->GetState() == kButtonUp)
+         fTxtSetMax->SetText(Form("%f", hist->GetMaximum()));
+      if (fChkSetMin->GetState() == kButtonUp)
+         fTxtSetMin->SetText(Form("%f", hist->GetMinimum()));
+   }
+   else if (fRadio1D->GetState() == kButtonDown) {
+      if (fChkSetMax->GetState() == kButtonUp)
+         fTxtSetMax->SetText( Form("%f", hist->GetXaxis()->GetXmax()) );
+      if (fChkSetMin->GetState() == kButtonUp)
+         fTxtSetMin->SetText( Form("%f", hist->GetXaxis()->GetXmin()) );
+   }
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::SetMinMaxLabel() {
+   // 
+   // Set Minimum, Maximum and labels without redrawing the plot
+   // (faster)
+   // 
+   
+   // search for histogram
+   TList* listOfPrimitives = fCanvMain->GetCanvas()->GetListOfPrimitives();
+   TObject* ptr = 0;
+   for (Int_t i = 0; i < listOfPrimitives->GetEntries(); i++) {
+      ptr = listOfPrimitives->At(i);
+      if ( ptr->InheritsFrom("TH1") ) break;
+   }
+   if ( ptr == 0 || !ptr->InheritsFrom("TH1") ) {  // if the loop did not find a TH1
+      fCanvMain->GetCanvas()->Update();
+      Warning("SetMinMaxLabel","No Histogram found!");
+      return;
+      // unable to find histogram, no min and max wil be read out
+   }
+   
+   TH1 *hist = (TH1*)ptr; 
+   TString minTxt(fTxtSetMin->GetText());
+   TString maxTxt(fTxtSetMax->GetText());
+   
+   // set min and max according to specified values, if checkbox is checked
+   if (fRadio2D->GetState() == kButtonDown) {
+      if (fChkSetMax->GetState() == kButtonDown && fChkSetMax->GetState() == kButtonDown &&(maxTxt.IsDigit() || maxTxt.IsFloat()) )
+         hist->SetMaximum(maxTxt.Atof());
+      if (fChkSetMax->GetState() == kButtonUp)
+         hist->SetMaximum(-1111);  // default value, to unzoom
+      if (fChkSetMin->GetState() == kButtonDown && (minTxt.IsDigit() || minTxt.IsFloat()) )
+         hist->SetMinimum(minTxt.Atof());
+      if (fChkSetMin->GetState() == kButtonUp)
+         hist->SetMinimum(-1111);  // default value, to unzoom
+   }
+   else if (fRadio2D->GetState() == kButtonDown) {
+      if (fChkSetMin->GetState() == kButtonDown && 
+          fChkSetMax->GetState() == kButtonDown && hist->GetXaxis())
+         hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetXmin(), hist->GetXaxis()->GetXmax());
+      else if (fChkSetMax->GetState() == kButtonDown && hist->GetXaxis())
+         hist->GetXaxis()->SetRangeUser(hist->GetXaxis()->GetXmin(), maxTxt.Atof());
+      else if (fChkSetMin->GetState() == kButtonDown && hist->GetXaxis())
+         hist->GetXaxis()->SetRangeUser(minTxt.Atof(), hist->GetXaxis()->GetXmax());
+      hist->SetTitle(hist->GetTitle());  // trick to update the histogram
+   }
+   
+   // get min and max from plot       
+   GetMinMax();
+   
+   // set labels according to specification, if cehckboxes are checked
+   if (fChkLabelTitle->GetState() == kButtonDown) 
+      hist->SetTitle(fTxtLabelTitle->GetText());
+   if (fChkLabelXaxis->GetState() == kButtonDown)
+      hist->GetXaxis()->SetTitle(fTxtLabelXaxis->GetText());
+   if (fChkLabelYaxis->GetState() == kButtonDown)
+      hist->GetYaxis()->SetTitle(fTxtLabelYaxis->GetText());
+   // get and/or set labels and title
+   if (fChkLabelGetAuto->GetState() == kButtonDown) {
+      fTxtLabelTitle->SetText(hist->GetTitle());
+      fTxtLabelXaxis->SetTitle(hist->GetXaxis()->GetTitle());
+      fTxtLabelYaxis->SetTitle(hist->GetYaxis()->GetTitle());
+   }
+   hist->SetTitle(hist->GetTitle());  // trick to update the histogram
+   fCanvMain->GetCanvas()->Update();
+}
+
+//________________________________________________________________________________________
+void AliBaseCalibViewerGUI::UnchekAllStat() {
+   // 
+   // Disable all statistical legend entries, no statistical legend.
+   // 
+   fChkStatName->SetState(kButtonUp);
+   fChkStatEntries->SetState(kButtonUp);
+   fChkStatMean->SetState(kButtonUp);
+   fChkStatMeanPM->SetState(kButtonUp);
+   fChkStatRMS->SetState(kButtonUp);
+   fChkStatRMSPM->SetState(kButtonUp);
+   fChkStatUnderflow->SetState(kButtonUp);
+   fChkStatOverflow->SetState(kButtonUp);
+   fChkStatIntegral->SetState(kButtonUp);
+   fChkStatSkewness->SetState(kButtonUp);
+   fChkStatSkewnessPM->SetState(kButtonUp);
+   fChkStatKurtosis->SetState(kButtonUp);
+   fChkStatKurtosisPM->SetState(kButtonUp);
+   
+   HandleButtonsStat(0);
+}
diff --git a/STEER/AliBaseCalibViewerGUI.h b/STEER/AliBaseCalibViewerGUI.h
new file mode 100644 (file)
index 0000000..ef1a19a
--- /dev/null
@@ -0,0 +1,203 @@
+#ifndef ALIBASECALIBVIEWERGUI_H
+#define ALIBASECALIBVIEWERGUI_H
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  Base class for the AliTPCCalibViewerGUI and AliTRDCalibViewerGUI         //
+//  used for the calibration monitor                                         //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TGFrame.h>
+#include <TGComboBox.h>
+
+class TROOTt;
+class TGWidget;
+class TGFrame;
+class TGButton;
+class TGRadioButton;
+class TGListBox;
+class TGNumberEntry;
+class TRootEmbeddedCanvas;
+class TGSplitter;
+class TGVSplitter;
+class TGButtonGroup;
+class TGTextButton;
+class TGTextEntry;
+class TGCheckButton;
+class TGLabel;
+class TGTab;
+class TGCompositeFrame;
+class TGWindow;
+class TGGroupFrame;
+class TString;
+class AliBaseCalibViewer;
+
+class AliBaseCalibViewerGUI : public TGCompositeFrame {
+
+ public:
+  AliBaseCalibViewerGUI(const TGWindow *p, UInt_t w, UInt_t h/*, char* fileName*/);  // constructor
+  AliBaseCalibViewerGUI(const AliBaseCalibViewerGUI &c);                          // copy constructor
+  AliBaseCalibViewerGUI &operator = (const AliBaseCalibViewerGUI &param);         // assignment operator
+
+  virtual ~AliBaseCalibViewerGUI();
+
+  void DrawGUI(const TGWindow *p, UInt_t w, UInt_t h);   // to be called by the costructor, here the windows is drawn
+
+  void SetInitialValues();                                     // set the initial button states
+  // initializes the GUI with default settings and opens tree for drawing
+  virtual void Initialize(const char* fileName, const char* treeName = "tree") = 0; 
+  // initializes the GUI with default settings and opens tree for drawing
+  virtual void Initialize(AliBaseCalibViewer *viewer) = 0;
+  // reload the viewer after it has been changed, e.g. added a new referenceTree, ...                  
+  virtual void Reload() = 0;                          
+  virtual void Reset() = 0;
+
+  virtual TString* GetDrawString() = 0;                   // create the draw string out of selection
+  virtual TString* GetCutString() = 0;                    // create the cut string out of selection
+  virtual TString* GetSectorString() = 0;                 // create the sector string out of selection
+  //virtual AliBaseCalibViewer* GetViewer() = 0;
+  AliBaseCalibViewer* GetViewer() {return fViewer;}       // return the AliBaseCalibViewer pointer
+  virtual Bool_t CreateDetailsTree(Int_t run, const Char_t* outFile, const Char_t* ocdbStorage="nothing") = 0;   // create a tree with pad level info for a given run
+
+  TGTextEntry* GetDrawEntry() {return fComboCustom->GetTextEntry();}
+  TGTextEntry* GetCutsEntry() {return fComboAddCuts->GetTextEntry();}
+  TGTextEntry* GetDrawOptEntry() {return fComboAddDrawOpt->GetTextEntry();}
+  TGTextEntry* GetFitEntry() {return fComboCustomFit->GetTextEntry();}
+
+  void HandleButtonsGeneral(Int_t id = -1); // handles mutual radio button exclusions for general Tab
+  void HandleButtons1D(Int_t id = -1);      // handles mutual radio button exclusions for 1D Tab
+  void HandleButtonsStat(Int_t id = -1);    // handles statistic check boxes
+  void HandleButtonsNoRedraw(Int_t id = -1);// handles label & scaling checkboxes without redrawing
+  void ReplacePlaceHolders(TString &str);   // replace place holders of the draw variable and normalisation variable
+  void DoNewSelection();                    // decides whether to redraw if user makes another selection
+  virtual void DoDraw() = 0;                        // main method for drawing according to user selection
+  void SavePicture();                       // method for saving
+  void GetMinMax();                         // Read current Min & Max from the plot and set it to fTxtSetMin & fTxtSetMax
+  void SetMinMaxLabel();                    // Set min, max and label without redrawing
+  virtual void MouseMove(Int_t event, Int_t x, Int_t y, TObject *selected) = 0; 
+  void UnchekAllStat();
+
+ protected:   
+  AliBaseCalibViewer   *fViewer;             // CalibViewer object used for drawing
+
+  TGCompositeFrame    *fContTopBottom;      // container for all GUI elements, vertical divided
+  TGCompositeFrame    *fContLCR;            // container for all GUI elements, horizontal divided
+  TGCompositeFrame    *fContLeft;           // container for GUI elements on left side
+  TGTab               *ftabLeft;            // Tabs on the left side for plot options
+  TGCompositeFrame    *ftabLeft0;           // Tab 0 on the left side for general plot options
+  TGCompositeFrame    *ftabLeft1;           // Tab 1 on the left side for 1D plot options
+  TGTab               *ftabRight;           // Tabs on the right side
+  TGCompositeFrame    *fTabRight0;          // Tab 0 on the right side for basic
+  TGCompositeFrame    *fTabRight1;          // Tab 1 on the right side for advanced
+  TGCompositeFrame    *fContRight;          // container for GUI elements on right side
+  TGCompositeFrame    *fContCenter;         // container for GUI elements at the center
+  TGCompositeFrame    *fContPlotOpt;        // container for plot options GUI elements
+  TGCompositeFrame    *fContDrawOpt;        // container for draw options GUI elements
+  TGCompositeFrame    *fContDrawOptSub1D2D; // container for 1D and 2D radio-button
+  TGCompositeFrame    *fContNormalized;     // container for normalization options GUI elements
+  TGCompositeFrame    *fContCustom;         // container for custom draw command GUI elements
+  TGCompositeFrame    *fContCuts;           // container for cut options GUI elements  (drawn at TPC/TRD level)
+  TGCompositeFrame    *fContAddCuts;        // container for additional cut command GUI elements
+  TGCompositeFrame    *fContFit;            // container for fit GUI elements
+  TGCompositeFrame    *fContAddFit;         // container for additional fit GUI elements
+  TGCompositeFrame    *fContScaling;        // container for scaling GUI elements
+  TGCompositeFrame    *fContSetMax;         // container for SetMaximum elements
+  TGCompositeFrame    *fContSetMin;         // container for SetMinimum elements
+  TGCompositeFrame    *fContAddDrawOpt;     // additional draw options container
+  TGListBox           *fListVariables;      // listbox with possible variables
+  TGTextButton        *fBtnDraw;            // draw button
+  TGTextButton        *fBtnFit;             // fit button
+  TGTextButton        *fBtnAddFitFunction;  // button to add fit function to normalization
+  TGTextButton        *fBtnGetMinMax;       // GetMinMax-button
+  TRootEmbeddedCanvas *fCanvMain;           // main drawing canvas
+  TGRadioButton       *fRadioRaw;           // raw radio button
+  TGRadioButton       *fRadioNormalized;    // normalized radio button
+  TGRadioButton       *fRadioPredefined;    // predefined plot radio button
+  TGRadioButton       *fRadioCustom;        // custom radio button
+  TGRadioButton       *fRadio1D;            // 1D radio button
+  TGRadioButton       *fRadio2D;            // 2D radio button
+  TGComboBox          *fComboAddDrawOpt;    // additional draw options combo box
+  TGCheckButton       *fChkAuto;            // automatic redraw checkbox
+  TGCheckButton       *fChkAutoAppend;      // automatic appendign of "~" checkbox
+  TGComboBox          *fComboMethod;        // normalization methods dropdown box
+  TGListBox           *fListNormalization;  // listbox with possible normalization variables
+  TGComboBox          *fComboCustom;        // combo box for custom draw commands
+  TGLabel             *fLblCustomDraw;      // custom draw labal
+  TGCheckButton       *fChkAddDrawOpt;      // additional draw options check box
+  TGLabel             *fLblAddCuts;         // additional cuts label
+  TGComboBox          *fComboAddCuts;       // additional cuts combo box
+  TGComboBox          *fComboCustomFit;     // custom fit combo box
+  TGCheckButton       *fChkSetMax;          // Set maximum check box
+  TGCheckButton       *fChkSetMin;          // Set maximum check box
+  TGCheckButton       *fChkGetMinMaxAuto;   // Get Min & Max automatically from plot
+  TGTextEntry         *fTxtSetMax;          // custom maximum text box
+  TGTextEntry         *fTxtSetMin;          // custom minimum text box
+  TGGroupFrame        *fContDrawOpt1D;      // container in tabLeft1 
+  TGCompositeFrame    *fcontDrawOpt1DSubLR; // container in tabLeft1 to divide L/R
+  TGCompositeFrame    *fContDrawOpt1DSubNSC; // container in tabLeft1 for following radio buttons 
+  TGRadioButton       *fRadioNorm;          // radio button for normal 1D drawing
+  TGRadioButton       *fRadioSigma;         // radio button for sigma 1D drawing
+  TGTextEntry         *fTxtSigmas;          // text box to specify sigmas
+  TGCompositeFrame    *fContCumuLR;         // container in tabLeft1 for two colums for cumulative and integrative
+  TGCompositeFrame    *fContCumLeft;        // container in tabLeft1 for cumulative, left
+  TGCompositeFrame    *fContCumRight;       // container in tabLeft1 for cumulative, right
+  TGLabel             *fLblSigmaMax;        // label to indicate sigmaMax
+  TGTextEntry         *fTxtSigmaMax;        // text box to specify sigmaMax
+  TGRadioButton       *fRadioCumulative;    // radio button for cumulative 1D drawing
+  TGCheckButton       *fCheckCumulativePM;  // checkbox for plus/minus cumulative 1D drawing
+  TGRadioButton       *fRadioIntegrate;     // radio button for integral 1D drawing
+  TGCompositeFrame    *fContDrawOpt1DSubMML; // container in tabLeft1 for following check boxes
+  TGCheckButton       *fChkMean;            // checkbox to plot mean
+  TGCheckButton       *fChkMedian;          // checkbox to plot median
+  TGCheckButton       *fChkLTM;             // checkbox to plot LTM
+  TGGroupFrame        *fContStatOpt;        // container for statistic options in tabLeft1 
+  TGCheckButton       *fChkStatName;        // checkbox to display histogram name in statistic legend
+  TGCheckButton       *fChkStatEntries;     // checkbox to display entries in statistic legend
+  TGCompositeFrame    *fContStatMean;       // container for mean and its error in stat opt
+  TGCheckButton       *fChkStatMean;        // checkbox to display mean in statistic legend
+  TGCheckButton       *fChkStatMeanPM;      // checkbox to display mean error in statistic legend
+  TGCompositeFrame    *fContStatRMS;        // container for RMS and its error in stat opt
+  TGCheckButton       *fChkStatRMS;         // checkbox to display RMS in statistic legend
+  TGCheckButton       *fChkStatRMSPM;       // checkbox to display RMS error in statistic legend
+  TGCheckButton       *fChkStatUnderflow;   // checkbox to display underflow error in statistic legend
+  TGCheckButton       *fChkStatOverflow;    // checkbox to display overflow error in statistic legend
+  TGCheckButton       *fChkStatIntegral;    // checkbox to display integral in statistic legend
+  TGCompositeFrame    *fContStatSkew;       // container for skewness and its error in stat opt
+  TGCheckButton       *fChkStatSkewness;    // checkbox to display skewness in statistic legend
+  TGCheckButton       *fChkStatSkewnessPM;  // checkbox to display skewness error in statistic legend
+  TGCompositeFrame    *fContStatKurt;       // container for kurtosis and its error in stat opt
+  TGCheckButton       *fChkStatKurtosis;    // checkbox to display kurtosis in statistic legend
+  TGCheckButton       *fChkStatKurtosisPM;  // checkbox to display kurtosis error in statistic legend
+  TGButton            *fBtnUnchekAll;       // Button to uncheck all statistic entries
+  TGGroupFrame        *fContLabeling;       // groupframe container for labeling
+  TGCheckButton       *fChkLabelTitle;      // checkbox to display specified title
+  TGTextEntry         *fTxtLabelTitle;      // text box to specify title
+  TGCheckButton       *fChkLabelXaxis;      // checkbox to display specified xaxis label
+  TGTextEntry         *fTxtLabelXaxis;      // text box to specify xaxis label
+  TGCheckButton       *fChkLabelYaxis;      // checkbox to display specified yaxis label
+  TGTextEntry         *fTxtLabelYaxis;      // text box to specify yaxis label
+  TGCheckButton       *fChkLabelGetAuto;    // checkbox to get labels atuomatically from plot
+  TGGroupFrame        *fContSave;           // container for save-button
+  TGButton            *fBtnSave;            // Save button
+  TGCompositeFrame    *fContAddSaveOpt;     // container for additional save options
+  TGCheckButton       *fChkAddSaveOpt;      // checkbox for additional save options
+  TGComboBox          *fComboAddSaveOpt;    // combobox for additional save options
+  TGGroupFrame        *fContExport;         // container for cint-export
+  TGCompositeFrame    *fContAddExport;      // container for dropdown list to enter export name
+  TGComboBox          *fComboExportName;    // dropdownbox to enter a name for the exported CalPad
+  TGTextButton        *fBtnExport;          // button to export a CalPad
+  TGTextButton        *fBtnAddNorm;         // button to add a CalPad to the normalization
+  TGCompositeFrame    *fContTree;           // container for tree functions
+  TGTextButton        *fBtnDumpToFile;      // button to dump a new CalibTree to file
+  TGTextButton        *fBtnLoadTree;        // button to load a new tree
+  TGCheckButton       *fChkAddAsReference;  // checkbox to add a new tree as referenceTree
+  TGTextEntry         *fTxtRefName;         // text box to specify the referenceTree's name
+  
+ protected:
+  Bool_t fInitialized;                      // has the GUI already been initialized?
+  
+  ClassDef(AliBaseCalibViewerGUI, 0)
+};
+    
+#endif
diff --git a/STEER/AliCalibViewerGUItime.cxx b/STEER/AliCalibViewerGUItime.cxx
new file mode 100644 (file)
index 0000000..b8e9e76
--- /dev/null
@@ -0,0 +1,1332 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  GUI for displaying calibration entries over time                         //
+//                                                                           //
+//  Authors:     Marian Ivanov (Marian.Ivanov@cern.ch)                       //
+//               Jens Wiechula (Jens.Wiechula@cern.ch)                       //
+//               Ionut Arsene  (iarsene@cern.ch)                             //
+//                                                                           //
+//  Usage:   AliCalibViewerGUItime::ShowGUI(TChain* chain)                   //
+//           AliCalibViewerGUItime::ShowGUI()                                //
+///////////////////////////////////////////////////////////////////////////////
+
+
+#include <iostream>
+//Root includes
+#include <TROOT.h>
+#include <TDirectory.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+#include <TPad.h>
+#include <TVirtualPad.h>
+#include <TObject.h>
+#include <TObjArray.h>
+#include <TObjString.h>
+#include <TSystem.h>
+#include <TVector.h>
+#include <TH1.h>
+#include <TCut.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <TChain.h>
+#include <TBranch.h>
+#include <TIterator.h>
+#include <TGraph.h>
+#include <TAxis.h>
+#include <TTimeStamp.h>
+#include <TMath.h>
+#include <TMap.h>
+//
+#include <TGFileDialog.h>
+#include <TGInputDialog.h>
+//
+#include <TGButton.h>
+#include <TGListBox.h>
+#include <TGComboBox.h>
+#include <TGNumberEntry.h>
+#include <TGLayout.h>
+#include <TRootEmbeddedCanvas.h>
+#include <TGSplitter.h>
+#include <TGButtonGroup.h>
+#include <TGLabel.h>
+#include <TGTab.h>
+#include <TGString.h>
+
+//AliRoot includes
+#include <AliLog.h>
+#include "AliBaseCalibViewer.h"
+#include "AliBaseCalibViewerGUI.h"
+#include "AliCalibViewerGUItime.h"
+
+
+ClassImp(AliCalibViewerGUItime)
+
+//_______________________________________________________________________________________________________________
+AliCalibViewerGUItime::AliCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h, const Char_t* det) :
+TGCompositeFrame(p,w,h),
+  fDetector(det),
+  fFile(0x0),
+  fTree(0x0),
+  fCalibViewerGUI(0x0),
+  fCalibViewerGUItab(0x0),
+  fCurrentHist(0x0),
+  fCurrentGraph(0x0),
+  fCurrentRunDetails(-1),
+  fOutputCacheDir("/tmp"),
+  fDrawString(""),
+  fIsCustomDraw(kFALSE),
+  fRunNumbers(10),
+  fTimeStamps(10),
+  fValuesX(10),
+  fValuesY(10),
+  fNoGraph(kFALSE),
+  fGraphLimitEntries(10000),
+  fMapRefTrees(new TMap),
+  //GUI elements
+  //main canvas Top part, bottom part
+  fContTopBottom(0x0),
+  //top left, centre, right
+  fContLCR(0x0),
+  //content left
+  fContLeft(0x0),
+  fContDrawOpt(0x0),
+  fChkDrawOptSame(0x0),
+  fComboAddDrawOpt(0x0),
+  fContDrawSel(0x0),
+  fContDrawSelSubRunTime(0x0),
+  fRadioXhist(0x0),
+  fRadioXrun(0x0),
+  fRadioXtime(0x0),
+  fListVariables(0x0),
+  fComboRunType(0x0),
+  fLblRunType(0x0),
+  fNmbPar(0x0),
+  fLblPar(0x0),
+  fListCalibType(0x0),
+  fContCalibType(0x0),
+  //content centre
+  fContCenter(0x0),
+  fCanvMain(0x0),
+  //content right
+  fContRight(0x0),
+  fContValues(0x0),
+  fLblRunNumber(0x0),
+  fLblRunTime(0x0),
+  fLblValueX(0x0),
+  fLblValueY(0x0),
+  fLblRunNumberVal(0x0),
+  fLblRunTimeVal(0x0),
+  fLblValueXVal(0x0),
+  fLblValueYVal(0x0),
+  fBtnDumpRuns(0x0),
+  fBtnSave(0x0),
+  //load a file
+  fContLoad(0x0),
+  fContFilename(0x0),
+  fContConfigFile(0x0),
+  fContTreeName(0x0),
+  fLblTreeName(0x0),
+  fTxtFilename(0x0),
+  fTxtConfigFile(0x0),
+  fTxtTreeName(0x0),
+  fBtnLoadFile(0x0),
+  // extract information from OCDB
+  //content bottom
+  fContCustom(0x0),
+  fContCustomCuts(0x0),
+  fLblCustomDraw(0x0),
+  fLblCustomCuts(0x0),
+  fComboCustomDraw(0x0),
+  fComboCustomCuts(0x0),
+  fTrashBox(new TObjArray)
+{
+  //
+  // ctor
+  //
+  fDetector.ToUpper();
+  fMapRefTrees->SetOwnerKeyValue();
+  fTrashBox->SetOwner();
+  DrawGUI(p,w,h);
+  gStyle->SetMarkerStyle(20);
+  gStyle->SetMarkerSize(0.5);
+  SetInitialValues();
+}
+
+//______________________________________________________________________________
+AliCalibViewerGUItime::~AliCalibViewerGUItime(){
+  //
+  // dtor
+  //
+  //  delete fConfigParser;
+  delete fTrashBox;
+  delete fMapRefTrees;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
+   //
+   // draw the GUI
+   //
+   // ======================================================================
+   // ************************* Display everything *************************
+   // ======================================================================
+  
+  SetCleanup(kDeepCleanup);
+  
+   // *****************************************************************************
+   // ************************* content of this MainFrame *************************
+   // *****************************************************************************
+   // top level container with horizontal layout
+  fContTopBottom = new TGCompositeFrame(this, w, h, kVerticalFrame | kFixedWidth | kFixedHeight);
+  AddFrame(fContTopBottom, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  
+  fContLCR = new TGCompositeFrame(fContTopBottom, w, h, kHorizontalFrame | kFixedWidth | kFixedHeight);
+  fContTopBottom->AddFrame(fContLCR, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  
+   // ***********************************************************************
+   // ************************* content of fContLCR *************************
+   // ***********************************************************************
+   // left container
+  fContLeft = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+  fContLCR->AddFrame(fContLeft, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandY, 5, 3, 3, 3));
+  
+   // left vertical splitter
+  TGVSplitter *splitLeft = new TGVSplitter(fContLCR);
+  splitLeft->SetFrame(fContLeft, kTRUE);
+  fContLCR->AddFrame(splitLeft, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
+  
+   // right container
+  fContRight = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+  fContLCR->AddFrame(fContRight, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandY, 3, 5, 3, 3));
+  
+   // center container
+  fContCenter = new TGCompositeFrame(fContLCR, 200, 200, kVerticalFrame | kFixedWidth | kFitHeight);
+  fContLCR->AddFrame(fContCenter, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  
+   // right vertical splitter
+  TGVSplitter *splitRight = new TGVSplitter(fContLCR);
+  splitRight->SetFrame(fContRight, kFALSE);
+  fContLCR->AddFrame(splitRight, new TGLayoutHints(kLHintsLeft | kLHintsExpandY, 0, 0, 0, 0));
+  
+  
+   // ========================================================================
+   // ************************* content of fContLeft *************************
+   // ========================================================================
+   // --- draw button and tabLeft ---
+  // draw options
+  fContDrawOpt = new TGGroupFrame(fContLeft, "Draw options", kVerticalFrame | kFitWidth | kFitHeight);
+  fContLeft->AddFrame(fContDrawOpt, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+  fChkDrawOptSame = new TGCheckButton(fContDrawOpt, "Same");
+  fContDrawOpt->AddFrame(fChkDrawOptSame, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
+  fChkDrawOptSame->SetToolTipText("Add draw option 'same'");
+  // additional draw options combo box
+  fComboAddDrawOpt = new TGComboBox(fContDrawOpt);
+  fComboAddDrawOpt->Resize(0, 22);
+  fComboAddDrawOpt->EnableTextInput(kTRUE);
+  fContDrawOpt->AddFrame(fComboAddDrawOpt, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+    
+  // draw selection group
+  fContDrawSel = new TGGroupFrame(fContLeft, "Draw selection", kVerticalFrame | kFitWidth | kFitHeight);
+  fContLeft->AddFrame(fContDrawSel, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 10, 0));
+  //x-axis variables selection, Run of Time
+  fContDrawSelSubRunTime = new TGCompositeFrame(fContDrawSel, 200, 23, kHorizontalFrame | kFitWidth | kFixedHeight);
+  fContDrawSel->AddFrame(fContDrawSelSubRunTime, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX , 0, 0, 0, 0));
+  
+  // ------------------------- content of fContDrawOpt -------------------------
+  // 
+  // Run radio button
+    // Time radio button
+  fRadioXhist = new TGRadioButton(fContDrawSelSubRunTime, "hist", kRadioXhist);
+  fContDrawSelSubRunTime->AddFrame(fRadioXhist, new TGLayoutHints(kLHintsNormal, 0, 2, 0, 0));
+  fRadioXhist->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
+  fRadioXhist->SetToolTipText("Draw the distribution of the variable");
+  
+  fRadioXrun = new TGRadioButton(fContDrawSelSubRunTime, ":Run", kRadioXrun);
+  fContDrawSelSubRunTime->AddFrame(fRadioXrun, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
+  fRadioXrun->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
+  fRadioXrun->SetToolTipText("Use run number as x-value");
+  
+  // Time radio button
+  fRadioXtime = new TGRadioButton(fContDrawSelSubRunTime, ":Time", kRadioXtime);
+  fContDrawSelSubRunTime->AddFrame(fRadioXtime, new TGLayoutHints(kLHintsNormal, 2, 2, 0, 0));
+  fRadioXtime->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleButtonsDrawSel()");
+  fRadioXtime->SetToolTipText("Use time stamp number as x-value");
+  
+  
+  // list of variables
+  fListVariables = new TGListBox(fContDrawSel);
+  fContDrawSel->AddFrame(fListVariables, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  fListVariables->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoNewSelection()");
+
+  
+//-------------------- run type selection ------------------------
+  // Parameter label
+  fLblRunType = new TGLabel(fContDrawSel, "Run Type:");
+  fLblRunType->SetTextJustify(kTextLeft);
+  fContDrawSel->AddFrame(fLblRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  
+  fComboRunType = new TGComboBox(fContDrawSel);
+  fComboRunType->EnableTextInput(kFALSE);
+  fContDrawSel->AddFrame(fComboRunType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  fComboRunType->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoDraw()");
+  fComboRunType->Resize(0, 22);
+  
+  //-------------------- parameter selection ------------------------
+  // Parameter label
+  fLblPar = new TGLabel(fContDrawSel, "Parameter:");
+  fLblPar->SetTextJustify(kTextLeft);
+  fContDrawSel->AddFrame(fLblPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  
+  fNmbPar = new TGNumberEntry(fContDrawSel, 0, 1, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, 71);
+  fContDrawSel->AddFrame(fNmbPar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  fNmbPar->Connect("ValueSet(Long_t)", "AliCalibViewerGUItime", this, "DoParLimitChange()");
+  fNmbPar->SetState(kFALSE);
+  
+  //-------------------- calibration type selection ------------------------
+  // label
+  // draw selection group
+  fContCalibType = new TGGroupFrame(fContLeft, "Calib type selection", kVerticalFrame | kFitWidth | kFitHeight);
+  fContLeft->AddFrame(fContCalibType, new TGLayoutHints(kLHintsExpandX , 0, 0, 10, 0));
+    
+    // list of variables
+  fListCalibType = new TGListBox(fContCalibType);
+  fContCalibType->AddFrame(fListCalibType, new TGLayoutHints(kLHintsNormal | kLHintsExpandX , 0, 0, 0, 0));
+  fListCalibType->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoChangeSelectionList()");
+  fListCalibType->Resize(0,88);
+  fListCalibType->SetMultipleSelections();
+  
+  
+     // ==========================================================================
+   // ************************* content of fContCenter *************************
+   // ========================================================================
+   // main drawing canvas
+  fCanvMain = new TRootEmbeddedCanvas("GUItime_Canvas", fContCenter, 200, 200, kFitWidth | kFitHeight);
+  fContCenter->AddFrame(fCanvMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  fCanvMain->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)", "AliCalibViewerGUItime", this, "MouseMove(Int_t, Int_t, Int_t, TObject*)");
+  fCanvMain->GetCanvas()->SetToolTipText("The Main_Canvas, here your plots are displayed.");
+  fCanvMain->GetCanvas()->SetRightMargin(0.062);
+  fCanvMain->GetCanvas()->SetLeftMargin(0.15);
+  
+   // =========================================================================
+   // ************************* content of fContRight *************************
+   // ========================================================================
+  //group frame for value information
+  fContValues = new TGGroupFrame(fContRight, "Data point info", kVerticalFrame | kFitWidth | kFitHeight);
+  fContRight->AddFrame(fContValues, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+  //set layout manager
+  fContValues->SetLayoutManager(new TGMatrixLayout(fContValues, 0, 2, 4));
+  //value information labels
+
+  //run number label
+  fLblRunNumber = new TGLabel(fContValues, "Run:");
+  fLblRunNumber->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblRunNumber, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+  //run number
+  fLblRunNumberVal = new TGLabel(fContValues, "0000000");
+  fLblRunNumberVal->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblRunNumberVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
+  //time stamp label
+  fLblRunTime = new TGLabel(fContValues, "Time:");
+  fLblRunTime->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblRunTime, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+  //run number
+  fLblRunTimeVal = new TGLabel(fContValues, "00.00.0000\n00:00:00");
+  fLblRunTimeVal->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblRunTimeVal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 0, 0, 0, 0));
+  //value label x
+  fLblValueX = new TGLabel(fContValues, "x-Value:");
+  fLblValueX->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+  //value x
+  fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
+  fLblValueXVal->SetTextJustify(kTextRight);
+  fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  //value label y
+  fLblValueY = new TGLabel(fContValues, "y-Value:");
+  fLblValueY->SetTextJustify(kTextLeft);
+  fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
+  //value y
+  fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
+  fLblValueYVal->SetTextJustify(kTextRight);
+  fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+   // draw button
+  fBtnDumpRuns = new TGTextButton(fContRight, "&Dump runs");
+  fContRight->AddFrame(fBtnDumpRuns, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+  fBtnDumpRuns->Connect("Clicked()", "AliCalibViewerGUItime", this, "DoDumpRuns()");
+  fBtnDumpRuns->SetToolTipText("Press to dump the run numbers of the current selection.");
+  // save button
+  fBtnSave = new TGTextButton(fContRight, "&Save picture");
+  fContRight->AddFrame(fBtnSave, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+  fBtnSave->SetToolTipText("Press to save the current picture in the canvas");
+  fBtnSave->Connect("Clicked()", "AliCalibViewerGUItime", this, "SavePicture()");
+
+  //group frame for loading a file
+  fContLoad = new TGGroupFrame(fContRight, "Load file", kVerticalFrame | kFitWidth | kFitHeight);
+  fContRight->AddFrame(fContLoad, new TGLayoutHints(kLHintsExpandX, 0, 0, 10, 0));
+
+    fContFilename = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+    fContLoad->AddFrame(fContFilename, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
+
+      fTxtFilename = new TGTextEntry(fContFilename, "Input file", 100);
+      fContFilename->AddFrame(fTxtFilename, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+      fTxtFilename->Connect("DoubleClicked()", "AliCalibViewerGUItime", this, "HandleLoadRunTextEntry()");
+     
+    fContTreeName = new TGCompositeFrame(fContLoad, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+    fContLoad->AddFrame(fContTreeName, new TGLayoutHints(kLHintsExpandX, 0, 0, 2, 0));
+
+      fLblTreeName = new TGLabel(fContTreeName, "Tree Name:");
+      fLblTreeName->SetTextJustify(kTextLeft);
+      fContTreeName->AddFrame(fLblTreeName, new TGLayoutHints(kLHintsNormal | kLHintsCenterY, 0, 1, 0, 0));
+
+      fTxtTreeName = new TGTextEntry(fContTreeName, "trdTree");
+      if(fDetector.Contains("TPC")) fTxtTreeName->SetText("dcs");
+      fContTreeName->AddFrame(fTxtTreeName, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+
+    fBtnLoadFile = new TGTextButton(fContLoad, "Load file", 100);
+    fContLoad->AddFrame(fBtnLoadFile, new TGLayoutHints(kLHintsExpandX, 0, 0, 0, 0));
+    fBtnLoadFile->SetToolTipText("Load a file into viewer");
+    fBtnLoadFile->Connect("Clicked()", "AliCalibViewerGUItime", this, "HandleLoadRunButtons()");
+
+   // =========================================================================
+   // ****************** bottom content of fContTopBottom *********************
+   // =========================================================================
+  
+  // custom options container
+  // --- fComboCustom --- the custom draw line on the very low
+  fContCustom = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+  fContTopBottom->AddFrame(fContCustom, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
+
+         // ------------------------- content of fContCustom -------------------------
+  fLblCustomDraw = new TGLabel(fContCustom, "Custom draw: ");
+  fLblCustomDraw->SetTextJustify(kTextLeft);
+  fContCustom->AddFrame(fLblCustomDraw, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
+         // text field for custom draw command
+  fComboCustomDraw = new TGComboBox(fContCustom);
+  fComboCustomDraw->Resize(0, 22);
+  fComboCustomDraw->EnableTextInput(kTRUE);
+  fContCustom->AddFrame(fComboCustomDraw, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  fComboCustomDraw->Connect("ReturnPressed()", "AliCalibViewerGUItime", this, "DoCustomDraw()");
+  fComboCustomDraw->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoCustomDraw()");
+  
+  
+      // additional cuts container
+  fContCustomCuts = new TGCompositeFrame(fContTopBottom, 200, 200, kHorizontalFrame | kFitWidth | kFitHeight);
+  fContTopBottom->AddFrame(fContCustomCuts, new TGLayoutHints(kLHintsExpandX, 10, 0, 0, 0));
+  
+         // ------------------------- content of fContCustomCuts -------------------------
+  fLblCustomCuts = new TGLabel(fContCustomCuts, "Custom cuts:  ");
+  fLblCustomCuts->SetTextJustify(kTextLeft);
+  fContCustomCuts->AddFrame(fLblCustomCuts, new TGLayoutHints(kLHintsNormal, 5, 0, 0, 0));
+         // combo text field for additional cuts
+  fComboCustomCuts = new TGComboBox(fContCustomCuts);
+//   fComboCustomCuts->Resize(0, fLblValueY->GetDefaultHeight());
+  fComboCustomCuts->Resize(0, 22);
+  fComboCustomCuts->EnableTextInput(kTRUE);
+  fContCustomCuts->AddFrame(fComboCustomCuts, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
+  fComboCustomCuts->Connect("ReturnPressed()", "AliCalibViewerGUItime", this, "DoCustomCutsDraw()");
+  fComboCustomCuts->Connect("Selected(Int_t)", "AliCalibViewerGUItime", this, "DoCustomCutsDraw()");
+
+  if(fDetector.Contains("TPC")) SetWindowName("AliTPCCalibViewer GUI - Time");
+  else if (fDetector.Contains("TRD")) SetWindowName("AliTRDCalibViewer GUI - Time");
+  else SetWindowName("Unknown detector");
+  MapSubwindows();
+  Resize(GetDefaultSize());
+  MapWindow();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::SetInitialValues(){
+  //
+  // Set inital selections of the gui
+  //
+  fRadioXrun->SetState(kButtonDown);
+  fRadioXtime->SetState(kButtonUp);
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::UseFile(const char* fileName, const char* treeName) {
+  //
+  // retrieve tree from file
+  //
+  TString s(fileName);
+  TObjArray *arr=s.Tokenize(" ");
+  TIter next(arr);
+  TObject *o=0;
+  if (fTree) delete fTree;
+  fTree=new TChain(treeName);
+  while ( (o=next()) ){
+    TString tmpString(o->GetName());
+    std::cout << "Adding " << tmpString.Data() << " to the chain" << std::endl;
+    if(tmpString.Contains(".root"))
+      fTree->AddFile(tmpString.Data());
+    else {
+      tmpString += "/*.root";
+      fTree->Add(tmpString.Data());
+    }
+  }
+  delete arr;
+  if (!CheckChain())
+    return;
+  //  UseConfigFile(fConfigFile.Data());
+  FillCalibTypes();
+  Reload();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::UseChain(TChain* chain)
+{
+  //
+  // load a chain
+  //
+  fTree=chain;
+  if (!CheckChain()) {
+    std::cout << "AliCalibViewerGUItime::UseChain !checkchain OUT" << std::endl;
+    return;
+  }
+  //set configuration file
+  //  UseConfigFile(fConfigFile.Data());
+  FillCalibTypes();
+  Reload();
+}
+
+//______________________________________________________________________________
+Bool_t AliCalibViewerGUItime::CheckChain()
+{
+  //
+  // check whether cahin has entries
+  // decide whether to draw graphs in 2D
+  //
+  if (!fTree) {
+    return kFALSE;
+  }
+  fTree->Lookup();
+  Long64_t entries=fTree->GetEntries();
+  if (entries==0){
+    AliError("No entries found in chain");
+    return kFALSE;
+  }
+  //check whether to draw graphs
+  CheckDrawGraph();
+  return kTRUE;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::FillRunTypes()
+{
+  //
+  //Loop over the tree entries and fill the run types
+  //
+  if (!fTree) {
+    return;
+  }
+  Int_t id=0;
+  fComboRunType->RemoveAll();
+  fComboRunType->AddEntry("ALL",id++);
+  fComboRunType->Select(0,kFALSE);
+  if (!fTree->GetBranch("runType.")) {
+    return;
+  }
+  TObjString *runType=0x0;
+  Int_t nevets=fTree->GetEntries();
+  fTree->SetBranchStatus("*",0);
+  fTree->SetBranchStatus("runType.*",1);
+  fTree->SetBranchAddress("runType.",&runType);
+  for (Int_t iev=0;iev<nevets;++iev){
+    fTree->GetEntry(iev);
+    TString type=runType->String();
+    if (!type.IsNull()&&!fComboRunType->FindEntry(type)) fComboRunType->AddEntry(type,id++);
+  }
+  fTree->ResetBranchAddresses();
+  fTree->SetBranchStatus("*",1);
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::FillCalibTypes()
+{
+  //
+  // loop over configuration and fill calibration types
+  //
+  Int_t id=0;
+  fListCalibType->RemoveAll();
+  //  TObject *o=0x0;
+  //  fConfigParser->ResetIter();
+  TString type="UNSPECIFIED";
+  fListCalibType->AddEntry(type.Data(),id);
+  fListCalibType->Select(id++);
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::CheckDrawGraph()
+{
+  //
+  // Check whether to draw graphs in 2D mode based on the number of entries in the chain
+  // GetEstimate() returns the maximum size of the arrays stored in GetV1()...
+  //
+  if (!fTree) {
+    return;
+  }
+  fNoGraph=kTRUE;
+  if (fTree->GetEntries()<fTree->GetEstimate()) fNoGraph=kFALSE;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::Reload(Int_t first)
+{
+  //
+  // reload the gui contents, this is needed after the input tree has changed
+  //
+  first = first;
+  if ( !fTree ) {
+    return;
+  }
+  
+  FillRunTypes();
+  
+  //activate all branches
+  fTree->SetBranchStatus("*",1);
+  //reset variables list
+  fListVariables->RemoveAll();
+  //get selected calibration types
+  TList calibTypes;
+  fListCalibType->GetSelectedEntries(&calibTypes);
+    
+  TObjArray *branchList = fTree->GetListOfBranches();
+  if ( !branchList ) return;
+  TIter nextBranch(branchList);
+  Int_t idCount=0,id=0;
+  TObject *objBranch=0;
+  while ( (objBranch=nextBranch()) ){
+    TString branchName(objBranch->GetName());
+    TString branchTitle(objBranch->GetName());
+    if (branchName == "run" || branchName == "time" || branchName == "runType.") continue;
+    Bool_t active=kTRUE;
+    TString calibType="UNSPECIFIED";
+   
+    //check if branch is in selected calibration types
+    //if not, don't show it in the list and deactivate the branch.
+    Bool_t calibActive=kFALSE;
+    TIter nextCalib(&calibTypes);
+    TObject *objCalib=0;
+    while ( (objCalib=nextCalib()) ) {
+      if (calibType==objCalib->GetTitle()) calibActive=kTRUE;
+    }
+    active&=calibActive;
+    if (!active){
+      TString s=branchName;
+      if (branchName.EndsWith(".")) s+="*";
+      fTree->SetBranchStatus(s.Data(),0);
+      continue;
+    }
+    fListVariables->AddEntry(SubstituteUnderscores(branchTitle.Data()),id);
+    //fListVariables->Select(id);
+    ++idCount;
+  }
+  //trick to display modifications
+  fListVariables->Resize(fListVariables->GetWidth()-1, fListVariables->GetHeight());
+  fListCalibType->Resize(fListCalibType->GetWidth()+1, fListCalibType->GetHeight());
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
+{
+  //
+  // map of reference trees that should always be attached to the CalibViewerGUI
+  //
+  fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
+}
+
+//______________________________________________________________________________
+const char* AliCalibViewerGUItime::GetDrawString(){
+  //
+  // create draw string for ttree by combining the user requestsa
+  //
+  
+  TString selectedVariable="";
+  Int_t id=-1;
+  if (!fListVariables->GetSelectedEntry()) {
+    return "";
+  }
+  selectedVariable = fListVariables->GetSelectedEntry()->GetTitle();
+  id=fListVariables->GetSelectedEntry()->EntryId();
+  TString branchName=selectedVariable;
+  //  const TObject *key=(*fConfigParser)(id);
+  //  if (key) branchName=(*fConfigParser)(id)->GetName();
+  //treat case of TVector
+  if (branchName.EndsWith(".")){
+    Int_t par = (Int_t)(fNmbPar->GetNumber());
+    branchName.Append(Form("fElements[%d]",par));
+  }
+
+  return branchName.Data();
+}
+//______________________________________________________________________________
+const char* AliCalibViewerGUItime::GetDrawOption(){
+  //
+  // get user selected draw options
+  //
+  TString drawOpt;
+  if (fComboAddDrawOpt->GetSelectedEntry()) drawOpt=fComboAddDrawOpt->GetSelectedEntry()->GetTitle();
+  if (fChkDrawOptSame->GetState()==kButtonDown && !drawOpt.Contains("same",TString::kIgnoreCase))
+    drawOpt+="same";
+  return drawOpt.Data();
+}
+//______________________________________________________________________________
+void AliCalibViewerGUItime::GetCutString(TString &cutStr){
+  //
+  // create cut string
+  //
+  TCut cuts(fComboCustomCuts->GetTextEntry()->GetText());
+  TString runType="";
+  if (fComboRunType->GetSelectedEntry()) runType=fComboRunType->GetSelectedEntry()->GetTitle();
+  if (runType!="ALL"&&!runType.IsNull()) cuts+=Form("runType.String().Data()==\"%s\"",runType.Data());
+  cutStr=cuts.GetTitle();
+}
+//______________________________________________________________________________
+void AliCalibViewerGUItime::UpdateValueArrays(Bool_t withGraph)
+{
+  //
+  // Update arrays of runs
+  //
+  if (!withGraph){
+    fValuesX.ResizeTo(1);
+    fValuesY.ResizeTo(1);
+    fRunNumbers.ResizeTo(1);
+    fTimeStamps.ResizeTo(1);
+  } else {
+    fValuesX.ResizeTo(fTree->GetSelectedRows());
+    fValuesY.ResizeTo(fTree->GetSelectedRows());
+    fRunNumbers.ResizeTo(fTree->GetSelectedRows());
+    fTimeStamps.ResizeTo(fTree->GetSelectedRows());
+    fValuesY.SetElements(fTree->GetV3());
+    fRunNumbers.SetElements(fTree->GetV1());
+    fTimeStamps.SetElements(fTree->GetV2());
+  }
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::GetHistogramTitle(TString &title)
+{
+  //
+  // Create string for histogram title
+  //
+
+  title=fDrawString;
+  Int_t pos=title.First(">>");
+  if (pos>0) title=title(0,pos);
+  if (!fIsCustomDraw){
+    if (fRadioXrun->GetState()==kButtonDown){
+      title+=":Run";
+    } else if (fRadioXtime->GetState()==kButtonDown){
+      title+=":Date";
+    }
+  }
+  TString cuts;
+  GetCutString(cuts);
+  TObjArray *arr=title.Tokenize(":");
+  TObject *o=0x0;
+  title+=" {";
+  title+=cuts;
+  title+="}";
+  TIter next(arr,kIterBackward);
+  while ( (o=next()) ){
+    TString varName=o->GetName();
+    title+=";";
+    title+=varName;
+  }
+  delete arr;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::AdjustYRange()
+{
+  //
+  // adjust the range of the Y axis
+  //
+  TIter nextGraphicObject(fTrashBox);
+  TObject *o=0x0;
+  Float_t min=0,max=0;
+  while ( (o=nextGraphicObject()) ){
+    if (o->IsA()==TGraph::Class()){
+      TGraph *gr=(TGraph*)o;
+      if (min==max) {
+        min=TMath::MinElement(gr->GetN(),gr->GetY());
+        max=TMath::MaxElement(gr->GetN(),gr->GetY());
+      } else {
+        Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
+        Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
+        if (currmax>max) max=currmax;
+        if (currmin<min) min=currmin;
+      }
+    }
+  }
+  if (min!=max){
+    if (min!=0) min=min-(max-min)/10;
+    if (max!=0) max=max+(max-min)/10;
+    fCurrentHist->SetMinimum(min);
+    fCurrentHist->SetMaximum(max);
+  }
+}
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoDraw() {
+  //
+  // Draw graphics
+  //
+  TString drawString=fDrawString;
+  TString cutString;
+  GetCutString(cutString);
+  TString optString  = GetDrawOption();
+  Bool_t graphOutput=!fNoGraph;  //ttree buffer for V1, V2... too small
+  graphOutput&=(drawString.First(">>")<0); //histogram output in custom draw
+  graphOutput&=fRadioXhist->GetState()!=kButtonDown; //histogram drawing selected
+  graphOutput&=!(fIsCustomDraw&&!fDrawString.Contains(":")); //custom draw 1D
+  Bool_t drawSame=optString.Contains("same",TString::kIgnoreCase);
+//   optString+="goff";
+  if (graphOutput) {
+    drawString.Prepend("run:time:");
+    optString="goff";
+  }else{
+    if (!fIsCustomDraw){
+      if (fRadioXrun->GetState()==kButtonDown){
+        drawString+=":run";
+      } else if (fRadioXtime->GetState()==kButtonDown){
+        drawString+=":time";
+      }
+    }
+  }
+  TVirtualPad *padsave=gPad;
+  fCanvMain->GetCanvas()->cd();
+  //delete old histograms and graphs
+  if (!drawSame){
+    fTrashBox->Delete();
+    fCurrentGraph=0x0;
+    fCurrentHist=0x0;
+  }
+
+  //select data
+  fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
+  if (fTree->GetSelectedRows()==-1) {
+    return;
+  }
+  UpdateValueArrays(graphOutput);
+  TString title;
+  GetHistogramTitle(title);
+  Bool_t drawGraph=kFALSE;
+  if (graphOutput){
+    if (fIsCustomDraw){
+      if (fDrawString.Contains(":")){
+        fValuesX.SetElements(fTree->GetV4());
+        drawGraph=kTRUE;
+      } else {
+        drawGraph=kFALSE;
+      }
+    }else{
+      drawGraph=kTRUE;
+      if (fRadioXrun->GetState()==kButtonDown){
+        fValuesX.SetElements(fTree->GetV1());
+      } else if (fRadioXtime->GetState()==kButtonDown){
+        fValuesX.SetElements(fTree->GetV2());
+      } else {
+        drawGraph=kFALSE;
+      }
+    }
+  }//create graph according to selection
+  if (drawGraph){
+    TGraph *graph=new TGraph(fValuesX,fValuesY);
+    TString grDraw="p";
+    if (!drawSame) grDraw+="a";
+    if (!fIsCustomDraw) grDraw+="l";
+    graph->Draw(grDraw.Data());
+    graph->SetEditable(kFALSE);
+    TH1 *hist=graph->GetHistogram();
+    hist->SetTitle(title.Data());
+    fTrashBox->Add(graph);
+    graph->SetLineColor(fTrashBox->GetEntries());
+    graph->SetMarkerColor(fTrashBox->GetEntries());
+    if (!drawSame) {
+      fCurrentGraph=graph;
+      fCurrentHist=hist;
+    }
+  } else {
+    TH1 *hist=fTree->GetHistogram();
+    hist->SetTitle(title.Data());
+    fTrashBox->Add(hist);
+    hist->SetLineColor(fTrashBox->GetEntries());
+    hist->SetMarkerColor(fTrashBox->GetEntries());
+    if (!drawSame) fCurrentHist=hist;
+  }
+  
+  //Set time axis if choosen as x-variables
+  if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
+    TAxis *xaxis=fCurrentHist->GetXaxis();
+    xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
+    xaxis->SetTimeDisplay(1);
+    xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
+    xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
+  }
+  if (!drawSame) {
+  //Set title offset
+    fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
+  } else {
+    //adjust y-range
+    AdjustYRange();
+  }
+  gPad->Modified();
+  gPad->Update();
+  padsave->cd();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoDumpRuns()
+{
+  //
+  // Dump the current run numbers to stdout
+  //
+  Int_t npoints=fRunNumbers.GetNrows();
+  Int_t    *sortIndex = new Int_t[npoints];
+  TMath::Sort(npoints,fRunNumbers.GetMatrixArray(),sortIndex,kFALSE);
+  Int_t run=0, prevRun=-1;
+  
+  for (Int_t irun=0;irun<npoints;++irun){
+    run=(Int_t)fRunNumbers.GetMatrixArray()[sortIndex[irun]];
+    if (run!=prevRun) std::cout << Form("%d",run) << std::endl;
+    prevRun=run;
+  }
+  delete sortIndex;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoParLimitChange()
+{
+  //
+  // DoParLimitChange()
+  //
+  UpdateParName();
+  DoDraw();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoNewSelection() {
+  //
+   // decides whether to redraw if user makes another selection
+   //
+  UpdateParLimits();
+  fDrawString=GetDrawString();
+  fIsCustomDraw=kFALSE;
+  DoDraw();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoCustomDraw()
+{
+  //
+  // Custom draw (TTree::Draw syntax)
+  //
+  fDrawString=fComboCustomDraw->GetTextEntry()->GetText();
+  fNmbPar->SetState(kFALSE);
+  fIsCustomDraw=kTRUE;
+  DoDraw();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::DoCustomCutsDraw()
+{
+  //
+  // Custom cuts (TTree::Draw syntax)
+  //
+  if (fIsCustomDraw) DoCustomDraw();
+  else {
+    fDrawString=GetDrawString();
+    fIsCustomDraw=kFALSE;
+    DoDraw();
+  }
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::HandleButtonsDrawSel(Int_t id)
+{
+  //
+  // Draw selection button handling (x-variable)
+  //
+
+  if (id == -1) {
+    TGButton *btn = (TGButton *) gTQSender;
+    id = btn->WidgetId();
+  }
+  
+  Bool_t doDraw=kFALSE;
+  switch (id) {
+  case (kRadioXhist):
+    doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
+    if (doDraw){
+      fRadioXrun->SetState(kButtonUp);
+      fRadioXtime->SetState(kButtonUp);
+    }
+    break;
+  case (kRadioXrun):
+    doDraw=(fRadioXtime->GetState()==kButtonDown||fRadioXhist->GetState()==kButtonDown);
+    if (doDraw){
+      fRadioXhist->SetState(kButtonUp);
+      fRadioXtime->SetState(kButtonUp);
+    }
+    break;
+  case (kRadioXtime):
+    doDraw=(fRadioXhist->GetState()==kButtonDown||fRadioXrun->GetState()==kButtonDown);
+    if (doDraw){
+      fRadioXrun->SetState(kButtonUp);
+      fRadioXhist->SetState(kButtonUp);
+    }
+    break;
+  }
+  if (doDraw) DoCustomCutsDraw();
+}
+//______________________________________________________________________________
+void AliCalibViewerGUItime::UpdateParName()
+{
+  //
+  // change parameter name
+  //
+  
+  Int_t par = (Int_t)(fNmbPar->GetNumber());
+  TString parName="";
+  parName.Form("%d",par);
+  fLblPar->SetText(Form("Parameter: %s",parName.Data()));
+  fDrawString=GetDrawString();
+  fIsCustomDraw=kFALSE;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::UpdateParLimits()
+{
+  //
+  // Adjust limits for TVectorT based variables
+  //
+  if (!fTree) return;
+  TString selectedVariableTitle="";
+  Int_t id=-1;
+  if (!fListVariables->GetSelectedEntry()) return;
+  selectedVariableTitle = fListVariables->GetSelectedEntry()->GetTitle();
+  id=fListVariables->GetSelectedEntry()->EntryId();
+  TString selectedVariable=selectedVariableTitle;
+  //  const TObject *key=(*fConfigParser)(id);
+  //  if (key) selectedVariable=(*fConfigParser)(id)->GetName();
+  
+  if (selectedVariable.IsNull()||!selectedVariable.EndsWith(".")) {
+    fNmbPar->SetState(kFALSE);
+    fLblPar->SetText("Parameter: none");
+    return;
+  }
+  TVectorD *vD=0x0;
+  TVectorF *vF=0x0;
+  Int_t maxPar=0;
+  fTree->GetEntry(1);
+  TBranch *branch=fTree->GetTree()->GetBranch(selectedVariable.Data());
+  TString branchClass=branch->GetClassName();
+  Int_t event=0;
+  if (branchClass=="TVectorT<double>"){
+//     branch->SetAddress(&vD);
+    fTree->SetBranchAddress(selectedVariable.Data(),&vD);
+    while (maxPar<2&&event<fTree->GetEntries()){
+      fTree->GetEntry(event++);
+      maxPar=vD->GetNrows();
+    }
+  } else if (branchClass=="TVectorT<float>"){
+//     branch->SetAddress(&vF);
+    fTree->SetBranchAddress(selectedVariable.Data(),&vF);
+    while (maxPar<2&&event<fTree->GetEntries()){
+      fTree->GetEntry(event++);
+      maxPar=vF->GetNrows();
+    }
+  } else {
+    //class not known
+    fNmbPar->SetState(kFALSE);
+    return;
+  }
+  fTree->SetBranchAddress(selectedVariable.Data(),0x0);
+  if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
+  fNmbPar->SetLimitValues(0,maxPar-1);
+  fNmbPar->SetState(kTRUE);
+  UpdateParName();
+}
+//______________________________________________________________________________
+void AliCalibViewerGUItime::MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/)
+{
+  //
+  // handle mouse events in the draw canvas
+  //
+  UInt_t dd=0,mm=0,yy=0,HH=0,MM=0,SS=0,run=0;
+  Double_t valx=0.,valy=0.;
+  if (!fCurrentGraph) {
+    fLblRunNumberVal->SetText(Form("%07u",run));
+    fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
+    fLblValueXVal->SetText(Form("%.3e", valx));
+    fLblValueYVal->SetText(Form("%.3e", valy));
+    return;
+  }
+  TVirtualPad *padsave=gPad;
+  fCanvMain->GetCanvas()->cd();
+  Int_t n=fValuesY.GetNrows();
+  Double_t *arr=0x0;
+  arr=fValuesX.GetMatrixArray();
+
+  Int_t minDist=1000000;
+  Int_t minPoint=-1;
+  for (Int_t i=0;i<n;++i){
+    Int_t pxp = gPad->XtoAbsPixel(gPad->XtoPad(arr[i]));
+    Int_t pyp = gPad->YtoAbsPixel(gPad->YtoPad(fValuesY[i]));
+    Int_t d   = TMath::Nint(TMath::Sqrt(TMath::Abs(pxp-x) + TMath::Abs(pyp-y)));
+    if (d < minDist) {
+      minDist  = d;
+      minPoint = i;
+    }
+  }
+  if (minDist<2){
+    TTimeStamp t((Int_t)fTimeStamps[minPoint]);
+    t.GetDate(kTRUE,0,&yy,&mm,&dd);
+    t.GetTime(kTRUE,0,&HH,&MM,&SS);
+    run=(UInt_t)fRunNumbers[minPoint];
+    valx=fValuesX[minPoint];
+    valy=fValuesY[minPoint];
+  } else {
+    dd=0;mm=0;yy=0;HH=0;MM=0;SS=0;run=0;
+    valx=0.;
+    valy=0.;
+  }
+  fLblRunNumberVal->SetText(Form("%07u",run));
+  fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
+  if (fIsCustomDraw){
+    fLblValueXVal->SetText(Form("%.3e", valx));
+  }else{
+    if (fRadioXrun->GetState()==kButtonDown){
+      fLblValueXVal->SetText("Run");
+    } else if (fRadioXtime->GetState()==kButtonDown){
+      fLblValueXVal->SetText("Time");
+    }
+  }
+  fLblValueYVal->SetText(Form("%.3e", valy));
+  padsave->cd();
+  if (run==0) {
+    return;
+  }
+  if (event == kButton1Double ){
+    SetGuiTree(run);
+  }
+  //find closes point of current selection
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::SetGuiTree(Int_t run)
+{
+  //
+  // create the AliCalibViewerGUI tree for run
+  // cache tree in directory fOutputCacheDir
+  // retrieve file from this directory if it already exists
+  //
+
+  //try to find file for run in fOutputCacheDir
+  TString fileName=fOutputCacheDir;
+  if (!fileName.EndsWith("/")) fileName+="/";
+  if(fDetector.Contains("TPC")) fileName+=Form("guiTreeRun_%d.root",run);
+  else if(fDetector.Contains("TRD")) fileName+=Form("trdOCDBDetails_run%d.root", run);
+  else return;
+  Bool_t load=kTRUE;
+  TFile f(fileName.Data());
+  if (!f.IsOpen()){
+    if(fDetector.Contains("TRD")) 
+      load = fCalibViewerGUI->CreateDetailsTree(run, fileName.Data(), "nothing");
+    if(fDetector.Contains("TPC")) 
+      load = fCalibViewerGUI->CreateDetailsTree(run, fileName.Data(), "nothing");
+
+    if (!load){
+      fCalibViewerGUI->Reset();
+      if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
+      return;
+    }
+  }
+  f.Close();
+  if(fDetector.Contains("TPC")) fCalibViewerGUI->Initialize(fileName.Data(), "calPads");
+  else fCalibViewerGUI->Initialize(fileName.Data(), "TRDcalibDetails");
+  if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %07d",run)));
+  TIter nextRefTree(fMapRefTrees);
+  TObject *o=0x0;
+  while ( (o=nextRefTree()) ){
+    if(fDetector.Contains("TPC"))
+      fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
+    else
+      fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"TRDcalibDetails",o->GetName());
+  }
+  //if(fDetector.Contains("TPC")) ((AliTPCCalibViewerGUI_new*)fCalibViewerGUI)->Reload();
+  //else ((AliTRDCalibViewerGUI*)fCalibViewerGUI)->Reload();
+  fCalibViewerGUI->Reload();
+}
+
+//______________________________________________________________________________
+const char* AliCalibViewerGUItime::SubstituteUnderscores(const char* in)
+{
+  //
+  // Substitute underscores from the branch names
+  //
+  TString s(in);
+  s.ReplaceAll("_{","|{");
+  s.ReplaceAll("_"," ");
+  s.ReplaceAll("|{","_{");
+  return s.Data();
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::SavePicture() {
+   // 
+   // saves the current picture
+   // 
+   
+  const char *kSaveAsTypes[] = {
+    "Postscript",  "*.ps",
+    "Encapsulated Postscript",   "*.eps",
+    "PDF",   "*.pdf",
+    "JPEG",   "*.jpg",
+    "PNG",   "*.png",
+    "TIFF",   "*.tiff",
+    "GIF",   "*.gif",
+    "XPM",   "*.xpm",
+    "SVG",   "*.svg",
+    "XML",   "*.xml",
+    "C++ macro",   "*.cxx",
+    "Macro file",  "*.C",
+    "ROOT file",   "*.root",
+    "All file",    "*",
+    0,              0
+  };
+  TString dir(".");
+  TGFileInfo fi;
+  fi.fFileTypes = kSaveAsTypes;
+  // fi.fIniDir    = StrDup(dir);
+  fi.fOverwrite = kFALSE;
+  new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDSave, &fi);
+  if (fi.fFilename && strlen(fi.fFilename)) {
+    fCanvMain->GetCanvas()->Print(fi.fFilename);
+  }  
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::HandleLoadRunButtons() {
+  //
+  //  Handle the buttons
+  //
+  Int_t id = ((TGTextButton*)gTQSender)->WidgetId();
+  if(id==100) {
+    UseFile(fTxtFilename->GetText(), fTxtTreeName->GetText());
+    return;
+  }
+  else
+    return;
+}
+
+//______________________________________________________________________________
+void AliCalibViewerGUItime::HandleLoadRunTextEntry() {
+  //
+  //  Handle the text entries
+  //
+  // buttons ID
+  // 100 - fTxtFilename
+  // 101 - fTxtConfigFile
+  
+  Int_t id = ((TGTextEntry*)gTQSender)->WidgetId();
+  if(id>=100 && id<=103) {
+    const char *kTypes[] = {
+      "All files",    "*",
+      0,              0
+    };
+    TString dir(".");
+    TGFileInfo fi;
+    fi.fFileTypes = kTypes;
+    fi.fOverwrite = kFALSE;
+    new TGFileDialog(gClient->GetRoot(), gClient->GetRoot(), kFDOpen, &fi);
+    if(fi.fFilename && strlen(fi.fFilename)) {
+      if(id==100) {
+        fTxtFilename->SetText(fi.fFilename);
+      }
+      if(id==101) {
+       //        fTxtConfigFile->SetText(fi.fFilename);
+       //        fConfigFile=fi.fFilename;
+      }
+      if(id==102) {
+       //fTxtRunList->SetText(fi.fFilename);
+      }
+      if(id==103) {
+       //fTxtOutputOCDB->SetText(fi.fFilename);
+      }
+    }
+    return;
+  }
+  else {
+    return;
+  }
+}
+
+//__________________________________________________________________
+TObjArray* AliCalibViewerGUItime::ShowGUI(TChain* chain) {
+  //
+  //  Launch the time trending GUI. Load the TChain chain into the viewer
+  //
+  TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 650);
+  frmMain->SetWindowName("Calib Viewer - time trend");
+  frmMain->SetCleanup(kDeepCleanup);
+
+  TGTab* tabMain = new TGTab(frmMain, 1000, 600);
+  frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+
+  TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
+
+  AliCalibViewerGUItime* calibViewerTime = new AliCalibViewerGUItime(tabCont1, 1000, 650);
+  tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  calibViewerTime->UseChain(chain);
+
+  TObjArray *guiArray = new TObjArray();
+  guiArray->Add(calibViewerTime);
+
+  frmMain->MapSubwindows();
+  frmMain->Resize();
+  frmMain->MapWindow();
+  return guiArray;
+}
+
+//__________________________________________________________________
+TObjArray* AliCalibViewerGUItime::ShowGUI() {
+  //
+  //  Launch the time trending GUI. The GUI will be empty but trees can be loaded by using the GUI interface
+  //
+  TGMainFrame* frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 650);
+  frmMain->SetWindowName("Calib Viewer - time trend");
+  frmMain->SetCleanup(kDeepCleanup);
+
+  TGTab* tabMain = new TGTab(frmMain, 1000, 600);
+  frmMain->AddFrame(tabMain, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+
+  TGCompositeFrame* tabCont1 = tabMain->AddTab("Time");
+
+  AliCalibViewerGUItime* calibViewerTime = new AliCalibViewerGUItime(tabCont1, 1000, 650);
+  tabCont1->AddFrame(calibViewerTime, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0, 0, 0, 0));
+  
+  TObjArray *guiArray = new TObjArray();
+  guiArray->Add(calibViewerTime);
+
+  frmMain->MapSubwindows();
+  frmMain->Resize();
+  frmMain->MapWindow();
+  return guiArray;
+}
diff --git a/STEER/AliCalibViewerGUItime.h b/STEER/AliCalibViewerGUItime.h
new file mode 100644 (file)
index 0000000..04fdb17
--- /dev/null
@@ -0,0 +1,187 @@
+#ifndef ALICALIBVIEWERGUITIME_H
+#define ALICALIBVIEWERGUITIME_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* $Id: AliCalibViewerGUItime.h,v */
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  GUI for displaying calibration entries over run/time                     //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+
+#ifndef ROOT_TGButton
+#include <TGWidget.h>
+#endif
+#ifndef ROOT_TGFrame
+#include <TGFrame.h>
+#endif
+#include <TString.h>
+#include <TVectorT.h>
+
+class TGCompositeFrame;
+class TRootEmbeddedCanvas;
+class TGTextButton;
+class TGListBox;
+class TGRadioButton;
+class TGComboBox;
+class TGGroupFrame;
+class TGLabel;
+class TGTabElement;
+class TGWindow;
+
+class TFile;
+class TTree;
+class TChain;
+class TGraph;
+class TObjArray;
+
+class TMap;
+
+class AliBaseCalibViewerGUI;
+
+class AliCalibViewerGUItime : public TGCompositeFrame {
+public:
+  AliCalibViewerGUItime(const TGWindow *p, UInt_t w, UInt_t h, const Char_t* det = "TRD");
+  virtual ~AliCalibViewerGUItime();
+
+  static TObjArray* ShowGUI(TChain* chain);   // launch the time trending GUI and load a chain
+  static TObjArray* ShowGUI();        // launch the empty time trending GUI
+
+  void DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h);
+  
+  void UseFile(const char* fileName, const char* treeName);
+  void UseChain(TChain *chain = 0);
+  void Reload(Int_t first=1);
+  void AddReferenceTree(const char* treeFileName, const char* refName="R");
+  
+  void SetCalibViewerGUI(AliBaseCalibViewerGUI *gui) {fCalibViewerGUI=gui;}
+  void SetCalibViewerGUItab(TGTabElement *tab) {fCalibViewerGUItab=tab;}
+  void SetCacheDir(const char* cachedir) {fOutputCacheDir=cachedir;}
+  
+  const char* GetDrawString();
+  const char* GetDrawOption();
+  void GetCutString(TString &cutStr);
+  TChain* GetChain() const {return fTree;}
+  //Slots
+  void DoDraw();
+  void DoDumpRuns();
+  void DoCustomDraw();
+  void DoCustomCutsDraw();
+  void DoParLimitChange();
+  void DoNewSelection();                    // decides whether to redraw if user makes another selection
+  void DoChangeSelectionList() {Reload(0);}
+  void HandleButtonsDrawSel(Int_t id = -1);              
+  void MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/);
+  void SavePicture();
+  void HandleLoadRunTextEntry();
+  void HandleLoadRunButtons();
+  
+ private:
+  TString fDetector;                       // TPC/TRD
+
+  TFile*  fFile;                          //file that keeps the tree
+  TChain*  fTree;                         //internal tree
+  AliBaseCalibViewerGUI *fCalibViewerGUI;  //calib viewer gui used to display verbose information for one run
+  TGTabElement *fCalibViewerGUItab;       //tab the calib view gui redies in
+  TH1*    fCurrentHist;                   //histogram currently drawn in main canvas
+  TGraph* fCurrentGraph;                  //current graph
+  Int_t   fCurrentRunDetails;             //run number for wich details are currently shown
+  TString fOutputCacheDir;                //output cache diretory for AliTPCCalibViewerGUI trees, created on the fly
+  TString fDrawString;                    //current draw string
+  Bool_t  fIsCustomDraw;                  //if custom draw string is selected
+  TVectorD fRunNumbers;                   //run numbers of current selection
+  TVectorD fTimeStamps;                   //timr stamps of current selection
+  TVectorD fValuesX;                      //values of current selection
+  TVectorD fValuesY;                      //values of current selection
+  //
+  Bool_t  fNoGraph;                       //Whether to create a graph
+  Long64_t fGraphLimitEntries;            //limit in number of entries in the chain for producing a graph
+  //
+  TMap *fMapRefTrees;                      //map of reference trees for the CalibViewer
+  //GUI elements
+  //main canvas Top part, bottom part
+  TGCompositeFrame    *fContTopBottom;      // container for all GUI elements, vertical divided
+  //top left, centre, right
+  TGCompositeFrame    *fContLCR;            // container for all GUI elements, horizontal divided
+  //content left
+  TGCompositeFrame    *fContLeft;           // container for GUI elements on left side
+  TGGroupFrame        *fContDrawOpt;        // Subgroup for draw selection
+  TGCheckButton       *fChkDrawOptSame;     // draw option 'same'
+  TGComboBox          *fComboAddDrawOpt;    // additional draw options combo box
+  TGGroupFrame        *fContDrawSel;        // Subgroup for draw selection
+  TGCompositeFrame    *fContDrawSelSubRunTime; //Radio button subframe
+  TGRadioButton       *fRadioXhist;         // Radio button x-variable: show only 1D distribution
+  TGRadioButton       *fRadioXrun;          // Radio button x-variable: run
+  TGRadioButton       *fRadioXtime;         // Radio button x-variable: time
+  TGListBox           *fListVariables;      // listbox with possible variables
+  TGComboBox          *fComboRunType;       // run type selection box
+  TGLabel             *fLblRunType;         // run type label
+  TGNumberEntry       *fNmbPar;             // parameter number
+  TGLabel             *fLblPar;             // parameter name
+  TGListBox           *fListCalibType;      // calibration type selection box
+  TGGroupFrame        *fContCalibType;      // calibration type label
+  //content centre
+  TGCompositeFrame    *fContCenter;         // container for GUI elements at the center
+  TRootEmbeddedCanvas *fCanvMain;           // main drawing canvas
+  //content right 
+  TGCompositeFrame    *fContRight;          // container for GUI elements on right side
+  TGGroupFrame        *fContValues;         // container to keep data point information
+  TGLabel             *fLblRunNumber;       // run number label
+  TGLabel             *fLblRunTime;         // time stamp label
+  TGLabel             *fLblValueX;          // value label
+  TGLabel             *fLblValueY;          // value label
+  TGLabel             *fLblRunNumberVal;    // run number of the data point hoovered
+  TGLabel             *fLblRunTimeVal;      // time stamp of the data point hoovered
+  TGLabel             *fLblValueXVal;       // value of the data point hoovered
+  TGLabel             *fLblValueYVal;       // value of the data point hoovered
+  TGTextButton        *fBtnDumpRuns;        // draw button
+  TGTextButton        *fBtnSave;            // Save button
+
+  TGGroupFrame        *fContLoad;           // Load file container
+  TGCompositeFrame    *fContFilename;       // filename container
+  TGCompositeFrame    *fContConfigFile;     // config file container
+  TGCompositeFrame    *fContTreeName;       // tree name container
+  TGLabel             *fLblTreeName;        // tree name label
+  TGTextEntry         *fTxtFilename;        // filename text entry
+  TGTextEntry         *fTxtConfigFile;      // config file text entry
+  TGTextEntry         *fTxtTreeName;        // tree name text entry
+  TGButton            *fBtnLoadFile;        // load file button
+
+  //content bottom
+  TGCompositeFrame    *fContCustom;         // container for custom draw command GUI elements
+  TGCompositeFrame    *fContCustomCuts;     // container for custom cut options GUI elements
+  TGLabel             *fLblCustomDraw;      // label for custom draw string
+  TGLabel             *fLblCustomCuts;      // label for custom cuts string
+  TGComboBox          *fComboCustomDraw;    // combo box custom draw string
+  TGComboBox          *fComboCustomCuts;    // combo box custom cuts string
+  //
+  TObjArray *fTrashBox;                   //graphics objects to be deleted (histograms, graphs,...)
+  
+  enum { kRadioXhist=10, kRadioXrun=11, kRadioXtime=12 };
+  enum { kBranchOnOff=0, kBranchTitle=1, kCalibType=2, kParamNames=3 };
+  
+  void UpdateParLimits();
+  void UpdateParName();
+  void SetGuiTree(Int_t run);
+  void FillRunTypes();
+  void FillCalibTypes();
+  void SetInitialValues();
+  void CheckDrawGraph();
+  Bool_t CheckChain();
+  void UpdateValueArrays(Bool_t withGraph);
+  const char* SubstituteUnderscores(const char* in);
+  void GetHistogramTitle(TString &title);
+  void AdjustYRange();
+private:
+  AliCalibViewerGUItime(const AliCalibViewerGUItime &v);
+  AliCalibViewerGUItime &operator = (const AliCalibViewerGUItime &v);         // assignment operator
+  
+  ClassDef(AliCalibViewerGUItime, 1)
+    
+};
+
+#endif
index 0f835ca..44e523d 100644 (file)
@@ -44,4 +44,8 @@
 #pragma link C++ class  TTreeStream+;
 #pragma link C++ class  TTreeSRedirector+;
 
+#pragma link C++ class  AliBaseCalibViewer+;
+#pragma link C++ class  AliBaseCalibViewerGUI+;
+#pragma link C++ class  AliCalibViewerGUItime+;
+
 #endif
index c3750ce..1374162 100644 (file)
@@ -7,7 +7,8 @@ AliDCSValue.cxx AliDCSSensor.cxx AliDCSSensorArray.cxx \
 AliDCSGenDB.cxx AliSplineFit.cxx TTreeStream.cxx \
 AliPreprocessor.cxx AliShuttleInterface.cxx \
 AliGRPDCS.cxx \
-AliCDBHandler.cxx
+AliCDBHandler.cxx \
+AliBaseCalibViewer.cxx AliBaseCalibViewerGUI.cxx AliCalibViewerGUItime.cxx
 
 HDRS:= $(SRCS:.cxx=.h)
 
@@ -20,7 +21,8 @@ AliDCSValue.h AliDCSSensor.h AliDCSSensorArray.h \
 AliDCSGenDB.h AliSplineFit.h TTreeStream.h \
 AliPreprocessor.h  AliShuttleInterface.h \
 AliGRPDCS.h \
-AliCDBHandler.h
+AliCDBHandler.h \
+AliBaseCalibViewer.h AliBaseCalibViewerGUI.h AliCalibViewerGUItime.h
 
 ifeq (win32gcc,$(ALICE_TARGET))
 PACKSOFLAGS:= $(SOFLAGS) -L$(ALICE_ROOT)/lib/tgt_$(ALICE_TARGET) -lSTEERBase -lMinuit