]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDCalibraFit.cxx
Helper classes for Et em corrections from Marcelo
[u/mrichter/AliRoot.git] / TRD / AliTRDCalibraFit.cxx
index a6e67efbbd01242f4f5711c6d2b557da17bee29b..eb9c4de9a50f68270230f692aa3cf4bd182f0d17 100644 (file)
@@ -1944,6 +1944,7 @@ AliTRDCalDet *AliTRDCalibraFit::CreateDetObjectGain(const TObjArray *vectorFit,
       } // Row
       if(count > 0) mean = mean/count;
     }
+    if(mean < 0.1) mean = 0.1;
     object->SetValue(detector,mean);
   }
  
@@ -4314,8 +4315,10 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
   const Float_t kDrWidth = AliTRDgeometry::DrThick();
   Int_t binmax      = 0;
   Int_t binmin      = 0;
-  Double_t    *x    = new Double_t[5];
-  Double_t    *y    = new Double_t[5];
+  //Double_t    *x    = new Double_t[5];
+  //Double_t    *y    = new Double_t[5];
+  Double_t x[5];
+  Double_t y[5];
   x[0]              = 0.0;
   x[1]              = 0.0;
   x[2]              = 0.0;
@@ -4338,7 +4341,11 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
   TF1 * polynome = 0x0;
   TF1 * polynomea = 0x0;
   TF1 * polynomeb = 0x0;
-  Double_t *c = 0x0;
+  Double_t c0 = 0.0;
+  Double_t c1 = 0.0;
+  Double_t c2 = 0.0;
+  Double_t c3 = 0.0;
+  Double_t c4 = 0.0;
   
   // Some variables
   TAxis   *xpph    = projPH->GetXaxis();
@@ -4378,7 +4385,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
       y[0] = pentea->GetBinContent(binmax-2);
       y[1] = pentea->GetBinContent(binmax-1);
       y[2] = pentea->GetBinContent(binmax);
-      c = CalculPolynomeLagrange2(x,y);
+      CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
       AliInfo("At the limit for beginning!");
       break;  
     case 2:
@@ -4392,7 +4399,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
       y[1] = pentea->GetBinContent(binmax-1);
       y[2] = pentea->GetBinContent(binmax);
       y[3] = pentea->GetBinContent(binmax+1);
-      c = CalculPolynomeLagrange3(x,y);
+      CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
       break;
     default:
       switch(binmax){
@@ -4408,7 +4415,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
        y[0] = pentea->GetBinContent(binmax);
        y[1] = pentea->GetBinContent(binmax+1);
        y[2] = pentea->GetBinContent(binmax+2);
-       c = CalculPolynomeLagrange2(x,y);
+       CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
        break;
       case 2:
        minnn = pentea->GetBinCenter(binmax-1);
@@ -4421,7 +4428,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
        y[1] = pentea->GetBinContent(binmax);
        y[2] = pentea->GetBinContent(binmax+1);
        y[3] = pentea->GetBinContent(binmax+2);
-               c = CalculPolynomeLagrange3(x,y);
+               CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
        break;
       default:
        minnn = pentea->GetBinCenter(binmax-2);
@@ -4436,7 +4443,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
        y[2] = pentea->GetBinContent(binmax);
        y[3] = pentea->GetBinContent(binmax+1);
        y[4] = pentea->GetBinContent(binmax+2);
-       c = CalculPolynomeLagrange4(x,y);
+       CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4);
        break;
       }
       break;
@@ -4445,7 +4452,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
   
   if(put) {
     polynomeb = new TF1("polb","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",minnn,maxxx);
-    polynomeb->SetParameters(c[0],c[1],c[2],c[3],c[4]);
+    polynomeb->SetParameters(c0,c1,c2,c3,c4);
       
     Double_t step = (maxxx-minnn)/10000;
     Double_t l = minnn;
@@ -4501,7 +4508,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
       y[0] = projPH->GetBinContent(binmax-2);
       y[1] = projPH->GetBinContent(binmax-1);
       y[2] = projPH->GetBinContent(binmax);
-      c = CalculPolynomeLagrange2(x,y);
+      CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
       //AliInfo("At the limit for the drift!");
       break;
     case 1:
@@ -4515,7 +4522,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
       y[1] = projPH->GetBinContent(binmax-1);
       y[2] = projPH->GetBinContent(binmax);
       y[3] = projPH->GetBinContent(binmax+1);
-      c = CalculPolynomeLagrange3(x,y);
+      CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
       break;
     default:
       switch(binmax)
@@ -4532,7 +4539,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
          y[0] = projPH->GetBinContent(binmax);
          y[1] = projPH->GetBinContent(binmax+1);
          y[2] = projPH->GetBinContent(binmax+2);
-         c = CalculPolynomeLagrange2(x,y);
+         CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
          break;
        case 2:
          minn = projPH->GetBinCenter(binmax-1);
@@ -4545,7 +4552,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
          y[1] = projPH->GetBinContent(binmax);
          y[2] = projPH->GetBinContent(binmax+1);
          y[3] = projPH->GetBinContent(binmax+2);
-         c = CalculPolynomeLagrange3(x,y);
+         CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
          break;
        default:
          minn = projPH->GetBinCenter(binmax-2);
@@ -4560,7 +4567,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
          y[2] = projPH->GetBinContent(binmax);
          y[3] = projPH->GetBinContent(binmax+1);
          y[4] = projPH->GetBinContent(binmax+2);
-         c = CalculPolynomeLagrange4(x,y);
+         CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4);
          break;
        }
       break;
@@ -4568,7 +4575,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
   
   if(put) {
     polynomea = new TF1("pola","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",minn,maxx);
-    polynomea->SetParameters(c[0],c[1],c[2],c[3],c[4]);
+    polynomea->SetParameters(c0,c1,c2,c3,c4);
        
     Double_t step = (maxx-minn)/1000;
     Double_t l = minn;
@@ -4649,7 +4656,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[3] = pente->GetBinContent(binmin+1);
     y[4] = pente->GetBinContent(binmin+2);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange4(x,y);
+    CalculPolynomeLagrange4(x,y,c0,c1,c2,c3,c4);
     //richtung +/-
     if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1)) &&
        (pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) {
@@ -4691,7 +4698,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[2] = pente->GetBinContent(binmin);
     y[3] = pente->GetBinContent(binmin+1);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange3(x,y);
+    CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
     //richtung +: nothing
     //richtung -
     if((pente->GetBinContent(binmin-2) <= pente->GetBinContent(binmin-1))) {
@@ -4713,7 +4720,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[2] = pente->GetBinContent(binmin+1);
     y[3] = pente->GetBinContent(binmin+2);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange3(x,y);
+    CalculPolynomeLagrange3(x,y,c0,c1,c2,c3,c4);
     //richtung +
     if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1))) {
       //AliInfo("polynome 3+ case 2");      
@@ -4731,7 +4738,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[1] = pente->GetBinContent(binmin+1);
     y[2] = pente->GetBinContent(binmin+2);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange2(x,y);
+    CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
     //richtung +
     if((pente->GetBinContent(binmin+2) <= pente->GetBinContent(binmin+1))) {
       //AliInfo("polynome 2+ false");
@@ -4750,7 +4757,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[1] = pente->GetBinContent(binmin);
     y[2] = pente->GetBinContent(binmin+1);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange2(x,y);
+    CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
     //richtung +: nothing
     //richtung -: nothing
   }
@@ -4766,7 +4773,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     y[1] = pente->GetBinContent(binmin-1);
     y[2] = pente->GetBinContent(binmin);
     //Calcul the polynome de Lagrange
-    c = CalculPolynomeLagrange2(x,y);
+    CalculPolynomeLagrange2(x,y,c0,c1,c2,c3,c4);
     //AliInfo("At the limit for the drift!");
     //fluctuation too big!
     //richtung +: nothing
@@ -4794,7 +4801,7 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
   
   if(put) {
     polynome = new TF1("pol","[0]+[1]*x+[2]*x*x+[3]*x*x*x+[4]*x*x*x*x",min,max);
-    polynome->SetParameters(c[0],c[1],c[2],c[3],c[4]);
+    polynome->SetParameters(c0,c1,c2,c3,c4);
     //AliInfo(Form("GetMinimum of the function %f",polynome->GetMinimumX()));
     Double_t step = (max-min)/1000;
     Double_t l = min;
@@ -4884,14 +4891,13 @@ void AliTRDCalibraFit::FitLagrangePoly(TH1* projPH)
     pente->Draw();
   }
   else {
-    if(pentea) delete pentea;
-    if(pente) delete pente;
+    delete pentea;
+    delete pente;
     if(polynome) delete polynome;
     if(polynomea) delete polynomea;
     if(polynomeb) delete polynomeb;
-    if(x) delete [] x;
-    if(y) delete [] y;
-    if(c) delete [] c;
+    //if(x) delete [] x;
+    //if(y) delete [] y;
     if(line) delete line;
 
   }
@@ -5633,68 +5639,59 @@ void AliTRDCalibraFit::FitBisCH(TH1* projch, Double_t mean)
   }
 } 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange2(const Double_t *x, const Double_t *y) const
+void AliTRDCalibraFit::CalculPolynomeLagrange2(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces trois points de degre 2
   //
-  Double_t *c = new Double_t[5];
   Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2]));
   Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2]));
   Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1]));
 
-  c[4] = 0.0;
-  c[3] = 0.0;
-  c[2] = x0+x1+x2;
-  c[1] = -(x0*(x[1]+x[2])+x1*(x[0]+x[2])+x2*(x[0]+x[1]));
-  c[0] = x0*x[1]*x[2]+x1*x[0]*x[2]+x2*x[0]*x[1];
-
-  return c;
-  
+  c4 = 0.0;
+  c3 = 0.0;
+  c2 = x0+x1+x2;
+  c1 = -(x0*(x[1]+x[2])+x1*(x[0]+x[2])+x2*(x[0]+x[1]));
+  c0 = x0*x[1]*x[2]+x1*x[0]*x[2]+x2*x[0]*x[1];
 
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange3(const Double_t *x, const Double_t *y) const
+void AliTRDCalibraFit::CalculPolynomeLagrange3(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces quatre points de degre 3
   //
-  Double_t *c = new Double_t[5];
   Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3]));
   Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3]));
   Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1])*(x[2]-x[3]));
   Double_t x3 = y[3]/((x[3]-x[0])*(x[3]-x[1])*(x[3]-x[2]));
 
-  c[4] = 0.0;
-  c[3] = x0+x1+x2+x3;
-  c[2] = -(x0*(x[1]+x[2]+x[3])
+  c4 = 0.0;
+  c3 = x0+x1+x2+x3;
+  c2 = -(x0*(x[1]+x[2]+x[3])
           +x1*(x[0]+x[2]+x[3])
           +x2*(x[0]+x[1]+x[3])
           +x3*(x[0]+x[1]+x[2]));
-  c[1] = (x0*(x[1]*x[2]+x[1]*x[3]+x[2]*x[3])
+  c1 = (x0*(x[1]*x[2]+x[1]*x[3]+x[2]*x[3])
          +x1*(x[0]*x[2]+x[0]*x[3]+x[2]*x[3])
          +x2*(x[0]*x[1]+x[0]*x[3]+x[1]*x[3])
          +x3*(x[0]*x[1]+x[0]*x[2]+x[1]*x[2]));
   
-  c[0] = -(x0*x[1]*x[2]*x[3]
+  c0 = -(x0*x[1]*x[2]*x[3]
          +x1*x[0]*x[2]*x[3]
          +x2*x[0]*x[1]*x[3]
          +x3*x[0]*x[1]*x[2]);  
 
 
-  return c;
-  
-
 }
 
 //_____________________________________________________________________________
-Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(const Double_t *x, const Double_t *y) const
+void AliTRDCalibraFit::CalculPolynomeLagrange4(const Double_t *x, const Double_t *y, Double_t &c0, Double_t &c1, Double_t &c2, Double_t &c3, Double_t &c4) const
 {
   //
   // Calcul the coefficients of the polynome passant par ces cinqs points de degre 4
   //
-  Double_t *c = new Double_t[5];
   Double_t x0 = y[0]/((x[0]-x[1])*(x[0]-x[2])*(x[0]-x[3])*(x[0]-x[4]));
   Double_t x1 = y[1]/((x[1]-x[0])*(x[1]-x[2])*(x[1]-x[3])*(x[1]-x[4]));
   Double_t x2 = y[2]/((x[2]-x[0])*(x[2]-x[1])*(x[2]-x[3])*(x[2]-x[4]));
@@ -5702,33 +5699,30 @@ Double_t *AliTRDCalibraFit::CalculPolynomeLagrange4(const Double_t *x, const Dou
   Double_t x4 = y[4]/((x[4]-x[0])*(x[4]-x[1])*(x[4]-x[2])*(x[4]-x[3]));
  
 
-  c[4] = x0+x1+x2+x3+x4;
-  c[3] = -(x0*(x[1]+x[2]+x[3]+x[4])
+  c4 = x0+x1+x2+x3+x4;
+  c3 = -(x0*(x[1]+x[2]+x[3]+x[4])
           +x1*(x[0]+x[2]+x[3]+x[4])
           +x2*(x[0]+x[1]+x[3]+x[4])
           +x3*(x[0]+x[1]+x[2]+x[4])
           +x4*(x[0]+x[1]+x[2]+x[3]));
-  c[2] = (x0*(x[1]*x[2]+x[1]*x[3]+x[1]*x[4]+x[2]*x[3]+x[2]*x[4]+x[3]*x[4])
+  c2 = (x0*(x[1]*x[2]+x[1]*x[3]+x[1]*x[4]+x[2]*x[3]+x[2]*x[4]+x[3]*x[4])
          +x1*(x[0]*x[2]+x[0]*x[3]+x[0]*x[4]+x[2]*x[3]+x[2]*x[4]+x[3]*x[4])
          +x2*(x[0]*x[1]+x[0]*x[3]+x[0]*x[4]+x[1]*x[3]+x[1]*x[4]+x[3]*x[4])
          +x3*(x[0]*x[1]+x[0]*x[2]+x[0]*x[4]+x[1]*x[2]+x[1]*x[4]+x[2]*x[4])
          +x4*(x[0]*x[1]+x[0]*x[2]+x[0]*x[3]+x[1]*x[2]+x[1]*x[3]+x[2]*x[3]));
 
-  c[1] = -(x0*(x[1]*x[2]*x[3]+x[1]*x[2]*x[4]+x[1]*x[3]*x[4]+x[2]*x[3]*x[4])
+  c1 = -(x0*(x[1]*x[2]*x[3]+x[1]*x[2]*x[4]+x[1]*x[3]*x[4]+x[2]*x[3]*x[4])
          +x1*(x[0]*x[2]*x[3]+x[0]*x[2]*x[4]+x[0]*x[3]*x[4]+x[2]*x[3]*x[4])
          +x2*(x[0]*x[1]*x[3]+x[0]*x[1]*x[4]+x[0]*x[3]*x[4]+x[1]*x[3]*x[4])
          +x3*(x[0]*x[1]*x[2]+x[0]*x[1]*x[4]+x[0]*x[2]*x[4]+x[1]*x[2]*x[4])
          +x4*(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3]));
 
-  c[0] = (x0*x[1]*x[2]*x[3]*x[4]
+  c0 = (x0*x[1]*x[2]*x[3]*x[4]
          +x1*x[0]*x[2]*x[3]*x[4]
          +x2*x[0]*x[1]*x[3]*x[4]
          +x3*x[0]*x[1]*x[2]*x[4]
          +x4*x[0]*x[1]*x[2]*x[3]);
 
-  return c;
-  
-
 }
 //_____________________________________________________________________________
 void AliTRDCalibraFit::NormierungCharge()
@@ -6213,3 +6207,5 @@ Double_t AliTRDCalibraFit::GausConstant(const Double_t *x, const Double_t *par)
 
 }
 
+
+