Import Geant4 10.3.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2016-06-30 14:12:05 +02:00
parent a654a7ab1f
commit 4ec577e5c4
2021 changed files with 100995 additions and 78277 deletions
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RandomDirection.hh 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4RandomDirection.hh 96120 2016-03-16 20:29:21Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -39,6 +39,7 @@
// providing more performant results.
// History:
// 15.03.16 E. Tcherniaev, removed unnecessary if and unit()
// 18.03.08 V. Grichine, unit radius sphere surface based algorithm
// ~ 2007 M. Kossov, algorithm based on 8 Quadrants technique
//
@@ -54,13 +55,10 @@
inline G4ThreeVector G4RandomDirection()
{
G4double cosTheta = 2.*G4UniformRand()-1.;
G4double sinTheta2 = 1. - cosTheta*cosTheta;
if( sinTheta2 < 0.) sinTheta2 = 0.;
G4double sinTheta = std::sqrt(sinTheta2);
G4double phi = CLHEP::twopi*G4UniformRand();
return G4ThreeVector(sinTheta*std::cos(phi),
sinTheta*std::sin(phi), cosTheta).unit();
G4double z = 2.*G4UniformRand() - 1.; // z = cos(theta)
G4double rho = std::sqrt((1.+z)*(1.-z)); // rho = sqrt(1-z*z)
G4double phi = CLHEP::twopi*G4UniformRand();
return G4ThreeVector(rho*std::cos(phi), rho*std::sin(phi), z);
}
#endif /* G4RANDOMDIR_HH */
+2 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: Randomize.hh 91902 2015-08-10 12:04:22Z gcosmo $
// $Id: Randomize.hh 96593 2016-04-25 10:12:49Z gcosmo $
//
#ifndef randomize_h
#define randomize_h 1
@@ -33,7 +33,7 @@
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+1 -1
View File
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
@@ -28,7 +28,7 @@
//
#if __clang__
#if ((defined(G4MULTITHREADED) && !defined(G4USE_STD11)) || \
!__has_feature(cxx_thread_local))
!__has_feature(cxx_thread_local)) || !__has_feature(c_atomic)
#define CLANG_NOSTDTLS
#endif
#endif
+55
View File
@@ -17,6 +17,61 @@ committal in the SVN repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
June 3, 2016 G.Cosmo (global-V10-02-15)
- Enabled new units 'us' and 'ps' in G4SystemOfUnits.hh.
Now requiring CLHEP-2.3.3.0.
- Updated version ID for 10.3-Beta.
May 2, 2016 G.Cosmo (global-V10-02-14)
- Added 'us' and 'ps' units symbols for microsend and picosecond
respectively to G4UnitsTable. (M.Maire)
Commented out in G4SystemOfUnits.hh, pending installation of new
external CLHEP library.
- Converted all units anc constants from "static const" to "static constexpr".
- Coworks with tag "externals-V10-02-08".
April 25, 2016 G.Cosmo (global-V10-02-13)
- Added check for support of atomics for clang compiler in HEPRandom wrappers.
April 14, 2016 G.Cosmo (global-V10-02-12)
- Define G4GeometryTolerance singleton instance pointer as tread-local
to get rid of spurious race conflicts at initialisation.
March 30, 2016 G.Cosmo (global-V10-02-11)
- Added MixMax in unit tests for HepRandom.
March 22, 2016 A.Dotti (global-V10-02-10)
- Fixing compilation of unit test for HEPRandom. Only test
subdirectory touched to port to new G4 interfaces
March 16, 2016 G.Cosmo (global-V10-02-09)
- Improved algorithm for G4RandomDirection (E.Tcherniaev).
- Turn warnings to fatal exceptions in G4UnitsTable for non existing
units or categories in the table. Addressing problem report #1843.
February 17, 1016 A.Dotti (global-V10-02-08, 07, 06, 05)
- Fixed sequential build and Windows builds for G4MTBarrier class.
February 16, 2016 A.Dotti (global-V10-02-04)
- Fixed typo CONDTIONBROADCAST for sequential mode.
- Removed default move constructor to prevent compilation errors on Windows.
February 16, 2016 A.Dotti (global-V10-02-03)
- Introduced new utility class G4MTBarrier implementing a synchronization
point between threads.
- Corrected typo for macro CONDITIONBROADCAST.
January 28, 2016 A.Dotti (global-V10-02-02)
- Changed exception code in G4TWorkspacePool from G4TWorkspacePool
to "WorkspaceNN".
December 17, 2015 G.Cosmo (global-V10-02-01)
- Corrected conditions for proper treatment of gcc-5 in tls.hh and
G4Threading.hh.
December 10, 2015 G.Cosmo (global-V10-02-00)
- Removed unused and buggy operator=(const G4String&) in G4SubString.
November 5, 2015 G.Cosmo (global-V10-01-25)
- Enabled units liter, L, dL, cL, mL in G4SystemOfUnits.hh and G4UnitsTable.
Requires new CLHEP version 2.3.1.0.
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GeometryTolerance.hh 92328 2015-08-28 07:44:26Z gcosmo $
// $Id: G4GeometryTolerance.hh 96427 2016-04-14 09:37:29Z gcosmo $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
@@ -69,25 +69,29 @@ class G4GeometryTolerance
G4double GetRadialTolerance() const;
// Returns the current radial tolerance.
public: // without description
~G4GeometryTolerance();
// Destructor.
protected:
static void SetSurfaceTolerance(G4double worldExtent);
void SetSurfaceTolerance(G4double worldExtent);
// Sets the Cartesian and Radial surface tolerance to a value computed
// from the maximum extent of the world volume. This method
// can be called only once, and is done only through the
// G4GeometryManager class.
G4GeometryTolerance();
~G4GeometryTolerance();
// Protected constructor and destructor.
// Protected constructor.
private:
static G4GeometryTolerance* fpInstance;
static G4double fCarTolerance;
static G4double fAngTolerance;
static G4double fRadTolerance;
static G4bool fInitialised;
static G4ThreadLocal G4GeometryTolerance* fpInstance;
G4double fCarTolerance;
G4double fAngTolerance;
G4double fRadTolerance;
G4bool fInitialised;
};
#endif // G4GeometryTolerance_hh
@@ -0,0 +1,164 @@
//
// ********************************************************************
// * 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$
//
// ---------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
//
// This class defines a synchronization point between threads: a master
// and a pool of workers.
// A barrier is a (shared) instance of this class. Master sets the number
// of active threads to wait for, then it waits for workers to become ready
// calling the method WaitForReadyWorkers(). The master thread will block on this
// call.
// Each of the workers calls ThisWorkerReady() when it is ready to continue.
// It will block on this call.
// When all worker threads have called ThisWorkerReady and are waiting the
// master will release the barrier and execution will continue.
//
// User code can implement more advanced barriers that require exchange
// of a message between master and threads inheriting from this class as in:
// class Derived : public G4MTBarrier {
// G4Mutex mutexForMessage;
// SomeType message;
// void MethodCalledByWorkers() {
// G4MTBarrirer::ThisWorkerReady();
// G4AutoLock l(&mutexForMessage);
// [... process message ...]
// }
// void WaitForReadyWorkers() override {
// Wait(); <== Mandatory
// [.. process message ...] <== User code between the two calls
// ReleaseBarrier(); <== Mandatory
// }
// void MethodCalledByMaster() { WaitForReadyWorkers(); }
// }
// User code can also achieve the same results as before using the granular
// methods LoopWaitingWorkers and ResetCounterAndBroadcast methods in the
// master. For examples of usage of this class see G4MTRunManager
//
// G4MTBarrier.hh
//
// Created on: Feb 10, 2016
// Author: adotti
//
// =====================================
// Barriers mechanism
// =====================================
// We want to implement barriers.
// We define a barrier has a point in which threads synchronize.
// When workers threads reach a barrier they wait for the master thread a
// signal that they can continue. The master thread broadcast this signal
// only when all worker threads have reached this point.
// Currently only three points require this sync in the life-time of a G4 applicattion:
// Just before and just after the for-loop controlling the thread event-loop.
// Between runs.
//
// The basic algorithm of each barrier works like this:
// In the master:
// WaitWorkers() {
// while (true)
// {
// G4AutoLock l(&counterMutex); || Mutex is locked (1)
// if ( counter == nActiveThreads ) break;
// G4CONDITIONWAIT( &conditionOnCounter, &counterMutex); || Mutex is atomically released and wait, upon return locked (2)
// } || unlock mutex
// G4AutoLock l(&counterMutex); || lock again mutex (3)
// G4CONDITIONBROADCAST( &doSomethingCanStart ); || Here mutex is locked (4)
// } || final unlock (5)
// In the workers:
// WaitSignalFromMaster() {
// G4AutoLock l(&counterMutex); || (6)
// ++counter;
// G4CONDITIONBROADCAST(&conditionOnCounter); || (7)
// G4CONDITIONWAIT( &doSomethingCanStart , &counterMutex);|| (8)
// }
// Each barriers requires 2 conditions and one mutex, plus a counter.
// Important note: the thread calling broadcast should hold the mutex
// before calling broadcast to obtain predictible behavior
// http://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread_cond_broadcast.html
// Also remember that the wait for condition will atomically release the mutex
// and wait on condition, but it will lock again on mutex when returning
// Here it is how the control flows.
// Imagine master starts and only one worker (nActiveThreads==1)
// Master | Worker | counter | Who holds mutex
// Gets to (1) | Blocks on (6) | 0 | M
// Waits in (2) | | 0 | -
// | Arrives to (7) | 1 | W
// | Waits in (8) | 1 | -
// Gets to (1) | | 1 | M
// Jumps to (3) | | 1 | M
// End | | 1 | -
// | End | 1 | -
// Similarly for more than one worker threads or if worker starts
#ifndef G4MTBARRIER_HH_
#define G4MTBARRIER_HH_
#include "G4Threading.hh"
#ifdef WIN32
#include "windefs.hh"
#endif
class G4MTBarrier
{
public:
G4MTBarrier() : G4MTBarrier(1) {}
virtual ~G4MTBarrier() {}
G4MTBarrier(const G4MTBarrier&) = delete;
G4MTBarrier& operator=(const G4MTBarrier&) = delete;
//on explicitly defaulted move at
//https://msdn.microsoft.com/en-us/library/dn457344.aspx
//G4MTBarrier(G4MTBarrier&&) = default;
//G4MTBarrier& operator=(G4MTBarrier&&) = default;
G4MTBarrier( unsigned int numThreads );
void ThisWorkerReady();
virtual void WaitForReadyWorkers();
inline void SetActiveThreads( unsigned int val ) { m_numActiveThreads = val; }
void ResetCounter();
unsigned int GetCounter();
void Wait();
void ReleaseBarrier();
inline void Wait( unsigned int numt ) {
SetActiveThreads( numt );
Wait();
}
private:
unsigned int m_numActiveThreads;
unsigned int m_counter;
G4Mutex m_mutex;
G4Condition m_counterChanged;
G4Condition m_continue;
#if defined(WIN32)
CRITICAL_SECTION cs1;
CRITICAL_SECTION cs2;
#endif
};
#endif /* G4MTBARRIER_HH_ */
+140 -137
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4SIunits.hh 92196 2015-08-21 09:55:47Z gcosmo $
// $Id: G4SIunits.hh 96706 2016-05-02 09:31:38Z gcosmo $
//
// ----------------------------------------------------------------------
//
@@ -64,6 +64,7 @@
// 01.03.01 parsec
// 11.06.15 upgrate. Equivalent to SystemOfUnits.h
// 08.08.15 add decimeter, liter (mma)
// 12.01.16 added symbols for microsecond (us) and picosecond (ps) (mma)
#ifndef SI_SYSTEM_OF_UNITS_HH
#define SI_SYSTEM_OF_UNITS_HH
@@ -71,264 +72,266 @@
//
//
//
static const double pi = 3.14159265358979323846;
static const double twopi = 2*pi;
static const double halfpi = pi/2;
static const double pi2 = pi*pi;
static constexpr double pi = 3.14159265358979323846;
static constexpr double twopi = 2*pi;
static constexpr double halfpi = pi/2;
static constexpr double pi2 = pi*pi;
//
// Length [L]
//
static const double meter = 1.;
static const double meter2 = meter*meter;
static const double meter3 = meter*meter*meter;
static constexpr double meter = 1.;
static constexpr double meter2 = meter*meter;
static constexpr double meter3 = meter*meter*meter;
static const double millimeter = 0.001*meter;
static const double millimeter2 = millimeter*millimeter;
static const double millimeter3 = millimeter*millimeter*millimeter;
static constexpr double millimeter = 0.001*meter;
static constexpr double millimeter2 = millimeter*millimeter;
static constexpr double millimeter3 = millimeter*millimeter*millimeter;
static const double centimeter = 10.*millimeter;
static const double centimeter2 = centimeter*centimeter;
static const double centimeter3 = centimeter*centimeter*centimeter;
static constexpr double centimeter = 10.*millimeter;
static constexpr double centimeter2 = centimeter*centimeter;
static constexpr double centimeter3 = centimeter*centimeter*centimeter;
static const double kilometer = 1000.*meter;
static const double kilometer2 = kilometer*kilometer;
static const double kilometer3 = kilometer*kilometer*kilometer;
static constexpr double kilometer = 1000.*meter;
static constexpr double kilometer2 = kilometer*kilometer;
static constexpr double kilometer3 = kilometer*kilometer*kilometer;
static const double parsec = 3.0856775807e+16*meter;
static constexpr double parsec = 3.0856775807e+16*meter;
static const double micrometer = 1.e-6 *meter;
static const double nanometer = 1.e-9 *meter;
static const double angstrom = 1.e-10*meter;
static const double fermi = 1.e-15*meter;
static constexpr double micrometer = 1.e-6 *meter;
static constexpr double nanometer = 1.e-9 *meter;
static constexpr double angstrom = 1.e-10*meter;
static constexpr double fermi = 1.e-15*meter;
static const double barn = 1.e-28*meter2;
static const double millibarn = 1.e-3 *barn;
static const double microbarn = 1.e-6 *barn;
static const double nanobarn = 1.e-9 *barn;
static const double picobarn = 1.e-12*barn;
static constexpr double barn = 1.e-28*meter2;
static constexpr double millibarn = 1.e-3 *barn;
static constexpr double microbarn = 1.e-6 *barn;
static constexpr double nanobarn = 1.e-9 *barn;
static constexpr double picobarn = 1.e-12*barn;
// symbols
static const double nm = nanometer;
static const double um = micrometer;
static constexpr double nm = nanometer;
static constexpr double um = micrometer;
static const double mm = millimeter;
static const double mm2 = millimeter2;
static const double mm3 = millimeter3;
static constexpr double mm = millimeter;
static constexpr double mm2 = millimeter2;
static constexpr double mm3 = millimeter3;
static const double cm = centimeter;
static const double cm2 = centimeter2;
static const double cm3 = centimeter3;
static constexpr double cm = centimeter;
static constexpr double cm2 = centimeter2;
static constexpr double cm3 = centimeter3;
static const double liter = 1.e+3*cm3;
static const double L = liter;
static const double dL = 1.e-1*liter;
static const double cL = 1.e-2*liter;
static const double mL = 1.e-3*liter;
static constexpr double liter = 1.e+3*cm3;
static constexpr double L = liter;
static constexpr double dL = 1.e-1*liter;
static constexpr double cL = 1.e-2*liter;
static constexpr double mL = 1.e-3*liter;
static const double m = meter;
static const double m2 = meter2;
static const double m3 = meter3;
static constexpr double m = meter;
static constexpr double m2 = meter2;
static constexpr double m3 = meter3;
static const double km = kilometer;
static const double km2 = kilometer2;
static const double km3 = kilometer3;
static constexpr double km = kilometer;
static constexpr double km2 = kilometer2;
static constexpr double km3 = kilometer3;
static const double pc = parsec;
static constexpr double pc = parsec;
//
// Angle
//
static const double radian = 1.;
static const double milliradian = 1.e-3*radian;
static const double degree = (pi/180.0)*radian;
static constexpr double radian = 1.;
static constexpr double milliradian = 1.e-3*radian;
static constexpr double degree = (pi/180.0)*radian;
static const double steradian = 1.;
static constexpr double steradian = 1.;
// symbols
static const double rad = radian;
static const double mrad = milliradian;
static const double sr = steradian;
static const double deg = degree;
static constexpr double rad = radian;
static constexpr double mrad = milliradian;
static constexpr double sr = steradian;
static constexpr double deg = degree;
//
// Time [T]
//
static const double second = 1.;
static const double nanosecond = 1.e-9 *second;
static const double millisecond = 1.e-3 *second;
static const double microsecond = 1.e-6 *second;
static const double picosecond = 1.e-12*second;
static constexpr double second = 1.;
static constexpr double nanosecond = 1.e-9 *second;
static constexpr double millisecond = 1.e-3 *second;
static constexpr double microsecond = 1.e-6 *second;
static constexpr double picosecond = 1.e-12*second;
static const double hertz = 1./second;
static const double kilohertz = 1.e+3*hertz;
static const double megahertz = 1.e+6*hertz;
static constexpr double hertz = 1./second;
static constexpr double kilohertz = 1.e+3*hertz;
static constexpr double megahertz = 1.e+6*hertz;
// symbols
static const double ns = nanosecond;
static const double s = second;
static const double ms = millisecond;
static constexpr double ns = nanosecond;
static constexpr double s = second;
static constexpr double ms = millisecond;
static constexpr double us = microsecond;
static constexpr double ps = picosecond;
//
// Mass [E][T^2][L^-2]
//
static const double kilogram = 1.;
static const double gram = 1.e-3*kilogram;
static const double milligram = 1.e-3*gram;
static constexpr double kilogram = 1.;
static constexpr double gram = 1.e-3*kilogram;
static constexpr double milligram = 1.e-3*gram;
// symbols
static const double kg = kilogram;
static const double g = gram;
static const double mg = milligram;
static constexpr double kg = kilogram;
static constexpr double g = gram;
static constexpr double mg = milligram;
//
// Electric current [Q][T^-1]
//
static const double ampere = 1.;
static const double milliampere = 1.e-3*ampere;
static const double microampere = 1.e-6*ampere;
static const double nanoampere = 1.e-9*ampere;
static constexpr double ampere = 1.;
static constexpr double milliampere = 1.e-3*ampere;
static constexpr double microampere = 1.e-6*ampere;
static constexpr double nanoampere = 1.e-9*ampere;
//
// Electric charge [Q]
//
static const double coulomb = ampere*second;
static const double e_SI = 1.602176487e-19; // positron charge in coulomb
static const double eplus = e_SI*coulomb ; // positron charge
static constexpr double coulomb = ampere*second;
static constexpr double e_SI = 1.602176487e-19; // positron charge in coulomb
static constexpr double eplus = e_SI*coulomb ; // positron charge
//
// Energy [E]
//
static const double joule = kg*m*m/(s*s);
static constexpr double joule = kg*m*m/(s*s);
static const double electronvolt = e_SI*joule;
static const double kiloelectronvolt = 1.e+3*electronvolt;
static const double megaelectronvolt = 1.e+6*electronvolt;
static const double gigaelectronvolt = 1.e+9*electronvolt;
static const double teraelectronvolt = 1.e+12*electronvolt;
static const double petaelectronvolt = 1.e+15*electronvolt;
static constexpr double electronvolt = e_SI*joule;
static constexpr double kiloelectronvolt = 1.e+3*electronvolt;
static constexpr double megaelectronvolt = 1.e+6*electronvolt;
static constexpr double gigaelectronvolt = 1.e+9*electronvolt;
static constexpr double teraelectronvolt = 1.e+12*electronvolt;
static constexpr double petaelectronvolt = 1.e+15*electronvolt;
// symbols
static const double MeV = megaelectronvolt;
static const double eV = electronvolt;
static const double keV = kiloelectronvolt;
static const double GeV = gigaelectronvolt;
static const double TeV = teraelectronvolt;
static const double PeV = petaelectronvolt;
static constexpr double MeV = megaelectronvolt;
static constexpr double eV = electronvolt;
static constexpr double keV = kiloelectronvolt;
static constexpr double GeV = gigaelectronvolt;
static constexpr double TeV = teraelectronvolt;
static constexpr double PeV = petaelectronvolt;
//
// Power [E][T^-1]
//
static const double watt = joule/second; // watt = 6.24150 e+3 * MeV/ns
static constexpr double watt = joule/second; // watt = 6.24150 e+3 * MeV/ns
//
// Force [E][L^-1]
//
static const double newton = joule/meter; // newton = 6.24150 e+9 * MeV/mm
static constexpr double newton = joule/meter; // newton = 6.24150 e+9 * MeV/mm
//
// Pressure [E][L^-3]
//
#define pascal hep_pascal // a trick to avoid warnings
static const double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
static const double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
static const double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
static constexpr double hep_pascal = newton/m2; // pascal = 6.24150 e+3 * MeV/mm3
static constexpr double bar = 100000*pascal; // bar = 6.24150 e+8 * MeV/mm3
static constexpr double atmosphere = 101325*pascal; // atm = 6.32420 e+8 * MeV/mm3
//
// Electric potential [E][Q^-1]
//
static const double megavolt = megaelectronvolt/eplus;
static const double kilovolt = 1.e-3*megavolt;
static const double volt = 1.e-6*megavolt;
static constexpr double megavolt = megaelectronvolt/eplus;
static constexpr double kilovolt = 1.e-3*megavolt;
static constexpr double volt = 1.e-6*megavolt;
//
// Electric resistance [E][T][Q^-2]
//
static const double ohm = volt/ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
static constexpr double ohm = volt/ampere; // ohm = 1.60217e-16*(MeV/eplus)/(eplus/ns)
//
// Electric capacitance [Q^2][E^-1]
//
static const double farad = coulomb/volt; // farad = 6.24150e+24 * eplus/Megavolt
static const double millifarad = 1.e-3*farad;
static const double microfarad = 1.e-6*farad;
static const double nanofarad = 1.e-9*farad;
static const double picofarad = 1.e-12*farad;
static constexpr double farad = coulomb/volt; // farad = 6.24150e+24 * eplus/Megavolt
static constexpr double millifarad = 1.e-3*farad;
static constexpr double microfarad = 1.e-6*farad;
static constexpr double nanofarad = 1.e-9*farad;
static constexpr double picofarad = 1.e-12*farad;
//
// Magnetic Flux [T][E][Q^-1]
//
static const double weber = volt*second; // weber = 1000*megavolt*ns
static constexpr double weber = volt*second; // weber = 1000*megavolt*ns
//
// Magnetic Field [T][E][Q^-1][L^-2]
//
static const double tesla = volt*second/meter2; // tesla =0.001*megavolt*ns/mm2
static constexpr double tesla = volt*second/meter2; // tesla =0.001*megavolt*ns/mm2
static const double gauss = 1.e-4*tesla;
static const double kilogauss = 1.e-1*tesla;
static constexpr double gauss = 1.e-4*tesla;
static constexpr double kilogauss = 1.e-1*tesla;
//
// Inductance [T^2][E][Q^-2]
//
static const double henry = weber/ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
static constexpr double henry = weber/ampere; // henry = 1.60217e-7*MeV*(ns/eplus)**2
//
// Temperature
//
static const double kelvin = 1.;
static constexpr double kelvin = 1.;
//
// Amount of substance
//
static const double mole = 1.;
static constexpr double mole = 1.;
//
// Activity [T^-1]
//
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;
static constexpr double becquerel = 1./second ;
static constexpr double curie = 3.7e+10 * becquerel;
static constexpr double kilobecquerel = 1.e+3*becquerel;
static constexpr double megabecquerel = 1.e+6*becquerel;
static constexpr double gigabecquerel = 1.e+9*becquerel;
static constexpr double millicurie = 1.e-3*curie;
static constexpr double microcurie = 1.e-6*curie;
static constexpr double Bq = becquerel;
static constexpr double kBq = kilobecquerel;
static constexpr double MBq = megabecquerel;
static constexpr double GBq = gigabecquerel;
static constexpr double Ci = curie;
static constexpr double mCi = millicurie;
static constexpr double uCi = microcurie;
//
// Absorbed dose [L^2][T^-2]
//
static const double gray = joule/kilogram;
static const double kilogray = 1.e+3*gray;
static const double milligray = 1.e-3*gray;
static const double microgray = 1.e-6*gray;
static constexpr double gray = joule/kilogram;
static constexpr double kilogray = 1.e+3*gray;
static constexpr double milligray = 1.e-3*gray;
static constexpr double microgray = 1.e-6*gray;
//
// Luminous intensity [I]
//
static const double candela = 1.;
static constexpr double candela = 1.;
//
// Luminous flux [I]
//
static const double lumen = candela*steradian;
static constexpr double lumen = candela*steradian;
//
// Illuminance [I][L^-2]
//
static const double lux = lumen/meter2;
static constexpr double lux = lumen/meter2;
//
// Miscellaneous
//
static const double perCent = 0.01 ;
static const double perThousand = 0.001;
static const double perMillion = 0.000001;
static constexpr double perCent = 0.01 ;
static constexpr double perThousand = 0.001;
static constexpr double perMillion = 0.000001;
#endif /* SI_SYSTEM_OF_UNITS_HH */
+1 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4String.hh 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4String.hh 94844 2015-12-10 16:23:09Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -66,7 +66,6 @@ public:
inline G4SubString& operator=(const char*);
inline G4SubString& operator=(const G4String&);
inline G4SubString& operator=(const G4SubString&);
inline char& operator()(str_size);
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4String.icc 92939 2015-09-22 07:24:30Z gcosmo $
// $Id: G4String.icc 94844 2015-12-10 16:23:09Z gcosmo $
//
//
//---------------------------------------------------------------
@@ -47,11 +47,6 @@ inline G4SubString::G4SubString(G4String& str, str_size siz, str_size e)
{
}
inline G4SubString& G4SubString::operator=(const G4String& str)
{
return operator=(str);
}
inline G4SubString& G4SubString::operator=(const G4SubString& str)
{
mystring->replace(mystart,extent,str.mystring->data(),str.length());
@@ -87,6 +87,8 @@ using CLHEP::megahertz;
using CLHEP::ns;
using CLHEP::s;
using CLHEP::ms;
using CLHEP::us;
using CLHEP::ps;
using CLHEP::eplus;
using CLHEP::e_SI;
using CLHEP::coulomb;
@@ -89,13 +89,13 @@ T* G4TWorkspacePool<T>::CreateWorkspace()
if ( !fMyWorkspace ) {
wrk = new T;
if ( !wrk ) {
G4Exception("G4TWorspacePool<someType>::CreateWorkspace", "Run0035",
G4Exception("G4TWorspacePool<someType>::CreateWorkspace", "Workspace01",
FatalException, "Failed to create workspace.");
} else {
fMyWorkspace = wrk;
}
} else {
G4Exception("ParticlesWorspacePool::CreateWorkspace", "Run0035",
G4Exception("ParticlesWorspacePool::CreateWorkspace", "Workspace02",
FatalException,
"Cannot create workspace twice for the same thread.");
wrk = fMyWorkspace;
@@ -54,7 +54,7 @@
// Multi-threaded build
//===============================
#if ( defined(__MACH__) && defined(__clang__) && defined(__x86_64__) ) || \
( defined(__MACH__) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=7 ) || \
( defined(__MACH__) && defined(__GNUC__) && (__GNUC__>=4 && __GNUC_MINOR__>=7 || __GNUC__>=5) ) || \
defined(__linux__) || defined(_AIX)
//
// Multi-threaded build: for POSIX systems
@@ -119,7 +119,7 @@
#define G4CONDITION_INITIALIZER PTHREAD_COND_INITIALIZER
#define G4CONDITIONWAIT( cond, mutex ) pthread_cond_wait( cond , mutex );
#define G4CONDTIONBROADCAST( cond ) pthread_cond_broadcast( cond );
#define G4CONDITIONBROADCAST( cond ) pthread_cond_broadcast( cond );
#elif defined(WIN32)
//
@@ -158,7 +158,7 @@
#define G4CONDITION_INITIALIZER CONDITION_VARIABLE_INIT
#define G4CONDITIONWAIT( cond , criticalsectionmutex ) SleepConditionVariableCS( cond, criticalsectionmutex , INFINITE );
#define G4CONDTIONBROADCAST( cond ) WakeAllConditionVariable( cond );
#define G4CONDITIONBROADCAST( cond ) WakeAllConditionVariable( cond );
#else
@@ -188,8 +188,8 @@
typedef G4int G4Pid_t;
typedef G4int G4Condition;
#define G4CONDITION_INITIALIZER 1
#define G4CONDITIONWAIT( cond, mutex ) ;;
#define G4CONDTIONBROADCAST( cond ) ;;
#define G4CONDITIONWAIT( cond, mutex ) { ++(*cond); ++(*mutex); }
#define G4CONDITIONBROADCAST( cond ) { ++(*cond); }
#endif //G4MULTITHREADING
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Version.hh 94738 2015-12-04 11:23:42Z gcosmo $
// $Id: G4Version.hh 97990 2016-06-30 10:04:56Z gcosmo $
// GEANT4 tag $Name:$
//
// Version information
@@ -46,11 +46,11 @@
// |--> patch number
#ifndef G4VERSION_NUMBER
#define G4VERSION_NUMBER 1020
#define G4VERSION_NUMBER 1030
#endif
#ifndef G4VERSION_TAG
#define G4VERSION_TAG "$Name: geant4-10-02 $"
#define G4VERSION_TAG "$Name: geant4-10-03-beta-01 $"
#endif
// as variables
@@ -58,10 +58,10 @@
#include "G4String.hh"
#ifdef G4MULTITHREADED
static const G4String G4Version = "$Name: geant4-10-02 [MT]$";
static const G4String G4Version = "$Name: geant4-10-03-beta-01 [MT]$";
#else
static const G4String G4Version = "$Name: geant4-10-02 $";
static const G4String G4Version = "$Name: geant4-10-03-beta-01 $";
#endif
static const G4String G4Date = "(4-December-2015)";
static const G4String G4Date = "(30-June-2016)";
#endif
+2 -2
View File
@@ -44,7 +44,7 @@
# define G4ThreadLocal __thread
#endif
#elif ( (defined(__linux__) || defined(__MACH__)) && \
!defined(__INTEL_COMPILER) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__<9 )
!defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__>=4 && __GNUC_MINOR__<9) || __GNUC__>=5 )
#if defined (G4USE_STD11)
# define G4ThreadLocalStatic static __thread
# define G4ThreadLocal thread_local
@@ -53,7 +53,7 @@
# define G4ThreadLocal __thread
#endif
#elif ( (defined(__linux__) || defined(__MACH__)) && \
!defined(__INTEL_COMPILER) && defined(__GNUC__) && __GNUC__>=4 && __GNUC_MINOR__>=9 )
!defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__>=4 && __GNUC_MINOR__>=9) || __GNUC__>=5 )
#if defined (G4USE_STD11)
# define G4ThreadLocalStatic static thread_local
# define G4ThreadLocal thread_local
+3 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 85359 2014-10-28 10:04:03Z gcosmo $
# $Id: sources.cmake 95631 2016-02-17 08:02:06Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -101,6 +101,7 @@ GEANT4_DEFINE_MODULE(NAME G4globman
G4ThreadLocalSingleton.hh
G4AutoDelete.hh
G4TWorkspacePool.hh
G4MTBarrier.hh
SOURCES
G4Allocator.cc
G4AllocatorPool.cc
@@ -135,6 +136,7 @@ GEANT4_DEFINE_MODULE(NAME G4globman
G4ofstreamDestination.cc
G4MTcoutDestination.cc
G4CacheDetails.cc
G4MTBarrier.cc
GRANULAR_DEPENDENCIES
GLOBAL_DEPENDENCIES
LINK_LIBRARIES
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4GeometryTolerance.cc 92328 2015-08-28 07:44:26Z gcosmo $
// $Id: G4GeometryTolerance.cc 96427 2016-04-14 09:37:29Z gcosmo $
//
// class G4GeometryTolerance
//
@@ -36,25 +36,25 @@
#include "G4GeometryTolerance.hh"
#include "G4SystemOfUnits.hh"
#include "G4AutoDelete.hh"
#include "globals.hh"
// ***************************************************************************
// Static class data
// Static class instance
// ***************************************************************************
//
G4GeometryTolerance* G4GeometryTolerance::fpInstance = 0;
G4bool G4GeometryTolerance::fInitialised = false;
G4double G4GeometryTolerance::fCarTolerance = 1E-9*mm;
G4double G4GeometryTolerance::fAngTolerance = 1E-9*rad;
G4double G4GeometryTolerance::fRadTolerance = 1E-9*mm;
G4ThreadLocal G4GeometryTolerance* G4GeometryTolerance::fpInstance = 0;
// ***************************************************************************
// Constructor.
// ***************************************************************************
//
G4GeometryTolerance::G4GeometryTolerance()
G4GeometryTolerance::G4GeometryTolerance() : fInitialised(false)
{
fCarTolerance = 1E-9*mm;
fAngTolerance = 1E-9*rad;
fRadTolerance = 1E-9*mm;
}
// ***************************************************************************
@@ -63,7 +63,6 @@ G4GeometryTolerance::G4GeometryTolerance()
//
G4GeometryTolerance::~G4GeometryTolerance()
{
delete fpInstance; fpInstance = 0;
}
// ***************************************************************************
@@ -76,6 +75,7 @@ G4GeometryTolerance* G4GeometryTolerance::GetInstance()
if (fpInstance == 0)
{
fpInstance = new G4GeometryTolerance;
G4AutoDelete::Register(fpInstance);
}
return fpInstance;
}
+120
View File
@@ -0,0 +1,120 @@
// ********************************************************************
// * 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$
//
// ---------------------------------------------------------------
/*
* G4MTBarrier.cc
*
* Created on: Feb 10, 2016
* Author: adotti
*/
#include "G4MTBarrier.hh"
#include "G4AutoLock.hh"
G4MTBarrier::G4MTBarrier(unsigned int numThreads ) :
m_numActiveThreads(numThreads),
m_counter(0),
m_mutex(G4MUTEX_INITIALIZER),
m_counterChanged(G4CONDITION_INITIALIZER),
m_continue(G4CONDITION_INITIALIZER)
{
#if defined(WIN32)
InitializeCriticalSection( &cs1 );
InitializeCriticalSection( &cs2 );
#endif
}
void G4MTBarrier::ThisWorkerReady() {
//Step-1: Worker acquires lock on shared resource (the counter)
#ifndef WIN32
G4AutoLock lock(&m_mutex);
#else
EnterCriticalSection( &cs1 );
#endif
//Step-2: Worker increases counter
++m_counter;
//Step-3: Worker broadcasts that the counter has changed
G4CONDITIONBROADCAST(&m_counterChanged);
//Step-4: Worker waits on condition to continue
#ifndef WIN32
G4CONDITIONWAIT(&m_continue,&m_mutex);
#else
# ifdef G4MULTITHREADED
G4CONDITIONWAIT(&m_continue,&cs1);
# endif
LeaveCriticalSection(&cs1);
#endif
}
void G4MTBarrier::Wait() {
while (true)
{
//Step-2: Acquires lock on shared resource (the counter)
#ifndef WIN32
G4AutoLock lock(&m_mutex);
#else
EnterCriticalSection(&cs2);
#endif
//If the counter equals active threads, all threads are ready, exit the loop
if ( m_counter == m_numActiveThreads ) { break; }
//Step-3: Not all workers are ready, wait for the number to change
//before repeating the check
#ifdef WIN32
# ifdef G4MULTITHREADED
G4CONDITIONWAIT(&m_counterChanged,&cs2);
# endif
LeaveCriticalSection(&cs2);
#else
G4CONDITIONWAIT(&m_counterChanged,&m_mutex);
#endif
}
}
void G4MTBarrier::ReleaseBarrier() {
//Step-4: re-aquire lock and re-set shared resource for future re-use
G4AutoLock lock(&m_mutex);
m_counter = 0;
G4CONDITIONBROADCAST(&m_continue);
}
void G4MTBarrier::WaitForReadyWorkers() {
//Step-1: Master enters a loop to wait all workers to be ready
Wait();
//Done, all workers are ready, broadcast a continue signal
ReleaseBarrier();
}
void G4MTBarrier::ResetCounter() {
G4AutoLock l(&m_mutex);
m_counter = 0;
}
unsigned int G4MTBarrier::GetCounter() {
G4AutoLock l(&m_mutex);
const unsigned int result = m_counter;
return result;
}
+6 -6
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UnitsTable.cc 94074 2015-11-05 14:56:40Z gcosmo $
// $Id: G4UnitsTable.cc 96706 2016-05-02 09:31:38Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
@@ -149,9 +149,9 @@ G4double G4UnitDefinition::GetValueOf(const G4String& str)
}
}
std::ostringstream message;
message << "The unit '" << str << "' does not exist in the Units Table.";
message << "The unit '" << str << "' does not exist in the Units Table!";
G4Exception("G4UnitDefinition::GetValueOf()", "InvalidUnit",
JustWarning, message, "Returning Value = 0.");
FatalException, message);
return 0.;
}
@@ -171,9 +171,9 @@ G4String G4UnitDefinition::GetCategory(const G4String& str)
}
}
std::ostringstream message;
message << "The unit '" << str << "' does not exist in the Units Table.";
message << "The unit '" << str << "' does not exist in the Units Table!";
G4Exception("G4UnitDefinition::GetCategory()", "InvalidUnit",
JustWarning, message, "Returning Value = 0.");
FatalException, message);
name = "None";
return name;
}
@@ -237,7 +237,7 @@ void G4UnitDefinition::BuildUnitsTable()
//Time
new G4UnitDefinition( "second","s" ,"Time",second);
new G4UnitDefinition("millisecond","ms" ,"Time",millisecond);
new G4UnitDefinition("microsecond","mus" ,"Time",microsecond);
new G4UnitDefinition("microsecond","us" ,"Time",microsecond);
new G4UnitDefinition( "nanosecond","ns" ,"Time",nanosecond);
new G4UnitDefinition( "picosecond","ps" ,"Time",picosecond);