Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MolecularConfiguration.cc 94289 2015-11-11 08:33:40Z gcosmo $
// $Id: G4MolecularConfiguration.cc 101354 2016-11-15 08:27:51Z gcosmo $
//
// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
//
@@ -1557,6 +1557,8 @@ G4MolecularConfiguration::GetMolecularConfiguration(const G4String& userID)
return GetManager()->GetMolecularConfiguration(userID);
}
//______________________________________________________________________________
void G4MolecularConfiguration::FinalizeAll()
{
const std::vector<G4MolecularConfiguration*>& species =
@@ -22,7 +22,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Molecule.cc 93883 2015-11-03 08:25:04Z gcosmo $
// $Id: G4Molecule.cc 100802 2016-11-02 14:55:27Z gcosmo $
//
// ---------------------------------------------------------------------
// GEANT 4 class header file
@@ -53,7 +53,7 @@
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#include "G4Track.hh"
#include "G4MoleculeCounter.hh"
#include "G4VMoleculeCounter.hh"
using namespace std;
@@ -154,10 +154,12 @@ G4Molecule::~G4Molecule()
{
if (fpTrack != NULL)
{
if (G4MoleculeCounter::GetMoleculeCounter()->InUse())
if (G4VMoleculeCounter::Instance()->InUse())
{
G4MoleculeCounter::GetMoleculeCounter()->RemoveAMoleculeAtTime(
fpMolecularConfiguration, fpTrack->GetGlobalTime());
G4VMoleculeCounter::Instance()->
RemoveAMoleculeAtTime(fpMolecularConfiguration,
fpTrack->GetGlobalTime(),
&(fpTrack->GetPosition()));
}
fpTrack = 0;
}
@@ -174,7 +176,8 @@ G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
//////////////////////////
{
fpMolecularConfiguration =
G4MolecularConfiguration::GetOrCreateMolecularConfiguration(moleculeDefinition);
G4MolecularConfiguration::
GetOrCreateMolecularConfiguration(moleculeDefinition);
}
//______________________________________________________________________________
@@ -182,8 +185,9 @@ G4Molecule::G4Molecule(G4MoleculeDefinition * moleculeDefinition) :
G4Molecule::G4Molecule(G4MoleculeDefinition* moleculeDefinition, int charge)
{
fpMolecularConfiguration =
G4MolecularConfiguration::GetOrCreateMolecularConfiguration(moleculeDefinition,
charge);
G4MolecularConfiguration::
GetOrCreateMolecularConfiguration(moleculeDefinition,
charge);
}
//______________________________________________________________________________
@@ -380,8 +384,7 @@ void G4Molecule::PrintState() const
G4Track * G4Molecule::BuildTrack(G4double globalTime,
const G4ThreeVector& position)
{
if (fpTrack != 0)
{
if (fpTrack != 0){
G4Exception("G4Molecule::BuildTrack", "Molecule001", FatalErrorInArgument,
"A track was already assigned to this molecule");
}
@@ -403,10 +406,11 @@ G4Track * G4Molecule::BuildTrack(G4double globalTime,
fpMolecularConfiguration->GetDefinition(), MomentumDirection,
KineticEnergy);
if (G4MoleculeCounter::InUse())
{
G4MoleculeCounter::GetMoleculeCounter()->AddAMoleculeAtTime(fpMolecularConfiguration,
globalTime);
if (G4VMoleculeCounter::InUse()){
G4VMoleculeCounter::Instance()->
AddAMoleculeAtTime(fpMolecularConfiguration,
globalTime,
&(fpTrack->GetPosition()));
}
//Set the Track
@@ -23,34 +23,30 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MoleculeCounter.cc 96699 2016-05-02 07:20:47Z gcosmo $
// $Id: G4MoleculeCounter.cc 101354 2016-11-15 08:27:51Z gcosmo $
//
#include <iomanip>
#include "G4MoleculeCounter.hh"
#include "G4MoleculeTable.hh"
#include "G4UIcommand.hh"
#include "G4UnitsTable.hh"
#include "G4MolecularConfiguration.hh"
#include "G4MoleculeDefinition.hh"
#include <iomanip>
#include "G4SystemOfUnits.hh"
#include "G4Scheduler.hh" // TODO: remove this dependency
using namespace std;
G4ThreadLocal double compDoubleWithPrecision::fPrecision = 0;
G4bool G4MoleculeCounter::fUse = false;
G4ThreadLocal G4MoleculeCounter* G4MoleculeCounter::fpInstance = 0;
void G4MoleculeCounter::Use(G4bool flag)
{
fUse=flag;
}
G4bool G4MoleculeCounter::InUse()
{
return fUse;
//------------------------------------------------------------------------------
G4MoleculeCounter* G4MoleculeCounter::Instance(){
if (!fpInstance) fpInstance = new G4MoleculeCounter();
return dynamic_cast<G4MoleculeCounter*>(fpInstance);
}
//------------------------------------------------------------------------------
G4MoleculeCounter::G4MoleculeCounter()
{
@@ -62,40 +58,18 @@ G4MoleculeCounter::G4MoleculeCounter()
}
}
//------------------------------------------------------------------------------
G4MoleculeCounter::~G4MoleculeCounter()
{
}
G4MoleculeCounter* G4MoleculeCounter::GetMoleculeCounter()
{
if (!fpInstance) fpInstance = new G4MoleculeCounter();
return fpInstance;
}
G4MoleculeCounter* G4MoleculeCounter::Instance()
{
if (!fpInstance) fpInstance = new G4MoleculeCounter();
return fpInstance;
}
void G4MoleculeCounter::DeleteInstance()
{
if (fpInstance)
{
delete fpInstance;
fpInstance = 0;
}
}
void G4MoleculeCounter::InitializeInstance()
{
if(fpInstance) fpInstance->Initialize();
}
//------------------------------------------------------------------------------
void G4MoleculeCounter::Initialize()
{
// G4cout << "G4MoleculeCounter::Initialize" << G4endl;
G4ConfigurationIterator mol_iterator = G4MoleculeTable::Instance()
->GetConfigurationIterator();
while ((mol_iterator)())
@@ -104,17 +78,22 @@ void G4MoleculeCounter::Initialize()
{
continue;
}
// G4cout << "G4MoleculeCounter::Initialize" << G4endl;
// G4cout << mol_iterator->value()->GetName() << G4endl;
fCounterMap[mol_iterator.value()]; // initialize the second map
}
}
//------------------------------------------------------------------------------
void G4MoleculeCounter::SetTimeSlice(double timeSlice)
{
compDoubleWithPrecision::fPrecision = timeSlice;
}
//------------------------------------------------------------------------------
G4bool G4MoleculeCounter::SearchTimeMap(G4MolecularConfiguration* molecule)
{
if (fpLastSearch.get() == 0)
@@ -145,6 +124,8 @@ G4bool G4MoleculeCounter::SearchTimeMap(G4MolecularConfiguration* molecule)
return false;
}
//------------------------------------------------------------------------------
int G4MoleculeCounter::SearchUpperBoundTime(double time,
bool sameTypeOfMolecule)
{
@@ -162,8 +143,6 @@ int G4MoleculeCounter::SearchUpperBoundTime(double time,
if (fpLastSearch->fLowerBoundSet && fpLastSearch->fLowerBoundTime
!= end_time)
{
//G4cout << fpLastSearch->fLowerBoundTime->first << G4endl;
// G4cout << "fpLastSearch->fLowerBoundTime != timeMap.end() " << time << G4endl;
if (fpLastSearch->fLowerBoundTime->first < time)
{
NbMoleculeAgainstTime::iterator upperToLast = fpLastSearch
@@ -185,9 +164,7 @@ int G4MoleculeCounter::SearchUpperBoundTime(double time,
/*
else
{
G4cout << "\n" << G4endl;
G4cout << "Molecule has changed" << G4endl;
G4cout << "\n" << G4endl;
G4cout << "--> Molecule has changed" << G4endl;
}
*/
//G4cout << "Searching" << G4endl;
@@ -198,7 +175,6 @@ int G4MoleculeCounter::SearchUpperBoundTime(double time,
{
NbMoleculeAgainstTime::reverse_iterator last_time = timeMap.rbegin();
// if (last_time->first <= time)
// {
//G4cout << "RETURN LAST : " << G4BestUnit(time, "Time") << G4endl;
return last_time->second;
@@ -227,21 +203,25 @@ int G4MoleculeCounter::SearchUpperBoundTime(double time,
return fpLastSearch->fLowerBoundTime->second;
}
//------------------------------------------------------------------------------
int G4MoleculeCounter::GetNMoleculesAtTime(G4MolecularConfiguration* molecule,
double time)
{
G4bool sameTypeOfMolecule = SearchTimeMap(molecule);
return SearchUpperBoundTime(time, sameTypeOfMolecule);
// NbMoleculeAgainstTime::iterator low_time_it = timeMap.lower_bound(time);
}
//------------------------------------------------------------------------------
void G4MoleculeCounter::AddAMoleculeAtTime(G4MolecularConfiguration* molecule,
G4double time, int number)
G4double time,
const G4ThreeVector* /*position*/,
int number)
{
if (fDontRegister[molecule->GetDefinition()]) return;
if (fVerbose)
{
if (fVerbose){
G4cout << "G4MoleculeCounter::AddAMoleculeAtTime : " << molecule->GetName()
<< " at time : " << G4BestUnit(time, "Time") << G4endl;
}
@@ -249,27 +229,14 @@ void G4MoleculeCounter::AddAMoleculeAtTime(G4MolecularConfiguration* molecule,
CounterMapType::iterator counterMap_i =
fCounterMap.find(molecule);
if (counterMap_i == fCounterMap.end())
{
// DEBUG
// if(fVerbose) G4cout << " !! ***** Map is empty " << G4endl;
if (counterMap_i == fCounterMap.end()){
fCounterMap[molecule][time] = number;
}
else if (counterMap_i->second.empty())
{
// DEBUG
// if(fVerbose) G4cout << " !! ***** Map is empty " << G4endl;
else if (counterMap_i->second.empty()){
counterMap_i->second[time] = number;
// G4cout << " !! New N = " << number << G4endl;
}
else
{
else{
NbMoleculeAgainstTime::reverse_iterator end = counterMap_i->second.rbegin();
// end--;
// DEBUG
// if(fVerbose)
// G4cout<<"!! End Time = "<< G4BestUnit(end->first, "Time") <<G4endl;
if (end->first <= time ||
fabs(end->first - time) <= compDoubleWithPrecision::fPrecision)
@@ -277,11 +244,7 @@ void G4MoleculeCounter::AddAMoleculeAtTime(G4MolecularConfiguration* molecule,
// Case 2 = new time is about the same as the last recorded one
{
double newValue = end->second + number;
// G4cout << " !! New N = " << newValue << G4endl;
counterMap_i->second[time] = newValue;
// double newValue = end->second + number;
// G4cout << " !! New N = " << end->second + number << G4endl;
// counterMap_i->second[time] = end->second + number;
}
else
{
@@ -299,44 +262,17 @@ void G4MoleculeCounter::AddAMoleculeAtTime(G4MolecularConfiguration* molecule,
"TIME_DONT_MATCH",
FatalException, errMsg);
}
// NbMoleculeAgainstTime::iterator it = counterMap_i->second.lower_bound(
// time);
//
// while (it->first > time && it != counterMap_i->second.begin())
// {
// // DEBUG
// // if(fVerbose)
// // G4cout<<"!! ********** Is going back!!!!"<<G4endl;
// it--;
// }
//
// if (it == counterMap_i->second.begin() && it->first > time)
// {
// // DEBUG
// // if(fVerbose)
// // G4cout<<"!! ********** Illegal !!!!"<<G4endl;
// return;
// }
//
// // DEBUG
// // if(fVerbose)
// // {
// // G4cout<<"!! PREVIOUS NB = "<< it->second <<G4endl;
// // G4cout<<"!! PREVIOUS TIME = "<< G4BestUnit(it->first,"Time") <<G4endl;
// // }
// counterMap_i->second[time] = it->second + number;
}
}
// DEBUG
// if(fVerbose)
// G4cout<<"!! NB = "<< fCounterMap[molecule][time]<<G4endl;
}
void G4MoleculeCounter::RemoveAMoleculeAtTime(G4MolecularConfiguration* molecule,
G4double time, int number)
//------------------------------------------------------------------------------
void
G4MoleculeCounter::RemoveAMoleculeAtTime(G4MolecularConfiguration* molecule,
G4double time,
const G4ThreeVector* /*position*/,
int number)
{
if (fDontRegister[molecule->GetDefinition()]) return;
@@ -382,78 +318,17 @@ void G4MoleculeCounter::RemoveAMoleculeAtTime(G4MolecularConfiguration* molecule
else
{
NbMoleculeAgainstTime::reverse_iterator it = nbMolPerTime.rbegin();
// if (nbMolPerTime.size() == 1)
// {
// it = nbMolPerTime.begin();
// // DEBUG
// // if(fVerbose)
// // G4cout << "!! fCounterMap[molecule].size() == 1" << G4endl;
// }
// else
// {
//// it = nbMolPerTime.lower_bound(time);
// it = nbMolPerTime.end();
// --it;
// }
if (it == nbMolPerTime.rend())
{
// DEBUG
// if(fVerbose)
// G4cout << " ********** NO ITERATOR !!!!!!!!! " << G4endl;
if (it == nbMolPerTime.rend()){
it--;
//if (time < it->first)
{
G4String errMsg = "There was no " + molecule->GetName()
+ " recorded at the time or even before the time asked";
G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", "",
FatalErrorInArgument, errMsg);
}
G4String errMsg = "There was no " + molecule->GetName()
+ " recorded at the time or even before the time asked";
G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", "",
FatalErrorInArgument, errMsg);
}
// DEBUG
// if(fVerbose)
// {
//// G4cout << "G4MoleculeCounter::RemoveAMoleculeAtTime " << G4endl;
// G4cout<<"!! Molecule = " << molecule.GetName() << G4endl;
// G4cout<<"!! At Time = "<< G4BestUnit(time,"Time") <<G4endl;
// G4cout<<"!! PREVIOUS TIME = "<< G4BestUnit(it->first,"Time")<<G4endl;
// G4cout<<"!! PREVIOUS Nb = "<< it->second <<G4endl;
// }
// If valgrind problem on the line below, it means that the pointer "it"
// points nowhere
// if (nbMolPerTime.value_comp()(*it, *nbMolPerTime.begin()))
// {
// // DEBUG
// // if(fVerbose)
// // G4cout<<"!! ***** In value_comp ... " << G4endl;
// it++;
// if (time < it->first)
// {
// G4String errMsg = "There was no " + molecule->GetName()
// + " record at the time or even before the time asked";
// G4Exception("G4MoleculeCounter::RemoveAMoleculeAtTime", "",
// FatalErrorInArgument, errMsg);
// }
// }
//
// while (it->first - time > compDoubleWithPrecision::fPrecision
// && it != nbMolPerTime.begin())
// {
// // DEBUG
// // if(fVerbose)
// // {
// // G4cout<<"!! ***** Is going back!!!!"<<G4endl;
// // G4cout<<"!! PREVIOUS TIME = "<< G4BestUnit(it-> first,"Time") <<G4endl;
// // }
// it--;
// }
if (time - it->first < -compDoubleWithPrecision::fPrecision)
{
if (time - it->first < -compDoubleWithPrecision::fPrecision){
Dump();
G4ExceptionDescription errMsg;
errMsg << "Is time going back?? " << molecule->GetName()
@@ -465,26 +340,10 @@ void G4MoleculeCounter::RemoveAMoleculeAtTime(G4MolecularConfiguration* molecule
FatalErrorInArgument,
errMsg);
}
/*
if (it == nbMolPerTime.begin() && it->first > time)
{
// DEBUG
// if(fVerbose)
// G4cout<<"!! ********** Illegal !!!!"<<G4endl;
return;
}
*/
// DEBUG
// if(fVerbose)
// {
// G4cout<<"!! PREVIOUS NB = "<< (*it).second <<G4endl;
// G4cout<<"!! PREVIOUS TIME = "<< G4BestUnit(it->first,"Time")<<G4endl;
// }
double finalN = it->second - number;
if(finalN < 0)
{
if(finalN < 0){
Dump();
G4ExceptionDescription errMsg;
errMsg << "After removal of " << number << " species of "
@@ -502,14 +361,10 @@ void G4MoleculeCounter::RemoveAMoleculeAtTime(G4MolecularConfiguration* molecule
nbMolPerTime[time] = finalN;
}
// DEBUG
// if(fVerbose)
// {
// G4cout<<"!! NB = "<< nbMolPerTime[time]<<G4endl;
// }
}
//------------------------------------------------------------------------------
G4MoleculeCounter::RecordedMolecules G4MoleculeCounter::GetRecordedMolecules()
{
if (fVerbose > 1)
@@ -527,6 +382,8 @@ G4MoleculeCounter::RecordedMolecules G4MoleculeCounter::GetRecordedMolecules()
return output;
}
//------------------------------------------------------------------------------
RecordedTimes G4MoleculeCounter::GetRecordedTimes()
{
RecordedTimes output(new std::set<G4double>);
@@ -554,6 +411,8 @@ RecordedTimes G4MoleculeCounter::GetRecordedTimes()
return output;
}
//------------------------------------------------------------------------------
// >>DEV<<
//void G4MoleculeCounter::SignalReceiver(G4SpeciesInCM* /*speciesInCM*/,
// size_t moleculeID,
@@ -576,6 +435,7 @@ RecordedTimes G4MoleculeCounter::GetRecordedTimes()
// }
//}
//------------------------------------------------------------------------------
void G4MoleculeCounter::Dump()
{
@@ -592,7 +452,8 @@ void G4MoleculeCounter::Dump()
for(;it2!=end2;++it2)
{
G4cout << " "<< G4BestUnit(it2->first, "Time") << " " << it2->second << G4endl;
G4cout << " " << G4BestUnit(it2->first, "Time")
<< " " << it2->second << G4endl;
}
}
}
@@ -69,26 +69,8 @@ G4MoleculeDefinition*
G4MoleculeTable::CreateMoleculeDefinition(const G4String& name,
double diffusion_coefficient)
{
// TODO
MoleculeDefTable::iterator it = fMoleculeDefTable.find(name);
G4MoleculeDefinition* definition(0);
if (it == fMoleculeDefTable.end())
{
definition = new G4MoleculeDefinition(name, -1 /* mass*/,
diffusion_coefficient);
fMoleculeDefTable[name] = definition;
}
else
{
// exception
G4ExceptionDescription description;
description << "The molecule definition " << name
<< " was already recorded in the table" << G4endl;
G4Exception("G4MoleculeTable::CreateMoleculeDefinition",
"DEFINITION_ALREADY_CREATED", FatalException, description);
}
return definition;
return new G4MoleculeDefinition(name, -1 /* mass*/,
diffusion_coefficient);
}
//------------------------------------------------------------------------------
@@ -272,11 +254,15 @@ void G4MoleculeTable::Finalize()
G4MolecularConfiguration::FinalizeAll();
}
//------------------------------------------------------------------------------
G4ConfigurationIterator G4MoleculeTable::GetConfigurationIterator()
{
return G4ConfigurationIterator(G4MolecularConfiguration::GetUserIDTable());
}
//------------------------------------------------------------------------------
int G4MoleculeTable::GetNumberOfDefinedSpecies()
{
return G4MolecularConfiguration::GetNumberOfSpecies();
@@ -23,30 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4VMolecularDissociationDisplacer.cc 85244 2014-10-27 08:24:13Z gcosmo $
// $Id: G4VMolecularDissociationDisplacer.cc 101423 2016-11-17 10:42:09Z gcosmo $
//
#include "G4VMolecularDissociationDisplacer.hh"
#include "G4Molecule.hh"
DisplacementType *G4VMolecularDecayDisplacer::Last = 0;
const DisplacementType G4VMolecularDecayDisplacer::NoDisplacement =
G4VMolecularDecayDisplacer::AddDisplacement();
G4CT_COUNT_INIT_IMPL(G4VMolecularDecayDisplacer, 0)
G4CT_COUNT_IMPL(G4VMolecularDecayDisplacer, NoDisplacement)
G4VMolecularDecayDisplacer::G4VMolecularDecayDisplacer()
{
if (!Last) Last = new DisplacementType(0);
//------------------------------------------------------------------------------
G4VMolecularDecayDisplacer::G4VMolecularDecayDisplacer(){
fVerbose = 0;
}
G4VMolecularDecayDisplacer::~G4VMolecularDecayDisplacer()
{
;
}
DisplacementType G4VMolecularDecayDisplacer::AddDisplacement()
{
if (!Last) Last = new DisplacementType(0);
DisplacementType output = *Last;
(*Last)++;
return output;
}
{;}
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// G4VMoleculeCounter.cc
// Geant4
//
// Created by Mathieu Karamitros on 02/11/2016.
//
//
#include "G4VMoleculeCounter.hh"
#include "G4MoleculeCounter.hh"
using namespace std;
G4bool G4VMoleculeCounter::fUse = false;
G4ThreadLocal
G4VMoleculeCounter* G4VMoleculeCounter::fpInstance = 0;
//------------------------------------------------------------------------------
void
G4VMoleculeCounter::SetInstance(G4VMoleculeCounter* instance)
{
if (fpInstance!=0){
G4ExceptionDescription errMsg;
errMsg<< "The G4MoleculeCounter was already initialized." << G4endl
<< "The previous instance will be deleted in order to use yours." << G4endl
<< "However this can generate conflicts. Make sure you call G4MoleculeCounter::SetInstance at the beginning of your application."
<< "A good place would be ActionInitialization::Build & BuildForMaster"
<< G4endl;
G4Exception("G4MoleculeCounter::SetInstance",
"SINGLETON_ALREADY_INITIALIZED",
JustWarning, errMsg);
delete fpInstance;
fpInstance = 0;
}
fpInstance = instance;
}
//------------------------------------------------------------------------------
G4VMoleculeCounter* G4VMoleculeCounter::Instance()
{
if (!fpInstance) fpInstance = new G4MoleculeCounter();
return fpInstance;
}
//------------------------------------------------------------------------------
void G4VMoleculeCounter::DeleteInstance()
{
if (fpInstance){
delete fpInstance;
fpInstance = 0;
}
}
//------------------------------------------------------------------------------
void G4VMoleculeCounter::InitializeInstance()
{
if(fpInstance) fpInstance->Initialize();
}
//------------------------------------------------------------------------------
void G4VMoleculeCounter::Use(G4bool flag)
{
fUse=flag;
}
//------------------------------------------------------------------------------
G4bool G4VMoleculeCounter::InUse()
{
return fUse;
}