--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/* $Id$ */
+
+//-----------------------------------------------------------------------------
+// Class: AliHerwigRndm
+// Responsibilities: Interface to Root random number generator
+// from Fortran (re-implements FINCTION RLU_HERWIG
+// from HERWIG)
+// Note: Since AliGenHerwig belongs to another module (THerwig) one cannot
+// pass the ponter to the generator via static variable
+// Collaborators: AliGenHerwig class
+// Example:
+//
+// root> AliGenHerwig *gener = new AliGenHerwig(-1);
+// root> AliHerwigRndm::SetHerwigRandom(new TRandom3());
+// root> AliHerwigRndm::GetHerwigRandom()->SetSeed(0);
+// root> cout<<"Seed "<< AliHerwigRndm::GetHerwigRandom()->GetSeed() <<endl;
+//-----------------------------------------------------------------------------
+
+#include <TRandom.h>
+
+#include "AliHerwigRndm.h"
+
+TRandom * AliHerwigRndm::fgHerwigRandom=0;
+
+ClassImp(AliHerwigRndm)
+
+//_______________________________________________________________________
+void AliHerwigRndm::SetHerwigRandom(TRandom *ran) {
+ //
+ // Sets the pointer to an existing random numbers generator
+ //
+ if(ran) fgHerwigRandom=ran;
+ else fgHerwigRandom=gRandom;
+}
+
+//_______________________________________________________________________
+TRandom * AliHerwigRndm::GetHerwigRandom() {
+ //
+ // Retrieves the pointer to the random numbers generator
+ //
+ return fgHerwigRandom;
+}
+
+//_______________________________________________________________________
+# define hwr hwr_
+
+extern "C" {
+ Double_t hwr()
+ {
+ // Wrapper to FUNCTION HWR from HERWIG
+ // Uses static method to retrieve the pointer to the (C++) generator
+ Double_t r;
+ do r=AliHerwigRndm::GetHerwigRandom()->Rndm();
+ while(0 >= r || r >= 1);
+ return r;
+ }
+}
--- /dev/null
+#ifndef ALIHERWIGRNDM_H
+#define ALIHERWIGRNDM_H
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+/* $Id$ */
+
+#include <Rtypes.h>
+#include <TError.h>
+
+class TRandom;
+
+class AliHerwigRndm {
+ public:
+ AliHerwigRndm() {
+ // Default constructor. The static data member is initialized
+ // in the implementation file
+ }
+ AliHerwigRndm(const AliHerwigRndm &/*rn*/) {
+ // Copy constructor: no copy allowed for the object
+ ::Fatal("Copy constructor","Not allowed\n");
+ }
+ virtual ~AliHerwigRndm() {
+ // Destructor
+ fgHerwigRandom=0;
+ }
+ AliHerwigRndm & operator=(const AliHerwigRndm& /*rn*/) {
+ // Assignment operator: no assignment allowed
+ ::Fatal("Assignment operator","Not allowed\n");
+ return (*this);
+ }
+
+ static void SetHerwigRandom(TRandom *ran=0);
+ static TRandom * GetHerwigRandom();
+
+private:
+
+ static TRandom * fgHerwigRandom; //! pointer to the random number generator
+
+ ClassDef(AliHerwigRndm,0) //Random Number generator wrapper (non persistent)
+};
+
+#endif
+