Import Geant4 10.0.0 source tree
This commit is contained in:
+39
-3
@@ -42,6 +42,9 @@ add_definitions(-DCLHEP_EXPORT)
|
||||
# - Headers
|
||||
set(G4clhep_HEADERS
|
||||
include/CLHEP/Evaluator/Evaluator.h
|
||||
include/CLHEP/Evaluator/hash_map.icc
|
||||
include/CLHEP/Evaluator/stack.icc
|
||||
include/CLHEP/Evaluator/string.icc
|
||||
include/CLHEP/Geometry/BasicVector3D.h
|
||||
include/CLHEP/Geometry/Normal3D.h
|
||||
include/CLHEP/Geometry/Plane3D.h
|
||||
@@ -56,22 +59,37 @@ set(G4clhep_HEADERS
|
||||
include/CLHEP/Random/MTwistEngine.h
|
||||
include/CLHEP/Random/NonRandomEngine.h
|
||||
include/CLHEP/Random/RandBinomial.h
|
||||
include/CLHEP/Random/RandBinomial.icc
|
||||
include/CLHEP/Random/RandBit.h
|
||||
include/CLHEP/Random/RandBreitWigner.h
|
||||
include/CLHEP/Random/RandBreitWigner.icc
|
||||
include/CLHEP/Random/RandChiSquare.h
|
||||
include/CLHEP/Random/RandChiSquare.icc
|
||||
include/CLHEP/Random/RandExponential.h
|
||||
include/CLHEP/Random/RandExponential.icc
|
||||
include/CLHEP/Random/RandFlat.h
|
||||
include/CLHEP/Random/RandFlat.icc
|
||||
include/CLHEP/Random/RandGamma.h
|
||||
include/CLHEP/Random/RandGamma.icc
|
||||
include/CLHEP/Random/RandGauss.h
|
||||
include/CLHEP/Random/RandGauss.icc
|
||||
include/CLHEP/Random/RandGaussQ.h
|
||||
include/CLHEP/Random/RandGaussQ.icc
|
||||
include/CLHEP/Random/RandGeneral.h
|
||||
include/CLHEP/Random/RandGeneral.icc
|
||||
include/CLHEP/Random/RandLandau.h
|
||||
include/CLHEP/Random/RandomEngine.h
|
||||
include/CLHEP/Random/Random.h
|
||||
include/CLHEP/Random/Randomize.h
|
||||
include/CLHEP/Random/RandLandau.icc
|
||||
include/CLHEP/Random/RandPoisson.h
|
||||
include/CLHEP/Random/RandPoisson.icc
|
||||
include/CLHEP/Random/RandPoissonQ.h
|
||||
include/CLHEP/Random/RandPoissonQ.icc
|
||||
include/CLHEP/Random/RandStudentT.h
|
||||
include/CLHEP/Random/RandStudentT.icc
|
||||
include/CLHEP/Random/Random.h
|
||||
include/CLHEP/Random/Random.icc
|
||||
include/CLHEP/Random/RandomEngine.h
|
||||
include/CLHEP/Random/RandomEngine.icc
|
||||
include/CLHEP/Random/Randomize.h
|
||||
include/CLHEP/Random/RanecuEngine.h
|
||||
include/CLHEP/Random/Ranlux64Engine.h
|
||||
include/CLHEP/Random/RanluxEngine.h
|
||||
@@ -79,6 +97,9 @@ set(G4clhep_HEADERS
|
||||
include/CLHEP/Random/SeedTable.h
|
||||
include/CLHEP/Random/Stat.h
|
||||
include/CLHEP/Random/StaticRandomStates.h
|
||||
include/CLHEP/Random/gaussQTables.cdat
|
||||
include/CLHEP/Random/gaussTables.cdat
|
||||
include/CLHEP/Random/poissonTables.cdat
|
||||
include/CLHEP/Units/PhysicalConstants.h
|
||||
include/CLHEP/Units/SystemOfUnits.h
|
||||
include/CLHEP/Utility/defs.h
|
||||
@@ -87,20 +108,35 @@ set(G4clhep_HEADERS
|
||||
include/CLHEP/Utility/noncopyable.h
|
||||
include/CLHEP/Utility/type_traits.h
|
||||
include/CLHEP/Vector/AxisAngle.h
|
||||
include/CLHEP/Vector/AxisAngle.icc
|
||||
include/CLHEP/Vector/Boost.h
|
||||
include/CLHEP/Vector/Boost.icc
|
||||
include/CLHEP/Vector/BoostX.h
|
||||
include/CLHEP/Vector/BoostX.icc
|
||||
include/CLHEP/Vector/BoostY.h
|
||||
include/CLHEP/Vector/BoostY.icc
|
||||
include/CLHEP/Vector/BoostZ.h
|
||||
include/CLHEP/Vector/BoostZ.icc
|
||||
include/CLHEP/Vector/EulerAngles.h
|
||||
include/CLHEP/Vector/EulerAngles.icc
|
||||
include/CLHEP/Vector/LorentzRotation.h
|
||||
include/CLHEP/Vector/LorentzRotation.icc
|
||||
include/CLHEP/Vector/LorentzVector.h
|
||||
include/CLHEP/Vector/LorentzVector.icc
|
||||
include/CLHEP/Vector/Rotation.h
|
||||
include/CLHEP/Vector/Rotation.icc
|
||||
include/CLHEP/Vector/RotationInterfaces.h
|
||||
include/CLHEP/Vector/RotationInterfaces.icc
|
||||
include/CLHEP/Vector/RotationX.h
|
||||
include/CLHEP/Vector/RotationX.icc
|
||||
include/CLHEP/Vector/RotationY.h
|
||||
include/CLHEP/Vector/RotationY.icc
|
||||
include/CLHEP/Vector/RotationZ.h
|
||||
include/CLHEP/Vector/RotationZ.icc
|
||||
include/CLHEP/Vector/ThreeVector.h
|
||||
include/CLHEP/Vector/ThreeVector.icc
|
||||
include/CLHEP/Vector/TwoVector.h
|
||||
include/CLHEP/Vector/TwoVector.icc
|
||||
)
|
||||
|
||||
# - Sources
|
||||
|
||||
Vendored
+13
@@ -17,6 +17,19 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
14 November 2013 - G.Cosmo
|
||||
- Updated to CLHEP-2.1.4.1:
|
||||
* Random (L.Garren <garren@fnal.gov>):
|
||||
o Added RandGaussZiggurat and RandExpZiggurat distributions
|
||||
contributed by ATLAS.
|
||||
* Units (L.Garren <garren@fnal.gov>):
|
||||
o Added new units for Radioactivity:
|
||||
kilo/mega/gigabecquerel, milli/microcurie.
|
||||
|
||||
20 August 2013 - G.Cosmo
|
||||
- Corrected CMakeLists.txt script to have missing .icc and .cdat files
|
||||
explicitly listed.
|
||||
|
||||
15 November 2012 - G.Cosmo
|
||||
- Updated to CLHEP-2.1.3.1:
|
||||
* Vector (L.Garren <garren@fnal.gov>):
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
Code adapted from:
|
||||
http://www.jstatsoft.org/v05/i08/
|
||||
|
||||
|
||||
Original disclaimer:
|
||||
|
||||
The ziggurat method for RNOR and REXP
|
||||
Combine the code below with the main program in which you want
|
||||
normal or exponential variates. Then use of RNOR in any expression
|
||||
will provide a standard normal variate with mean zero, variance 1,
|
||||
while use of REXP in any expression will provide an exponential variate
|
||||
with density exp(-x),x>0.
|
||||
Before using RNOR or REXP in your main, insert a command such as
|
||||
zigset(86947731 );
|
||||
with your own choice of seed value>0, rather than 86947731.
|
||||
(If you do not invoke zigset(...) you will get all zeros for RNOR and REXP.)
|
||||
For details of the method, see Marsaglia and Tsang, "The ziggurat method
|
||||
for generating random variables", Journ. Statistical Software.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef RandExpZiggurat_h
|
||||
#define RandExpZiggurat_h 1
|
||||
|
||||
#include "CLHEP/Random/Random.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
/**
|
||||
* @author ATLAS
|
||||
* @ingroup random
|
||||
*/
|
||||
class RandExpZiggurat : public HepRandom {
|
||||
|
||||
public:
|
||||
|
||||
inline RandExpZiggurat ( HepRandomEngine& anEngine, double mean=1.0 );
|
||||
inline RandExpZiggurat ( HepRandomEngine* anEngine, double mean=1.0 );
|
||||
// These constructors should be used to instantiate a RandExpZiggurat
|
||||
// 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 RandExpZiggurat destructor.
|
||||
// If the engine is passed by reference the corresponding engine object
|
||||
// will not be deleted by the RandExpZiggurat destructor.
|
||||
|
||||
virtual ~RandExpZiggurat();
|
||||
// Destructor
|
||||
|
||||
// Static methods to shoot random values using the static generator
|
||||
|
||||
static float shoot() {return shoot(HepRandom::getTheEngine());};
|
||||
static float shoot( float mean ) {return shoot(HepRandom::getTheEngine(),mean);};
|
||||
|
||||
/* ENGINE IS INTRINSIC FLOAT
|
||||
static double shoot() {return shoot(HepRandom::getTheEngine());};
|
||||
static double shoot( double mean ) {return shoot(HepRandom::getTheEngine(),mean);};
|
||||
*/
|
||||
|
||||
static void shootArray ( const int size, float* vect, float mean=1.0 );
|
||||
static void shootArray ( const int size, double* vect, double mean=1.0 );
|
||||
|
||||
// Static methods to shoot random values using a given engine
|
||||
// by-passing the static generator.
|
||||
|
||||
static inline float shoot( HepRandomEngine* anEngine ) {return ziggurat_REXP(anEngine);};
|
||||
static inline float shoot( HepRandomEngine* anEngine, float mean ) {return shoot(anEngine)*mean;};
|
||||
|
||||
/* ENGINE IS INTRINSIC FLOAT
|
||||
static inline double shoot( HepRandomEngine* anEngine ) {return ziggurat_REXP(anEngine);};
|
||||
|
||||
static inline double shoot( HepRandomEngine* anEngine, double mean ) {return shoot(anEngine)*mean;};
|
||||
*/
|
||||
|
||||
static void shootArray ( HepRandomEngine* anEngine, const int size, float* vect, float mean=1.0 );
|
||||
static void shootArray ( HepRandomEngine* anEngine, const int size, double* vect, double mean=1.0 );
|
||||
|
||||
// Methods using the localEngine to shoot random values, by-passing
|
||||
// the static generator.
|
||||
|
||||
inline float fire() {return fire(defaultMean);};
|
||||
inline float fire( float mean ) {return ziggurat_REXP(localEngine)*mean;};
|
||||
|
||||
/* ENGINE IS INTRINSIC FLOAT
|
||||
inline double fire() {return fire(defaultMean);};
|
||||
inline double fire( double mean ) {return ziggurat_REXP(localEngine)*mean;};
|
||||
*/
|
||||
|
||||
void fireArray ( const int size, float* vect );
|
||||
void fireArray ( const int size, double* vect );
|
||||
void fireArray ( const int size, float* vect, float mean );
|
||||
void fireArray ( const int size, double* vect, double mean );
|
||||
|
||||
virtual double operator()();
|
||||
inline float operator()( float mean ) {return fire( mean );};
|
||||
|
||||
// Save and restore to/from streams
|
||||
|
||||
std::ostream & put ( std::ostream & os ) const;
|
||||
std::istream & get ( std::istream & is );
|
||||
|
||||
std::string name() const;
|
||||
HepRandomEngine & engine();
|
||||
|
||||
static std::string distributionName() {return "RandExpZiggurat";}
|
||||
// Provides the name of this distribution class
|
||||
|
||||
static bool ziggurat_init();
|
||||
protected:
|
||||
//////////////////////////
|
||||
// Ziggurat Original code:
|
||||
//////////////////////////
|
||||
//static unsigned long jz,jsr=123456789;
|
||||
//
|
||||
//#define SHR3 (jz=jsr, jsr^=(jsr<<13), jsr^=(jsr>>17), jsr^=(jsr<<5),jz+jsr)
|
||||
//#define UNI (.5 + (signed) SHR3*.2328306e-9)
|
||||
//#define IUNI SHR3
|
||||
//
|
||||
//static long hz;
|
||||
//static unsigned long iz, kn[128], ke[256];
|
||||
//static float wn[128],fn[128], we[256],fe[256];
|
||||
//
|
||||
//#define RNOR (hz=SHR3, iz=hz&127, (fabs(hz)<kn[iz])? hz*wn[iz] : nfix())
|
||||
//#define REXP (jz=SHR3, iz=jz&255, ( jz <ke[iz])? jz*we[iz] : efix())
|
||||
|
||||
static unsigned long kn[128], ke[256];
|
||||
static float wn[128],fn[128], we[256],fe[256];
|
||||
|
||||
static bool ziggurat_is_init;
|
||||
|
||||
static inline unsigned long ziggurat_SHR3(HepRandomEngine* anEngine) {return (unsigned int)(*anEngine);};
|
||||
static inline float ziggurat_UNI(HepRandomEngine* anEngine) {return anEngine->flat();};
|
||||
static inline float ziggurat_REXP(HepRandomEngine* anEngine) {
|
||||
unsigned long jz=ziggurat_SHR3(anEngine);
|
||||
unsigned long iz=jz&255;
|
||||
return (jz<ke[iz]) ? jz*we[iz] : ziggurat_efix(jz,anEngine);
|
||||
};
|
||||
static float ziggurat_efix(unsigned long jz,HepRandomEngine* anEngine);
|
||||
|
||||
private:
|
||||
|
||||
// Private copy constructor. Defining it here disallows use.
|
||||
RandExpZiggurat(const RandExpZiggurat& d);
|
||||
|
||||
HepRandomEngine* localEngine;
|
||||
bool deleteEngine;
|
||||
double defaultMean;
|
||||
};
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
inline RandExpZiggurat::RandExpZiggurat(HepRandomEngine & anEngine, double mean ) : localEngine(&anEngine), deleteEngine(false), defaultMean(mean)
|
||||
{
|
||||
if(!ziggurat_is_init) ziggurat_init();
|
||||
}
|
||||
|
||||
inline RandExpZiggurat::RandExpZiggurat(HepRandomEngine * anEngine, double mean ) : localEngine(anEngine), deleteEngine(true), defaultMean(mean)
|
||||
{
|
||||
if(!ziggurat_is_init) ziggurat_init();
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
Code adapted from:
|
||||
http://www.jstatsoft.org/v05/i08/
|
||||
|
||||
|
||||
Original disclaimer:
|
||||
|
||||
The ziggurat method for RNOR and REXP
|
||||
Combine the code below with the main program in which you want
|
||||
normal or exponential variates. Then use of RNOR in any expression
|
||||
will provide a standard normal variate with mean zero, variance 1,
|
||||
while use of REXP in any expression will provide an exponential variate
|
||||
with density exp(-x),x>0.
|
||||
Before using RNOR or REXP in your main, insert a command such as
|
||||
zigset(86947731 );
|
||||
with your own choice of seed value>0, rather than 86947731.
|
||||
(If you do not invoke zigset(...) you will get all zeros for RNOR and REXP.)
|
||||
For details of the method, see Marsaglia and Tsang, "The ziggurat method
|
||||
for generating random variables", Journ. Statistical Software.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#ifndef RandGaussZiggurat_h
|
||||
#define RandGaussZiggurat_h 1
|
||||
|
||||
#include "cmath"
|
||||
#include "CLHEP/Random/RandGauss.h"
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
/**
|
||||
* @author ATLAS
|
||||
* @ingroup random
|
||||
*/
|
||||
class RandGaussZiggurat : public RandGauss {
|
||||
|
||||
public:
|
||||
|
||||
inline RandGaussZiggurat ( HepRandomEngine& anEngine, double mean=0.0, double stdDev=1.0 );
|
||||
inline RandGaussZiggurat ( HepRandomEngine* anEngine, double mean=0.0, double stdDev=1.0 );
|
||||
|
||||
// Destructor
|
||||
virtual ~RandGaussZiggurat();
|
||||
|
||||
// Static methods to shoot random values using the static generator
|
||||
|
||||
static inline float shoot() {return ziggurat_RNOR(HepRandom::getTheEngine());};
|
||||
static inline float shoot( float mean, float stdDev ) {return shoot()*stdDev + mean;};
|
||||
|
||||
static void shootArray ( const int size, float* vect, float mean=0.0, float stdDev=1.0 );
|
||||
static void shootArray ( const int size, double* vect, double mean=0.0, double stdDev=1.0 );
|
||||
|
||||
// Static methods to shoot random values using a given engine
|
||||
// by-passing the static generator.
|
||||
|
||||
static inline float shoot( HepRandomEngine* anotherEngine ) {return ziggurat_RNOR(anotherEngine);};
|
||||
static inline float shoot( HepRandomEngine* anotherEngine, float mean, float stdDev ) {return shoot(anotherEngine)*stdDev + mean;};
|
||||
|
||||
static void shootArray ( HepRandomEngine* anotherEngine, const int size, float* vect, float mean=0.0, float stdDev=1.0 );
|
||||
static void shootArray ( HepRandomEngine* anotherEngine, const int size, double* vect, double mean=0.0, double stdDev=1.0 );
|
||||
|
||||
// Instance methods using the localEngine to instead of the static
|
||||
// generator, and the default mean and stdDev established at construction
|
||||
|
||||
inline float fire() {return ziggurat_RNOR(localEngine.get()) * defaultStdDev + defaultMean;};
|
||||
|
||||
inline float fire ( float mean, float stdDev ) {return ziggurat_RNOR(localEngine.get()) * stdDev + mean;};
|
||||
|
||||
void fireArray ( const int size, float* vect);
|
||||
void fireArray ( const int size, double* vect);
|
||||
void fireArray ( const int size, float* vect, float mean, float stdDev );
|
||||
void fireArray ( const int size, double* vect, double mean, double stdDev );
|
||||
|
||||
virtual double operator()();
|
||||
virtual double operator()( double mean, double stdDev );
|
||||
|
||||
// Save and restore to/from streams
|
||||
|
||||
std::ostream & put ( std::ostream & os ) const;
|
||||
std::istream & get ( std::istream & is );
|
||||
|
||||
std::string name() const;
|
||||
HepRandomEngine & engine();
|
||||
|
||||
static std::string distributionName() {return "RandGaussZiggurat";}
|
||||
// Provides the name of this distribution class
|
||||
|
||||
static bool ziggurat_init();
|
||||
protected:
|
||||
//////////////////////////
|
||||
// Ziggurat Original code:
|
||||
//////////////////////////
|
||||
//static unsigned long jz,jsr=123456789;
|
||||
//
|
||||
//#define SHR3 (jz=jsr, jsr^=(jsr<<13), jsr^=(jsr>>17), jsr^=(jsr<<5),jz+jsr)
|
||||
//#define UNI (.5 + (signed) SHR3*.2328306e-9)
|
||||
//#define IUNI SHR3
|
||||
//
|
||||
//static long hz;
|
||||
//static unsigned long iz, kn[128], ke[256];
|
||||
//static float wn[128],fn[128], we[256],fe[256];
|
||||
//
|
||||
//#define RNOR (hz=SHR3, iz=hz&127, (fabs(hz)<kn[iz])? hz*wn[iz] : nfix())
|
||||
//#define REXP (jz=SHR3, iz=jz&255, ( jz <ke[iz])? jz*we[iz] : efix())
|
||||
|
||||
static unsigned long kn[128], ke[256];
|
||||
static float wn[128],fn[128], we[256],fe[256];
|
||||
|
||||
static bool ziggurat_is_init;
|
||||
|
||||
static inline unsigned long ziggurat_SHR3(HepRandomEngine* anEngine) {return (unsigned int)(*anEngine);};
|
||||
static inline float ziggurat_UNI(HepRandomEngine* anEngine) {return anEngine->flat();};
|
||||
static inline float ziggurat_RNOR(HepRandomEngine* anEngine) {
|
||||
long hz=(signed)ziggurat_SHR3(anEngine);
|
||||
unsigned long iz=hz&127;
|
||||
return ((unsigned long)abs(hz)<kn[iz]) ? hz*wn[iz] : ziggurat_nfix(hz,anEngine);
|
||||
};
|
||||
static float ziggurat_nfix(long hz,HepRandomEngine* anEngine);
|
||||
|
||||
private:
|
||||
|
||||
// Private copy constructor. Defining it here disallows use.
|
||||
RandGaussZiggurat(const RandGaussZiggurat& d);
|
||||
|
||||
// All the engine info, and the default mean and sigma, are in the RandGauss
|
||||
// base class.
|
||||
|
||||
};
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
RandGaussZiggurat::RandGaussZiggurat(HepRandomEngine & anEngine, double mean,double stdDev ): RandGauss(anEngine, mean, stdDev)
|
||||
{
|
||||
if(!ziggurat_is_init) ziggurat_init();
|
||||
}
|
||||
|
||||
RandGaussZiggurat::RandGaussZiggurat(HepRandomEngine * anEngine, double mean,double stdDev ): RandGauss(anEngine, mean, stdDev)
|
||||
{
|
||||
if(!ziggurat_is_init) ziggurat_init();
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
|
||||
#endif
|
||||
@@ -39,11 +39,13 @@
|
||||
#include "CLHEP/Random/RandBreitWigner.h"
|
||||
#include "CLHEP/Random/RandChiSquare.h"
|
||||
#include "CLHEP/Random/RandExponential.h"
|
||||
#include "CLHEP/Random/RandExpZiggurat.h"
|
||||
#include "CLHEP/Random/RandFlat.h"
|
||||
#include "CLHEP/Random/RandBit.h"
|
||||
#include "CLHEP/Random/RandGamma.h"
|
||||
#include "CLHEP/Random/RandGauss.h"
|
||||
#include "CLHEP/Random/RandGaussQ.h"
|
||||
#include "CLHEP/Random/RandGaussZiggurat.h"
|
||||
#include "CLHEP/Random/RandGeneral.h"
|
||||
#include "CLHEP/Random/RandLandau.h"
|
||||
#include "CLHEP/Random/RandPoissonQ.h"
|
||||
|
||||
@@ -252,6 +252,18 @@ namespace CLHEP {
|
||||
//
|
||||
static const double becquerel = 1./second ;
|
||||
static const double curie = 3.7e+10 * becquerel;
|
||||
static const double kilobecquerel = 1.e+3*becquerel;
|
||||
static const double megabecquerel = 1.e+6*becquerel;
|
||||
static const double gigabecquerel = 1.e+9*becquerel;
|
||||
static const double millicurie = 1.e-3*curie;
|
||||
static const double microcurie = 1.e-6*curie;
|
||||
static const double Bq = becquerel;
|
||||
static const double kBq = kilobecquerel;
|
||||
static const double MBq = megabecquerel;
|
||||
static const double GBq = gigabecquerel;
|
||||
static const double Ci = curie;
|
||||
static const double mCi = millicurie;
|
||||
static const double uCi = microcurie;
|
||||
|
||||
//
|
||||
// Absorbed dose [L^2][T^-2]
|
||||
|
||||
@@ -1486,6 +1486,15 @@ do_nothing_deleter::operator () ( void const * ) const
|
||||
} // namespace CLHEP
|
||||
|
||||
|
||||
#if defined __GNUC__
|
||||
#if __GNUC__ > 3 && __GNUC_MINOR__ > 6
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif // CLHEP_MEMORY_H
|
||||
|
||||
+177
@@ -0,0 +1,177 @@
|
||||
#include "CLHEP/Random/DoubConv.h"
|
||||
|
||||
#include "CLHEP/Random/RandExpZiggurat.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <cmath> // for std::log()
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
bool RandExpZiggurat::ziggurat_is_init=RandExpZiggurat::ziggurat_init();
|
||||
unsigned long RandExpZiggurat::kn[128], RandExpZiggurat::ke[256];
|
||||
float RandExpZiggurat::wn[128],RandExpZiggurat::fn[128],RandExpZiggurat::we[256],RandExpZiggurat::fe[256];
|
||||
|
||||
std::string RandExpZiggurat::name() const {return "RandExpZiggurat";}
|
||||
|
||||
HepRandomEngine & RandExpZiggurat::engine() {return *localEngine;}
|
||||
|
||||
RandExpZiggurat::~RandExpZiggurat() {
|
||||
if ( deleteEngine ) delete localEngine;
|
||||
}
|
||||
|
||||
RandExpZiggurat::RandExpZiggurat(const RandExpZiggurat& right) : HepRandom(right),defaultMean(right.defaultMean)
|
||||
{
|
||||
if(!ziggurat_is_init) ziggurat_init();
|
||||
}
|
||||
|
||||
double RandExpZiggurat::operator()()
|
||||
{
|
||||
return fire( defaultMean );
|
||||
}
|
||||
|
||||
void RandExpZiggurat::shootArray( const int size, float* vect, float mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = shoot(mean);
|
||||
}
|
||||
|
||||
void RandExpZiggurat::shootArray( const int size, double* vect, double mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = shoot(mean);
|
||||
}
|
||||
|
||||
void RandExpZiggurat::shootArray(HepRandomEngine* anEngine, const int size, float* vect, float mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = shoot(anEngine, mean);
|
||||
}
|
||||
|
||||
void RandExpZiggurat::shootArray(HepRandomEngine* anEngine, const int size, double* vect, double mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = shoot(anEngine, mean);
|
||||
}
|
||||
|
||||
void RandExpZiggurat::fireArray( const int size, float* vect)
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = fire( defaultMean );
|
||||
}
|
||||
|
||||
void RandExpZiggurat::fireArray( const int size, double* vect)
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = fire( defaultMean );
|
||||
}
|
||||
|
||||
void RandExpZiggurat::fireArray( const int size, float* vect, float mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = fire( mean );
|
||||
}
|
||||
|
||||
void RandExpZiggurat::fireArray( const int size, double* vect, double mean )
|
||||
{
|
||||
for (int i=0; i<size; ++i) vect[i] = fire( mean );
|
||||
}
|
||||
|
||||
std::ostream & RandExpZiggurat::put ( std::ostream & os ) const {
|
||||
int pr=os.precision(20);
|
||||
std::vector<unsigned long> t(2);
|
||||
os << " " << name() << "\n";
|
||||
os << "Uvec" << "\n";
|
||||
t = DoubConv::dto2longs(defaultMean);
|
||||
os << defaultMean << " " << t[0] << " " << t[1] << "\n";
|
||||
os.precision(pr);
|
||||
return os;
|
||||
#ifdef REMOVED
|
||||
int pr=os.precision(20);
|
||||
os << " " << name() << "\n";
|
||||
os << defaultMean << "\n";
|
||||
os.precision(pr);
|
||||
return os;
|
||||
#endif
|
||||
}
|
||||
|
||||
std::istream & RandExpZiggurat::get ( std::istream & is ) {
|
||||
std::string inName;
|
||||
is >> inName;
|
||||
if (inName != name()) {
|
||||
is.clear(std::ios::badbit | is.rdstate());
|
||||
std::cerr << "Mismatch when expecting to read state of a "
|
||||
<< name() << " distribution\n"
|
||||
<< "Name found was " << inName
|
||||
<< "\nistream is left in the badbit state\n";
|
||||
return is;
|
||||
}
|
||||
if (possibleKeywordInput(is, "Uvec", defaultMean)) {
|
||||
std::vector<unsigned long> t(2);
|
||||
is >> defaultMean >> t[0] >> t[1]; defaultMean = DoubConv::longs2double(t);
|
||||
return is;
|
||||
}
|
||||
// is >> defaultMean encompassed by possibleKeywordInput
|
||||
return is;
|
||||
}
|
||||
|
||||
|
||||
float RandExpZiggurat::ziggurat_efix(unsigned long jz,HepRandomEngine* anEngine)
|
||||
{
|
||||
unsigned long iz=jz&255;
|
||||
|
||||
float x;
|
||||
for(;;)
|
||||
{
|
||||
if(iz==0) return (7.69711-std::log(ziggurat_UNI(anEngine))); /* iz==0 */
|
||||
x=jz*we[iz];
|
||||
if( fe[iz]+ziggurat_UNI(anEngine)*(fe[iz-1]-fe[iz]) < std::exp(-x) ) return (x);
|
||||
|
||||
/* initiate, try to exit for(;;) loop */
|
||||
jz=ziggurat_SHR3(anEngine);
|
||||
iz=(jz&255);
|
||||
if(jz<ke[iz]) return (jz*we[iz]);
|
||||
}
|
||||
}
|
||||
|
||||
bool RandExpZiggurat::ziggurat_init()
|
||||
{
|
||||
const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
|
||||
double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
|
||||
double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
|
||||
int i;
|
||||
|
||||
/* Set up tables for RNOR */
|
||||
q=vn/std::exp(-.5*dn*dn);
|
||||
kn[0]=(unsigned long)((dn/q)*rzm1);
|
||||
kn[1]=0;
|
||||
|
||||
wn[0]=q/rzm1;
|
||||
wn[127]=dn/rzm1;
|
||||
|
||||
fn[0]=1.;
|
||||
fn[127]=std::exp(-.5*dn*dn);
|
||||
|
||||
for(i=126;i>=1;i--) {
|
||||
dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
|
||||
kn[i+1]=(unsigned long)((dn/tn)*rzm1);
|
||||
tn=dn;
|
||||
fn[i]=std::exp(-.5*dn*dn);
|
||||
wn[i]=dn/rzm1;
|
||||
}
|
||||
|
||||
/* Set up tables for REXP */
|
||||
q = ve/std::exp(-de);
|
||||
ke[0]=(unsigned long)((de/q)*rzm2);
|
||||
ke[1]=0;
|
||||
|
||||
we[0]=q/rzm2;
|
||||
we[255]=de/rzm2;
|
||||
|
||||
fe[0]=1.;
|
||||
fe[255]=std::exp(-de);
|
||||
|
||||
for(i=254;i>=1;i--) {
|
||||
de=-std::log(ve/de+std::exp(-de));
|
||||
ke[i+1]= (unsigned long)((de/te)*rzm2);
|
||||
te=de;
|
||||
fe[i]=std::exp(-de);
|
||||
we[i]=de/rzm2;
|
||||
}
|
||||
ziggurat_is_init=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
#include "CLHEP/Random/RandGaussZiggurat.h"
|
||||
#include "CLHEP/Units/PhysicalConstants.h"
|
||||
#include <iostream>
|
||||
#include <cmath> // for std::log()
|
||||
|
||||
namespace CLHEP {
|
||||
|
||||
bool RandGaussZiggurat::ziggurat_is_init=RandGaussZiggurat::ziggurat_init();
|
||||
//bool RandGaussZiggurat::ziggurat_is_init=false;
|
||||
unsigned long RandGaussZiggurat::kn[128], RandGaussZiggurat::ke[256];
|
||||
float RandGaussZiggurat::wn[128],RandGaussZiggurat::fn[128],RandGaussZiggurat::we[256],RandGaussZiggurat::fe[256];
|
||||
|
||||
HepRandomEngine & RandGaussZiggurat::engine() {return RandGauss::engine();}
|
||||
|
||||
RandGaussZiggurat::~RandGaussZiggurat() {
|
||||
}
|
||||
|
||||
std::string RandGaussZiggurat::name() const
|
||||
{
|
||||
return "RandGaussZiggurat";
|
||||
}
|
||||
|
||||
bool RandGaussZiggurat::ziggurat_init()
|
||||
{
|
||||
const double rzm1 = 2147483648.0, rzm2 = 4294967296.;
|
||||
double dn=3.442619855899,tn=dn,vn=9.91256303526217e-3, q;
|
||||
double de=7.697117470131487, te=de, ve=3.949659822581572e-3;
|
||||
int i;
|
||||
|
||||
/* Set up tables for RNOR */
|
||||
q=vn/std::exp(-.5*dn*dn);
|
||||
kn[0]=(unsigned long)((dn/q)*rzm1);
|
||||
kn[1]=0;
|
||||
|
||||
wn[0]=q/rzm1;
|
||||
wn[127]=dn/rzm1;
|
||||
|
||||
fn[0]=1.;
|
||||
fn[127]=std::exp(-.5*dn*dn);
|
||||
|
||||
for(i=126;i>=1;i--) {
|
||||
dn=std::sqrt(-2.*std::log(vn/dn+std::exp(-.5*dn*dn)));
|
||||
kn[i+1]=(unsigned long)((dn/tn)*rzm1);
|
||||
tn=dn;
|
||||
fn[i]=std::exp(-.5*dn*dn);
|
||||
wn[i]=dn/rzm1;
|
||||
}
|
||||
|
||||
/* Set up tables for REXP */
|
||||
q = ve/std::exp(-de);
|
||||
ke[0]=(unsigned long)((de/q)*rzm2);
|
||||
ke[1]=0;
|
||||
|
||||
we[0]=q/rzm2;
|
||||
we[255]=de/rzm2;
|
||||
|
||||
fe[0]=1.;
|
||||
fe[255]=std::exp(-de);
|
||||
|
||||
for(i=254;i>=1;i--) {
|
||||
de=-std::log(ve/de+std::exp(-de));
|
||||
ke[i+1]= (unsigned long)((de/te)*rzm2);
|
||||
te=de;
|
||||
fe[i]=std::exp(-de);
|
||||
we[i]=de/rzm2;
|
||||
}
|
||||
ziggurat_is_init=true;
|
||||
|
||||
//std::cout<<"Done RandGaussZiggurat::ziggurat_init()"<<std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
float RandGaussZiggurat::ziggurat_nfix(long hz,HepRandomEngine* anEngine)
|
||||
{
|
||||
const float r = 3.442620f; /* The start of the right tail */
|
||||
float x, y;
|
||||
unsigned long iz=hz&127;
|
||||
for(;;)
|
||||
{
|
||||
x=hz*wn[iz]; /* iz==0, handles the base strip */
|
||||
if(iz==0) {
|
||||
do {
|
||||
/* change to (1.0 - UNI) as argument to std::log(), because CLHEP generates [0,1),
|
||||
while the original UNI generates (0,1] */
|
||||
x=-std::log(1.0 - ziggurat_UNI(anEngine))*0.2904764; /* .2904764 is 1/r */
|
||||
y=-std::log(1.0 - ziggurat_UNI(anEngine));
|
||||
} while(y+y<x*x);
|
||||
return (hz>0)? r+x : -r-x;
|
||||
}
|
||||
/* iz>0, handle the wedges of other strips */
|
||||
if( fn[iz]+(1.0 - ziggurat_UNI(anEngine))*(fn[iz-1]-fn[iz]) < std::exp(-.5*x*x) ) return x;
|
||||
|
||||
/* initiate, try to exit for(;;) for loop*/
|
||||
hz=(signed)ziggurat_SHR3(anEngine);
|
||||
iz=hz&127;
|
||||
if((unsigned long)abs(hz)<kn[iz]) return (hz*wn[iz]);
|
||||
}
|
||||
}
|
||||
|
||||
double RandGaussZiggurat::operator()() {
|
||||
return ziggurat_RNOR(localEngine.get()) * defaultStdDev + defaultMean;
|
||||
}
|
||||
|
||||
double RandGaussZiggurat::operator()( double mean, double stdDev ) {
|
||||
return ziggurat_RNOR(localEngine.get()) * stdDev + mean;
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::shootArray( const int size, float* vect, float mean, float stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = shoot(mean,stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::shootArray( const int size, double* vect, double mean, double stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = shoot(mean,stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::shootArray( HepRandomEngine* anEngine, const int size, float* vect, float mean, float stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = shoot(anEngine,mean,stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::shootArray( HepRandomEngine* anEngine, const int size, double* vect, double mean, double stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = shoot(anEngine,mean,stdDev);
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::fireArray( const int size, float* vect)
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = fire( defaultMean, defaultStdDev );
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::fireArray( const int size, double* vect)
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = fire( defaultMean, defaultStdDev );
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::fireArray( const int size, float* vect, float mean, float stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = fire( mean, stdDev );
|
||||
}
|
||||
}
|
||||
|
||||
void RandGaussZiggurat::fireArray( const int size, double* vect, double mean, double stdDev )
|
||||
{
|
||||
for (int i=0; i<size; ++i) {
|
||||
vect[i] = fire( mean, stdDev );
|
||||
}
|
||||
}
|
||||
|
||||
std::ostream & RandGaussZiggurat::put ( std::ostream & os ) const {
|
||||
int pr=os.precision(20);
|
||||
os << " " << name() << "\n";
|
||||
RandGauss::put(os);
|
||||
os.precision(pr);
|
||||
return os;
|
||||
}
|
||||
|
||||
std::istream & RandGaussZiggurat::get ( std::istream & is ) {
|
||||
std::string inName;
|
||||
is >> inName;
|
||||
if (inName != name()) {
|
||||
is.clear(std::ios::badbit | is.rdstate());
|
||||
std::cerr << "Mismatch when expecting to read state of a "
|
||||
<< name() << " distribution\n"
|
||||
<< "Name found was " << inName
|
||||
<< "\nistream is left in the badbit state\n";
|
||||
return is;
|
||||
}
|
||||
RandGauss::get(is);
|
||||
return is;
|
||||
}
|
||||
|
||||
} // namespace CLHEP
|
||||
+13
@@ -210,17 +210,30 @@ void Evaluator::setSystemOfUnits(double meter,
|
||||
const double Bq = 1./s;
|
||||
setVariable("becquerel", Bq);
|
||||
setVariable("Bq", Bq);
|
||||
setVariable("kilobecquerel", kilo_ * Bq);
|
||||
setVariable("kBq", kilo_ * Bq);
|
||||
setVariable("megabecquerel", mega_ * Bq);
|
||||
setVariable("MBq", mega_ * Bq);
|
||||
setVariable("gigabecquerel", giga_ * Bq);
|
||||
setVariable("GBq", giga_ * Bq);
|
||||
|
||||
// --- honors Pierre Curie (1859-1906) of France
|
||||
// and Marie Sklodowska Curie (1867-1934) of Poland
|
||||
setVariable("curie", 3.7e+10 * Bq);
|
||||
setVariable("Ci", 3.7e+10 * Bq);
|
||||
setVariable("millicurie", milli_ * 3.7e+10 * Bq);
|
||||
setVariable("mCi", milli_ * 3.7e+10 * Bq);
|
||||
setVariable("microcurie", micro_ * 3.7e+10 * Bq);
|
||||
setVariable("uCi", micro_ * 3.7e+10 * Bq);
|
||||
|
||||
// Specific energy
|
||||
// --- honors Louis Harold Gray, F.R.S. (1905-1965) of England
|
||||
const double Gy = J / kg;
|
||||
setVariable("gray", Gy);
|
||||
setVariable("Gy", Gy);
|
||||
setVariable("kilogray", kilo_ * Gy);
|
||||
setVariable("milligray", milli_ * Gy);
|
||||
setVariable("microgray", micro_ * Gy);
|
||||
|
||||
// Dose equivalent
|
||||
const double Sv = J / kg;
|
||||
|
||||
Reference in New Issue
Block a user