CLHEP/Random/Random.h

// $Id: Random.h,v 1.14 2000/04/17 23:00:23 mf Exp $
// -*- C++ -*-
//
// -----------------------------------------------------------------------
//                             HEP Random
//                          --- HepRandom ---
//                          class header file
// -----------------------------------------------------------------------
// This file is part of Geant4 (simulation toolkit for HEP).
//
// It's a singleton instantiated by default within the HEP Random module.
// It uses an instantiated HepJamesRandom engine as default algorithm
// for pseudo-random number generation. HepRandom defines a static private
// data member theGenerator and a set of static inlined methods to manipulate
// it. By means of theGenerator the user can change the underlying engine
// algorithm, get and set the seeds and use any kind of defined random
// distribution.
// Distribution classes inherit from HepRandom and define both static and
// not-static interfaces.
// A static table of uncorrelated seeds is available in this class.
// A static method "getTheTableSeeds()" is defined to access a couple of
// seeds at a given index in the table.

// =======================================================================
// Gabriele Cosmo - Created: 5th Sep 1995
//                - Minor update: 17th May 1996
//                - Poisson now operates on doubles : 31st Oct 1996
//                - Added methods for engine status: 19th Nov 1996
//                - Fixed default values to setTheSeed() and
//                  setTheSeeds() static methods: 16th Oct 1997
//                - Modified HepRandom to act as a singleton, constructors
//                  are kept public for backward compatibility. Added table
//                  of seeds from HepRandomEngine: 19th Mar 1998
//                - Relocated Poisson and Gauss data and simplified
//                  initialisation of static generator: 5th Jan 1999
// =======================================================================

#ifndef HepRandom_h
#define HepRandom_h 1

#include "CLHEP/Random/RandomEngine.h"

class HepRandom {

public:

  HepRandom();
  HepRandom(long seed);
  // Contructors with and without a seed using the default engine
  // (JamesRandom).
 
  HepRandom(HepRandomEngine & algorithm);
  HepRandom(HepRandomEngine * algorithm);
  // Constructor taking an alternative engine as argument. If a pointer is
  // given the corresponding object will be deleted by the HepRandom
  // destructor.
  
  virtual ~HepRandom();
  // Destructor

  HepDouble flat();
  // Returns the flat value ( interval ]0.1[ ).

  void flatArray(const HepInt size, HepDouble* vect);
  // Fills "vect" array of flat random values, given the size.

  inline HepDouble flat (HepRandomEngine* theNewEngine);
  // Returns a flat value, given a defined Random Engine.

  inline void flatArray(HepRandomEngine* theNewEngine, 
                        const HepInt size, HepDouble* vect);
  // Fills "vect" array of flat random values, given the size
  // and a defined Random Engine.

  virtual HepDouble operator()();
  // To get a flat random number using the operator ().

  // --------------------------------------------------
  // Static member functions using the static generator
  // --------------------------------------------------

  static void setTheSeed(long seed, HepInt lux=3);
  // (Re)Initializes the generator with a seed.

  static long getTheSeed();
  // Gets the current seed of the current generator.

  static void setTheSeeds(const long* seeds, HepInt aux=-1);
  // (Re)Initializes the generator with a zero terminated list of seeds.

  static const long* getTheSeeds();
  // Gets the current array of seeds of the current generator.

  static void getTheTableSeeds (long* seeds, HepInt index);
  // Gets the array of seeds in the static seedTable at "index" position.

  static HepRandom * getTheGenerator();
  // Return the current static generator.

  static void setTheEngine (HepRandomEngine* theNewEngine);
  // To set the underlying algorithm object.

  static HepRandomEngine * getTheEngine();
  // Returns a pointer to the underlying algorithm object.

  static void saveEngineStatus( const char filename[] = "Config.conf" );
  // Saves to file the current status of the current engine.

  static void restoreEngineStatus( const char filename[] = "Config.conf" );
  // Restores a saved status (if any) for the current engine.

  static void showEngineStatus();
  // Dumps the current engine status on screen.

  static HepInt createInstance();
  // Create a single instance of the generator, it returns
  // 0 if the singleton is already instantiated.
     
protected:     // -------- Data members ---------

  static const long seedTable[215][2];
  // Table of seeds

private:       // -------- Data members ---------

  static HepRandomEngine * theEngine;
  // The corresponding algorithm.

  static HepRandom * theGenerator;
  // The common shared static generator
  
  static HepInt isActive;
  // Flag notifying singleton instance
  
  HepBoolean deleteEngine;
  // True if the engine should be deleted on destruction.

};

#include "CLHEP/Random/Random.icc"

#endif

Generated by GNU enscript 1.6.1.