]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FASTSIM/AliFastGlauber.cxx
code defect corrected
[u/mrichter/AliRoot.git] / FASTSIM / AliFastGlauber.cxx
index 357eae98074265a9cd45eca5e896592aae1fb076..13699f147304a62aa3b792a0f6cc672cc732ef95 100644 (file)
@@ -50,7 +50,6 @@
 // from AliRoot
 #include "AliFastGlauber.h"
 // from root
-#include <Riostream.h>
 #include <TCanvas.h>
 #include <TF1.h>
 #include <TF2.h>
@@ -59,7 +58,6 @@
 #include <TH2F.h>
 #include <TLegend.h>
 #include <TMath.h>
-#include <TROOT.h>
 #include <TRandom.h>
 #include <TStyle.h>
 
@@ -286,7 +284,7 @@ void AliFastGlauber::Init(Int_t mode)
     Char_t almondName[100];
     TFile* ff = new TFile(fName.Data());
     for(Int_t k=0; k<40; k++) {
-      sprintf(almondName,"WAlmondFixedB%d",k);
+      snprintf(almondName,100, "WAlmondFixedB%d",k);
       fgWAlmondCurrent = (TF2*)ff->Get(almondName);
       fgWAlmondFixedB[k] = fgWAlmondCurrent;
     }
@@ -352,13 +350,13 @@ void AliFastGlauber::DrawWSb() const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"r_{0} = %.2f fm",fWSr0);
+  snprintf(label,100, "r_{0} = %.2f fm",fWSr0);
   l1a->AddEntry(fgWSb,label,"");
-  sprintf(label,"d = %.2f fm",fWSd);
+  snprintf(label,100, "d = %.2f fm",fWSd);
   l1a->AddEntry(fgWSb,label,"");
-  sprintf(label,"n = %.2e fm^{-3}",fWSn);
+  snprintf(label,100, "n = %.2e fm^{-3}",fWSn);
   l1a->AddEntry(fgWSb,label,"");
-  sprintf(label,"#omega = %.2f",fWSw);
+  snprintf(label,100, "#omega = %.2f",fWSw);
   l1a->AddEntry(fgWSb,label,"");
   l1a->Draw();
   c1->Update();
@@ -398,7 +396,7 @@ void AliFastGlauber::DrawParticipants() const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"#sigma^{inel.}_{NN} = %.1f mbarn",fSigmaNN);
+  snprintf(label,100, "#sigma^{inel.}_{NN} = %.1f mbarn",fSigmaNN);
   l1a->AddEntry(fgWParticipants,label,"");
   l1a->Draw();
   c3->Update();
@@ -438,7 +436,7 @@ void AliFastGlauber::DrawGeo() const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"#sigma_{NN}^{inel.} = %.1f mbarn",fSigmaNN);
+  snprintf(label,100, "#sigma_{NN}^{inel.} = %.1f mbarn",fSigmaNN);
   l1a->AddEntry(fgWSgeo,label,"");
   l1a->Draw();
   c5->Update();
@@ -462,7 +460,7 @@ void AliFastGlauber::DrawBinary() const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"#sigma_{NN}^{hard} = %.1f mbarn",fSigmaHard);
+  snprintf(label,100, "#sigma_{NN}^{hard} = %.1f mbarn",fSigmaHard);
   l1a->AddEntry(fgWSb,label,"");
   l1a->Draw();
   c6->Update();
@@ -486,9 +484,9 @@ void AliFastGlauber::DrawN() const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"#sigma^{hard}_{NN} = %.1f mbarn",fSigmaHard);
+  snprintf(label,100, "#sigma^{hard}_{NN} = %.1f mbarn",fSigmaHard);
   l1a->AddEntry(fgWSN,label,"");
-  sprintf(label,"#sigma^{inel.}_{NN} = %.1f mbarn",fSigmaNN);
+  snprintf(label,100, "#sigma^{inel.}_{NN} = %.1f mbarn",fSigmaNN);
   l1a->AddEntry(fgWSN,label,"");
   l1a->Draw();
   c7->Update();
@@ -512,7 +510,7 @@ void AliFastGlauber::DrawKernel(Double_t b) const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"b = %.1f fm",b);
+  snprintf(label, 100, "b = %.1f fm",b);
   l1a->AddEntry(fgWStarfi,label,"");
   l1a->Draw();
   c8->Update();
@@ -536,7 +534,7 @@ void AliFastGlauber::DrawAlmond(Double_t b) const
   l1a->SetFillStyle(0);
   l1a->SetBorderSize(0);
   Char_t label[100];
-  sprintf(label,"b = %.1f fm",b);
+  snprintf(label, 100, "b = %.1f fm",b);
   l1a->AddEntry(fgWAlmond,label,"");
   l1a->Draw();
   c9->Update();
@@ -618,7 +616,7 @@ void AliFastGlauber::DrawIntRadius(Double_t b) const
   fgWIntRadius->Draw("same");
 }
 
-Double_t AliFastGlauber::WSb(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WSb(const Double_t* x, const Double_t* par)
 {
   //
   //  Woods-Saxon Parameterisation
@@ -633,7 +631,7 @@ Double_t AliFastGlauber::WSb(Double_t* x, Double_t* par)
   return y; //fm^-3
 }
 
-Double_t AliFastGlauber::WSbz(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WSbz(const Double_t* x, const Double_t* par)
 {
   //
   //  Wood Saxon Parameterisation
@@ -650,7 +648,7 @@ Double_t AliFastGlauber::WSbz(Double_t* x, Double_t* par)
   return y; //fm^-3
 }
 
-Double_t AliFastGlauber::WSz(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WSz(const Double_t* x, const Double_t* par)
 {
   //
   //  Wood Saxon Parameterisation
@@ -667,7 +665,7 @@ Double_t AliFastGlauber::WSz(Double_t* x, Double_t* par)
   return y; //fm^-3
 }
 
-Double_t AliFastGlauber::WSta(Double_t* x, Double_t* /*par*/)
+Double_t AliFastGlauber::WSta(const Double_t* x, const Double_t* /*par*/)
 {
   //
   //  Thickness function T_A
@@ -679,7 +677,7 @@ Double_t AliFastGlauber::WSta(Double_t* x, Double_t* /*par*/)
   return y; //fm^-2
 }
 
-Double_t AliFastGlauber::WStarfi(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WStarfi(const Double_t* x, const Double_t* par)
 {
   //
   //  Kernel for overlap function: T_A(s)*T_A(s-b)
@@ -692,7 +690,7 @@ Double_t AliFastGlauber::WStarfi(Double_t* x, Double_t* par)
   return y; //fm^-3
 }
 
-Double_t AliFastGlauber::WStaa(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WStaa(const Double_t* x, const Double_t* par)
 {
   //
   //  Overlap function 
@@ -736,7 +734,7 @@ Double_t AliFastGlauber::WStaa(Double_t* x, Double_t* par)
   return y;
 }
 
-Double_t AliFastGlauber::WKParticipants(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WKParticipants(const Double_t* x, const Double_t* par)
 {
   //
   //  Kernel for number of participants
@@ -765,7 +763,7 @@ Double_t AliFastGlauber::WKParticipants(Double_t* x, Double_t* par)
   return y; //fm^-1
 }
 
-Double_t AliFastGlauber::WParticipants(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WParticipants(const Double_t* x, const Double_t* par)
 {
   //
   //  Number of Participants as 
@@ -792,7 +790,7 @@ Double_t AliFastGlauber::WParticipants(Double_t* x, Double_t* par)
   return y; //no units
 }
 
-Double_t AliFastGlauber::WSgeo(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WSgeo(const Double_t* x, const Double_t* par)
 {
   //
   //  Geometrical Cross-Section
@@ -805,7 +803,7 @@ Double_t AliFastGlauber::WSgeo(Double_t* x, Double_t* par)
   return y; //fm
 }
 
-Double_t AliFastGlauber::WSbinary(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WSbinary(const Double_t* x, const Double_t* par)
 {
   //
   //  Number of binary hard collisions
@@ -818,7 +816,7 @@ Double_t AliFastGlauber::WSbinary(Double_t* x, Double_t* par)
   return y; //fm
 }
 
-Double_t AliFastGlauber::WSN(Double_t* x, Double_t* /*par*/)
+Double_t AliFastGlauber::WSN(const Double_t* x, const Double_t* /*par*/)
 {
   //
   //  Number of hard processes per event
@@ -828,7 +826,7 @@ Double_t AliFastGlauber::WSN(Double_t* x, Double_t* /*par*/)
   return y; //no units
 }
 
-Double_t AliFastGlauber::WEnergyDensity(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WEnergyDensity(const Double_t* x, const Double_t* par)
 {
   //
   //  Initial energy density 
@@ -847,7 +845,7 @@ Double_t AliFastGlauber::WEnergyDensity(Double_t* x, Double_t* par)
   return y; //fm^-4
 }
 
-Double_t AliFastGlauber::WAlmond(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WAlmond(const Double_t* x, const Double_t* par)
 {
   //
   //  Almond shaped interaction region
@@ -866,7 +864,7 @@ Double_t AliFastGlauber::WAlmond(Double_t* x, Double_t* par)
   return y; //fm^-4
 }
 
-Double_t AliFastGlauber::WIntRadius(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WIntRadius(const Double_t* x, const Double_t* par)
 {
   //
   //  Average interaction density over radius 
@@ -891,7 +889,7 @@ Double_t AliFastGlauber::WIntRadius(Double_t* x, Double_t* par)
   return y; //fm^-3
 }
 
-Double_t AliFastGlauber::WPathLength0(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WPathLength0(const Double_t* x, const Double_t* par)
 {
   //
   //  Path Length as a function of phi 
@@ -937,7 +935,7 @@ Double_t AliFastGlauber::WPathLength0(Double_t* x, Double_t* par)
   return y; //fm
 }
 
-Double_t AliFastGlauber::WPathLength(Double_t* x, Double_t* par)
+Double_t AliFastGlauber::WPathLength(const Double_t* x, const Double_t* par)
 {
   //
   //  Path Length as a function of phi 
@@ -1021,7 +1019,7 @@ Double_t AliFastGlauber::FractionOfHardCrossSection(Double_t b1, Double_t b2) co
   return fgWSbinary->Integral(b1, b2)/fgWSbinary->Integral(0., 100.);
 }
 
-Double_t AliFastGlauber::NHard(Double_t b1, Double_t b2) const
+Double_t AliFastGlauber::NHard(const Double_t b1, const Double_t b2) const
 {
   //
   //  Number of binary hard collisions 
@@ -1039,7 +1037,7 @@ Double_t AliFastGlauber::Binaries(Double_t b) const
   //
   // Return number of binary hard collisions normalized to 1 at b=0
   //
-  if(b==0) b=1e-4;
+  if(b < 1.e-4) b = 1e-4;
   return fgWSN->Eval(b)/fgWSN->Eval(1e-4);
 }
 
@@ -1086,7 +1084,7 @@ Double_t AliFastGlauber::GetNumberOfBinaries(Double_t b) const
   //
   // Return number of binary hard collisions at b
   //
-  if(b==0) b=1e-4;
+  if(b<1.e-4) b=1e-4;
   return fgWSN->Eval(b);
 }
 
@@ -1095,7 +1093,7 @@ Double_t AliFastGlauber::Participants(Double_t  b) const
   //
   // Return the number of participants normalized to 1 at b=0
   //
-  if(b==0) b=1e-4;
+  if(b<1.e-4) b=1e-4;
   return (fgWParticipants->Eval(b)/fgWParticipants->Eval(1e-4));
 }
 
@@ -1104,7 +1102,7 @@ Double_t AliFastGlauber::GetNumberOfParticipants(Double_t  b) const
   //
   // Return the number of participants for impact parameter b
   //
-  if(b==0) b=1e-4;
+  if(b<1.e-4) b=1e-4;
   return (fgWParticipants->Eval(b));
 }
 
@@ -1113,7 +1111,7 @@ Double_t AliFastGlauber::GetNumberOfCollisions(Double_t  b) const
   //
   // Return the number of collisions for impact parameter b
   //
-  if(b==0) b=1e-4;
+  if(b<1.e-4) b=1e-4;
   return (fgWStaa->Eval(b)*fSigmaNN);
 }
 
@@ -1248,7 +1246,7 @@ void AliFastGlauber::StoreAlmonds() const
   Char_t almondName[100];
   TFile* ff = new TFile(fName.Data(),"update");
   for(Int_t k=0; k<40; k++) {
-    sprintf(almondName,"WAlmondFixedB%d",k);
+    snprintf(almondName, 100, "WAlmondFixedB%d",k);
     Double_t b = 0.25+k*0.5;
     Info("StoreAlmonds"," b = %f\n",b); 
     fgWAlmond->SetParameter(0,b);