Import Geant4 10.5.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2018-06-29 10:58:11 +02:00
parent fe81a77428
commit 6aa23be517
1581 changed files with 124288 additions and 83758 deletions
@@ -1,170 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTHepRandom
//
// Modified version with MT extensions
// of corresponding CLHEP class HepRandom
// --------------------------------------------------------------------
#ifndef G4MTHepRandom_h
#define G4MTHepRandom_h 1
#include <CLHEP/Random/RandomEngine.h>
#include <CLHEP/Random/RandExponential.h>
#include <CLHEP/Random/RandFlat.h>
#include <CLHEP/Random/RandBit.h>
#include <CLHEP/Random/RandGamma.h>
#include <CLHEP/Random/RandGaussQ.h>
#include <CLHEP/Random/RandGeneral.h>
#include "tls.hh"
#include "G4Types.hh"
class G4MTHepRandom
{
public:
G4MTHepRandom();
G4MTHepRandom(G4long seed);
// Contructors with and without a seed using the default engine
// (JamesRandom).
G4MTHepRandom(CLHEP::HepRandomEngine & algorithm);
G4MTHepRandom(CLHEP::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 ~G4MTHepRandom();
// Destructor
G4double flat();
// Returns the flat value ( interval ]0...1[ ).
void flatArray(const G4int size, G4double* vect);
// Fills "vect" array of flat random values, given the size.
inline G4double flat (CLHEP::HepRandomEngine* theNewEngine);
// Returns a flat value, given a defined Random Engine.
inline void flatArray(CLHEP::HepRandomEngine* theNewEngine,
const G4int size, G4double* vect);
// Fills "vect" array of flat random values, given the size
// and a defined Random Engine.
virtual G4double operator()();
// To get a flat random number using the operator ().
virtual std::ostream & put ( std::ostream & os ) const;
virtual std::istream & get ( std::istream & is );
// Save and restore to/from streams
// --------------------------------------------------
// Static member functions using the static generator
// --------------------------------------------------
static void setTheSeed(G4long seed, G4int lux=3);
// (Re)Initializes the generator with a seed.
static G4long getTheSeed();
// Gets the current seed of the current generator.
static void setTheSeeds(const G4long* seeds, G4int aux=-1);
// (Re)Initializes the generator with a zero terminated list of seeds.
static const G4long* getTheSeeds();
// Gets the current array of seeds of the current generator.
static void getTheTableSeeds (G4long* seeds, G4int index);
// Gets the array of seeds in the static seedTable at "index" position.
static G4MTHepRandom * getTheGenerator();
// Return the current static generator.
static void setTheEngine (CLHEP::HepRandomEngine* theNewEngine);
// To set the underlying algorithm object.
static CLHEP::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 std::ostream& saveFullState ( std::ostream & os );
// Saves to stream the state of the engine and cached data.
static std::istream& restoreFullState ( std::istream & is );
// Restores from stream the state of the engine and cached data.
static std::ostream& saveDistState ( std::ostream & os ) {return os;}
// Saves to stream the state of the cached data.
static std::istream& restoreDistState ( std::istream & is ) {return is;}
// Restores from stream the state of the cached data.
static std::ostream& saveStaticRandomStates ( std::ostream & os );
// Saves to stream the engine and cached data for all distributions.
static std::istream& restoreStaticRandomStates ( std::istream & is );
// Restores from stream the engine and cached data for all distributions.
static void showEngineStatus();
// Dumps the current engine status on screen.
static G4int createInstance();
// used to initialise HepRandom::isActive and instantiate singleton
static G4int createInstanceOnce();
// used to initialise HepRandom::isActive and instantiate singleton
private: // -------- Data members ---------
static G4ThreadLocal CLHEP::HepRandomEngine * theEngine;
// The corresponding algorithm.
static G4ThreadLocal G4MTHepRandom * theGenerator;
// The common shared static generator
static G4ThreadLocal G4int isActive;
// Flag notifying singleton instance
G4bool deleteEngine;
// True if the engine should be deleted on destruction.
};
std::ostream & operator<< (std::ostream & os, const G4MTHepRandom & dist);
std::istream & operator>> (std::istream & is, G4MTHepRandom & dist);
#include "G4MTHepRandom.icc"
#endif
@@ -1,39 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4double G4MTHepRandom::flat(CLHEP::HepRandomEngine* theNewEngine)
{
return theNewEngine->flat();
}
inline void G4MTHepRandom::flatArray(CLHEP::HepRandomEngine* theNewEngine,
const G4int size, G4double* vect)
{
theNewEngine->flatArray(size,vect);
}
@@ -1,79 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandBit
//
// Modified version with MT extensions
// of corresponding CLHEP class RandBit
// --------------------------------------------------------------------
#ifndef G4MTRandBit_h
#define G4MTRandBit_h 1
#include "G4MTRandFlat.hh"
class G4MTRandBit : public G4MTRandFlat
{
public:
inline G4MTRandBit ( CLHEP::HepRandomEngine& anEngine );
inline G4MTRandBit ( CLHEP::HepRandomEngine& anEngine, G4double width );
inline G4MTRandBit ( CLHEP::HepRandomEngine& anEngine, G4double a, G4double b );
inline G4MTRandBit ( CLHEP::HepRandomEngine* anEngine );
inline G4MTRandBit ( CLHEP::HepRandomEngine* anEngine, G4double width );
inline G4MTRandBit ( CLHEP::HepRandomEngine* anEngine, G4double a, G4double b );
// These constructors should be used to instantiate a G4MTRandBit
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandBit destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandBit destructor.
virtual ~G4MTRandBit();
// Destructor
// Other than the Bit routines, constructors, and destructor, everything is
// simply inherited from RandFlat.
static G4int shootBit();
static G4int shootBit( CLHEP::HepRandomEngine* );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
inline G4int fireBit();
};
#include "G4MTRandBit.icc"
#endif
@@ -1,67 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine & anEngine)
: G4MTRandFlat (anEngine)
{}
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine & anEngine, G4double width )
: G4MTRandFlat (anEngine, width)
{}
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine & anEngine, G4double a, G4double b )
: G4MTRandFlat (anEngine, a, b)
{}
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine * anEngine)
: G4MTRandFlat (anEngine)
{}
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine * anEngine, G4double width )
: G4MTRandFlat (anEngine, width)
{}
inline G4MTRandBit::
G4MTRandBit(CLHEP::HepRandomEngine * anEngine, G4double a, G4double b )
: G4MTRandFlat (anEngine, a, b)
{}
//---------------------
inline G4int G4MTRandBit::fireBit()
{
G4double x = fire(0,1);
G4int retval = 0;
if (x > .5) { retval = 1; }
return retval;
}
@@ -1,101 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandExponential
//
// Modified version with MT extensions
// of corresponding CLHEP class RandExponential
// --------------------------------------------------------------------
#ifndef G4MTRandExponential_h
#define G4MTRandExponential_h 1
#include "G4MTHepRandom.hh"
class G4MTRandExponential : public G4MTHepRandom
{
public:
inline G4MTRandExponential ( CLHEP::HepRandomEngine& anEngine, G4double mean=1.0 );
inline G4MTRandExponential ( CLHEP::HepRandomEngine* anEngine, G4double mean=1.0 );
// These constructors should be used to instantiate a G4MTRandExponential
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandExponential destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandExponential destructor.
virtual ~G4MTRandExponential();
// Destructor
// Static methods to shoot random values using the static generator
static G4double shoot();
static G4double shoot( G4double mean );
static void shootArray ( const G4int size, G4double* vect,
G4double mean=1.0 );
// Static methods to shoot random values using a given engine
// by-passing the static generator.
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine );
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine, G4double mean );
static void shootArray ( CLHEP::HepRandomEngine* anEngine, const G4int size,
G4double* vect, G4double mean=1.0 );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
inline G4double fire();
inline G4double fire( G4double mean );
void fireArray ( const G4int size, G4double* vect );
void fireArray ( const G4int size, G4double* vect, G4double mean );
G4double operator()();
G4double operator()( G4double mean );
private:
CLHEP::HepRandomEngine* localEngine;
G4bool deleteEngine;
G4double defaultMean;
};
#include "G4MTRandExponential.icc"
#endif
@@ -1,62 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
#include <cmath> // for log()
inline G4MTRandExponential::
G4MTRandExponential(CLHEP::HepRandomEngine & anEngine, G4double mean )
: localEngine(&anEngine), deleteEngine(false), defaultMean(mean) {}
inline G4MTRandExponential::
G4MTRandExponential(CLHEP::HepRandomEngine * anEngine, G4double mean )
: localEngine(anEngine), deleteEngine(true), defaultMean(mean) {}
//-------------
inline G4double G4MTRandExponential::shoot(CLHEP::HepRandomEngine* anEngine)
{
return -std::log(anEngine->flat());
}
inline G4double G4MTRandExponential::shoot(CLHEP::HepRandomEngine* anEngine,
G4double mean)
{
return -std::log(anEngine->flat())*mean;
}
//-------------
inline G4double G4MTRandExponential::fire()
{
return -std::log(localEngine->flat())*defaultMean;
}
inline G4double G4MTRandExponential::fire(G4double mean)
{
return -std::log(localEngine->flat())*mean;
}
@@ -1,166 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandFlat
//
// Modified version with MT extensions
// of corresponding CLHEP class RandFlat
// --------------------------------------------------------------------
#ifndef G4MTRandFlat_hh
#define G4MTRandFlat_hh 1
#include "G4MTHepRandom.hh"
class G4MTRandFlat : public G4MTHepRandom
{
public:
inline G4MTRandFlat ( CLHEP::HepRandomEngine& anEngine );
inline G4MTRandFlat ( CLHEP::HepRandomEngine& anEngine, G4double width );
inline G4MTRandFlat ( CLHEP::HepRandomEngine& anEngine, G4double a, G4double b );
inline G4MTRandFlat ( CLHEP::HepRandomEngine* anEngine );
inline G4MTRandFlat ( CLHEP::HepRandomEngine* anEngine, G4double width );
inline G4MTRandFlat ( CLHEP::HepRandomEngine* anEngine, G4double a, G4double b );
// These constructors should be used to instantiate a RandFlat
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the RandFlat destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the RandFlat destructor.
virtual ~G4MTRandFlat();
// Destructor
// Static methods to shoot random values using the static generator
static G4double shoot();
static inline G4double shoot( G4double width );
static inline G4double shoot( G4double a, G4double b );
static inline G4long shootInt( G4long n );
static inline G4long shootInt( G4long m, G4long n );
static inline G4int shootBit();
static void shootArray ( const G4int size, G4double* vect );
static void shootArray ( const G4int size, G4double* vect,
G4double lx, G4double dx );
// Static methods to shoot random values using a given engine
// by-passing the static generator.
static inline G4double shoot ( CLHEP::HepRandomEngine* anEngine );
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine, G4double width );
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine,
G4double a, G4double b );
static inline G4long shootInt( CLHEP::HepRandomEngine* anEngine, G4long n );
static inline G4long shootInt( CLHEP::HepRandomEngine* anEngine, G4long m, G4long n );
static inline G4int shootBit( CLHEP::HepRandomEngine* );
static inline void shootArray ( CLHEP::HepRandomEngine* anEngine,
const G4int size, G4double* vect );
static void shootArray ( CLHEP::HepRandomEngine* anEngine,
const G4int size, G4double* vect,
G4double lx, G4double dx );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
inline G4double fire();
inline G4double fire( G4double width );
inline G4double fire( G4double a, G4double b );
inline G4long fireInt( G4long n );
inline G4long fireInt( G4long m, G4long n );
inline G4int fireBit();
void fireArray (const G4int size, G4double* vect);
void fireArray (const G4int size, G4double* vect,
G4double lx, G4double dx);
G4double operator()();
G4double operator()( G4double width );
G4double operator()( G4double a, G4double b );
private:
// ShootBits generates an integer random number,
// which is used by fireBit().
// The number is stored in randomInt and firstUnusedBit
inline void fireBits();
static inline void shootBits();
static inline void shootBits(CLHEP::HepRandomEngine*);
// In MSB, the most significant bit of the integer random number
// generated by ShootBits() is set.
// Note:
// the number of significant bits must be chosen so that
// - an unsigned long can hold it
// - and it should be less than the number of bits returned
// by Shoot() which are not affected by precision problems
// on _each_ architecture.
// (Aim: the random generators should be machine-independent).
static const unsigned long MSB;
static const G4int MSBBits;
// These two are set up in RandFlat.cc and need not be saved/restored
unsigned long randomInt;
unsigned long firstUnusedBit;
static G4ThreadLocal unsigned long staticRandomInt;
static G4ThreadLocal unsigned long staticFirstUnusedBit;
CLHEP::HepRandomEngine* localEngine;
G4bool deleteEngine;
G4double defaultA;
G4double defaultB;
};
#include "G4MTRandFlat.icc"
#endif
@@ -1,190 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine & anEngine)
: firstUnusedBit(0), localEngine(&anEngine), deleteEngine(false),
defaultA(0.0), defaultB(1.0) {}
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine & anEngine, G4double width )
: firstUnusedBit(0), localEngine(&anEngine), deleteEngine(false),
defaultA(0.0), defaultB(width) {}
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine & anEngine, G4double a, G4double b )
: firstUnusedBit(0), localEngine(&anEngine), deleteEngine(false),
defaultA(a), defaultB(b) {}
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine * anEngine)
: firstUnusedBit(0), localEngine(anEngine), deleteEngine(true),
defaultA(0.0), defaultB(1.0) {}
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine * anEngine, G4double width )
: firstUnusedBit(0), localEngine(anEngine), deleteEngine(true),
defaultA(0.0), defaultB(width) {}
inline G4MTRandFlat::
G4MTRandFlat(CLHEP::HepRandomEngine * anEngine, G4double a, G4double b )
: firstUnusedBit(0), localEngine(anEngine), deleteEngine(true),
defaultA(a), defaultB(b) {}
inline G4double G4MTRandFlat::shoot(G4double a, G4double b)
{
return (b-a)* shoot() + a;
}
inline G4double G4MTRandFlat::shoot(G4double width)
{
return width * shoot();
}
inline G4long G4MTRandFlat::shootInt(G4long n)
{
return G4long(shoot()*G4double(n));
}
inline G4long G4MTRandFlat::shootInt(G4long mLong, G4long nLong)
{
return G4long(shoot()*G4double(nLong-mLong)) + mLong;
}
inline void G4MTRandFlat::shootBits()
{
const G4double factor= 2.0*MSB; // this should fit into a double!
staticFirstUnusedBit= MSB;
staticRandomInt= (unsigned long)(factor*shoot());
}
inline G4int G4MTRandFlat::shootBit()
{
if (staticFirstUnusedBit==0)
shootBits();
unsigned long temp= staticFirstUnusedBit&staticRandomInt;
staticFirstUnusedBit>>= 1;
return temp!=0;
}
//---------------------
inline G4double G4MTRandFlat::shoot(CLHEP::HepRandomEngine* anEngine)
{
return anEngine->flat();
}
inline G4double G4MTRandFlat::shoot(CLHEP::HepRandomEngine* anEngine,
G4double a, G4double b)
{
return (b-a)* anEngine->flat() + a;
}
inline G4double G4MTRandFlat::shoot(CLHEP::HepRandomEngine* anEngine,
G4double width)
{
return width * anEngine->flat();
}
inline G4long G4MTRandFlat::shootInt(CLHEP::HepRandomEngine* anEngine,
G4long n)
{
return G4long(anEngine->flat()*G4double(n));
}
inline G4long G4MTRandFlat::shootInt(CLHEP::HepRandomEngine* anEngine,
G4long mparam, G4long n)
{
return G4long(G4double(n-mparam)*anEngine->flat()) + mparam;
}
inline void G4MTRandFlat::shootArray(CLHEP::HepRandomEngine* anEngine,
const G4int size, G4double* vect)
{
anEngine->flatArray(size,vect);
}
inline void G4MTRandFlat::shootBits(CLHEP::HepRandomEngine* engine)
{
const G4double factor= 2.0*MSB; // this should fit into a double!
staticFirstUnusedBit= MSB;
staticRandomInt= (unsigned long)(factor*shoot(engine));
}
inline G4int G4MTRandFlat::shootBit(CLHEP::HepRandomEngine* engine)
{
if (staticFirstUnusedBit==0)
shootBits(engine);
unsigned long temp= staticFirstUnusedBit&staticRandomInt;
staticFirstUnusedBit>>= 1;
return temp!=0;
}
//---------------------
inline G4double G4MTRandFlat::fire()
{
return (defaultB-defaultA)*localEngine->flat()+defaultA;
}
inline G4double G4MTRandFlat::fire(G4double a, G4double b)
{
return (b-a)* localEngine->flat() + a;
}
inline G4double G4MTRandFlat::fire(G4double width)
{
return width * localEngine->flat();
}
inline G4long G4MTRandFlat::fireInt(G4long n)
{
return G4long(localEngine->flat()*G4double(n));
}
inline G4long G4MTRandFlat::fireInt(G4long mparam, G4long n)
{
return G4long(localEngine->flat()*G4double(n-mparam)) + mparam;
}
inline void G4MTRandFlat::fireBits()
{
const G4double factor= 2.0*MSB; // this should fit into a double!
firstUnusedBit= MSB;
randomInt= (unsigned long)(factor*localEngine->flat());
}
inline G4int G4MTRandFlat::fireBit()
{
if (firstUnusedBit==0)
fireBits();
unsigned long temp= firstUnusedBit&randomInt;
firstUnusedBit>>= 1;
return temp!=0;
}
@@ -1,109 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandGamma
//
// Modified version with MT extensions
// of corresponding CLHEP class RandGamma
// --------------------------------------------------------------------
#ifndef G4MTRandGamma_h
#define G4MTRandGamma_h 1
#include "G4MTHepRandom.hh"
class G4MTRandGamma : public G4MTHepRandom
{
public:
inline G4MTRandGamma ( CLHEP::HepRandomEngine& anEngine, G4double k=1.0,
G4double lambda=1.0 );
inline G4MTRandGamma ( CLHEP::HepRandomEngine* anEngine, G4double k=1.0,
G4double lambda=1.0 );
// These constructors should be used to instantiate a G4MTRandGamma
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandGamma destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandGamma destructor.
virtual ~G4MTRandGamma();
// Destructor
// Static methods to shoot random values using the static generator
static inline G4double shoot();
static G4double shoot( G4double k, G4double lambda );
static void shootArray ( const G4int size, G4double* vect,
G4double k=1.0, G4double lambda=1.0 );
// Static methods to shoot random values using a given engine
// by-passing the static generator.
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine );
static G4double shoot( CLHEP::HepRandomEngine* anEngine,
G4double k, G4double lambda );
static void shootArray ( CLHEP::HepRandomEngine* anEngine, const G4int size,
G4double* vect, G4double k=1.0,
G4double lambda=1.0 );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
inline G4double fire();
G4double fire( G4double k, G4double lambda );
void fireArray ( const G4int size, G4double* vect);
void fireArray ( const G4int size, G4double* vect,
G4double k, G4double lambda );
inline G4double operator()();
inline G4double operator()( G4double k, G4double lambda );
private:
static G4double genGamma( CLHEP::HepRandomEngine *anEngine, G4double k,
G4double lambda );
CLHEP::HepRandomEngine* localEngine;
G4bool deleteEngine;
G4double defaultK;
G4double defaultLambda;
};
#include "G4MTRandGamma.icc"
#endif
@@ -1,57 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4MTRandGamma::G4MTRandGamma(CLHEP::HepRandomEngine & anEngine, G4double k,
G4double lambda )
: localEngine(&anEngine), deleteEngine(false),
defaultK(k), defaultLambda(lambda) {}
inline G4MTRandGamma::G4MTRandGamma(CLHEP::HepRandomEngine * anEngine, G4double k,
G4double lambda )
: localEngine(anEngine), deleteEngine(true),
defaultK(k), defaultLambda(lambda) {}
inline G4double G4MTRandGamma::shoot() {
return shoot( 1.0, 1.0 );
}
inline G4double G4MTRandGamma::shoot( CLHEP::HepRandomEngine* anEngine ) {
return shoot( anEngine, 1.0, 1.0 );
}
inline G4double G4MTRandGamma::operator()() {
return fire( defaultK, defaultLambda );
}
inline G4double G4MTRandGamma::operator()( G4double k, G4double lambda ) {
return fire( k, lambda );
}
inline G4double G4MTRandGamma::fire() {
return fire( defaultK, defaultLambda );
}
@@ -1,135 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandGauss
//
// Modified version with MT extensions
// of corresponding CLHEP class RandGauss
// --------------------------------------------------------------------
#ifndef G4MTRandGauss_h
#define G4MTRandGauss_h 1
#include "G4MTHepRandom.hh"
class G4MTRandGauss : public G4MTHepRandom
{
public:
inline G4MTRandGauss ( CLHEP::HepRandomEngine& anEngine, G4double mean=0.0,
G4double stdDev=1.0 );
inline G4MTRandGauss ( CLHEP::HepRandomEngine* anEngine, G4double mean=0.0,
G4double stdDev=1.0 );
// These constructors should be used to instantiate a G4MTRandGauss
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandGauss destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandGauss destructor.
virtual ~G4MTRandGauss();
// Destructor
// Static methods to shoot random values using the static generator
static G4double shoot();
static inline G4double shoot( G4double mean, G4double stdDev );
static void shootArray ( const G4int size, G4double* vect,
G4double mean=0.0, G4double stdDev=1.0 );
// Static methods to shoot random values using a given engine
// by-passing the static generator.
static G4double shoot( CLHEP::HepRandomEngine* anEngine );
static inline G4double shoot( CLHEP::HepRandomEngine* anEngine,
G4double mean, G4double stdDev );
static void shootArray ( CLHEP::HepRandomEngine* anEngine, const G4int size,
G4double* vect, G4double mean=0.0,
G4double stdDev=1.0 );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
G4double fire();
inline G4double fire( G4double mean, G4double stdDev );
void fireArray ( const G4int size, G4double* vect);
void fireArray ( const G4int size, G4double* vect,
G4double mean, G4double stdDev );
virtual G4double operator()();
virtual G4double operator()( G4double mean, G4double stdDev );
// values.
static G4bool getFlag() {return set_st;}
static void setFlag( G4bool val ) {set_st = val;}
G4bool getF() const {return set;}
void setF( G4bool val ) {set = val;}
// Methods overriding the base class static saveEngineStatus ones,
// by adding extra data so that save in one program, then further gaussians,
// will produce the identical sequence to restore in another program, then
// generating gaussian randoms there
static G4double getVal() {return nextGauss_st;}
static void setVal( G4double nextVal ) {nextGauss_st = nextVal;}
G4double normal();
G4double defaultMean;
G4double defaultStdDev;
CLHEP::HepRandomEngine* localEngine;
private:
G4bool deleteEngine, set;
G4double nextGauss;
// static data
static G4ThreadLocal G4bool set_st;
static G4ThreadLocal G4double nextGauss_st;
};
#include "G4MTRandGauss.icc"
#endif
@@ -1,62 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4MTRandGauss::
G4MTRandGauss(CLHEP::HepRandomEngine& anEngine, G4double mean, G4double stdDev )
: defaultMean(mean), defaultStdDev(stdDev),
localEngine(&anEngine), deleteEngine(false), set(false), nextGauss(0.0)
{
}
inline G4MTRandGauss::
G4MTRandGauss(CLHEP::HepRandomEngine* anEngine, G4double mean, G4double stdDev )
: defaultMean(mean), defaultStdDev(stdDev),
localEngine(anEngine), deleteEngine(true), set(false), nextGauss(0.0)
{
}
inline G4double G4MTRandGauss::shoot(G4double mean, G4double stdDev)
{
return shoot()*stdDev + mean;
}
inline G4double G4MTRandGauss::shoot(CLHEP::HepRandomEngine* anEngine,
G4double mean, G4double stdDev)
{
return shoot(anEngine)*stdDev + mean;
}
inline G4double G4MTRandGauss::fire()
{
return normal()*defaultStdDev + defaultMean;
}
inline G4double G4MTRandGauss::fire(G4double mean, G4double stdDev)
{
return normal()*stdDev + mean;
}
@@ -1,122 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandGaussQ
//
// Modified version with MT extensions
// of corresponding CLHEP class RandGaussQ
// --------------------------------------------------------------------
#ifndef G4MTRandGaussQ_h
#define G4MTRandGaussQ_h 1
#include "G4MTRandGauss.hh"
class G4MTRandGaussQ : public G4MTRandGauss
{
public:
inline G4MTRandGaussQ ( CLHEP::HepRandomEngine& anEngine, G4double mean=0.0,
G4double stdDev=1.0 );
inline G4MTRandGaussQ ( CLHEP::HepRandomEngine* anEngine, G4double mean=0.0,
G4double stdDev=1.0 );
// These constructors should be used to instantiate a G4MTRandGaussQ
// distribution object defining a local engine for it.
// The static generator will be skipped using the non-static methods
// defined below.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandGaussQ destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandGaussQ destructor.
// Destructor
virtual ~G4MTRandGaussQ();
//
// Methods to generate Gaussian-distributed random deviates:
//
// If a fast good engine takes 1 usec, G4MTRandGauss::fire()
// adds 1 usec while G4MTRandGaussQ::fire() adds only .4 usec.
//
// Static methods to shoot random values using the static generator
static inline G4double shoot();
static inline G4double shoot( G4double mean, G4double stdDev );
static void shootArray ( const G4int size, G4double* vect,
G4double mean=0.0, G4double stdDev=1.0 );
// Static methods to shoot random values using a given engine
// by-passing the static generator.
static inline G4double shoot( CLHEP::HepRandomEngine* anotherEngine );
static inline G4double shoot( CLHEP::HepRandomEngine* anotherEngine,
G4double mean, G4double stdDev );
static void shootArray ( CLHEP::HepRandomEngine* anotherEngine,
const G4int size,
G4double* vect, G4double mean=0.0,
G4double stdDev=1.0 );
// Instance methods using the localEngine to instead of the static
// generator, and the default mean and stdDev established at construction
inline G4double fire();
inline G4double fire ( G4double mean, G4double stdDev );
void fireArray ( const G4int size, G4double* vect);
void fireArray ( const G4int size, G4double* vect,
G4double mean, G4double stdDev );
virtual G4double operator()();
virtual G4double operator()( G4double mean, G4double stdDev );
protected:
static G4double transformQuick (G4double r);
static G4double transformSmall (G4double r);
private:
// Private copy constructor. Defining it here disallows use.
G4MTRandGaussQ(const G4MTRandGaussQ& d);
// All the engine info, and the default mean and sigma,
// are in the G4MTRandGauss base class.
};
#include "G4MTRandGaussQ.icc"
#endif
@@ -1,79 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
G4MTRandGaussQ::
G4MTRandGaussQ(CLHEP::HepRandomEngine & anEngine, G4double mean,
G4double stdDev )
: G4MTRandGauss(anEngine, mean, stdDev)
{
}
G4MTRandGaussQ::
G4MTRandGaussQ(CLHEP::HepRandomEngine * anEngine, G4double mean,
G4double stdDev )
: G4MTRandGauss(anEngine, mean, stdDev)
{
}
// Getting a Gaussian deviate - static methods
// -------------------------------------------
G4double G4MTRandGaussQ::shoot()
{
CLHEP::HepRandomEngine* anEngine = G4MTHepRandom::getTheEngine();
return transformQuick (anEngine->flat());
}
G4double G4MTRandGaussQ::shoot( CLHEP::HepRandomEngine* anotherEngine )
{
return transformQuick (anotherEngine->flat());
}
G4double G4MTRandGaussQ::shoot(G4double mean, G4double stdDev)
{
return shoot()*stdDev + mean;
}
G4double G4MTRandGaussQ::shoot(CLHEP::HepRandomEngine* anotherEngine,
G4double mean, G4double stdDev)
{
return shoot(anotherEngine)*stdDev + mean;
}
// Getting a Gaussian deviate - instance methods
// ---------------------------------------------
G4double G4MTRandGaussQ::fire()
{
return transformQuick(localEngine->flat()) * defaultStdDev + defaultMean;
}
G4double G4MTRandGaussQ::fire(G4double mean, G4double stdDev)
{
return transformQuick(localEngine->flat()) * stdDev + mean;
}
@@ -1,127 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
// Class G4MTRandGeneral
//
// Modified version with MT extensions
// of corresponding CLHEP class RandGeneral
// --------------------------------------------------------------------
#ifndef G4MTRandGeneral_h
#define G4MTRandGeneral_h 1
#include <vector>
#include "G4MTHepRandom.hh"
class G4MTRandGeneral : public G4MTHepRandom
{
public:
G4MTRandGeneral ( const G4double* aProbFunc,
G4int theProbSize,
G4int IntType=0 );
G4MTRandGeneral ( CLHEP::HepRandomEngine& anEngine,
const G4double* aProbFunc,
G4int theProbSize,
G4int IntType=0 );
G4MTRandGeneral ( CLHEP::HepRandomEngine* anEngine,
const G4double* aProbFunc,
G4int theProbSize,
G4int IntType=0 );
// These constructors should be used to instantiate a G4MTRandGeneral
// distribution object defining a local engine for it.
// The static generator will be skiped by using the non-static methods
// defined below. In case no engine is specified in the constructor, the
// default engine used by the static generator is applied.
// If the engine is passed by pointer the corresponding engine object
// will be deleted by the G4MTRandGeneral destructor.
// If the engine is passed by reference the corresponding engine object
// will not be deleted by the G4MTRandGeneral destructor.
// The probability distribution function (Pdf) must be provided by the user
// as an array of positive real number. The array size must also be
// provided. The Pdf doesn't need to be normalized to 1.
// if IntType = 0 ( default value ) a uniform random number is
// generated using the engine. The uniform number is then transformed
// to the user's distribution using the cumulative probability
// distribution constructed from his histogram. The cumulative
// distribution is inverted using a binary search for the nearest
// bin boundary and a linear interpolation within the
// bin. G4MTRandGeneral therefore generates a constant density within
// each bin.
// if IntType = 1 no interpolation is performed and the result is a
// discrete distribution.
virtual ~G4MTRandGeneral();
// Destructor
// Methods to shoot random values using the static generator
// N.B.: The methods are NOT static since they use nonstatic members
// theIntegralPdf & nBins
inline G4double shoot();
inline void shootArray ( const G4int size, G4double* vect);
// Methods to shoot random values using a given engine
// by-passing the static generator.
G4double shoot( CLHEP::HepRandomEngine* anEngine );
void shootArray ( CLHEP::HepRandomEngine* anEngine, const G4int size,
G4double* vect );
// Methods using the localEngine to shoot random values, by-passing
// the static generator.
G4double fire();
void fireArray ( const G4int size, G4double* vect);
G4double operator()();
private:
CLHEP::HepRandomEngine* localEngine;
G4bool deleteEngine;
std::vector<G4double> theIntegralPdf;
G4int nBins;
G4double oneOverNbins;
G4int InterpolationType;
// Private methods to factor out replicated implementation sections
void prepareTable(const G4double* aProbFunc);
void useFlatDistribution();
G4double mapRandom(G4double rand) const;
};
#include "G4MTRandGeneral.icc"
#endif
@@ -1,54 +0,0 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
inline G4double G4MTRandGeneral::fire()
{
G4double rand = localEngine->flat();
return mapRandom(rand);
}
inline G4double G4MTRandGeneral::shoot()
{
return fire();
}
inline G4double G4MTRandGeneral::operator() ()
{
return fire();
}
inline G4double G4MTRandGeneral::shoot( CLHEP::HepRandomEngine* anEngine )
{
G4double rand = anEngine->flat();
return mapRandom(rand);
}
inline void G4MTRandGeneral::shootArray( const G4int size, G4double* vect )
{
fireArray(size, vect);
}
@@ -32,8 +32,10 @@
// ------------------------------------------------------------
// Class description:
//
//
// Class implementing a pool of random numbers filled according
// to specified fixed size (default 1024).
// Author: A.Dotti (SLAC)
// ------------------------------------------------------------
#ifndef G4UNIFORMRANDPOOL_HH
#define G4UNIFORMRANDPOOL_HH
@@ -72,7 +74,7 @@ class G4UniformRandPool
private:
inline void Fill( G4int howmany );
void Fill( G4int howmany );
private:
@@ -98,14 +100,4 @@ inline /*PoolSize_t*/ G4int G4UniformRandPool::GetPoolSize() const
return size;
}
inline void G4UniformRandPool::Fill( G4int howmany )
{
assert(howmany>0 && howmany <= size);
// Fill buffer with random numbers
//
G4Random::getTheEngine()->flatArray(howmany,buffer);
currentIdx = 0;
}
#endif
+1 -46
View File
@@ -24,57 +24,13 @@
// ********************************************************************
//
//
// $Id: Randomize.hh 96593 2016-04-25 10:12:49Z gcosmo $
// $Id: Randomize.hh 108829 2018-03-09 12:44:00Z gcosmo $
//
#ifndef randomize_h
#define randomize_h 1
#include <CLHEP/Random/Randomize.h>
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
#if (defined(G4MULTITHREADED) && \
(!defined(G4USE_STD11) || (defined(CLANG_NOSTDTLS) || defined(__INTEL_COMPILER))))
// MT needs special Random Number distribution classes
//
#include "G4MTHepRandom.hh"
#include "G4MTRandBit.hh"
#include "G4MTRandExponential.hh"
#include "G4MTRandFlat.hh"
#include "G4MTRandGamma.hh"
#include "G4MTRandGauss.hh"
#include "G4MTRandGaussQ.hh"
#include "G4MTRandGeneral.hh"
// NOTE: G4RandStat MT-version is missing, but actually currently
// never used in the G4 source
//
#define G4RandFlat G4MTRandFlat
#define G4RandBit G4MTRandBit
#define G4RandGamma G4MTRandGamma
#define G4RandGauss G4MTRandGaussQ
#define G4RandExponential G4MTRandExponential
#define G4RandGeneral G4MTRandGeneral
#define G4Random G4MTHepRandom
#define G4UniformRand() G4MTHepRandom::getTheEngine()->flat()
//
//#include "G4UniformRandPool.hh"
//#define G4UniformRand() G4UniformRandPool::flat()
// Currently not be used in G4 source
//
#define G4RandFlatArray G4MTRandFlat::shootArray
#define G4RandFlatInt G4MTRandFlat::shootInt
#define G4RandGeneralTmp G4MTRandGeneral
#else // Sequential mode or supporting C++11 standard
// Distributions used ...
//
#include <CLHEP/Random/RandFlat.h>
@@ -96,5 +52,4 @@
#define G4UniformRand() CLHEP::HepRandom::getTheEngine()->flat()
#endif // G4MULTITHREADED
#endif // randomize_h