]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCCalibViewer.cxx
Setter for the PID response parameterization (Jens)
[u/mrichter/AliRoot.git] / TPC / AliTPCCalibViewer.cxx
index 81ffb656845c3ffa53022a0230e0b4e89f8a59f1..cb6972c02d1ac2e9baae65ad3bd907e772f284cd 100644 (file)
@@ -70,6 +70,7 @@
 //
 #include "AliTPCCalibViewer.h"
 
+using std::ifstream;
 ClassImp(AliTPCCalibViewer)
 
 
@@ -160,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));
@@ -194,20 +197,18 @@ 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;
 }
 
@@ -575,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) {
@@ -687,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
    // 
    //
@@ -748,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) {
@@ -793,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
@@ -804,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";
@@ -838,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++) {
@@ -899,7 +899,7 @@ 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) {
@@ -920,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  
    */
    
@@ -945,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;
@@ -995,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
@@ -1004,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(">>");
@@ -1044,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);
   
@@ -1263,22 +1262,22 @@ TH1F* AliTPCCalibViewer::SigmaCut(TH1F *const histogram, Float_t mean, Float_t s
    // 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();
@@ -1298,7 +1297,7 @@ TH1F* AliTPCCalibViewer::SigmaCut(TH1F *const histogram, Float_t mean, Float_t s
          shistPM->Draw();   
          return macro_example_canvas;
       }  
-      end_macro
+      End_Macro
    */ 
    
    Float_t *array = histogram->GetArray();
@@ -1382,20 +1381,12 @@ TH1F* AliTPCCalibViewer::SigmaCut(Int_t n, const Float_t *array, Float_t mean, F
 }
 
 
-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){
+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;
 }   
@@ -1410,20 +1401,20 @@ TH1F* AliTPCCalibViewer::Integrate(TH1F *const histogram, Float_t mean, Float_t
    // "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();
@@ -1438,7 +1429,7 @@ TH1F* AliTPCCalibViewer::Integrate(TH1F *const histogram, Float_t mean, Float_t
          
          return macro_example_canvas_Integrate;
       }  
-      end_macro
+      End_Macro
    */ 
 
    
@@ -1765,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++){
@@ -1773,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)); 
    }
@@ -1800,10 +1798,10 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
    returnFormula.Append(" )");
    delete formulaTokens;
    delete fitter;
-  for (Int_t i = 0; i < dim + 1; i++){
-    delete [] values[i];
-  }
-  delete [] values;
+   for (Int_t i = 0; i < dim + 1; i++){
+     delete [] values[i];
+   }
+   delete [] values;
    return preturnFormula;
 }
 
@@ -2370,6 +2368,7 @@ void AliTPCCalibViewer::CreateObjectList(const Char_t *filename, TObjArray *cali
       }
       delete fIn;
    }
+   delete arrFileLine;
 }