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
@@ -15,6 +15,22 @@ track of all tags.
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
15/6/2018 Gabriele Cosmo (ThreadsafeScorers-V10-04-03)
- Fixed shadowing warnings in G4atomic.hh header.
6/6/2018 Jonathan Madsen (ThreadsafeScorers-V10-04-02)
- TSPhysicsLists no longer declares G4VPhysicsConstructors in header
- Added TiMemory timing to TSPrimaryGeneratorAction and G4Run
- Added TiMemory ASCII output and serialization to ts_scorers.cc
10/05/2018 Ben Morban (ThreadsafeScorers-V10-04-01)
- Include G4Types before use of G4MULTITHREADED. For forward
compatibility with move to #defines over -D for G4 preprocessor
symbols.
12/2/2018 Jonathan Madsen (ThreadsafeScorers-V10-04-00)
- Removed G4MUTEX_INITIALIZER from constructors of G4TAtomicHits{Collection,Map}
12/8/17 Hisaya Kurashige (ThreadsafeScorers-V10-03-02)
- Add inclusion of <deque> in TSPhysicsList.hh
@@ -161,15 +161,14 @@ protected:
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <class T>
G4TAtomicHitsCollection<T>::G4TAtomicHitsCollection()
: theCollection(new container_type), fMutex(G4MUTEX_INITIALIZER)
: theCollection(new container_type)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <class T>
G4TAtomicHitsCollection<T>::G4TAtomicHitsCollection(G4String detName,
G4String colNam)
: G4VHitsCollection(detName,colNam),
theCollection(new container_type),
fMutex(G4MUTEX_INITIALIZER)
theCollection(new container_type)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <class T> G4TAtomicHitsCollection<T>::~G4TAtomicHitsCollection()
@@ -178,7 +177,6 @@ template <class T> G4TAtomicHitsCollection<T>::~G4TAtomicHitsCollection()
delete (*theCollection)[i];
theCollection->clear();
delete theCollection;
G4MUTEXDESTROY(fMutex);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <class T>
@@ -153,16 +153,14 @@ private:
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <typename T>
G4TAtomicHitsMap<T>::G4TAtomicHitsMap()
: theCollection(new container_type),
fMutex(G4MUTEX_INITIALIZER)
: theCollection(new container_type)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <typename T>
G4TAtomicHitsMap<T>::G4TAtomicHitsMap(G4String detName,
G4String colNam)
: G4VHitsCollection(detName,colNam),
theCollection(new container_type),
fMutex(G4MUTEX_INITIALIZER)
theCollection(new container_type)
{ }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <typename T>
@@ -172,7 +170,6 @@ G4TAtomicHitsMap<T>::~G4TAtomicHitsMap()
delete itr->second;
delete theCollection;
G4MUTEXDESTROY(fMutex);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
template <typename T>
@@ -80,28 +80,31 @@
template<typename _Tp>
class G4atomic
{
public:
public:
typedef typename std::atomic<_Tp> base_type;
typedef _Tp value_type;
private:
using mem_odr = std::memory_order;
private:
using mem_ord = std::memory_order;
public:
public:
// constructors
explicit
G4atomic(mem_odr odr = std::memory_order_acq_rel) : fMemOrder(odr)
G4atomic(mem_ord mo = std::memory_order_acq_rel) : fMemOrder(mo)
{ atomics::set(&fvalue, value_type()); }
explicit
G4atomic(const value_type& _init,
mem_odr odr = std::memory_order_acq_rel) : fMemOrder(odr)
mem_ord mo = std::memory_order_acq_rel) : fMemOrder(mo)
{ atomics::set(&fvalue, _init); }
// copy-constructor from pure C++11 atomic
explicit
G4atomic(const base_type& rhs,
mem_odr odr = std::memory_order_acq_rel) : fMemOrder(odr)
mem_ord mo = std::memory_order_acq_rel) : fMemOrder(mo)
{ atomics::set(&fvalue, rhs); }
// copy-constructor
@@ -143,20 +146,16 @@ public:
bool is_lock_free() const volatile { return fvalue.is_lock_free(); }
// store functions
void store(_Tp _desired, std::memory_order mem_odr
= std::memory_order_seq_cst)
{ atomics::set(fvalue, _desired, mem_odr); }
void store(_Tp _desired, std::memory_order mem_odr
= std::memory_order_seq_cst) volatile
{ atomics::set(fvalue, _desired, mem_odr); }
void store(_Tp _desired, mem_ord mo = std::memory_order_seq_cst)
{ atomics::set(fvalue, _desired, mo); }
void store(_Tp _desired, mem_ord mo = std::memory_order_seq_cst) volatile
{ atomics::set(fvalue, _desired, mo); }
// load functions
_Tp load(std::memory_order mem_odr
= std::memory_order_seq_cst) const
{ return atomics::get(fvalue, mem_odr); }
_Tp load(std::memory_order mem_odr
= std::memory_order_seq_cst) const volatile
{ return atomics::get(fvalue, mem_odr); }
_Tp load(mem_ord mo = std::memory_order_seq_cst) const
{ return atomics::get(fvalue, mo); }
_Tp load(mem_ord mo = std::memory_order_seq_cst) const volatile
{ return atomics::get(fvalue, mo); }
// implicit conversion functions
operator _Tp() const { return this->load(); }
@@ -166,39 +165,33 @@ public:
// compare-and-swap functions
bool compare_exchange_weak(_Tp& _expected, _Tp _desired,
std::memory_order _success,
std::memory_order _failure)
mem_ord _success, mem_ord _failure)
{ return fvalue.compare_exchange_weak(_expected, _desired,
_success, _failure); }
bool compare_exchange_weak(_Tp& _expected, _Tp _desired,
std::memory_order _success,
std::memory_order _failure) volatile
mem_ord _success, mem_ord _failure) volatile
{ return fvalue.compare_exchange_weak(_expected, _desired,
_success, _failure); }
bool compare_exchange_weak(_Tp& _expected, _Tp _desired,
std::memory_order _order)
bool compare_exchange_weak(_Tp& _expected, _Tp _desired, mem_ord _order)
{ return fvalue.compare_exchange_weak(_expected, _desired, _order); }
bool compare_exchange_weak(_Tp& _expected, _Tp _desired,
std::memory_order _order) volatile
mem_ord _order) volatile
{ return fvalue.compare_exchange_weak(_expected, _desired, _order); }
bool compare_exchange_strong(_Tp& _expected, _Tp _desired,
std::memory_order _success,
std::memory_order _failure)
mem_ord _success, mem_ord _failure)
{ return fvalue.compare_exchange_weak(_expected, _desired,
_success, _failure); }
bool compare_exchange_strong(_Tp& _expected, _Tp _desired,
std::memory_order _success,
std::memory_order _failure) volatile
mem_ord _success, mem_ord _failure) volatile
{ return fvalue.compare_exchange_weak(_expected, _desired,
_success, _failure); }
bool compare_exchange_strong(_Tp& _expected, _Tp _desired,
std::memory_order _order)
bool compare_exchange_strong(_Tp& _expected, _Tp _desired, mem_ord _order)
{ return fvalue.compare_exchange_weak(_expected, _desired, _order); }
bool compare_exchange_strong(_Tp& _expected, _Tp _desired,
std::memory_order _order) volatile
mem_ord _order) volatile
{ return fvalue.compare_exchange_weak(_expected, _desired, _order); }
// value_type operators
@@ -258,9 +251,10 @@ public:
value_type operator--(int)
{ value_type _tmp = fvalue--; return _tmp; }
protected:
protected:
base_type fvalue;
mem_odr fMemOrder;
mem_ord fMemOrder;
};
@@ -47,14 +47,7 @@
#include "globals.hh"
#include "G4VUserPhysicsList.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "G4HadronPhysicsQGSP_BERT_HP.hh"
#include "G4HadronElasticPhysicsHP.hh"
#include "G4IonElasticPhysics.hh"
#include "G4IonBinaryCascadePhysics.hh"
#include "G4DecayPhysics.hh"
#include "G4VPhysicsConstructor.hh"
#include <deque>
class TSPhysicsList : public G4VUserPhysicsList
@@ -66,26 +59,15 @@ public:
TSPhysicsList();
virtual ~TSPhysicsList();
static TSPhysicsList* Instance();
public:
static TSPhysicsList* Instance();
void ConstructParticle();
void ConstructProcess();
void SetCuts();
private:
static TSPhysicsList* fgInstance;
G4EmStandardPhysics_option4* fEmPhysics_opt4;
G4DecayPhysics* fDecayPhysics;
G4RadioactiveDecayPhysics* fRadDecayPhysics;
G4HadronPhysicsQGSP_BERT_HP* fHadronInelasticPhysics;
G4HadronElasticPhysicsHP* fHadronElasticPhysics;
G4IonElasticPhysics* fIonElasticPhysics;
G4IonBinaryCascadePhysics* fIonBinaryCascadePhysics;
PhysicsSet_t fConstructors;
G4double fDefaultCutValue;
};
@@ -71,6 +71,18 @@
#include "G4StepLimiter.hh"
// Constructors
#include "G4EmStandardPhysics_option3.hh"
#include "G4EmStandardPhysics_option4.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "G4HadronPhysicsQGSP_BERT.hh"
#include "G4HadronPhysicsQGSP_BERT_HP.hh"
#include "G4HadronElasticPhysics.hh"
#include "G4HadronElasticPhysicsHP.hh"
#include "G4IonElasticPhysics.hh"
#include "G4IonBinaryCascadePhysics.hh"
#include "G4DecayPhysics.hh"
#include <set>
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -87,26 +99,17 @@ TSPhysicsList* TSPhysicsList::Instance()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
TSPhysicsList::TSPhysicsList()
: fEmPhysics_opt4(new G4EmStandardPhysics_option4),
fDecayPhysics(new G4DecayPhysics),
fRadDecayPhysics(new G4RadioactiveDecayPhysics),
fHadronInelasticPhysics(new G4HadronPhysicsQGSP_BERT_HP),
fHadronElasticPhysics(new G4HadronElasticPhysicsHP),
fIonElasticPhysics(new G4IonElasticPhysics),
fIonBinaryCascadePhysics(new G4IonBinaryCascadePhysics),
fDefaultCutValue(1.*CLHEP::mm)
: fDefaultCutValue(1.*CLHEP::mm)
{
fgInstance = this;
fConstructors.push_back(fEmPhysics_opt4);
fConstructors.push_back(fDecayPhysics);
fConstructors.push_back(fRadDecayPhysics);
fConstructors.push_back(fHadronInelasticPhysics);
fConstructors.push_back(fHadronElasticPhysics);
fConstructors.push_back(fIonElasticPhysics);
fConstructors.push_back(fIonBinaryCascadePhysics);
fConstructors.push_back(new G4EmStandardPhysics_option4);
fConstructors.push_back(new G4DecayPhysics);
fConstructors.push_back(new G4RadioactiveDecayPhysics);
fConstructors.push_back(new G4HadronPhysicsQGSP_BERT_HP);
fConstructors.push_back(new G4HadronElasticPhysicsHP);
fConstructors.push_back(new G4IonElasticPhysics);
fConstructors.push_back(new G4IonBinaryCascadePhysics);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -46,6 +46,7 @@
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4TiMemory.hh"
using namespace CLHEP;
@@ -76,6 +77,7 @@ TSPrimaryGeneratorAction::~TSPrimaryGeneratorAction()
void TSPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
TIMEMORY_AUTO_TIMER();
static TSDetectorConstruction* detector
= TSDetectorConstruction::Instance();
@@ -58,6 +58,7 @@
#include "G4SDManager.hh"
#include "G4MultiFunctionalDetector.hh"
#include "G4VPrimitiveScorer.hh"
#include "G4TiMemory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -153,43 +154,50 @@ void TSRun::RecordEvent(const G4Event* aEvent)
{
G4Run::RecordEvent(aEvent);
//=============================
// HitsCollection of This Event
//============================
G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
if (!HCE) return;
//=============================
// HitsCollection of This Event
//============================
G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
if (!HCE) return;
for(unsigned i = 0; i < fCollIDs.size(); ++i)
{
G4int fCollID = fCollIDs.at(i);
//=======================================================
// Sum up HitsMap of this Event into HitsMap of this RUN
//=======================================================
G4THitsMap<G4double>* EvtMap = 0;
if ( fCollID >= 0 ) // Collection is attached to HCE
EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID));
else
G4cout <<" Error EvtMap Not Found " << G4endl;
if ( EvtMap )
for(unsigned i = 0; i < fCollIDs.size(); ++i)
{
//=== Sum up HitsMap of this event to HitsMap of RUN.===
*fRunMaps[fCollID] += *EvtMap;
// atomic run map
*fAtomicRunMaps[fCollID] += *EvtMap;
// mutex run map
static G4Mutex mtx = G4MUTEX_INITIALIZER;
{
G4AutoLock lock(&mtx);
for(const auto& itr : *EvtMap)
{
fMutexRunMaps[fCollNames[fCollID]][itr.first] += *itr.second;
}
}
//----------------------------------------------------------------//
}
G4int fCollID = fCollIDs.at(i);
//=======================================================
// Sum up HitsMap of this Event into HitsMap of this RUN
//=======================================================
G4THitsMap<G4double>* EvtMap = 0;
if ( fCollID >= 0 ) // Collection is attached to HCE
EvtMap = static_cast<G4THitsMap<G4double>*>(HCE->GetHC(fCollID));
else
G4cout <<" Error EvtMap Not Found " << G4endl;
}
if ( EvtMap )
{
//=== Sum up HitsMap of this event to HitsMap of RUN.===
{
TIMEMORY_AUTO_TIMER("[standard_run_map]");
*fRunMaps[fCollID] += *EvtMap;
}
// atomic run map
{
TIMEMORY_AUTO_TIMER("[atomic_run_map]");
*fAtomicRunMaps[fCollID] += *EvtMap;
}
TIMEMORY_AUTO_TIMER("[mutex_run_map]");
// mutex run map
static G4Mutex mtx = G4MUTEX_INITIALIZER;
{
G4AutoLock lock(&mtx);
for(const auto& itr : *EvtMap)
{
fMutexRunMaps[fCollNames[fCollID]][itr.first]
+= *itr.second;
}
}
//----------------------------------------------------------------//
}
}
}
@@ -156,6 +156,13 @@ void TSRunAction::EndOfRunAction(const G4Run* aRun)
} else {
valid = false;
}
if(!valid)
{
G4Exception("TSRunAction", "000", JustWarning,
G4String(primScorerNames.at(i) +
" HitsMap is either not "
"created or the HitsMap was empty").c_str());
}
} else {
G4TAtomicHitsMap<G4double>* hitmap
= tsRun->GetAtomicHitsMap(fName + "/" +
@@ -176,7 +183,7 @@ void TSRunAction::EndOfRunAction(const G4Run* aRun)
}
if(!valid)
{
G4Exception("TSRunAction", "000", JustWarning,
G4Exception("TSRunAction", "001", JustWarning,
G4String(primScorerNames.at(i) +
" HitsMap is either not "
"created or the HitsMap was empty").c_str());
File diff suppressed because it is too large Load Diff
@@ -44,6 +44,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#include "G4Types.hh"
#ifdef G4MULTITHREADED
#include "G4MTRunManager.hh"
@@ -64,6 +65,7 @@
#include "G4UImanager.hh"
#include "G4VisExecutive.hh"
#include "G4UIExecutive.hh"
#include "G4TiMemory.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -134,11 +136,21 @@ int main(int argc, char** argv)
delete ui;
}
#ifdef GEANT4_USE_TIMEMORY
G4cout << "\nOutputting TiMemory results...\n" << G4endl;
tim::manager* manager = tim::manager::instance();
manager->write_report(std::cout, true);
std::string fname = argv[0];
std::string rfname = fname + ".txt";
std::string sfname = fname + ".json";
manager->write_report(rfname);
manager->write_serialization(sfname);
#endif
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runmanager;