]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCCalibViewer.cxx
Adding debug information (on demand)
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewer.cxx
index 361b47d6ea9b9a784bcbe3edcc800f0abb271ad1..cb6972c02d1ac2e9baae65ad3bd907e772f284cd 100644 (file)
 //
 // ROOT includes 
 //
-#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 <iostream>
+
+#include <TFile.h>
+#include <TFriendElement.h>
+#include <TGraph.h>
+#include <TKey.h>
+#include <TPad.h>
+//#include <TCanvas.h>
 #include <TH1.h> 
 #include <TH1F.h>
-#include <THashTable.h>
+#include <TLegend.h>
+#include <TLine.h>
+#include <TMath.h>
 #include <TObjString.h>
-#include "TTreeStream.h"
-#include "TFile.h"
-#include "TKey.h"
-#include "TGraph.h"
-#include "TDirectory.h"
-#include "AliTPCCalibPulser.h"
-#include "AliTPCCalibPedestal.h"
-#include "AliTPCCalibCE.h"
-#include "TFriendElement.h"
-// #include "TObjArray.h"
-// #include "TObjString.h"
-// #include "TString.h"
-// #include "AliTPCCalPad.h"
+//#include <TROOT.h>
+#include <TRandom.h>
+#include <TString.h>
+#include <TStyle.h>
+#include <TTreeStream.h>
 
+#include "AliTPCCalibCE.h"
+#include "AliMathBase.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCCalibPedestal.h"
+#include "AliTPCCalibPulser.h"
 
 //
 // AliRoot includes
 //
 #include "AliTPCCalibViewer.h"
 
+using std::ifstream;
 ClassImp(AliTPCCalibViewer)
 
 
@@ -110,7 +112,7 @@ AliTPCCalibViewer::AliTPCCalibViewer(const AliTPCCalibViewer &c)
 }
 
 //_____________________________________________________________________________
-AliTPCCalibViewer::AliTPCCalibViewer(TTree* tree)
+AliTPCCalibViewer::AliTPCCalibViewer(TTree *const tree)
                   :TObject(),
                    fTree(0),
                    fFile(0),
@@ -159,6 +161,8 @@ AliTPCCalibViewer & AliTPCCalibViewer::operator =(const AliTPCCalibViewer & para
    // assignment operator - dummy
    // not yet working!!!
    //
+  if (this == &param) return (*this);
+
    fTree = param.fTree;
    fTreeMustBeDeleted = param.fTreeMustBeDeleted;
    //fFile = new TFile(*(param.fFile));
@@ -193,25 +197,23 @@ AliTPCCalibViewer::~AliTPCCalibViewer()
 }
 
 //_____________________________________________________________________________
-void AliTPCCalibViewer::Delete(Option_t* option) {
+void AliTPCCalibViewer::Delete(Option_t* /*option*/) {
    //
    // Should be called from AliTPCCalibViewerGUI 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 fFile;
    delete fListOfObjectsToBeDeleted;
 }
 
 
-const char* AliTPCCalibViewer::AddAbbreviations(char* c, Bool_t printDrawCommand){ 
+const char* AliTPCCalibViewer::AddAbbreviations(const Char_t *c, Bool_t printDrawCommand){ 
    // Replace all "<variable>" with "<variable><fAbbreviation>" (Adds forgotten "~")
    // but take care on the statistical information, like "CEQmean_Mean"
    // and also take care on correct given variables, like "CEQmean~"
@@ -304,8 +306,10 @@ const char* AliTPCCalibViewer::AddAbbreviations(char* c, Bool_t printDrawCommand
    str.ReplaceAll(removeString, "");
   
    if (printDrawCommand) std::cout << "The string looks now like: " << str.Data() << std::endl;
-   delete varSort;
-   delete normSort;
+   delete [] varLengths;
+   delete [] normLengths;
+   delete [] varSort;
+   delete [] normSort;
    return str.Data();
 }
 
@@ -417,9 +421,7 @@ Int_t AliTPCCalibViewer::EasyDraw(const char* drawCommand, Int_t sector, const c
   // writeDrawCommand: write the command, that is passed to TTree::Draw
   //
    if (sector >= 0 && sector < 72) {
-      char sectorChr[3];
-      sprintf(sectorChr, "%i", sector);
-      return EasyDraw(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
+      return EasyDraw(drawCommand, Form("%i", sector), cuts, drawOptions, writeDrawCommand);
    }
    Error("EasyDraw","The TPC contains only sectors between 0 and 71.");
    return -1;
@@ -500,9 +502,7 @@ Int_t AliTPCCalibViewer::EasyDraw1D(const char* drawCommand, Int_t sector, const
   //
 
    if (sector >= 0 && sector < 72) {
-      char sectorChr[3];
-      sprintf(sectorChr, "%i", sector);
-      return EasyDraw1D(drawCommand, sectorChr, cuts, drawOptions, writeDrawCommand);
+      return EasyDraw1D(drawCommand, Form("%i",sector), cuts, drawOptions, writeDrawCommand);
    }
   Error("EasyDraw","The TPC contains only sectors between 0 and 71.");
   return -1;
@@ -550,9 +550,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, Int_t sector, con
    // "plotMean", "plotMedian" and "plotLTM": what kind of lines do you want to see?
    // 
    if (sector >= 0 && sector < 72) {
-      char sectorChr[3];
-      sprintf(sectorChr, "%i", sector);
-      return DrawHisto1D(drawCommand, sectorChr, cuts, sigmas, plotMean, plotMedian, plotLTM);
+      return DrawHisto1D(drawCommand, Form("%i", sector), cuts, sigmas, plotMean, plotMedian, plotLTM);
    }
    Error("DrawHisto1D","The TPC contains only sectors between 0 and 71.");
    return -1;
@@ -578,7 +576,8 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
       Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
       nsigma[i] = sig;
    }
-   
+   delete sigmasTokens;
+
    TString drawStr(drawCommand);
    Bool_t dangerousToDraw = drawStr.Contains(":") || drawStr.Contains(">>");
    if (dangerousToDraw) {
@@ -596,9 +595,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
    Double_t sigma = TMath::RMS(entries, values);
    Double_t maxY = htemp->GetMaximum();
    
-   char c[500];
    TLegend * legend = new TLegend(.7,.7, .99, .99, "Statistical information");
-//    sprintf(c, "%s, sector: %i", type, sector);
    //fListOfObjectsToBeDeleted->Add(legend);
 
    if (plotMean) {
@@ -609,8 +606,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
       line->SetLineWidth(2);
       line->SetLineStyle(1);
       line->Draw();
-      sprintf(c, "Mean: %f", mean);
-      legend->AddEntry(line, c, "l");
+      legend->AddEntry(line, Form("Mean: %f", mean), "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);
@@ -623,8 +619,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
          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");
+         legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l");
       }
    }
    if (plotMedian) {
@@ -635,8 +630,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
       line->SetLineWidth(2);
       line->SetLineStyle(1);
       line->Draw();
-      sprintf(c, "Median: %f", median);
-      legend->AddEntry(line, c, "l");
+      legend->AddEntry(line, Form("Median: %f", median), "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);
@@ -649,8 +643,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
          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");
+         legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f",(Int_t)(nsigma[i]), (Float_t)(nsigma[i] * sigma)), "l");
       }
    }
    if (plotLTM) {
@@ -663,8 +656,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
       line->SetLineWidth(2);
       line->SetLineStyle(1);
       line->Draw();
-      sprintf(c, "LTM: %f", ltm);
-      legend->AddEntry(line, c, "l");
+      legend->AddEntry(line, Form("LTM: %f", ltm), "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);
@@ -678,8 +670,7 @@ Int_t  AliTPCCalibViewer::DrawHisto1D(const char* drawCommand, const char* secto
          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");
+         legend->AddEntry(lineMinusSigma, Form("%i #sigma = %f", (Int_t)(nsigma[i]), (Float_t)(nsigma[i] * ltmRms)), "l");
       }
    }
    if (!plotMean && !plotMedian && !plotLTM) return -1;
@@ -698,7 +689,7 @@ Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, Int_t sector, const c
    // 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
    // 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 }
+   // f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = (#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)
    // End_Latex
    // 
    //
@@ -710,9 +701,7 @@ Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, Int_t sector, const c
    // plotMean/plotMedian/plotLTM: specifies where to put the center
    //
    if (sector >= 0 && sector < 72) {
-      char sectorChr[3];
-      sprintf(sectorChr, "%i", sector);
-      return SigmaCut(drawCommand, sectorChr, cuts, sigmaMax, plotMean, plotMedian, plotLTM, pm, sigmas, sigmaStep);
+      return SigmaCut(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, pm, sigmas, sigmaStep);
    }
    Error("SigmaCut","The TPC contains only sectors between 0 and 71.");
    return -1;
@@ -761,7 +750,8 @@ Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, const char* sector, c
       Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
       nsigma[i] = sig;
    }
-  
+   delete sigmasTokens;
+
    if (plotMean) {
       cutHistoMean = AliTPCCalibViewer::SigmaCut(htemp, mean, sigma, sigmaMax, sigmaStep, pm);
       if (cutHistoMean) {
@@ -806,7 +796,7 @@ Int_t AliTPCCalibViewer::SigmaCut(const char* drawCommand, const char* sector, c
 }
 
 
-Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t pm, const char *sigmas, Float_t sigmaStep) const {
+Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector, const char* cuts, Float_t /*sigmaMax*/, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, Bool_t /*pm*/, const char *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
@@ -817,10 +807,6 @@ Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector
    //
   
    // Double_t ltmFraction = 0.8;  //unused
-   // avoid compiler warnings:
-   sigmaMax = sigmaMax;
-   pm = pm;
-   sigmaStep = sigmaStep;
    
    TString drawStr(drawCommand);
    drawStr += " >> tempHist";
@@ -851,6 +837,7 @@ Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector
       Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
       nsigma[i] = sig;
    }
+   delete sigmasTokens;
    
    if (plotMean) {
       for (Int_t i = 0; i < entries; i++) {
@@ -867,6 +854,9 @@ Int_t AliTPCCalibViewer::SigmaCutNew(const char* drawCommand, const char* sector
          DrawLines(cutGraphMean, nsigma, legend, kRed, kTRUE);
       }
    }
+  delete [] index;
+  delete [] xarray;
+  delete [] yarray;
    /*
    if (plotMedian) {
       cutHistoMedian = AliTPCCalibViewer::SigmaCut(htemp, median, sigma, sigmaMax, sigmaStep, pm);
@@ -909,13 +899,11 @@ Int_t AliTPCCalibViewer::Integrate(const char* drawCommand,       Int_t sector,
    // "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 }
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
       End_Latex  
    */
    if (sector >= 0 && sector < 72) {
-      char sectorChr[3];
-      sprintf(sectorChr, "%i", sector);
-      return Integrate(drawCommand, sectorChr, cuts, sigmaMax, plotMean, plotMedian, plotLTM, sigmas, sigmaStep);
+      return Integrate(drawCommand, Form("%i", sector), cuts, sigmaMax, plotMean, plotMedian, plotLTM, sigmas, sigmaStep);
    }
    Error("Integrate","The TPC contains only sectors between 0 and 71.");
    return -1;
@@ -932,7 +920,7 @@ Int_t AliTPCCalibViewer::IntegrateOld(const char* drawCommand, const char* secto
    // "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 }
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
       End_Latex  
    */
    
@@ -957,7 +945,8 @@ Int_t AliTPCCalibViewer::IntegrateOld(const char* drawCommand, const char* secto
       Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
       nsigma[i] = sig;
    }
-  
+   delete sigmasTokens;
+
    TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram");
    //fListOfObjectsToBeDeleted->Add(legend);
    TH1F *integralHistoMean = 0;
@@ -1007,7 +996,7 @@ Int_t AliTPCCalibViewer::IntegrateOld(const char* drawCommand, const char* secto
 }
 
 
-Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector, const char* cuts, Float_t sigmaMax, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *sigmas, Float_t sigmaStep) const {
+Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector, const char* cuts, Float_t /*sigmaMax*/, Bool_t plotMean, Bool_t plotMedian, Bool_t plotLTM, const char *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
@@ -1016,14 +1005,11 @@ Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector,
    // "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 }
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #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(">>");
@@ -1056,7 +1042,8 @@ Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector,
       Double_t sig = (str.IsFloat()) ? str.Atof() : 0;
       nsigma[i] = sig;
    }
-  
+   delete sigmasTokens;
+
    TLegend * legend = new TLegend(.7,.7, .99, .99, "Integrated histogram");
    //fListOfObjectsToBeDeleted->Add(legend);
   
@@ -1109,6 +1096,10 @@ Int_t AliTPCCalibViewer::Integrate(const char* drawCommand, const char* sector,
          DrawLines(integralGraphLTM, nsigma, legend, kGreen+2, kTRUE);
       }
    }
+   delete [] index;
+   delete [] xarray;
+   delete [] yarray;
+  
    if (!plotMean && !plotMedian && !plotLTM) return -1;
    legend->Draw();
    return entries;
@@ -1122,7 +1113,6 @@ void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *leg
    // 
    
    // start to draw the lines, loop over requested sigmas
-   char c[500];
    for (Int_t i = 0; i < nsigma.GetNoElements(); i++) {
       if (!pm) { 
          Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
@@ -1136,8 +1126,7 @@ void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *leg
          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");
+         legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
       }
       else { // if (pm)
          Int_t bin = histogram->GetXaxis()->FindBin(nsigma[i]);
@@ -1151,8 +1140,7 @@ void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *leg
          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");
+         legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
          bin = histogram->GetXaxis()->FindBin(-nsigma[i]);
          TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], histogram->GetBinContent(bin));
          //fListOfObjectsToBeDeleted->Add(lineUp2);
@@ -1164,8 +1152,7 @@ void AliTPCCalibViewer::DrawLines(TH1F *histogram, TVectorF nsigma, TLegend *leg
          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");
+         legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], histogram->GetBinContent(bin)), "l");
       }
    }  // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)   
 }
@@ -1178,7 +1165,6 @@ void AliTPCCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legen
    // 
    
    // start to draw the lines, loop over requested sigmas
-   char 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]));
@@ -1191,8 +1177,7 @@ void AliTPCCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legen
          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");
+         legend->AddEntry(lineLeft, Form("Fraction(%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l");
       }
       else { // if (pm)
          TLine* lineUp1 = new TLine(nsigma[i], 0, nsigma[i], graph->Eval(nsigma[i]));
@@ -1205,8 +1190,7 @@ void AliTPCCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legen
          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");
+         legend->AddEntry(lineLeft1, Form("Fraction(+%f #sigma) = %f",nsigma[i], graph->Eval(nsigma[i])), "l");
          TLine* lineUp2 = new TLine(-nsigma[i], 0, -nsigma[i], graph->Eval(-nsigma[i]));
          //fListOfObjectsToBeDeleted->Add(lineUp2);
          lineUp2->SetLineColor(color);
@@ -1217,8 +1201,7 @@ void AliTPCCalibViewer::DrawLines(TGraph *graph, TVectorF nsigma, TLegend *legen
          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");
+         legend->AddEntry(lineLeft2, Form("Fraction(-%f #sigma) = %f",nsigma[i], graph->Eval(-nsigma[i])), "l");
       }
    }  // for (Int_t i = 0; i < nsigma.GetNoElements(); i++)   
 }
@@ -1250,7 +1233,7 @@ Int_t AliTPCCalibViewer::GetBin(Float_t value, Int_t nbins, Double_t binLow, Dou
 }   
 
 
-Double_t AliTPCCalibViewer::GetLTM(Int_t n, Double_t *array, Double_t *sigma, Double_t fraction){
+Double_t AliTPCCalibViewer::GetLTM(Int_t n, const Double_t *const array, Double_t *const sigma, Double_t fraction){
    //
    //  returns the LTM and sigma
    //
@@ -1269,7 +1252,7 @@ Double_t AliTPCCalibViewer::GetLTM(Int_t n, Double_t *array, Double_t *sigma, Do
 }
 
 
-TH1F* AliTPCCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep, Bool_t pm) {
+TH1F* AliTPCCalibViewer::SigmaCut(TH1F *const 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'
@@ -1279,22 +1262,22 @@ TH1F* AliTPCCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma,
    // 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    
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = (#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 }
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #int_{#mu}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
       End_Latex  
-      begin_macro(source)
+      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);
+         TH1F *distribution = new TH1F("Distrib1", "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);
+         TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer1", "", 350, 350);
          macro_example_canvas->Divide(0,3);
          TVirtualPad *pad1 = macro_example_canvas->cd(1);
          pad1->SetGridy();
@@ -1314,7 +1297,7 @@ TH1F* AliTPCCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma,
          shistPM->Draw();   
          return macro_example_canvas;
       }  
-      end_macro
+      End_Macro
    */ 
    
    Float_t *array = histogram->GetArray();
@@ -1325,7 +1308,7 @@ TH1F* AliTPCCalibViewer::SigmaCut(TH1F *histogram, Float_t mean, Float_t sigma,
 }   
    
 
-TH1F* AliTPCCalibViewer::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){
+TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, const 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
@@ -1398,26 +1381,18 @@ TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, Float_t *array, Float_t mean, Float_t
 }
 
 
-TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, Double_t *array, Double_t mean, Double_t sigma, Int_t nbins, Double_t *xbins, Double_t sigmaMax){
+TH1F* AliTPCCalibViewer::SigmaCut(Int_t /*n*/, const Double_t */*array*/, Double_t /*mean*/, Double_t /*sigma*/, Int_t /*nbins*/, const 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;
 }   
 
 
-TH1F* AliTPCCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma, Float_t sigmaMax, Float_t sigmaStep){
+TH1F* AliTPCCalibViewer::Integrate(TH1F *const 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
@@ -1426,20 +1401,20 @@ TH1F* AliTPCCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma,
    // "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 }
+         f(x, #mu, #sigma)     #Rightarrow       S(t, #mu, #sigma) = #int_{-#infty}^{#mu + t #sigma} f(x, #mu, #sigma) dx / #int_{-#infty}^{+#infty} f(x, #mu, #sigma) dx
       End_Latex  
-      begin_macro(source)
+      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);
+         TH1F *distribution = new TH1F("Distrib2", "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);
+         TCanvas* macro_example_canvas = new TCanvas("cAliTPCCalibViewer2", "", 350, 350);
          macro_example_canvas->Divide(0,2);
          TVirtualPad *pad1 = macro_example_canvas->cd(1);
          pad1->SetGridy();
@@ -1454,7 +1429,7 @@ TH1F* AliTPCCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma,
          
          return macro_example_canvas_Integrate;
       }  
-      end_macro
+      End_Macro
    */ 
 
    
@@ -1466,7 +1441,7 @@ TH1F* AliTPCCalibViewer::Integrate(TH1F *histogram, Float_t mean, Float_t sigma,
 }   
 
 
-TH1F* AliTPCCalibViewer::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){
+TH1F* AliTPCCalibViewer::Integrate(Int_t n, const Float_t *const 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 
@@ -1781,7 +1756,10 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
    fitter->ClearPoints();
    
    Int_t entries = Draw(drawStr.Data(), cutStr.Data(), "goff");
-   if (entries == -1) return new TString("An ERROR has occured during fitting!");
+   if (entries == -1) {
+     delete formulaTokens;
+     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++){
@@ -1789,7 +1767,11 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
       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!");
+      if (entries != centries) {
+        delete [] values;
+       delete formulaTokens;
+        return new TString("An ERROR has occured during fitting!");
+      }
       values[i] = new Double_t[entries];
       memcpy(values[i],  fTree->GetV1(), entries*sizeof(Double_t)); 
    }
@@ -1805,7 +1787,7 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
    fitter->GetParameters(fitParam);
    fitter->GetCovarianceMatrix(covMatrix);
    chi2 = fitter->GetChisquare();
-   chi2 = chi2;
+//    chi2 = chi2;
    
    TString *preturnFormula = new TString(Form("( %e+",fitParam[0])), &returnFormula = *preturnFormula;
    
@@ -1816,12 +1798,15 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
    returnFormula.Append(" )");
    delete formulaTokens;
    delete fitter;
-   delete[] values;
+   for (Int_t i = 0; i < dim + 1; i++){
+     delete [] values[i];
+   }
+   delete [] values;
    return preturnFormula;
 }
 
 
-void AliTPCCalibViewer::MakeTreeWithObjects(const char * fileName, TObjArray * array, const char * mapFileName) {
+void AliTPCCalibViewer::MakeTreeWithObjects(const char *fileName, const TObjArray *const array, const char * mapFileName) {
   //
   // Write tree with all available information
   // im mapFileName is speciefied, the Map information are also written to the tree
@@ -1970,7 +1955,7 @@ void AliTPCCalibViewer::MakeTreeWithObjects(const char * fileName, TObjArray * a
 }
 
 
-void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
+void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad *const outlierPad, Float_t ltmFraction) {
   //
   // Write a tree with all available information
   // if mapFileName is speciefied, the Map information are also written to the tree
@@ -2383,6 +2368,7 @@ void AliTPCCalibViewer::CreateObjectList(const Char_t *filename, TObjArray *cali
       }
       delete fIn;
    }
+   delete arrFileLine;
 }