]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFit.cxx
Fixing some documentation and comments.
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.cxx
index af0bb52f404d97ff386b477e6553480473aa01e6..c1af66260345543ccf9969f93ad1eab63088d772 100644 (file)
 //                            
 //////////////////////////////////////////////////////////////////////////////////////
 
-#include <TTree.h>
 #include <TLine.h>
 #include <TH1I.h>
 #include <TStyle.h>
 #include <TProfile2D.h>
-#include <TFile.h>
 #include <TCanvas.h>
 #include <TGraphErrors.h>
-#include <TGraph.h>
 #include <TObjArray.h>
 #include <TH1.h>
 #include <TH1F.h>
 #include <TF1.h>
-#include <TH2F.h>
 #include <TAxis.h>
-#include <TStopwatch.h>
 #include <TMath.h>
-#include <TLegend.h>
 #include <TDirectory.h>
 #include <TROOT.h>
 #include <TTreeStream.h>
@@ -72,7 +66,6 @@
 #include <TArrayF.h>
 
 #include "AliLog.h"
-#include "AliCDBManager.h"
 #include "AliMathBase.h"
 
 #include "AliTRDCalibraFit.h"
@@ -137,8 +130,9 @@ AliTRDCalibraFit::AliTRDCalibraFit()
   ,fMethod(0)
   ,fBeginFitCharge(3.5)
   ,fFitPHPeriode(1)
-  ,fTakeTheMaxPH(kFALSE)
-  ,fT0Shift(0.124797)
+  ,fTakeTheMaxPH(kTRUE)
+  ,fT0Shift0(0.124797)
+  ,fT0Shift1(0.267451)
   ,fRangeFitPRF(1.0)
   ,fAccCDB(kFALSE)
   ,fMinEntries(800)
@@ -195,7 +189,8 @@ AliTRDCalibraFit::AliTRDCalibraFit(const AliTRDCalibraFit &c)
 ,fBeginFitCharge(c.fBeginFitCharge)
 ,fFitPHPeriode(c.fFitPHPeriode)
 ,fTakeTheMaxPH(c.fTakeTheMaxPH)
-,fT0Shift(c.fT0Shift)
+,fT0Shift0(c.fT0Shift0)
+,fT0Shift1(c.fT0Shift1)
 ,fRangeFitPRF(c.fRangeFitPRF)
 ,fAccCDB(c.fAccCDB)
 ,fMinEntries(c.fMinEntries)
@@ -321,6 +316,28 @@ void AliTRDCalibraFit::Destroy()
     fgInstance = 0x0;
   }
 
+}
+//__________________________________________________________________________________
+void AliTRDCalibraFit::RangeChargeIntegration(Float_t vdrift, Float_t t0, Int_t &begin, Int_t &peak, Int_t &end)
+{
+  //
+  // From the drift velocity and t0
+  // return the position of the peak and maximum negative slope
+  //
+  
+  const Float_t kDrWidth = AliTRDgeometry::DrThick();    // drift region
+  Double_t widbins = 0.1;                                // 0.1 mus
+
+  //peak and maxnegslope in mus
+  Double_t begind = t0*widbins + fT0Shift0;
+  Double_t peakd  = t0*widbins + fT0Shift1;
+  Double_t maxnegslope = (kDrWidth + vdrift*peakd)/vdrift; 
+
+  // peak and maxnegslope in timebin
+  begin = TMath::Nint(begind*widbins);
+  peak  = TMath::Nint(peakd*widbins);
+  end   = TMath::Nint(maxnegslope*widbins); 
+
 }
 //____________Functions fit Online CH2d________________________________________
 Bool_t AliTRDCalibraFit::AnalyseCH(TH2I *ch)
@@ -1751,15 +1768,32 @@ void AliTRDCalibraFit::SetBeginFitCharge(Float_t beginFitCharge)
 }
 
 //_____________________________________________________________________________
-void AliTRDCalibraFit::SetT0Shift(Float_t t0Shift) 
+void AliTRDCalibraFit::SetT0Shift0(Float_t t0Shift) 
 { 
   //
-  // The t0 calculated with the maximum positif slope is shift from t0Shift
-  // You can here set t0Shift
+  // The t0 calculated with the maximum positif slope is shift from t0Shift0
+  // You can here set t0Shift0
   //
 
   if (t0Shift > 0) {
-    fT0Shift = t0Shift; 
+    fT0Shift0 = t0Shift; 
+  } 
+  else {
+    AliInfo("t0Shift0 must be strict positif!");
+  }
+
+}
+
+//_____________________________________________________________________________
+void AliTRDCalibraFit::SetT0Shift1(Float_t t0Shift) 
+{ 
+  //
+  // The t0 calculated with the maximum of the amplification region is shift from t0Shift1
+  // You can here set t0Shift1
+  //
+
+  if (t0Shift > 0) {
+    fT0Shift1 = t0Shift; 
   } 
   else {
     AliInfo("t0Shift must be strict positif!");
@@ -2540,7 +2574,7 @@ void AliTRDCalibraFit::FillFillCH(Int_t idect)
     Float_t gfs        = fCurrentCoef[1]; 
     Float_t gfE        = fCurrentCoefE;
     
-    (*fDebugStreamer) << "GAIN" <<
+    (*fDebugStreamer) << "FillFillCH" <<
       "detector=" << detector <<
       "caligroup=" << caligroup <<
       "rowmin=" << rowmin <<
@@ -2597,7 +2631,7 @@ void AliTRDCalibraFit::FillFillPH(Int_t idect)
    
 
 
-      (* fDebugStreamer) << "PH"<<
+      (* fDebugStreamer) << "FillFillPH"<<
        "detector="<<detector<<
        "caligroup="<<caligroup<<
        "rowmin="<<rowmin<<
@@ -2651,7 +2685,7 @@ void AliTRDCalibraFit::FillFillPRF(Int_t idect)
       Float_t wids         = fCurrentCoef[1]; 
       Float_t widfE        = fCurrentCoefE;
 
-      (* fDebugStreamer) << "PRF"<<
+      (* fDebugStreamer) << "FillFillPRF"<<
        "detector="<<detector<<
        "plane="<<plane<<
        "caligroup="<<caligroup<<
@@ -2706,10 +2740,10 @@ void AliTRDCalibraFit::FillFillLinearFitter()
     Float_t vs               = fCurrentCoef[1]; 
     Float_t vfE              = fCurrentCoefE;
     Float_t lorentzangler    = fCurrentCoef2[0];
-    Float_t Elorentzangler   = fCurrentCoefE2;
+    Float_t elorentzangler   = fCurrentCoefE2;
     Float_t lorentzangles    = fCurrentCoef2[1];
    
-    (* fDebugStreamer) << "LinearFitter"<<
+    (* fDebugStreamer) << "FillFillLinearFitter"<<
       "detector="<<detector<<
       "chamber="<<chamber<<
       "plane="<<plane<<
@@ -2720,7 +2754,7 @@ void AliTRDCalibraFit::FillFillLinearFitter()
       "vs="<<vs<<
       "vfE="<<vfE<<
       "lorentzangler="<<lorentzangler<<
-      "Elorentzangler="<<Elorentzangler<<
+      "Elorentzangler="<<elorentzangler<<
       "lorentzangles="<<lorentzangles<<
       "\n";  
   }
@@ -3067,9 +3101,16 @@ void AliTRDCalibraFit::FitPente(TH1* projPH)
   if((l3P1dr != 0.0) && (l3P2dr != 0.0)){
     fCurrentCoefE += (l3P1drE/l3P1dr + l3P2drE/l3P2dr)*fPhd[2]; 
   }
-  Float_t fPhdt0 = 0.0;
-  if(fTakeTheMaxPH) fPhdt0 = fPhd[1];
-  else fPhdt0 = fPhd[0];
+  Float_t fPhdt0  = 0.0;
+  Float_t t0Shift = 0.0;
+  if(fTakeTheMaxPH) {
+    fPhdt0 = fPhd[1];
+    t0Shift = fT0Shift1;
+  }
+  else {
+    fPhdt0 = fPhd[0];
+    t0Shift = fT0Shift0;
+  }
 
   if ((fPhd[2] > fPhd[0]) && 
       (fPhd[2] > fPhd[1]) && 
@@ -3079,7 +3120,7 @@ void AliTRDCalibraFit::FitPente(TH1* projPH)
     fNumberFitSuccess++;
 
     if (fPhdt0 >= 0.0) {
-      fCurrentCoef2[0] = (fPhdt0 - fT0Shift) / widbins;
+      fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins;
       if (fCurrentCoef2[0] < -1.0) {
         fCurrentCoef2[0] = fCurrentCoef2[1];
       }
@@ -3588,9 +3629,16 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     fPhd[2] = placeminimum;
   }
   
-  Float_t fPhdt0 = 0.0;
-  if(fTakeTheMaxPH) fPhdt0 = fPhd[1];
-  else fPhdt0 = fPhd[0];
+  Float_t fPhdt0  = 0.0;
+  Float_t t0Shift = 0.0;
+  if(fTakeTheMaxPH) {
+    fPhdt0 = fPhd[1];
+    t0Shift = fT0Shift1;
+  }
+  else {
+    fPhdt0 = fPhd[0];
+    t0Shift = fT0Shift0;
+  }
 
   if ((fPhd[2] > fPhd[0]) && 
       (fPhd[2] > fPhd[1]) && 
@@ -3599,7 +3647,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     fCurrentCoef[0] = (kDrWidth) / (fPhd[2]-fPhd[1]);
     fNumberFitSuccess++;
     if (fPhdt0 >= 0.0) {
-      fCurrentCoef2[0] = (fPhdt0 - fT0Shift) / widbins;
+      fCurrentCoef2[0] = (fPhdt0 - t0Shift) / widbins;
       if (fCurrentCoef2[0] < -1.0) {
         fCurrentCoef2[0] = fCurrentCoef2[1];
       }
@@ -4016,7 +4064,7 @@ void AliTRDCalibraFit::FitTnpRange(Double_t *arraye, Double_t *arraym, Double_t
       Float_t  wid          = fCurrentCoef[0];
       Float_t  widfE        = fCurrentCoefE;
 
-      (* fDebugStreamer) << "FitTnpRangeFill"<<
+      (* fDebugStreamer) << "FitTnpRange0"<<
        "detector="<<detector<<
        "plane="<<plane<<
        "nbtotal="<<nbtotal<<
@@ -4093,7 +4141,7 @@ void AliTRDCalibraFit::FitTnpRange(Double_t *arraye, Double_t *arraym, Double_t
       Double_t colsize[6]   = {0.635,0.665,0.695,0.725,0.755,0.785};  
       Double_t sigmax       = TMath::Sqrt(TMath::Abs(pars0[2]))*10000*colsize[plane];      
 
-      (* fDebugStreamer) << "FitTnpRangeFit"<<
+      (* fDebugStreamer) << "FitTnpRange1"<<
        "detector="<<detector<<
        "plane="<<plane<<
        "nbtotal="<<nbtotal<<
@@ -4308,7 +4356,7 @@ void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean)
 
 
   //Some parameters to initialise
-  Double_t widthLandau, widthGaus, MPV, Integral;
+  Double_t widthLandau, widthGaus, mPV, integral;
   Double_t chisquarel = 0.0;
   Double_t chisquareg = 0.0;
   projch->Fit("landau","0M+",""
@@ -4322,14 +4370,14 @@ void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean)
   widthGaus    = projch->GetFunction("gaus")->GetParameter(2);
   chisquareg = projch->GetFunction("gaus")->GetChisquare();
     
-  MPV = (projch->GetFunction("landau")->GetParameter(1))/2;
-  Integral = (projch->GetFunction("gaus")->Integral(0.3*mean,3*mean)+projch->GetFunction("landau")->Integral(0.3*mean,3*mean))/2;
+  mPV = (projch->GetFunction("landau")->GetParameter(1))/2;
+  integral = (projch->GetFunction("gaus")->Integral(0.3*mean,3*mean)+projch->GetFunction("landau")->Integral(0.3*mean,3*mean))/2;
   
   // Setting fit range and start values
   Double_t fr[2];
   //Double_t sv[4] = { l3P2, fChargeCoef[1], projch->Integral("width"), fG3P2 };
   //Double_t sv[4]   = { fL3P2, fChargeCoef[1], fL3P0, fG3P2 };
-  Double_t sv[4]   = { widthLandau, MPV, Integral, widthGaus};
+  Double_t sv[4]   = { widthLandau, mPV, integral, widthGaus};
   Double_t pllo[4] = { 0.001, 0.001, projch->Integral()/3, 0.001};
   Double_t plhi[4] = { 300.0, 300.0, 30*projch->Integral(), 300.0};
   Double_t fp[4]   = { 1.0, 1.0, 1.0, 1.0 };
@@ -4374,7 +4422,7 @@ void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean)
   }
 } 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(Double_t *x, Double_t *y)
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(Double_t *x, Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces trois points de degre 2
@@ -4396,7 +4444,7 @@ Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(Double_t *x, Double_t *y)
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(Double_t *x, Double_t *y)
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(Double_t *x, Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces quatre points de degre 3
@@ -4430,7 +4478,7 @@ Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(Double_t *x, Double_t *y)
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(Double_t *x, Double_t *y)
+Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(Double_t *x, Double_t *y) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces cinqs points de degre 4
@@ -4517,7 +4565,7 @@ void AliTRDCalibraFit::NormierungCharge()
       fDebugStreamer = new TTreeSRedirector("TRDDebugFit.root");
       if ( backup ) backup->cd();  //we don't want to be cd'd to the debug streamer
     } 
-    (* fDebugStreamer) << "ScaleFactor"<<
+    (* fDebugStreamer) << "NormierungCharge"<<
       "scalefactor="<<scalefactor<<
       "\n";  
     }
@@ -4671,6 +4719,10 @@ Int_t AliTRDCalibraFit::GetSector(Int_t d) const
 //_______________________________________________________________________________
 void AliTRDCalibraFit::ResetVectorFit()
 {
+  //
+  // Reset the VectorFits
+  //
+
   fVectorFit.SetOwner();
   fVectorFit.Clear();
   fVectorFit2.SetOwner();
@@ -4853,7 +4905,7 @@ 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
                                       , Double_t *fitparams, Double_t *fiterrors
-                                      , Double_t *chiSqr, Int_t *ndf)
+                                      , Double_t *chiSqr, Int_t *ndf) const
 {
   //
   // Function for the fit
@@ -4991,8 +5043,8 @@ Double_t AliTRDCalibraFit::GausConstant(Double_t *x, Double_t *par)
   // Gaus with identical mean
   //
 
-  Double_t Gauss   = par[0] * TMath::Gaus(x[0],0.0,par[1])+par[2];
+  Double_t gauss   = par[0] * TMath::Gaus(x[0],0.0,par[1])+par[2];
  
-  return Gauss;
+  return gauss;
 
 }