]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
AliFastGlauber is a singleton.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Nov 2008 15:34:55 +0000 (15:34 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Nov 2008 15:34:55 +0000 (15:34 +0000)
EVGEN/AliGenMUONCocktail.cxx
FASTSIM/AliFastGlauber.cxx
FASTSIM/AliFastGlauber.h
PYTHIA6/AliPythia.cxx
PYTHIA6/AliPythia6.cxx

index 1b8257e48eb1724e6fef17ae2d998ba06fe593ad..dd263e502a381cd6379faefae7f84ed1dc1c45a1 100644 (file)
@@ -82,7 +82,7 @@ void AliGenMUONCocktail::Init()
   Double_t sigmaReaction =   0.072;   // MinBias NN cross section for PbPb LHC energies  http://arxiv.org/pdf/nucl-ex/0302016
 
   // Initialising Fast Glauber object
-  fFastGlauber = new AliFastGlauber();
+  fFastGlauber = AliFastGlauber::Instance();
   fFastGlauber->SetPbPbLHC();
   fFastGlauber->SetNNCrossSection(sigmaReaction*1000.); //Expected NN cross-section in mb at LHC with diffractive part http://arxiv.org/pdf/nucl-ex/0302016 )
   fFastGlauber->Init(1);
index 020b456d89202faf8f860ce426744918d998132c..eed4aeb6b52beba405d2704c62734f735107463b 100644 (file)
@@ -85,7 +85,8 @@ TF1*    AliFastGlauber::fgWParticipants  = NULL;
 TF2*    AliFastGlauber::fgWAlmondCurrent = NULL;    
 TF2*    AliFastGlauber::fgWAlmondFixedB[40]; 
 const Int_t AliFastGlauber::fgkMCInts = 100000;
-Int_t AliFastGlauber::fgCounter = 0;       
+AliFastGlauber* AliFastGlauber::fgGlauber = NULL;
+
 
 AliFastGlauber::AliFastGlauber(): 
     fWSr0(0.),
@@ -101,10 +102,6 @@ AliFastGlauber::AliFastGlauber():
     fName()     
 {
   //  Default Constructor 
-  fgCounter++;
-  if(fgCounter>1)
-    Error("AliFastGlauber","More than one instance (%d) is not supported, check your code!",fgCounter);
-
   //  Defaults for Pb
   SetMaxImpact();
   SetLengthDefinition();
@@ -129,10 +126,20 @@ AliFastGlauber::AliFastGlauber(const AliFastGlauber & gl)
     gl.Copy(*this);
 }
 
+AliFastGlauber* AliFastGlauber::Instance()
+{ 
+// Set random number generator 
+    if (fgGlauber) {
+       return fgGlauber;
+    } else {
+       fgGlauber = new AliFastGlauber();
+       return fgGlauber;
+    }
+}
+
 AliFastGlauber::~AliFastGlauber()
 {
 // Destructor
-  fgCounter--;
   for(Int_t k=0; k<40; k++) delete fgWAlmondFixedB[k];
 }
 
index 0036b27c8ec6c4a715b7df2ba2c7ea51c696428d..479a6afd5385d5d5c6dc9ec0335980954bf9b248 100644 (file)
@@ -18,8 +18,7 @@ class TF2;
 
 class AliFastGlauber : public TObject {
  public:
-    AliFastGlauber();
-    AliFastGlauber(const AliFastGlauber& glauber);
+    static AliFastGlauber* Instance();
     virtual ~AliFastGlauber();
     void Init(Int_t mode = 0);
 
@@ -178,11 +177,15 @@ class AliFastGlauber : public TObject {
     static Double_t WEnergyDensity (Double_t *xx, Double_t *par);
 
     void Reset() const;
+ private:
+    AliFastGlauber();
+    AliFastGlauber(const AliFastGlauber& glauber);
 
-    static Float_t fgBMax;           // Maximum Impact Parameter
-    static Int_t fgCounter;          // Counter to protect double instantiation
-    static const Int_t fgkMCInts;    // Number of MC integrations
-
+    static Float_t         fgBMax;       // Maximum Impact Parameter
+    static const Int_t     fgkMCInts;    // Number of MC integrations
+    static AliFastGlauber* fgGlauber;    // Singleton instance
+     
+    
     static TF1*    fgWSb;            // Wood-Saxon Function (b)
     static TF2*    fgWSbz;           // Wood-Saxon Function (b, z)
     static TF1*    fgWSz;            // Wood-Saxon Function (b = b0, z)
index 34c3bf29e43d7caa14bf4d4718e6dc287afb6be3..2a532d3760c8e15e874ead10a166b15b49619f26 100644 (file)
@@ -692,7 +692,7 @@ void AliPythia::InitQuenching(Float_t cMin, Float_t cMax, Float_t k, Int_t iECMe
 // (2) The nuclear geometry using the Glauber Model
 //     
     
-    fGlauber = new AliFastGlauber();
+    fGlauber = AliFastGlauber::Instance();
     fGlauber->Init(2);
     fGlauber->SetCentralityClass(cMin, cMax); 
 
index b0b126d0e730ae00d2f4d4cd77da0b52c2fee603..f8c761f3fec84cd55dba0dd7060accbbb048fad3 100644 (file)
@@ -704,7 +704,7 @@ void AliPythia6::InitQuenching(Float_t cMin, Float_t cMax, Float_t k, Int_t iECM
 // (2) The nuclear geometry using the Glauber Model
 //     
     
-    fGlauber = new AliFastGlauber();
+    fGlauber = AliFastGlauber::Instance();
     fGlauber->Init(2);
     fGlauber->SetCentralityClass(cMin, cMax);