]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFit.cxx
Compare method fixed (Plamen)
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.cxx
index dba5ced0cd142b9ce43f7f76b093fe64a000a68f..c472d7f361b499c98488c55ba877ff3767d8860c 100644 (file)
@@ -76,6 +76,7 @@
 #include "AliTRDgeometry.h"
 #include "AliTRDpadPlane.h"
 #include "AliTRDgeometry.h"
+#include "AliTRDCommonParam.h"
 #include "./Cal/AliTRDCalROC.h"
 #include "./Cal/AliTRDCalPad.h"
 #include "./Cal/AliTRDCalDet.h"
@@ -331,7 +332,7 @@ void AliTRDCalibraFit::DestroyDebugStreamer()
  
 }
 //__________________________________________________________________________________
-void AliTRDCalibraFit::RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end)
+void AliTRDCalibraFit::RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end) const
 {
   //
   // From the drift velocity and t0
@@ -353,7 +354,7 @@ void AliTRDCalibraFit::RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t
 
 }
 //____________Functions fit Online CH2d________________________________________
-Bool_t AliTRDCalibraFit::AnalyseCH(TH2I *ch)
+Bool_t AliTRDCalibraFit::AnalyseCH(const TH2I *ch)
 {
   //
   // Fit the 1D histos, projections of the 2D ch on the Xaxis, for each
@@ -483,34 +484,31 @@ Bool_t AliTRDCalibraFit::AnalyseCH(AliTRDCalibraVector *calvect)
     // Take the histo
     Double_t nentries = 0.0;
     Double_t mean = 0.0;
-    TH1F *projch = 0x0;
-    Bool_t something = kTRUE;
-    if(!calvect->GetCHEntries(fCountDet)) something = kFALSE;
-    if(something){
-      TString tname("CH");
-      tname += idect;
-      projch  = calvect->ConvertVectorCHHisto(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0)))),(const char *) tname);
-      projch->SetDirectory(0);
-      for (Int_t k = 0; k < calvect->GetNumberBinCharge(); k++) {
-        nentries += projch->GetBinContent(k+1);
-       mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
-      }
-      if (nentries > 0) {
-       fNumberEnt++;
-       mean /= nentries;
-      }
-      //printf("The number of entries for the group %d is %f\n",idect,nentries);
-      // Rebin
-      if (fRebin >  1) {
-       projch = ReBin((TH1F *) projch);
-      }
+    if(!calvect->GetCHEntries(fCountDet)) {
+      NotEnoughStatisticCH(idect);
+      continue;
+    }
+    
+    TString tname("CH");
+    tname += idect;
+    TH1F *projch  = calvect->ConvertVectorCHHisto(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0)))),(const char *) tname);
+    projch->SetDirectory(0);
+    for (Int_t k = 0; k < calvect->GetNumberBinCharge(); k++) {
+      nentries += projch->GetBinContent(k+1);
+      mean += projch->GetBinCenter(k+1)*projch->GetBinContent(k+1);
+    }
+    if (nentries > 0) {
+      fNumberEnt++;
+      mean /= nentries;
+    }
+    //printf("The number of entries for the group %d is %f\n",idect,nentries);
+    // Rebin
+    if (fRebin >  1) {
+      projch = ReBin((TH1F *) projch);
     }
     // This detector has not enough statistics or was not found in VectorCH
     if (nentries <= fMinEntries) {
       NotEnoughStatisticCH(idect);
-      if (fDebugLevel != 1) {
-       if(projch) delete projch;
-      }     
       continue;
     }
     // Statistic of the histos fitted
@@ -527,10 +525,6 @@ Bool_t AliTRDCalibraFit::AnalyseCH(AliTRDCalibraVector *calvect)
       }
     // Fill Infos Fit
     FillInfosFitCH(idect); 
-    // Memory!!!
-    if (fDebugLevel != 1) {
-      delete projch;
-    }
   } // Boucle object
   // Normierungcharge
   if (fDebugLevel != 1) {
@@ -549,7 +543,7 @@ Bool_t AliTRDCalibraFit::AnalyseCH(AliTRDCalibraVector *calvect)
   return kTRUE;
 }
 //________________functions fit Online PH2d____________________________________
-Bool_t AliTRDCalibraFit::AnalysePH(TProfile2D *ph)
+Bool_t AliTRDCalibraFit::AnalysePH(const TProfile2D *ph)
 {
   //
   // Take the 1D profiles (average pulse height), projections of the 2D PH
@@ -670,24 +664,21 @@ Bool_t AliTRDCalibraFit::AnalysePH(AliTRDCalibraVector *calvect)
     UpdatefCountDetAndfCount(idect,1);
     ReconstructFitRowMinRowMax(idect,1);
     // Take the histo
-    TH1F *projph = 0x0;
     fEntriesCurrent = 0;
-    Bool_t something = kTRUE;
-    if(!calvect->GetPHEntries(fCountDet)) something = kFALSE;
-    if(something){
-      TString tname("PH");
-      tname += idect;
-      projph  = CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPHTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)));
-      projph->SetDirectory(0);
+    if(!calvect->GetPHEntries(fCountDet)) {
+      NotEnoughStatisticPH(idect,fEntriesCurrent);
+      continue;
     }
+    TString tname("PH");
+    tname += idect;
+    TH1F *projph  = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPHTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent);
+    projph->SetDirectory(0);
+    if(fEntriesCurrent > 0) fNumberEnt++;
     //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent);
     // This detector has not enough statistics or was off
     if (fEntriesCurrent <=  fMinEntries) {
       //printf("Not enough stat!\n");
       NotEnoughStatisticPH(idect,fEntriesCurrent);
-      if (fDebugLevel != 1) {
-       if(projph) delete projph;
-      }
       continue;
     }
     // Statistic of the histos fitted
@@ -706,12 +697,8 @@ Bool_t AliTRDCalibraFit::AnalysePH(AliTRDCalibraVector *calvect)
       }
     // Fill the tree if end of a detector or only the pointer to the branch!!!
     FillInfosFitPH(idect,fEntriesCurrent);
-    // Memory!!!
-    if (fDebugLevel != 1) {
-      delete projph;
-    }
   } // Boucle object
+  
   // Mean Statistic
   if (fNumberFit > 0) {
     AliInfo(Form("There are %d with at least one entries. %d fits have been proceeded (sucessfully or not...). There is a mean statistic of: %d over these fitted histograms and %d successfulled fits",fNumberEnt, fNumberFit, (Int_t) fStatisticMean/fNumberFit,fNumberFitSuccess));
@@ -725,7 +712,7 @@ Bool_t AliTRDCalibraFit::AnalysePH(AliTRDCalibraVector *calvect)
   return kTRUE;
 }
 //____________Functions fit Online PRF2d_______________________________________
-Bool_t AliTRDCalibraFit::AnalysePRF(TProfile2D *prf)
+Bool_t AliTRDCalibraFit::AnalysePRF(const TProfile2D *prf)
 {
   //
   // Take the 1D profiles (pad response function), projections of the 2D PRF
@@ -812,7 +799,7 @@ Bool_t AliTRDCalibraFit::AnalysePRF(TProfile2D *prf)
   return kTRUE;
 }
 //____________Functions fit Online PRF2d_______________________________________
-Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(TProfile2D *prf)
+Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(const TProfile2D *prf)
 {
   //
   // Take the 1D profiles (pad response function), projections of the 2D PRF
@@ -941,22 +928,19 @@ Bool_t AliTRDCalibraFit::AnalysePRF(AliTRDCalibraVector *calvect)
     UpdatefCountDetAndfCount(idect,2);
     ReconstructFitRowMinRowMax(idect,2);
     // Take the histo
-    TH1F *projprf = 0x0;
     fEntriesCurrent = 0;
-    Bool_t something = kTRUE;
-    if(!calvect->GetPRFEntries(fCountDet)) something = kFALSE;
-    if(something){
-      TString tname("PRF");
-      tname += idect;
-      projprf  = CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)));
-      projprf->SetDirectory(0);
+    if(!calvect->GetPRFEntries(fCountDet)) {
+      NotEnoughStatisticPRF(idect);
+      continue;
     }
+    TString tname("PRF");
+    tname += idect;
+    TH1F *projprf  = calvect->CorrectTheError((TGraphErrors *) (calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname)),fEntriesCurrent);
+    projprf->SetDirectory(0);
+    if(fEntriesCurrent > 0) fNumberEnt++;
     // This detector has not enough statistics or was off
     if (fEntriesCurrent <= fMinEntries) {
       NotEnoughStatisticPRF(idect);
-      if (fDebugLevel != 1) {
-       if(projprf) delete projprf;
-      }
       continue;
     }
     // Statistic of the histos fitted
@@ -973,10 +957,6 @@ Bool_t AliTRDCalibraFit::AnalysePRF(AliTRDCalibraVector *calvect)
       }    
     // Fill the tree if end of a detector or only the pointer to the branch!!!
     FillInfosFitPRF(idect);
-    // Memory!!!
-    if (fDebugLevel != 1) {
-      delete projprf;
-    }
   } // Boucle object
   // Mean Statistics
   if (fNumberFit > 0) {
@@ -1036,35 +1016,33 @@ Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(AliTRDCalibraVector *calvect)
     UpdatefCountDetAndfCount(idect,2);
     ReconstructFitRowMinRowMax(idect,2);
     // Take the histo
-    TGraphErrors *projprftree = 0x0;
     fEntriesCurrent  = 0;
-    Bool_t something = kTRUE;
-    if(!calvect->GetPRFEntries(fCountDet)) something = kFALSE;
-    if(something){
-      TString tname("PRF");
-      tname += idect;
-      projprftree  = calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname);
-      nbins   = projprftree->GetN();
-      arrayx  = (Double_t *)projprftree->GetX();
-      arraye  = (Double_t *)projprftree->GetEX();
-      arraym  = (Double_t *)projprftree->GetY();
-      arrayme = (Double_t *)projprftree->GetEY();
-      Float_t step = arrayx[1]-arrayx[0];
-      lowedge = arrayx[0] - step/2.0;
-      upedge  = arrayx[(nbins-1)] + step/2.0;
-      //printf("nbins est %d\n",nbins);
-      for(Int_t k = 0; k < nbins; k++){
-       fEntriesCurrent += (Int_t)arraye[k];
-       //printf("for %d we have %f, %f\n",k,arraye[k],((projprftree->GetEX())[k]));
-       if(arraye[k]>0.0) arrayme[k] = TMath::Sqrt(TMath::Abs(arrayme[k]-arraym[k]*arraym[k])/arraye[k]);
-      }
-      if(fEntriesCurrent > 0) fNumberEnt++;
+    if(!calvect->GetPRFEntries(fCountDet)) {
+      NotEnoughStatisticPRF(idect);
+      continue;
     }
+    TString tname("PRF");
+    tname += idect;
+    TGraphErrors *projprftree  = calvect->ConvertVectorPRFTGraphErrors(fCountDet,(idect-(fCount-(fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1)))),(const char *) tname);
+    nbins   = projprftree->GetN();
+    arrayx  = (Double_t *)projprftree->GetX();
+    arraye  = (Double_t *)projprftree->GetEX();
+    arraym  = (Double_t *)projprftree->GetY();
+    arrayme = (Double_t *)projprftree->GetEY();
+    Float_t step = arrayx[1]-arrayx[0];
+    lowedge = arrayx[0] - step/2.0;
+    upedge  = arrayx[(nbins-1)] + step/2.0;
+    //printf("nbins est %d\n",nbins);
+    for(Int_t k = 0; k < nbins; k++){
+      fEntriesCurrent += (Int_t)arraye[k];
+      //printf("for %d we have %f, %f\n",k,arraye[k],((projprftree->GetEX())[k]));
+      if(arraye[k]>0.0) arrayme[k] = TMath::Sqrt(TMath::Abs(arrayme[k]-arraym[k]*arraym[k])/arraye[k]);
+    }
+    if(fEntriesCurrent > 0) fNumberEnt++;
     //printf("The number of entries for the group %d is %d\n",idect,fEntriesCurrent);
     // This detector has not enough statistics or was off
     if (fEntriesCurrent <= fMinEntries) {
       NotEnoughStatisticPRF(idect);
-      if(projprftree) delete projprftree;
       continue;
     }
     // Statistic of the histos fitted
@@ -1081,10 +1059,6 @@ Bool_t AliTRDCalibraFit::AnalysePRFMarianFit(AliTRDCalibraVector *calvect)
       }    
     // Fill the tree if end of a detector or only the pointer to the branch!!!
     FillInfosFitPRF(idect);
-    // Memory!!!
-    if (fDebugLevel != 1) {
-      delete projprftree;
-    }
   } // Boucle object
   // Mean Statistics
   if (fNumberFit > 0) {
@@ -1659,7 +1633,7 @@ void AliTRDCalibraFit::PutMeanValueOtherVectorFit2(Int_t ofwhat, Bool_t perdetec
   
 }
 //_____________________________________________________________________________
-AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(TObjArray *vectorFit, Bool_t perdetector)
+AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(const TObjArray *vectorFit, Bool_t perdetector)
 {
   //
   // It creates the AliTRDCalDet object from the AliTRDFitInfo
@@ -1701,7 +1675,7 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectVdrift(TObjArray *vectorFit, Bool
   return object;
 }
 //_____________________________________________________________________________
-AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(TObjArray *vectorFit, Bool_t meanOtherBefore, Double_t scaleFitFactor, Bool_t perdetector)
+AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(const TObjArray *vectorFit, Bool_t meanOtherBefore, Double_t scaleFitFactor, Bool_t perdetector)
 {
   //
   // It creates the AliTRDCalDet object from the AliTRDFitInfo
@@ -1752,7 +1726,7 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(TObjArray *vectorFit, Bool_t
   return object;
 }
 //_____________________________________________________________________________
-AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(TObjArray *vectorFit, Bool_t perdetector)
+AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(const TObjArray *vectorFit, Bool_t perdetector)
 {
   //
   // It creates the AliTRDCalDet object from the AliTRDFitInfo2
@@ -1798,7 +1772,7 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectT0(TObjArray *vectorFit, Bool_t p
 
 }
 //_____________________________________________________________________________
-AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(TObjArray *vectorFit)
+AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(const TObjArray *vectorFit)
 {
   //
   // It creates the AliTRDCalDet object from the AliTRDFitInfo2
@@ -1838,7 +1812,7 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectLorentzAngle(TObjArray *vectorFit
   
 }
 //_____________________________________________________________________________
-TObject *AliTRDCalibraFit::CreatePadObjectGain(TObjArray *vectorFit, Double_t scaleFitFactor, AliTRDCalDet *detobject)
+TObject *AliTRDCalibraFit::CreatePadObjectGain(const TObjArray *vectorFit, Double_t scaleFitFactor, const AliTRDCalDet *detobject)
 {
   //
   // It Creates the AliTRDCalPad object from AliTRDFitInfo
@@ -1886,7 +1860,7 @@ TObject *AliTRDCalibraFit::CreatePadObjectGain(TObjArray *vectorFit, Double_t sc
   return object;  
 }
 //_____________________________________________________________________________
-TObject *AliTRDCalibraFit::CreatePadObjectVdrift(TObjArray *vectorFit, AliTRDCalDet *detobject)
+TObject *AliTRDCalibraFit::CreatePadObjectVdrift(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
 {
   //
   // It Creates the AliTRDCalPad object from AliTRDFitInfo
@@ -1933,7 +1907,7 @@ TObject *AliTRDCalibraFit::CreatePadObjectVdrift(TObjArray *vectorFit, AliTRDCal
 
 }
 //_____________________________________________________________________________
-TObject *AliTRDCalibraFit::CreatePadObjectT0(TObjArray *vectorFit, AliTRDCalDet *detobject)
+TObject *AliTRDCalibraFit::CreatePadObjectT0(const TObjArray *vectorFit, const AliTRDCalDet *detobject)
 {
   //
   // It Creates the AliTRDCalPad object from AliTRDFitInfo2
@@ -1982,7 +1956,7 @@ TObject *AliTRDCalibraFit::CreatePadObjectT0(TObjArray *vectorFit, AliTRDCalDet
 
 }
 //_____________________________________________________________________________
-TObject *AliTRDCalibraFit::CreatePadObjectPRF(TObjArray *vectorFit)
+TObject *AliTRDCalibraFit::CreatePadObjectPRF(const TObjArray *vectorFit)
 {
   //
   // It Creates the AliTRDCalPad object from AliTRDFitInfo
@@ -2014,7 +1988,7 @@ TObject *AliTRDCalibraFit::CreatePadObjectPRF(TObjArray *vectorFit)
 
 }
 //_____________________________________________________________________________
-AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(TObjArray *vectorFit, const char *name, Double_t &mean)
+AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(const TObjArray *vectorFit, const char *name, Double_t &mean)
 {
   //
   // It Creates the AliTRDCalDet object from AliTRDFitInfo
@@ -2052,7 +2026,7 @@ AliTRDCalDet *AliTRDCalibraFit::MakeOutliersStatDet(TObjArray *vectorFit, const
   return object;  
 }
 //_____________________________________________________________________________
-TObject *AliTRDCalibraFit::MakeOutliersStatPad(TObjArray *vectorFit, const char *name, Double_t &mean)
+TObject *AliTRDCalibraFit::MakeOutliersStatPad(const TObjArray *vectorFit, const char *name, Double_t &mean)
 {
   //
   // It Creates the AliTRDCalPad object from AliTRDFitInfo
@@ -2468,13 +2442,13 @@ Bool_t AliTRDCalibraFit::InitFitLinearFitter()
     fCalDet2 = new AliTRDCalDet("lorentz angle tan","lorentz angle tan (detector value)");
     //printf("test2\n");
     for(Int_t k = 0; k < 540; k++){
-      fCalDet2->SetValue(k,cal->GetOmegaTau(fCalDet->GetValue(k),-fMagneticField));
+      fCalDet2->SetValue(k,AliTRDCommonParam::Instance()->GetOmegaTau(fCalDet->GetValue(k)));
     }
     //printf("test3\n");
   }
   else{
     Float_t devalue  = 1.5;
-    Float_t devalue2 = cal->GetOmegaTau(1.5,-fMagneticField); 
+    Float_t devalue2 = AliTRDCommonParam::Instance()->GetOmegaTau(1.5); 
     if(fCalDet) delete fCalDet;
     if(fCalDet2) delete fCalDet2;
     //printf("test1\n");
@@ -5426,7 +5400,7 @@ void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean)
   }
 } 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(Double_t *x, Double_t *y) const
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(const Double_t *x, const Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces trois points de degre 2
@@ -5448,7 +5422,7 @@ Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(Double_t *x, Double_t *y) co
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(Double_t *x, Double_t *y) const
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(const Double_t *x, const Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces quatre points de degre 3
@@ -5482,7 +5456,7 @@ Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(Double_t *x, Double_t *y) co
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(Double_t *x, Double_t *y) const
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(const Double_t *x, const Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces cinqs points de degre 4
@@ -5575,7 +5549,7 @@ void AliTRDCalibraFit::NormierungCharge()
     }
 }
 //_____________________________________________________________________________
-TH1I *AliTRDCalibraFit::ReBin(TH1I *hist) const
+TH1I *AliTRDCalibraFit::ReBin(const TH1I *hist) const
 {
   //
   // Rebin of the 1D histo for the gain calibration if needed.
@@ -5604,7 +5578,7 @@ TH1I *AliTRDCalibraFit::ReBin(TH1I *hist) const
 }
 
 //_____________________________________________________________________________
-TH1F *AliTRDCalibraFit::ReBin(TH1F *hist) const
+TH1F *AliTRDCalibraFit::ReBin(const TH1F *hist) const
 {
   //
   // Rebin of the 1D histo for the gain calibration if needed
@@ -5630,53 +5604,6 @@ TH1F *AliTRDCalibraFit::ReBin(TH1F *hist) const
 
   return rehist;
   
-}
-
-//_____________________________________________________________________________
-TH1F *AliTRDCalibraFit::CorrectTheError(TGraphErrors *hist)
-{
-  //
-  // In the case of the vectors method the trees contains TGraphErrors for PH and PRF
-  // to be able to add them after
-  // We convert it to a TH1F to be able to applied the same fit function method
-  // After having called this function you can not add the statistics anymore
-  //
-
-  TH1F *rehist = 0x0;
-
-  Int_t nbins       = hist->GetN();
-  Double_t *x       = hist->GetX();
-  Double_t *entries = hist->GetEX();
-  Double_t *mean    = hist->GetY();
-  Double_t *square  = hist->GetEY();
-  fEntriesCurrent   = 0;
-
-  if (nbins < 2) {
-    return rehist; 
-  }
-
-  Double_t step     = x[1] - x[0]; 
-  Double_t minvalue = x[0] - step/2;
-  Double_t maxvalue = x[(nbins-1)] + step/2;
-
-  rehist = new TH1F("projcorrecterror","",nbins,minvalue,maxvalue);
-
-  for (Int_t k = 0; k < nbins; k++) {
-    rehist->SetBinContent(k+1,mean[k]);
-    if (entries[k] > 0.0) {
-      fEntriesCurrent += (Int_t) entries[k];
-      Double_t d = TMath::Abs(square[k] - (mean[k]*mean[k]));
-      rehist->SetBinError(k+1,TMath::Sqrt(d/entries[k]));
-    }
-    else {
-      rehist->SetBinError(k+1,0.0);
-    }
-  }
-
-  if(fEntriesCurrent > 0) fNumberEnt++;
-
-  return rehist;
 }
 //
 //____________Some basic geometry function_____________________________________
@@ -5738,7 +5665,7 @@ void AliTRDCalibraFit::ResetVectorFit()
 //
 
 //_____________________________________________________________________________
-Double_t AliTRDCalibraFit::PH(Double_t *x, Double_t *par) 
+Double_t AliTRDCalibraFit::PH(const Double_t *x, const Double_t *par) 
 {
   //
   // Function for the fit
@@ -5793,7 +5720,7 @@ Double_t AliTRDCalibraFit::PH(Double_t *x, Double_t *par)
 }
 
 //_____________________________________________________________________________
-Double_t AliTRDCalibraFit::AsymmGauss(Double_t *x, Double_t *par) 
+Double_t AliTRDCalibraFit::AsymmGauss(const Double_t *x, const Double_t *par)
 {
   //
   // Function for the fit
@@ -5829,7 +5756,7 @@ Double_t AliTRDCalibraFit::AsymmGauss(Double_t *x, Double_t *par)
 }
 
 //_____________________________________________________________________________
-Double_t AliTRDCalibraFit::FuncLandauGaus(Double_t *x, Double_t *par)
+Double_t AliTRDCalibraFit::FuncLandauGaus(const Double_t *x, const Double_t *par)
 {
   //
   // Sum Landau + Gaus with identical mean
@@ -5845,7 +5772,7 @@ Double_t AliTRDCalibraFit::FuncLandauGaus(Double_t *x, Double_t *par)
 }
 
 //_____________________________________________________________________________
-Double_t AliTRDCalibraFit::LanGauFun(Double_t *x, Double_t *par) 
+Double_t AliTRDCalibraFit::LanGauFun(const Double_t *x, const Double_t *par) 
 {
   //
   // Function for the fit
@@ -5906,8 +5833,8 @@ Double_t AliTRDCalibraFit::LanGauFun(Double_t *x, Double_t *par)
 
 }
 //_____________________________________________________________________________
-TF1 *AliTRDCalibraFit::LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startvalues
-                                      , Double_t *parlimitslo, Double_t *parlimitshi
+TF1 *AliTRDCalibraFit::LanGauFit(TH1 *his, const Double_t *fitrange, const Double_t *startvalues
+                                      , const Double_t *parlimitslo, const Double_t *parlimitshi
                                       , Double_t *fitparams, Double_t *fiterrors
                                       , Double_t *chiSqr, Int_t *ndf) const
 {
@@ -5945,7 +5872,7 @@ TF1 *AliTRDCalibraFit::LanGauFit(TH1 *his, Double_t *fitrange, Double_t *startva
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDCalibraFit::LanGauPro(Double_t *params, Double_t &maxx, Double_t &fwhm) 
+Int_t AliTRDCalibraFit::LanGauPro(const Double_t *params, Double_t &maxx, Double_t &fwhm) 
 {
   //
   // Function for the fit
@@ -6041,7 +5968,7 @@ Int_t AliTRDCalibraFit::LanGauPro(Double_t *params, Double_t &maxx, Double_t &fw
   return (0);
 }
 //_____________________________________________________________________________
-Double_t AliTRDCalibraFit::GausConstant(Double_t *x, Double_t *par)
+Double_t AliTRDCalibraFit::GausConstant(const Double_t *x, const Double_t *par)
 {
   //
   // Gaus with identical mean