coverity fix
[u/mrichter/AliRoot.git] / TPC / AliTPCPRF2D.cxx
index 7600b87..4f8d636 100644 (file)
@@ -52,7 +52,7 @@ const Double_t AliTPCPRF2D::fgkSQRT12=3.464101;
 const Int_t   AliTPCPRF2D::fgkNPRF = 100;
 
 
-static Double_t funGauss2D(Double_t *x, Double_t * par)
+static Double_t FunGauss2D(const Double_t *const x, const Double_t *const par)
 { 
 //Gauss function  -needde by the generic function object 
   return ( TMath::Exp(-(x[0]*x[0])/(2*par[0]*par[0]))*
@@ -60,14 +60,14 @@ static Double_t funGauss2D(Double_t *x, Double_t * par)
 
 }
 
-static Double_t funCosh2D(Double_t *x, Double_t * par)
+static Double_t FunCosh2D(const Double_t *const x, const Double_t *const par)
 {
  //Cosh function  -needde by the generic function object 
   return ( 1/(TMath::CosH(3.14159*x[0]/(2*par[0]))*
           TMath::CosH(3.14159*x[1]/(2*par[1]))));
 }    
 
-static Double_t funGati2D(Double_t *x, Double_t * par)
+static Double_t FunGati2D(const Double_t *const x, const Double_t *const par)
 {
   //Gati function  -needde by the generic function object 
   Float_t k3=par[1];
@@ -134,6 +134,11 @@ AliTPCPRF2D::AliTPCPRF2D()
   //default constructor for response function object
 
   fNPRF =fgkNPRF ;
+  for(Int_t i=0;i<5;i++){
+        funParam[i]=0.;
+        fType[i]=0;
+  }
+  
 
   //chewron default values   
   SetPad(0.8,0.8);
@@ -269,7 +274,7 @@ Float_t  AliTPCPRF2D::GetGRF(Float_t xin, Float_t yin)
 }
 
    
-void AliTPCPRF2D::SetParam( TF2 * GRF,  Float_t kNorm, 
+void AliTPCPRF2D::SetParam( TF2 *const GRF,  Float_t kNorm, 
                       Float_t sigmaX, Float_t sigmaY)
 {
   //adjust parameters of the original charge distribution
@@ -277,7 +282,8 @@ void AliTPCPRF2D::SetParam( TF2 * GRF,  Float_t kNorm,
    if (fGRF !=0 ) fGRF->Delete();
    fGRF = GRF;
    fKNorm = kNorm;
-   sprintf(fType,"User");
+   //sprintf(fType,"User");
+   snprintf(fType,5,"User");
    if (sigmaX ==0) sigmaX=(fWidth*(1+TMath::Abs(fK)))/fgkSQRT12;
    if (sigmaY ==0) sigmaY=(fWidth*(1+TMath::Abs(fK)))/fgkSQRT12;
    fOrigSigmaX=sigmaX; 
@@ -307,9 +313,10 @@ void AliTPCPRF2D::SetGauss(Float_t sigmaX, Float_t sigmaY,
   fKNorm = kNorm;
   fOrigSigmaX=sigmaX;
   fOrigSigmaY=sigmaY;
-  sprintf(fType,"Gauss");
+  //sprintf(fType,"Gauss");
+  snprintf(fType,5,"Gauss");
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF2("funGauss2D",funGauss2D,-5.,5.,-5.,5.,4);
+  fGRF = new TF2("FunGauss2D",FunGauss2D,-5.,5.,-5.,5.,4);
   
   funParam[0]=sigmaX;
   funParam[1]=sigmaY;  
@@ -340,9 +347,10 @@ void AliTPCPRF2D::SetCosh(Float_t sigmaX, Float_t sigmaY,
   fKNorm = kNorm;
   fOrigSigmaX=sigmaX;
   fOrigSigmaY=sigmaY; 
-  sprintf(fType,"Cosh");
+  //  sprintf(fType,"Cosh");
+  snprintf(fType,5,"Cosh");
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF2("funCosh2D",  funCosh2D,-5.,5.,-5.,5.,4);   
+  fGRF = new TF2("FunCosh2D",  FunCosh2D,-5.,5.,-5.,5.,4);   
   funParam[0]=sigmaX;
   funParam[1]=sigmaY;
   funParam[2]=fK;  
@@ -371,9 +379,10 @@ void AliTPCPRF2D::SetGati(Float_t K3X, Float_t K3Y,
   fK3X=K3X;
   fK3Y=K3Y;
   fPadDistance=padDistance;  
-  sprintf(fType,"Gati");
+  //sprintf(fType,"Gati");
+  snprintf(fType,5,"Gati");
   if (fGRF !=0 ) fGRF->Delete();
-  fGRF = new TF2("funGati2D",  funGati2D,-5.,5.,-5.,5.,5);  
+  fGRF = new TF2("FunGati2D",  FunGati2D,-5.,5.,-5.,5.,5);  
  
   funParam[0]=padDistance;
   funParam[1]=K3X;
@@ -664,30 +673,30 @@ void AliTPCPRF2D::UpdateSigma()
 }
 
 
-void AliTPCPRF2D::Streamer(TBuffer &R__b)
+void AliTPCPRF2D::Streamer(TBuffer &xRuub)
 {
    // Stream an object of class AliTPCPRF2D
 
-   if (R__b.IsReading()) {
-      UInt_t R__s, R__c;
-      Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
-      AliTPCPRF2D::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
+   if (xRuub.IsReading()) {
+      UInt_t xRuus, xRuuc;
+      Version_t xRuuv = xRuub.ReadVersion(&xRuus, &xRuuc);
+      AliTPCPRF2D::Class()->ReadBuffer(xRuub, this, xRuuv, xRuus, xRuuc);
       //read functions
       if (strncmp(fType,"User",3)!=0){
        delete fGRF;  
         if (strncmp(fType,"Gauss",3)==0) 
-         fGRF = new TF2("funGauss2D",funGauss2D,-5.,5.,-5.,5.,4);
+         fGRF = new TF2("FunGauss2D",FunGauss2D,-5.,5.,-5.,5.,4);
         if (strncmp(fType,"Cosh",3)==0) 
-         fGRF = new TF2("funCosh2D",funCosh2D,-5.,5.,-5.,5.,4);
+         fGRF = new TF2("FunCosh2D",FunCosh2D,-5.,5.,-5.,5.,4);
         if (strncmp(fType,"Gati",3)==0) 
-         fGRF = new TF2("funGati2D",funGati2D,-5.,5.,-5.,5.,5);      
+         fGRF = new TF2("FunGati2D",FunGati2D,-5.,5.,-5.,5.,5);      
         if (fGRF!=0) fGRF->SetParameters(funParam);
       }
       //calculate conversion coefitient to convert position to virtual wire
       fDYtoWire=Float_t(fNYdiv-1)/(fY2-fY1);
       fDStepM1=1/fDStep;
    } else {
-      AliTPCPRF2D::Class()->WriteBuffer(R__b,this);
+      AliTPCPRF2D::Class()->WriteBuffer(xRuub,this);
    }
 }
 
@@ -698,7 +707,8 @@ TH1F *  AliTPCPRF2D::GenerDrawXHisto(Float_t x1, Float_t x2,Float_t y)
   //  at position y 
   char s[100]; 
   const Int_t kn=200;
-  sprintf(s,"Pad Response Function");  
+  //sprintf(s,"Pad Response Function"); 
+  snprintf(s,100,"Pad Response Function");  
   TH1F * hPRFc = new TH1F("hPRFc",s,kn+1,x1,x2);
   Float_t x=x1;
   Float_t y1;
@@ -719,7 +729,8 @@ AliH2F * AliTPCPRF2D::GenerDrawHisto(Float_t x1, Float_t x2, Float_t y1, Float_t
   //gener two dimensional histogram with PRF
   //
   char s[100];
-  sprintf(s,"Pad Response Function");  
+  //sprintf(s,"Pad Response Function"); 
+  snprintf(s,100,"Pad Response Function");  
   AliH2F * hPRFc = new AliH2F("hPRFc",s,Nx,x1,x2,Ny,y1,y2);
   Float_t dx=(x2-x1)/Float_t(Nx);
   Float_t dy=(y2-y1)/Float_t(Ny) ;
@@ -747,7 +758,8 @@ AliH2F * AliTPCPRF2D::GenerDrawDistHisto(Float_t x1, Float_t x2, Float_t y1, Flo
   const Float_t kminth=0.00001;
   if (thr<kminth) thr=kminth;
   char s[100]; 
-  sprintf(s,"COG distortion of PRF (threshold=%2.2f)",thr);  
+  //sprintf(s,"COG distortion of PRF (threshold=%2.2f)",thr); 
+  snprintf(s,100,"COG distortion of PRF (threshold=%2.2f)",thr); 
   AliH2F * hPRFDist = new AliH2F("hDistortion",s,Nx,x1,x2,Ny,y1,y2);
   Float_t dx=(x2-x1)/Float_t(Nx);
   Float_t dy=(y2-y1)/Float_t(Ny) ;
@@ -816,9 +828,11 @@ void AliTPCPRF2D::DrawX(Float_t x1 ,Float_t x2,Float_t y1,Float_t y2, Int_t N)
     else y = y1+i*(y2-y1)/Float_t(N-1);
     pad2->cd(i+1);
     TH1F * hPRFc =GenerDrawXHisto(x1, x2,y);
-    sprintf(ch,"PRF at wire position: %2.3f",y);
+    //sprintf(ch,"PRF at wire position: %2.3f",y);
+    snprintf(ch,40,"PRF at wire position: %2.3f",y);
     hPRFc->SetTitle(ch);  
-    sprintf(ch,"PRF %d",i);
+    //sprintf(ch,"PRF %d",i);
+    snprintf(ch,15,"PRF %d",i);
     hPRFc->SetName(ch);  
      hPRFc->Fit("gaus");
   }
@@ -889,55 +903,74 @@ void AliTPCPRF2D::DrawComment(TPaveText *comment)
   //draw comments to picture
   TText * title = comment->AddText("Pad Response Function  parameters:");
   title->SetTextSize(0.03);
-  sprintf(s,"Height of pad:  %2.2f cm",fHeightFull);
+  //sprintf(s,"Height of pad:  %2.2f cm",fHeightFull);
+  snprintf(s,100,"Height of pad:  %2.2f cm",fHeightFull);
   comment->AddText(s);
-  sprintf(s,"Width pad:  %2.2f cm",fWidth);
+  //sprintf(s,"Width pad:  %2.2f cm",fWidth);
+  snprintf(s,100,"Width pad:  %2.2f cm",fWidth);
   comment->AddText(s);
-  sprintf(s,"Pad Angle:  %2.2f ",fPadAngle);
+  //sprintf(s,"Pad Angle:  %2.2f ",fPadAngle);
+  snprintf(s,100,"Pad Angle:  %2.2f ",fPadAngle);
   comment->AddText(s);
   
   if (TMath::Abs(fK)>0.0001){
-    sprintf(s,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
+    //sprintf(s,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
+    snprintf(s,100,"Height of one chevron unit h:  %2.2f cm",2*fHeightS);
     comment->AddText(s);
-    sprintf(s,"Overlap factor:  %2.2f",fK);
+    //sprintf(s,"Overlap factor:  %2.2f",fK);
+    snprintf(s,100,"Overlap factor:  %2.2f",fK);
     comment->AddText(s); 
   }
 
   if (strncmp(fType,"User",3)==0){
-    sprintf(s,"Charge distribution - user defined function  %s ",fGRF->GetTitle());
+    //sprintf(s,"Charge distribution - user defined function  %s ",fGRF->GetTitle());
+    snprintf(s,100,"Charge distribution - user defined function  %s ",fGRF->GetTitle());
     comment->AddText(s);  
-    sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    //sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    snprintf(s,100,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);  
     comment->AddText(s);  
-    sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    //sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    snprintf(s,100,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
     comment->AddText(s); 
   }
   if (strncmp(fType,"Gauss",3)==0){
-    sprintf(s,"Gauss charge distribution");
+    //sprintf(s,"Gauss charge distribution");
+    snprintf(s,100,"Gauss charge distribution");
     comment->AddText(s);  
-    sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    //sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    snprintf(s,100,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
     comment->AddText(s);  
-    sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    //sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    snprintf(s,100,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
     comment->AddText(s); 
   }
   if (strncmp(fType,"Gati",3)==0){
-    sprintf(s,"Gati charge distribution");
+    //sprintf(s,"Gati charge distribution");
+    snprintf(s,100,"Gati charge distribution");
     comment->AddText(s);  
-    sprintf(s,"K3X of Gati : %2.2f ",fK3X);
+    //sprintf(s,"K3X of Gati : %2.2f ",fK3X);
+    snprintf(s,100,"K3X of Gati : %2.2f ",fK3X);
     comment->AddText(s);  
-    sprintf(s,"K3Y of Gati: %2.2f ",fK3Y);
+    //sprintf(s,"K3Y of Gati: %2.2f ",fK3Y);
+    snprintf(s,100,"K3Y of Gati: %2.2f ",fK3Y);
     comment->AddText(s); 
-    sprintf(s,"Wire to Pad Distance: %2.2f ",fPadDistance);
+    //sprintf(s,"Wire to Pad Distance: %2.2f ",fPadDistance);
+    snprintf(s,100,"Wire to Pad Distance: %2.2f ",fPadDistance);
     comment->AddText(s); 
   }
   if (strncmp(fType,"Cosh",3)==0){
-    sprintf(s,"Cosh charge distribution");
+    //sprintf(s,"Cosh charge distribution");
+    snprintf(s,100,"Cosh charge distribution");
     comment->AddText(s);  
-    sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    //sprintf(s,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
+    snprintf(s,100,"Sigma x of charge distribution: %2.2f ",fOrigSigmaX);
     comment->AddText(s);  
-    sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    //sprintf(s,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
+    snprintf(s,100,"Sigma y of charge distribution: %2.2f ",fOrigSigmaY);
     comment->AddText(s); 
   }
-  sprintf(s,"Normalisation: %2.2f ",fKNorm);
+  //sprintf(s,"Normalisation: %2.2f ",fKNorm);
+  snprintf(s,100,"Normalisation: %2.2f ",fKNorm);
   comment->AddText(s);    
 }