Import Geant4 3.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-08 15:55:53 +02:00
parent e7d7193284
commit cfcb558cfe
3050 changed files with 91703 additions and 48310 deletions
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Run.cc,v 1.1.10.1 1999/12/07 20:52:59 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4Run.cc,v 1.2 1999/12/15 14:53:53 gunter Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4Run.hh"
+13 -10
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4RunManager.cc,v 1.15 2000/06/28 10:25:54 gcosmo Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4RunManager.cc,v 1.18 2000/12/14 10:38:14 gcosmo Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
//
@@ -52,7 +52,7 @@ G4RunManager::G4RunManager()
currentRun(NULL),currentEvent(NULL),n_perviousEventsToBeStored(0),
geometryInitialized(false),physicsInitialized(false),cutoffInitialized(false),
geometryNeedsToBeClosed(true),initializedAtLeastOnce(false),
runAborted(false),pauseAtBeginOfEvent(false),pauseAtEndOfEvent(false),
runAborted(false),
geometryToBeOptimized(true),verboseLevel(0),DCtable(NULL),runIDCounter(0),
storeRandomNumberStatus(0)
{
@@ -66,10 +66,11 @@ G4RunManager::G4RunManager()
previousEvents = new G4RWTPtrOrderedVector<G4Event>;
G4ParticleTable::GetParticleTable()->CreateMessenger();
G4ProcessTable::GetProcessTable()->CreateMessenger();
randomNumberStatusDir = "./";
G4cout
<< "**********************************************" << G4endl
<< " Geant4 version $Name: geant4-02-00 $" << G4endl
<< " (30-Jun-2000)" << G4endl
<< " Geant4 version $Name: geant4-03-00 $" << G4endl
<< " (15-Dec-2000)" << G4endl
<< " Copyright : Geant4 Collaboration" << G4endl
<< "**********************************************" << G4endl;
}
@@ -228,8 +229,6 @@ void G4RunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_selec
{
stateManager->SetNewState(EventProc);
if(pauseAtBeginOfEvent) stateManager->Pause("BeginOfEvent");
currentEvent = GenerateEvent(i_event);
eventManager->ProcessOneEvent(currentEvent);
@@ -237,7 +236,6 @@ void G4RunManager::DoEventLoop(G4int n_event,const char* macroFile,G4int n_selec
AnalyzeEvent(currentEvent);
if(i_event<n_select) G4UImanager::GetUIpointer()->ApplyCommand(msg);
if(pauseAtEndOfEvent) stateManager->Pause("EndOfEvent");
stateManager->SetNewState(GeomClosed);
StackPreviousEvent(currentEvent);
currentEvent = NULL;
@@ -398,7 +396,7 @@ void G4RunManager::DefineWorldVolume(G4VPhysicalVolume* worldVol)
void G4RunManager::StoreRandomNumberStatus(G4int eventID)
{
G4String fileN = "RandEngine";
G4String fileN = randomNumberStatusDir+"RandEngine";
if(storeRandomNumberStatus>0 && currentRun != NULL)
{
char st[20];
@@ -421,7 +419,12 @@ void G4RunManager::StoreRandomNumberStatus(G4int eventID)
void G4RunManager::RestoreRandomNumberStatus(G4String fileN)
{
HepRandom::restoreEngineStatus(fileN);
G4String fileNameWithDirectory;
if(fileN.index("/")==G4std::string::npos)
{ fileNameWithDirectory = randomNumberStatusDir+fileN; }
else
{ fileNameWithDirectory = fileN; }
HepRandom::restoreEngineStatus(fileNameWithDirectory);
}
+17 -4
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4RunMessenger.cc,v 1.4.8.1.2.5 1999/12/14 09:16:50 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4RunMessenger.cc,v 1.7 2000/11/13 01:24:21 asaim Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4RunMessenger.hh"
@@ -18,6 +18,7 @@
#include "G4UIcmdWithABool.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UImanager.hh"
#include "G4ios.hh"
#include "g4std/strstream"
@@ -128,10 +129,17 @@ G4RunMessenger::G4RunMessenger(G4RunManager * runMgr)
restoreRandCmd->SetGuidance("Restore the status of the random number engine from a file.");
restoreRandCmd->SetGuidance("See CLHEP manual for detail.");
restoreRandCmd->SetGuidance("The engine status must be stored beforehand.");
restoreRandCmd->SetGuidance("Directory of the status file should be set by /run/randomNumberStatusDirectory command.");
restoreRandCmd->SetParameterName("fileName",true);
restoreRandCmd->SetDefaultValue("RandEngine.stat");
restoreRandCmd->AvailableForStates(PreInit,Idle,GeomClosed);
randDirCmd = new G4UIcmdWithAString("/run/randomNumberStatusDirectory",this);
randDirCmd->SetGuidance("Define the directory name of the random number status files.");
randDirCmd->SetGuidance("Directory must be creates before storing the file.");
randDirCmd->SetParameterName("fileName",true);
randDirCmd->SetDefaultValue("./");
randDirCmd->AvailableForStates(PreInit,Idle,GeomClosed);
}
G4RunMessenger::~G4RunMessenger()
@@ -147,6 +155,7 @@ G4RunMessenger::~G4RunMessenger()
delete cutCmd;
delete storeRandCmd;
delete restoreRandCmd;
delete randDirCmd;
delete runDirectory;
}
@@ -169,9 +178,9 @@ void G4RunMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
else if( command==optCmd )
{ runManager->SetGeometryToBeOptimized(optCmd->GetNewBoolValue(newValue)); }
else if( command==brkBoECmd )
{ runManager->SetPauseAtBeginOfEvent(brkBoECmd->GetNewBoolValue(newValue)); }
{ G4UImanager::GetUIpointer()->SetPauseAtBeginOfEvent(brkBoECmd->GetNewBoolValue(newValue)); }
else if( command==brkEoECmd )
{ runManager->SetPauseAtEndOfEvent(brkEoECmd->GetNewBoolValue(newValue)); }
{ G4UImanager::GetUIpointer()->SetPauseAtEndOfEvent(brkEoECmd->GetNewBoolValue(newValue)); }
else if( command==abortCmd )
{ runManager->AbortRun(); }
else if( command==initCmd )
@@ -184,6 +193,8 @@ void G4RunMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
{ runManager->SetRandomNumberStore(storeRandCmd->GetNewIntValue(newValue)); }
else if( command==restoreRandCmd )
{ runManager->RestoreRandomNumberStatus(newValue); }
else if( command==randDirCmd )
{ runManager->SetRandomNumberStoreDir(newValue); }
}
G4String G4RunMessenger::GetCurrentValue(G4UIcommand * command)
@@ -194,6 +205,8 @@ G4String G4RunMessenger::GetCurrentValue(G4UIcommand * command)
{ cv = verboseCmd->ConvertToString(runManager->GetVerboseLevel()); }
else if( command==storeRandCmd )
{ cv = storeRandCmd->ConvertToString(runManager->GetRandomNumberStore()); }
else if( command==randDirCmd )
{ cv = runManager->GetRandomNumberStoreDir(); }
return cv;
}
+45 -7
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4UserPhysicsListMessenger.cc,v 1.2.8.1 1999/12/07 20:52:59 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4UserPhysicsListMessenger.cc,v 1.5 2000/11/08 12:40:05 kurasige Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
//
//---------------------------------------------------------------
@@ -42,7 +42,7 @@ G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pPart
verboseCmd->SetGuidance(" 2 : Display more");
verboseCmd->SetParameterName("level",true);
verboseCmd->SetDefaultValue(0);
verboseCmd->SetRange("level >=0 && level <=2");
verboseCmd->SetRange("level >=0 && level <=3");
// /run/particle/setCut command
setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/particle/setCut",this);
@@ -81,6 +81,22 @@ G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pPart
buildPTCmd->SetParameterName("particleType", true);
buildPTCmd->SetDefaultValue("");
buildPTCmd->AvailableForStates(Init,Idle,GeomClosed,EventProc);
// /run/particle/storePhysicsTable command
storeCmd = new G4UIcmdWithAString("/run/particle/storePhysicsTable",this);
storeCmd->SetGuidance("Store Physics Table");
storeCmd->SetGuidance(" Enter directory name");
storeCmd->SetParameterName("dirName",true);
storeCmd->SetDefaultValue("");
storeCmd->AvailableForStates(Idle);
// /run/particle/retrievePhysicsTable command
retrieveCmd = new G4UIcmdWithAString("/run/particle/retrievePhysicsTable",this);
retrieveCmd->SetGuidance("Retrieve Physics Table");
retrieveCmd->SetGuidance(" Enter directory name or OFF to switch off");
retrieveCmd->SetParameterName("dirName",true);
retrieveCmd->SetDefaultValue("");
retrieveCmd->AvailableForStates(PreInit,Idle);
}
G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
@@ -91,7 +107,9 @@ G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
delete dumpCutValuesCmd;
delete addProcManCmd;
delete buildPTCmd;
delete theDirectory;
delete storeCmd;
delete retrieveCmd;
delete theDirectory;
}
void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
@@ -123,8 +141,18 @@ void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newV
G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
if (particle == NULL) return;
thePhysicsList->BuildPhysicsTable(particle);
} else if ( command == storeCmd ){
thePhysicsList->StorePhysicsTable(newValue);
} else if( command == retrieveCmd ) {
if ((newValue == "OFF") || (newValue == "off") ){
thePhysicsList->ResetPhysicsTableRetrieved();
} else {
thePhysicsList->SetPhysicsTableRetrieved(newValue);
}
}
}
}
G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
{
@@ -137,7 +165,7 @@ G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
} else if( command==verboseCmd ){
cv = verboseCmd->ConvertToString(thePhysicsList->GetVerboseLevel());
} else if( command== addProcManCmd ){
// set candidate list
piter -> reset();
@@ -147,7 +175,7 @@ G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
}
addProcManCmd->SetCandidates(candidates);
cv = "";
} else if( command== buildPTCmd ){
// set candidate list
piter -> reset();
@@ -157,6 +185,16 @@ G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
}
addProcManCmd->SetCandidates(candidates);
cv = "";
} else if ( command == storeCmd ){
cv = thePhysicsList->GetPhysicsTableDirectory();
}else if( command == retrieveCmd ) {
if (thePhysicsList->IsPhysicsTableRetrieved()) {
cv = thePhysicsList->GetPhysicsTableDirectory();
} else {
cv = "OFF";
}
}
return cv;
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4UserRunAction.cc,v 1.2.8.1 1999/12/07 20:53:00 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4UserRunAction.cc,v 1.3 1999/12/15 14:53:54 gunter Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4UserRunAction.hh"
+2 -2
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VPersistencyManager.cc,v 1.1.10.1 1999/12/07 20:53:00 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4VPersistencyManager.cc,v 1.2 1999/12/15 14:53:54 gunter Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4VPersistencyManager.hh"
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VUserDetectorConstruction.cc,v 1.1.10.1 1999/12/07 20:53:00 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4VUserDetectorConstruction.cc,v 1.2 1999/12/15 14:53:54 gunter Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4VUserDetectorConstruction.hh"
+466 -58
View File
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VUserPhysicsList.cc,v 1.7.8.1.2.3 1999/12/14 07:08:32 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4VUserPhysicsList.cc,v 1.12 2000/11/16 14:46:48 kurasige Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
//
// ------------------------------------------------------------
@@ -41,7 +41,11 @@
G4VUserPhysicsList::G4VUserPhysicsList()
:verboseLevel(1)
:verboseLevel(1),
numberOfMaterial(0),
fRetrievePhysicsTable(false),
directoryPhysicsTable("."),
fIsCheckedForRetrievePhysicsTable(false)
{
// default cut value (1.0mm)
defaultCutValue = 1.0*mm;
@@ -484,56 +488,74 @@ void G4VUserPhysicsList::ReCalcCutValueForOthers()
void G4VUserPhysicsList::BuildPhysicsTable(G4ParticleDefinition* particle)
{
if (fRetrievePhysicsTable) {
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::BuildPhysicsTable ";
G4cout << " Retrieve Physics Table for ";
G4cout << particle->GetParticleName() << G4endl;
}
#endif
if (CheckForRetrievePhysicsTable(directoryPhysicsTable)) {
// Retrieve PhysicsTable from files for proccesses
RetrievePhysicsTable(particle);
return;
} else {
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "CheckForRetrievePhysicsTable failed " << G4endl;
}
#endif
fRetrievePhysicsTable = false;
}
}
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::BuildPhysicsTable ";
G4cout << " for " << particle->GetParticleName() << G4endl;
}
#endif
G4int j;
// Rebuild the physics tables for every process for this particle type
G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
for ( j=0; j < pVector->entries(); ++j) {
(*pVector)[j]->BuildPhysicsTable(*particle);
}
for ( j=0; j < pVector->entries(); ++j) {
//*********************************************************************
// temporary addition to make the integral schema of electromagnetic
// processes work.
//
if((*pVector)[j]->GetProcessName() == "Imsc")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IeIoni")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IeBrems")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "Iannihil")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IhIoni")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IMuIoni")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IMuBrems")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
if((*pVector)[j]->GetProcessName() == "IMuPairProd")
{
(*pVector)[j]->BuildPhysicsTable(*particle);
}
//*********************************************************************
// temporary addition to make the integral schema
BuildIntegralPhysicsTable((*pVector)[j], particle);
}
}
void G4VUserPhysicsList::BuildIntegralPhysicsTable(G4VProcess* process,
G4ParticleDefinition* particle)
{
//*********************************************************************
// temporary addition to make the integral schema of electromagnetic
// processes work.
//
if ( (process->GetProcessName() == "Imsc") ||
(process->GetProcessName() == "IeIoni") ||
(process->GetProcessName() == "IeBrems") ||
(process->GetProcessName() == "Iannihil") ||
(process->GetProcessName() == "IhIoni") ||
(process->GetProcessName() == "IMuIoni") ||
(process->GetProcessName() == "IMuBrems") ||
(process->GetProcessName() == "IMuPairProd") ) {
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::BuildIntegralPhysicsTable ";
G4cout << " BuildPhysicsTable is invoked for ";
G4cout << process->GetProcessName();
G4cout << "(" << particle->GetParticleName() << ")" << G4endl;
}
#endif
process->BuildPhysicsTable(*particle);
}
}
void G4VUserPhysicsList::DumpList() const
{
theParticleIterator->reset();
@@ -611,8 +633,9 @@ void G4VUserPhysicsList::DumpCutValuesTable() const
G4String name[size] = {"gamma", "e-", "mu-", "proton", "neutron"};
G4ParticleDefinition* particle[size];
G4bool IsOK = true;
G4int size_display=2;
G4int idx;
for (idx=0; idx <size; idx++) {
for (idx=0; idx <size_display; idx++) {
particle[idx] = theParticleTable->FindParticle(name[idx]);
}
@@ -625,14 +648,14 @@ void G4VUserPhysicsList::DumpCutValuesTable() const
// line 3
G4cout << " ";
for (idx=0; idx <size; idx++) {
for (idx=0; idx <size_display; idx++) {
G4cout << " " << G4std::setw(11) << name[idx] << " ";
}
G4cout << G4endl;
// line 4
G4cout << "Cut in range ";
for (idx=0; idx <size; idx++) {
for (idx=0; idx <size_display; idx++) {
if (particle[idx] == 0) {
G4cout << " ";
} else {
@@ -649,7 +672,7 @@ void G4VUserPhysicsList::DumpCutValuesTable() const
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
for (G4int J=0; J<materialTable->entries(); J++) {
G4cout << " " << G4std::setw(18) << ((*materialTable)[J])->GetName();
for (idx=0; idx <size; idx++) {
for (idx=0; idx <size_display; idx++) {
if (particle[idx] == 0) {
G4cout << " ";
} else {
@@ -674,15 +697,400 @@ void G4VUserPhysicsList::DumpCutValuesTable() const
G4cout.precision(prec);
}
G4bool G4VUserPhysicsList::StorePhysicsTable(const G4String& directory)
{
G4String dir = directory;
if (dir.isNull()) dir = directoryPhysicsTable;
if (!StoreMaterialInfo(dir)) return false;
if (!StoreCutValues(dir)) return false;
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::StorePhysicsTable ";
G4cout << " Store material and cu values successfully" << G4endl;
}
#endif
return true;
}
G4bool G4VUserPhysicsList::StoreMaterialInfo(const G4String& directory)
{
const G4String fileName = directory + "/" + "material.dat";
const G4String key = "MATERIAL";
G4std::ofstream fOut;
// open output file //
fOut.open(fileName,G4std::ios::out);
// check if the file has been opened successfully
if (!fOut) {
#ifdef G4VERBOSE
G4cerr << "G4VUserPhysicsList::StoreMaterialInfo ";
G4cerr << " Can not open file " << fileName << G4endl;
#endif
return false;
}
// key word
fOut << key << G4endl;
const G4MaterialTable* matTable = G4Material::GetMaterialTable();
// number of materials in the table
numberOfMaterial = matTable->entries();
fOut << numberOfMaterial << G4endl;
fOut.setf(G4std::ios::scientific);
// material name and density
for (G4int idx=0; idx<matTable->entries(); ++idx){
fOut << G4std::setw(20) << ((*matTable)[idx])->GetName();
fOut << G4std::setw(20) << ((*matTable)[idx])->GetDensity()/(g/cm3) << G4endl;
}
fOut.unsetf(G4std::ios::scientific);
fOut.close();
return true;
}
G4bool G4VUserPhysicsList::StoreCutValues(const G4String& directory)
{
const G4String fileName = directory + "/" + "cut_value.dat";
const G4String key = "CUT_VALUE";
G4std::ofstream fOut;
// open output file //
fOut.open(fileName,G4std::ios::out);
// check if the file has been opened successfully
if (!fOut) {
#ifdef G4VERBOSE
G4cerr << "G4VUserPhysicsList::StoreCutValues ";
G4cerr << " Can not open file " << fileName << G4endl;
#endif
return false;
}
// key word
fOut << key << G4endl;
fOut.setf(G4std::ios::scientific);
// default cut value
fOut << "Default " << G4std::setw(20) << defaultCutValue/mm << G4endl;
// loop over all particles in G4ParticleTable
theParticleIterator->reset();
while( (*theParticleIterator)() ){
G4ParticleDefinition* particle = theParticleIterator->value();
if ( (particle->GetParticleName() == "gamma" ) ||
(particle->GetParticleName() == "e-" ) ||
(particle->GetParticleName() == "e+" ) ||
(particle->GetParticleName() == "mu-" ) ||
(particle->GetParticleName() == "mu+" ) ||
(particle->GetParticleName() == "proton" ) ||
(particle->GetParticleName() == "anti_proton" ) ||
((particle->GetPDGCharge()==0.0)&&(!particle->IsShortLived())) ) {
// particle name and cut in length
fOut << G4std::setw(40) << particle->GetParticleName();
fOut << G4std::setw(20) << particle->GetLengthCuts()/mm << G4endl;
G4double* cutArray = particle->GetEnergyCuts();
// cut energy for each material
G4int jj =0;
for(G4int idx=0; idx<numberOfMaterial; ++idx, ++jj) {
if (jj==4) {
fOut << G4endl;
jj =0;
}
fOut << G4std::setw(20) << cutArray[idx]/keV;
}
fOut << G4endl;
}
}
fOut.unsetf(G4std::ios::scientific);
fOut.close();
return true;
}
void G4VUserPhysicsList::RetrievePhysicsTable(G4ParticleDefinition* particle)
{
G4int j;
G4bool success[100];
// Retrieve physics tables for every process for this particle type
G4ProcessVector* pVector = (particle->GetProcessManager())->GetProcessList();
for ( j=0; j < pVector->entries(); ++j) {
success[j] =
(*pVector)[j]->RetrievePhysicsTable(directoryPhysicsTable);
if (!success[j]) {
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << "G4VUserPhysicsList::RetrievePhysicsTable ";
G4cout << " Fail to retrieve for ";
G4cout << (*pVector)[j]->GetProcessName();
G4cout << "(" << particle->GetParticleName() <<")" << G4endl;
}
#endif
(*pVector)[j]->BuildPhysicsTable(*particle);
}
}
for ( j=0; j < pVector->entries(); ++j) {
// temporary addition to make the integral schema
if (!success[j]) BuildIntegralPhysicsTable((*pVector)[j], particle);
}
}
G4bool G4VUserPhysicsList::CheckForRetrievePhysicsTable(const G4String& directory)
{
if (!fIsCheckedForRetrievePhysicsTable) {
if (CheckMaterialInfo(directory)) {
if (CheckCutValues(directory)) {
fIsCheckedForRetrievePhysicsTable = true;
}
}
}
return fIsCheckedForRetrievePhysicsTable;
}
G4bool G4VUserPhysicsList::CheckMaterialInfo(const G4String& directory)
{
const G4String fileName = directory + "/" + "material.dat";
const G4String key = "MATERIAL";
G4std::ifstream fIn;
// open input file //
fIn.open(fileName,G4std::ios::in);
// check if the file has been opened successfully
if (!fIn) {
#ifdef G4VERBOSE
G4cerr << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cerr << " Can not open file " << fileName << G4endl;
#endif
return false;
}
// key word
G4String keyword;
fIn >> keyword;
if (key!=keyword) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cout << " Can not find key word " << keyword << G4endl;
}
#endif
return false;
}
const G4MaterialTable* matTable = G4Material::GetMaterialTable();
numberOfMaterial = matTable->entries();
// number of materials in the table
G4int nmat;
fIn >> nmat;
if (nmat!=numberOfMaterial) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cout << "Number of material is inconsistent "<< G4endl;
}
#endif
return false;
}
// list of material
for (G4int idx=0; idx<matTable->entries(); ++idx){
// check eof
if(fIn.eof()) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cout << " encountered End of File" << G4endl;
}
#endif
fIn.close();
return false;
}
// check material name and density
char name[40];
double density;
fIn >> name >> density;
if (fIn.fail()) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cout << " Bad data format " << G4endl;
}
#endif
fIn.close();
return false;
}
G4double ratio = abs( (density*g/cm3)/((*matTable)[idx])->GetDensity() );
if ( (name != ((*matTable)[idx])->GetName()) || (0.999>ratio) || (ratio>1.001) ){
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckMaterialInfo ";
G4cout << " Inconsistent material name or density" << G4endl;;
G4cout << G4std::setw(40) << name;
G4cout << G4std::setw(20) << G4std::setiosflags(G4std::ios::scientific) << density << G4endl;
G4cout << G4std::resetiosflags(G4std::ios::scientific);
}
#endif
fIn.close();
return false;
}
}
fIn.close();
return true;
}
G4bool G4VUserPhysicsList::CheckCutValues(const G4String& directory)
{
const G4String fileName = directory + "/" + "cut_value.dat";
const G4String key = "CUT_VALUE";
G4std::ifstream fIn;
// open output file //
fIn.open(fileName,G4std::ios::in);
// check if the file has been opened successfully
if (!fIn) {
#ifdef G4VERBOSE
G4cerr << "G4VUserPhysicsList::CheckCutValues ";
G4cerr << " Can not open file " << fileName << G4endl;
#endif
return false;
}
// key word
G4String keyword;
fIn >> keyword;
if (key!=keyword) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Can not find key word " << keyword << G4endl;
}
#endif
}
// default cut value
G4double defaultCut;
fIn >> keyword >> defaultCut;
if (fIn.fail()) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Bad data format " << G4endl;
}
#endif
fIn.close();
return false;
}
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout.setf(G4std::ios::scientific);
G4cout << "Default " << G4std::setw(20) << defaultCutValue/mm << G4endl;
G4cout.unsetf(G4std::ios::scientific);
}
#endif
// check default value
G4double ratio = abs(defaultCut / (defaultCutValue/mm) );
if ((keyword != "Default")|| (ratio<0.999) ||(ratio>1.001) ){
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Inconsistent default cut values" << G4endl;;
}
#endif
fIn.close();
return false;
}
// loop over all particles
while(!fIn.eof()){
// read in particle name and cut in length
G4String name;
G4double cutLength;
fIn >> name >> cutLength;
if (fIn.eof()) break;
if (fIn.fail()) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Bad data format " << G4endl;
}
#endif
fIn.close();
return false;
}
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout.setf(G4std::ios::scientific);
G4cout << name << G4std::setw(20) << cutLength << G4endl;
G4cout.unsetf(G4std::ios::scientific);
}
#endif
// Search particle
G4ParticleDefinition* particle = theParticleTable->FindParticle(name);
if (particle==0) {
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Particle " << name <<" is not found "<< G4endl;
}
fIn.close();
return false;
#endif
}
// check cut in length
ratio = abs(cutLength/ (particle->GetLengthCuts()/mm) );
if ((ratio<0.999) ||(ratio>1.001) ){
#ifdef G4VERBOSE
if (verboseLevel>0){
G4cout << "G4VUserPhysicsList::CheckCutValues ";
G4cout << " Inconsistent cut values for " << name << G4endl;;
}
#endif
fIn.close();
return false;
}
// read in energy cut for all materials (not used)
G4int jj;
for(G4int idx=0; idx<numberOfMaterial; ++idx) {
#ifdef G4VERBOSE
if (verboseLevel>2){
if(jj==4) G4cout << G4endl;
}
#endif
G4double value;
fIn >> value;
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout.setf(G4std::ios::scientific);
G4cout << G4std::setw(20) << value;
G4cout.unsetf(G4std::ios::scientific);
++jj;
}
#endif
}
#ifdef G4VERBOSE
if (verboseLevel>2){
G4cout << G4endl;
}
#endif
}
fIn.close();
return true;
}
@@ -5,8 +5,8 @@
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VUserPrimaryGeneratorAction.cc,v 1.1.10.1 1999/12/07 20:53:00 gunter Exp $
// GEANT4 tag $Name: geant4-02-00 $
// $Id: G4VUserPrimaryGeneratorAction.cc,v 1.2 1999/12/15 14:53:54 gunter Exp $
// GEANT4 tag $Name: geant4-03-00 $
//
#include "G4VUserPrimaryGeneratorAction.hh"