]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVGEN/AliGenGeVSim.cxx
fixing coverity (index out of bounds)
[u/mrichter/AliRoot.git] / EVGEN / AliGenGeVSim.cxx
index fb065e22d0b9059278ac0828675629e2ce51b244..bbcda72548f580f1fa25b4d5643bdf3ca53e32eb 100644 (file)
@@ -73,6 +73,7 @@
 #include <TObjArray.h>
 #include <TPDGCode.h>
 #include <TParticle.h>
+#include <TDatabasePDG.h>
 #include <TROOT.h>
 
 
@@ -97,7 +98,8 @@ AliGenGeVSim::AliGenGeVSim() :
   fPhiFormula(0),
   fCurrentForm(0),
   fPtYHist(0),
-  fPartTypes(0) {
+  fPartTypes(0) 
+{
   //
   //  Default constructor
   // 
@@ -110,7 +112,18 @@ AliGenGeVSim::AliGenGeVSim() :
 
 //////////////////////////////////////////////////////////////////////////////////
 
-AliGenGeVSim::AliGenGeVSim(Float_t psi, Bool_t isMultTotal) : AliGenerator(-1) {
+AliGenGeVSim::AliGenGeVSim(Float_t psi, Bool_t isMultTotal) 
+    : AliGenerator(-1),
+      fModel(0),
+      fPsi(psi),
+      fIsMultTotal(isMultTotal),
+      fPtFormula(0),
+      fYFormula(0),
+      fPhiFormula(0),
+      fCurrentForm(0),
+      fPtYHist(0),
+      fPartTypes(0) 
+ {
   //
   //  Standard Constructor.
   //  
@@ -131,12 +144,12 @@ AliGenGeVSim::AliGenGeVSim(Float_t psi, Bool_t isMultTotal) : AliGenerator(-1) {
   // checking consistancy
   
   if (psi < 0 || psi > 360 ) 
-    Error ("AliGenGeVSim", "Reaction plane angle ( %d )out of range [0..360]", psi);
+    Error ("AliGenGeVSim", "Reaction plane angle ( %13.3f )out of range [0..360]", psi);
 
   fPsi = psi * TMath::Pi() / 180. ;
   fIsMultTotal = isMultTotal;
 
-  // initialization 
+  // Initialization 
 
   fPartTypes = new TObjArray();
   InitFormula();
@@ -253,11 +266,10 @@ static Double_t aPtYFormula2(Double_t *x, Double_t * par) {
   // mass -> [0] , temperature -> [1] , expansion velocity -> [2]
 
   Double_t aFormE = TMath::Sqrt(par[0]*par[0] + x[0]*x[0]) * TMath::CosH(x[1]);
-  Double_t aFormG = 1 / TMath::Sqrt( 1 - par[2]*par[2] );
+  Double_t aFormG = 1 / TMath::Sqrt((1.-par[2])*(1.+par[2]));
   Double_t aFormYp = par[2]*TMath::Sqrt( (par[0]*par[0] + x[0]*x[0]) 
-                                        * TMath::CosH(x[1])*TMath::CosH(x[1])
-                                        - par[0]*par[0] )
-    /( par[1]*TMath::Sqrt(1-par[2]*par[2]));
+                                        * (TMath::CosH(x[1])-par[0])*(TMath::CosH(x[1])+par[0]))
+    /( par[1]*TMath::Sqrt((1.-par[2])*(1.+par[2])));
 
   return x[0] * aFormE * TMath::Exp( - aFormG * aFormE / par[1])
     *( TMath::SinH(aFormYp)/aFormYp 
@@ -414,8 +426,8 @@ Float_t AliGenGeVSim::FindScaler(Int_t paramId, Int_t pdg) {
       
       form = 0;
       
-      if (i == 0) sprintf(buffer, patt1, params[paramId], ending[j]);      
-      else sprintf(buffer, patt2, pdg, params[paramId], ending[j]);
+      if (i == 0) snprintf(buffer, 80, patt1, params[paramId], ending[j]);      
+      else snprintf(buffer, 80, patt2, pdg, params[paramId], ending[j]);
       
       form = (TF1 *)gROOT->GetFunction(buffer);
 
@@ -567,7 +579,7 @@ void AliGenGeVSim::SetFormula(Int_t pdg) {
     
     if (!fCurrentForm) {
 
-      sprintf(buff, pattern[1], pdg);
+      snprintf(buff, 40, pattern[1], pdg);
       fCurrentForm = (TF2*)gROOT->GetFunction(buff);
 
       if (!fCurrentForm) Error(where, msg[0], pdg);
@@ -585,7 +597,7 @@ void AliGenGeVSim::SetFormula(Int_t pdg) {
       
       if (!fHist[i]) {
        
-       sprintf(buff, pattern[3+2*i], pdg);
+       snprintf(buff, 40, pattern[3+2*i], pdg);
        fHist[i] = (TH1D*)gROOT->FindObject(buff);
        
        if (!fHist[i]) Error(where, msg[1+i], pdg);
@@ -602,7 +614,7 @@ void AliGenGeVSim::SetFormula(Int_t pdg) {
     
     if (!fPtYHist) {
       
-      sprintf(buff, pattern[7], pdg);
+      snprintf(buff, 40, pattern[7], pdg);
       fPtYHist = (TH2D*)gROOT->FindObject(buff);
     }