Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -38,7 +38,8 @@
G4MTcoutDestination::G4MTcoutDestination(const G4int& threadId,
std::ostream& co, std::ostream& ce)
: finalcout(co), finalcerr(ce), id(threadId), useBuffer(false),
threadCoutToFile(false), threadCerrToFile(false), ignoreCout(false)
threadCoutToFile(false), threadCerrToFile(false),
ignoreCout(false), ignoreInit(true)
{
G4coutbuf.SetDestination(this);
G4cerrbuf.SetDestination(this);
@@ -53,6 +54,7 @@ G4MTcoutDestination::~G4MTcoutDestination()
}
namespace { G4Mutex coutm = G4MUTEX_INITIALIZER; }
#include "G4StateManager.hh"
G4int G4MTcoutDestination::ReceiveG4cout(const G4String& msg)
{
@@ -61,7 +63,27 @@ G4int G4MTcoutDestination::ReceiveG4cout(const G4String& msg)
else if( useBuffer )
{ cout_buffer<<msg; }
else if( !ignoreCout )
{ G4AutoLock l(&coutm); finalcout<<prefix<<id<<" > "<<msg; }
{
if(!ignoreInit ||
G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle )
{
G4AutoLock l(&coutm);
finalcout<<prefix;
if ( id!=G4Threading::GENERICTHREAD_ID ) finalcout<<id;
finalcout<<" > "<<msg<<std::flush;
}
}
//forward message to master G4coutDestination if set
if ( masterG4coutDestination && !ignoreCout &&
( !ignoreInit || G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle )
){
G4AutoLock l(&coutm);
std::stringstream ss;
ss<<prefix;
if ( id!=G4Threading::GENERICTHREAD_ID ) ss<<id;
ss<<" > "<<msg;
masterG4coutDestination->ReceiveG4cout(ss.str());
}
return 0;
}
@@ -72,7 +94,22 @@ G4int G4MTcoutDestination::ReceiveG4cerr(const G4String& msg)
if( useBuffer )
{ cerr_buffer<<msg; }
else
{ G4AutoLock l(&coutm); finalcerr<<prefix<<id<<" > "<<msg; }
{ G4AutoLock l(&coutm);
finalcerr<<prefix;
if ( id!=G4Threading::GENERICTHREAD_ID ) finalcerr<<id;
finalcerr<<" > "<<msg<<std::flush;
}
//forward message to master G4coutDestination if set
if ( masterG4coutDestination && !ignoreCout &&
( !ignoreInit || G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle )
){
G4AutoLock l(&coutm);
std::stringstream ss;
ss<<prefix;
if ( id!=G4Threading::GENERICTHREAD_ID ) ss<<id;
ss<<" > "<<msg;
masterG4coutDestination->ReceiveG4cerr(ss.str());
}
return 0;
}
@@ -23,10 +23,6 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
// $Id:$
//
//
// --------------------------------------------------------------
// GEANT 4 class implementation file
//
@@ -311,7 +307,14 @@ G4bool G4Physics2DVector::Retrieve(std::ifstream& in)
// binning
G4int k;
in >> k >> numberOfXNodes >> numberOfYNodes;
if (in.fail() || 0 >= numberOfXNodes || 0 >= numberOfYNodes) {
if (in.fail() || 0 >= numberOfXNodes || 0 >= numberOfYNodes ||
numberOfXNodes >= INT_MAX || numberOfYNodes >= INT_MAX) {
if( 0 >= numberOfXNodes || numberOfXNodes >= INT_MAX) {
numberOfXNodes = 0;
}
if( 0 >= numberOfYNodes || numberOfYNodes >= INT_MAX) {
numberOfYNodes = 0;
}
return false;
}
PrepareVectors();
@@ -36,13 +36,19 @@
modelCatalog* G4PhysicsModelCatalog::catalog = 0;
G4PhysicsModelCatalog::G4PhysicsModelCatalog()
{ catalog = new modelCatalog; }
{ if(!catalog) {
static modelCatalog catal;
catalog = &catal;
}
}
G4PhysicsModelCatalog::~G4PhysicsModelCatalog()
{ delete catalog; catalog = 0; }
{}
//{ delete catalog; catalog = 0; }
G4int G4PhysicsModelCatalog::Register(G4String& name)
G4int G4PhysicsModelCatalog::Register(const G4String& name)
{
G4PhysicsModelCatalog();
G4int idx = GetIndex(name);
if(idx>=0) return idx;
#ifdef G4MULTITHREADED
@@ -52,18 +58,16 @@ G4int G4PhysicsModelCatalog::Register(G4String& name)
return catalog->size()-1;
}
G4String& G4PhysicsModelCatalog::GetModelName(G4int idx)
const G4String& G4PhysicsModelCatalog::GetModelName(G4int idx)
{
static G4String undef = "Undefined";
if(!catalog) new G4PhysicsModelCatalog;
static const G4String undef = "Undefined";
if(idx>=0 && idx<Entries()) return (*catalog)[idx];
return undef;
}
G4int G4PhysicsModelCatalog::GetIndex(G4String& name)
G4int G4PhysicsModelCatalog::GetIndex(const G4String& name)
{
if(!catalog) new G4PhysicsModelCatalog;
for(G4int idx=0;idx<Entries();idx++)
for(G4int idx=0;idx<Entries();++idx)
{ if((*catalog)[idx]==name) return idx; }
return -1;
}
@@ -72,12 +76,5 @@ G4int G4PhysicsModelCatalog::Entries()
{ return (catalog) ? G4int(catalog->size()) : -1; }
void G4PhysicsModelCatalog::Destroy()
{
#ifdef G4MULTITHREADED
if(G4Threading::IsWorkerThread()) return;
#endif
if(catalog) delete catalog;
catalog = 0;
}
{}
+22 -28
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4PhysicsVector.cc 74256 2013-10-02 14:24:02Z gcosmo $
// $Id: G4PhysicsVector.cc 83009 2014-07-24 14:51:29Z gcosmo $
//
//
// --------------------------------------------------------------
@@ -56,7 +56,7 @@
#include <iomanip>
#include "G4PhysicsVector.hh"
G4ThreadLocal G4Allocator<G4PhysicsVector> *fpPVAllocator = 0;
//G4ThreadLocal G4Allocator<G4PhysicsVector> *fpPVAllocator = 0;
// --------------------------------------------------------------
@@ -67,8 +67,7 @@ G4PhysicsVector::G4PhysicsVector(G4bool)
dBin(0.), baseBin(0.),
verboseLevel(0)
{
if (!fpPVAllocator) fpPVAllocator = new G4Allocator<G4PhysicsVector>;
// g4pow = G4Pow::GetInstance();
// if (!fpPVAllocator) fpPVAllocator = new G4Allocator<G4PhysicsVector>;
}
// --------------------------------------------------------------
@@ -81,8 +80,6 @@ G4PhysicsVector::~G4PhysicsVector()
G4PhysicsVector::G4PhysicsVector(const G4PhysicsVector& right)
{
// g4pow = G4Pow::GetInstance();
dBin = right.dBin;
baseBin = right.baseBin;
verboseLevel = right.verboseLevel;
@@ -138,17 +135,19 @@ void G4PhysicsVector::CopyData(const G4PhysicsVector& vec)
useSpline = vec.useSpline;
size_t i;
dataVector.clear();
for(i=0; i<(vec.dataVector).size(); i++){
dataVector.push_back( (vec.dataVector)[i] );
dataVector.resize(numberOfNodes);
for(i=0; i<numberOfNodes; ++i) {
dataVector[i] = (vec.dataVector)[i];
}
binVector.clear();
for(i=0; i<(vec.binVector).size(); i++){
binVector.push_back( (vec.binVector)[i] );
binVector.resize(numberOfNodes);
for(i=0; i<numberOfNodes; ++i) {
binVector[i] = (vec.binVector)[i];
}
secDerivative.clear();
for(i=0; i<(vec.secDerivative).size(); i++){
secDerivative.push_back( (vec.secDerivative)[i] );
if(0 < (vec.secDerivative).size()) {
secDerivative.resize(numberOfNodes);
for(i=0; i<numberOfNodes; ++i){
secDerivative[i] = (vec.secDerivative)[i];
}
}
}
@@ -469,20 +468,16 @@ G4bool G4PhysicsVector::SplinePossible()
// or not ordered than spline cannot be applied
{
G4bool result = true;
secDerivative.clear();
secDerivative.reserve(numberOfNodes);
for(size_t j=0; j<numberOfNodes; ++j)
for(size_t j=1; j<numberOfNodes; ++j)
{
secDerivative.push_back(0.0);
if(j > 0)
{
if(binVector[j]-binVector[j-1] <= 0.) {
result = false;
secDerivative.clear();
break;
}
if(binVector[j] <= binVector[j-1]) {
result = false;
useSpline = false;
secDerivative.clear();
break;
}
}
secDerivative.resize(numberOfNodes,0.0);
return result;
}
@@ -507,8 +502,7 @@ std::ostream& operator<<(std::ostream& out, const G4PhysicsVector& pv)
//---------------------------------------------------------------
G4double
G4PhysicsVector::Value(G4double theEnergy, size_t& lastIdx) const
G4double G4PhysicsVector::Value(G4double theEnergy, size_t& lastIdx) const
{
G4double y;
if(theEnergy <= edgeMin) {
+13 -10
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Pow.cc 74256 2013-10-02 14:24:02Z gcosmo $
// $Id: G4Pow.cc 83383 2014-08-21 14:20:37Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -44,7 +44,9 @@
// -------------------------------------------------------------------
#include "G4Pow.hh"
#ifdef G4MULTITHREADED
#include "G4Threading.hh"
#endif
G4Pow* G4Pow::fpInstance = 0;
@@ -54,7 +56,8 @@ G4Pow* G4Pow::GetInstance()
{
if (fpInstance == 0)
{
fpInstance = new G4Pow;
static G4Pow geant4pow;
fpInstance = &geant4pow;
}
return fpInstance;
}
@@ -63,12 +66,14 @@ G4Pow* G4Pow::GetInstance()
G4Pow::G4Pow()
: onethird(1.0/3.0), max2(5)
{
if(G4Threading::IsWorkerThread() == true) {
G4Exception ("G4Pow::G4Pow()", "glob090", FatalException,
"Attempt to instantiate G4Pow in worker thread");
{
#ifdef G4MULTITHREADED
if(G4Threading::IsWorkerThread())
{
G4Exception ("G4Pow::G4Pow()", "InvalidSetup", FatalException,
"Attempt to instantiate G4Pow in worker thread!");
}
#endif
const G4int maxZ = 512;
const G4int maxZfact = 170;
@@ -116,9 +121,7 @@ G4Pow::G4Pow()
// -------------------------------------------------------------------
G4Pow::~G4Pow()
{
delete fpInstance; fpInstance = 0;
}
{}
// -------------------------------------------------------------------
+37 -11
View File
@@ -35,6 +35,10 @@
// ---------------------------------------------------------------
#include "G4Threading.hh"
#include "G4AutoDelete.hh"
#include "G4AutoLock.hh"
#include "globals.hh"
#if defined (WIN32)
#include <Windows.h>
#else
@@ -45,10 +49,10 @@
#if defined(G4MULTITHREADED)
#include <map>
namespace {
G4ThreadLocal G4int G4ThreadID = -1;
namespace
{
G4ThreadLocal G4int G4ThreadID = G4Threading::MASTER_ID;
G4bool isMTAppType = false;
}
G4Pid_t G4Threading::G4GetPidId()
@@ -84,14 +88,34 @@ BOOL G4ReleaseMutex( __in G4Mutex m)
{ return ReleaseMutex(m); }
#endif
#else // Sequential mode
#if defined(__linux__) || defined(_AIX)
G4bool G4Threading::G4SetPinAffinity(G4int cpu, G4Thread& aT)
{
cpu_set_t* aset = new cpu_set_t;
G4AutoDelete::Register(aset);
CPU_ZERO(aset);
CPU_SET(cpu,aset);
return ( pthread_setaffinity_np(aT, sizeof(cpu_set_t), aset) == 0 );
}
#else //Not available for Mac, WIN,...
G4bool G4Threading::G4SetPinAffinity(G4int, G4Thread&)
{
G4Exception("G4Threading::G4SetPinAffinity()",
"NotImplemented", JustWarning,
"Affinity setting not available for this architecture, ignoring...");
return true;
}
#endif
#include "globals.hh"
void G4Threading::SetMultithreadedApplication(G4bool value ) { isMTAppType = value; }
G4bool G4Threading::IsMultithreadedApplication() { return isMTAppType; }
#else // Sequential mode
G4int fake_mutex_lock_unlock( G4Mutex* ) { return 0; }
G4Pid_t G4Threading::G4GetPidId() // In sequential mode return Process ID and not Thread ID
{
G4Pid_t G4Threading::G4GetPidId()
{ // In sequential mode return Process ID and not Thread ID
#if defined(WIN32)
return GetCurrentProcessId();
#else
@@ -100,10 +124,12 @@ G4Pid_t G4Threading::G4GetPidId() // In sequential mode return Process ID and n
}
G4int G4Threading::G4GetNumberOfCores() { return 1; }
G4int G4Threading::G4GetThreadId() { return -2; }
G4int G4Threading::G4GetThreadId() { return G4Threading::SEQUENTIAL_ID; }
G4bool G4Threading::IsWorkerThread() { return false; }
void G4Threading::G4SetThreadId(G4int) {}
G4bool G4Threading::G4SetPinAffinity(G4int,G4Thread&) { return true;}
void G4Threading::SetMultithreadedApplication(G4bool) {}
G4bool G4Threading::IsMultithreadedApplication() { return false; }
#endif
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4coutDestination.cc 67970 2013-03-13 10:10:06Z gcosmo $
// $Id: G4coutDestination.cc 82279 2014-06-13 14:44:00Z gcosmo $
//
//
// ----------------------------------------------------------------------
@@ -33,6 +33,8 @@
#include "G4coutDestination.hh"
G4coutDestination* G4coutDestination::masterG4coutDestination = 0;
G4coutDestination::G4coutDestination()
{
}
+17 -5
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4ios.cc 70021 2013-05-22 07:55:29Z gcosmo $
// $Id: G4ios.cc 78780 2014-01-23 13:55:15Z gcosmo $
//
//
// --------------------------------------------------------------
@@ -57,10 +57,22 @@
void G4iosFinalization()
{
delete G4cout_p;
delete G4cerr_p;
delete G4coutbuf_p;
delete G4cerrbuf_p;
delete G4cout_p; G4cout_p = 0;
delete G4cerr_p; G4cerr_p = 0;
delete G4coutbuf_p; G4coutbuf_p = 0;
delete G4cerrbuf_p; G4cerrbuf_p = 0;
}
// These two functions are guaranteed to be called at load and
// unload of the library containing this code.
namespace
{
#ifndef WIN32
void setupG4ioSystem(void) __attribute__ ((constructor));
void cleanupG4ioSystem(void) __attribute__((destructor));
#endif
void setupG4ioSystem(void) { G4iosInitialization(); }
void cleanupG4ioSystem(void) { G4iosFinalization(); }
}
#else // Sequential