AliHerwigRndm added.
authormorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Jul 2005 15:11:16 +0000 (15:11 +0000)
committermorsch <morsch@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 12 Jul 2005 15:11:16 +0000 (15:11 +0000)
HERWIG/AliHerwigRndm.cxx [new file with mode: 0644]
HERWIG/AliHerwigRndm.h [new file with mode: 0644]
HERWIG/herwigLinkDef.h [new file with mode: 0644]
HERWIG/libherwig.pkg

diff --git a/HERWIG/AliHerwigRndm.cxx b/HERWIG/AliHerwigRndm.cxx
new file mode 100644 (file)
index 0000000..fef5d0a
--- /dev/null
@@ -0,0 +1,72 @@
+/**************************************************************************
+ * 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;
+  }
+}
diff --git a/HERWIG/AliHerwigRndm.h b/HERWIG/AliHerwigRndm.h
new file mode 100644 (file)
index 0000000..5753ab3
--- /dev/null
@@ -0,0 +1,44 @@
+#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 
+
diff --git a/HERWIG/herwigLinkDef.h b/HERWIG/herwigLinkDef.h
new file mode 100644 (file)
index 0000000..95cef11
--- /dev/null
@@ -0,0 +1,8 @@
+#ifdef __CINT__
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+#pragma link C++ class AliHerwigRndm+;
+#endif
index 892f1e3..ace0fc6 100644 (file)
@@ -1,3 +1,9 @@
+SRCS:=AliHerwigRndm.cxx
+
+HDRS= $(SRCS:.cxx=.h) 
+
+DHDR:=herwigLinkDef.h
+
 CSRCS:= \
 main.c herwig6_address.c