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);
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.),
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();
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];
}
class AliFastGlauber : public TObject {
public:
- AliFastGlauber();
- AliFastGlauber(const AliFastGlauber& glauber);
+ static AliFastGlauber* Instance();
virtual ~AliFastGlauber();
void Init(Int_t mode = 0);
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)
// (2) The nuclear geometry using the Glauber Model
//
- fGlauber = new AliFastGlauber();
+ fGlauber = AliFastGlauber::Instance();
fGlauber->Init(2);
fGlauber->SetCentralityClass(cMin, cMax);
// (2) The nuclear geometry using the Glauber Model
//
- fGlauber = new AliFastGlauber();
+ fGlauber = AliFastGlauber::Instance();
fGlauber->Init(2);
fGlauber->SetCentralityClass(cMin, cMax);