//-----------------------------------------------------------------------------
// Class: AliPythiaRndm
-// Random Number Interface to Fortran (FINCTION PYR from PYTHIA)
-// Very similar to AliHijingRndm
-// Author:
+// Responsibilities: Interface to Root random number generator
+// from Fortran (re-implements FINCTION PYR from PYTHIA)
+// Very similar to AliHijingRndm
+// Collaborators: AliPythia and AliGenPythia classes
+// Example:
+//
+// root> AliPythia::Instance();
+// root> AliPythiaRndm::SetPythiaRandom(new TRandom3());
+// root> AliPythiaRndm::GetPythiaRandom()->SetSeed(0);
+// root> cout<<"Seed "<< AliPythiaRndm::GetPythiaRandom()->GetSeed() <<endl;
+//
//-----------------------------------------------------------------------------
-#include <TError.h>
+#include <TRandom.h>
#include "AliPythiaRndm.h"
ClassImp(AliPythiaRndm)
-//_______________________________________________________________________
-AliPythiaRndm::AliPythiaRndm()
-{
- //
- // Default ctor
- //
-}
-
-//_______________________________________________________________________
-AliPythiaRndm::AliPythiaRndm(const AliPythiaRndm& rn)
-{
- //
- // Copy constructor
- //
- rn.Copy(*this);
-}
-
-//_______________________________________________________________________
-AliPythiaRndm::~AliPythiaRndm() {
- //
- // Destructor
- //
- fgPythiaRandom=0;
-}
-
-//_______________________________________________________________________
-void AliPythiaRndm::Copy(AliPythiaRndm&) const
-{
- //
- // No copy is allowed for the object
- //
- ::Fatal("Copy","Not implemented\n");
-}
//_______________________________________________________________________
void AliPythiaRndm::SetPythiaRandom(TRandom *ran) {
}
//_______________________________________________________________________
-#define pyr pyr_
-#define pyrset pyrset_
-#define pyrget pyrget_
+#define pyr pyr_
+#define pygauss pygauss_
+#define pyrset pyrset_
+#define pyrget pyrget_
extern "C" {
- Double_t pyr(Int_t*)
- {
- // Wrapper to FINCTION PYR from PYTHIA
- // Uses static method to retrieve the pointer to the (C++) generator
- Double_t r;
- do r=AliPythiaRndm::GetPythiaRandom()->Rndm();
- while(0 >= r || r >= 1);
- return r;
- }
- void pyrset(Int_t*,Int_t*) {}
- void pyrget(Int_t*,Int_t*) {}
+ Double_t pyr(Int_t*)
+ {
+ // Wrapper to FINCTION PYR from PYTHIA
+ // Uses static method to retrieve the pointer to the (C++) generator
+ Double_t r;
+ do r=AliPythiaRndm::GetPythiaRandom()->Rndm();
+ while(0 >= r || r >= 1);
+ return r;
+ }
+
+ Double_t pygauss(Double_t x0, Double_t sig)
+ {
+ Double_t s = 2.;
+ Double_t v1 = 0.;
+ Double_t v2 = 0.;
+
+ while (s > 1.) {
+ v1 = 2. * pyr(0) - 1.;
+ v2 = 2. * pyr(0) - 1.;
+ s = v1 * v1 + v2 * v2;
+ }
+ return v1 * TMath::Sqrt(-2. * TMath::Log(s) / s) * sig + x0;
+ }
+
+ void pyrset(Int_t*,Int_t*) {}
+ void pyrget(Int_t*,Int_t*) {}
}