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
-52
View File
@@ -1,52 +0,0 @@
// ********************************************************************
// * 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: G4UIaliasList.cc,v 1.6 2006-06-29 19:08:33 gunter Exp $
//
#include "G4AnyType.hh"
#include "G4UIcommand.hh"
#include "G4Types.hh"
#include "G4ThreeVector.hh"
// The definitions of these specializations have been moved to the
// to the header file to solve Windows linking problem
#if 0
template <> void G4AnyType::Ref<bool>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertToBool(val.c_str());
}
template <> void G4AnyType::Ref<G4String>::FromString(const std::string& val) {
if (val[0] == '"' ) fRef = val.substr(1,val.size()-2);
else fRef = val;
}
template <> void G4AnyType::Ref<G4ThreeVector>::FromString(const std::string& val) {
fRef = G4UIcommand::ConvertTo3Vector(val.c_str());
}
#endif
@@ -142,6 +142,10 @@ G4String G4GenericMessenger::GetCurrentValue(G4UIcommand* command) {
Property& p = properties[command->GetCommandName()];
return p.variable.ToString();
}
else if ( methods.find(command->GetCommandName()) != methods.end()) {
G4cout<<" GetCurrentValue() is not available for a command defined by G4GenericMessenger::DeclareMethod()."<<G4endl;
return G4String();
}
else {
throw G4InvalidUICommand();
}
@@ -95,6 +95,14 @@ G4LocalThreadCoutMessenger::G4LocalThreadCoutMessenger()
ignoreCmd->SetParameterName("threadID",true);
ignoreCmd->SetDefaultValue(0);
ignoreCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
ignoreInitCmd = new G4UIcmdWithABool("/control/cout/ignoreInitializationCout",this);
ignoreInitCmd->SetGuidance("Omit cout from threads during initialization, as they should be identical to the masther thread.");
ignoreInitCmd->SetGuidance("This command takes effect only if cout destination is screen without buffering.");
ignoreInitCmd->SetGuidance("This command does not affect to cerr.");
ignoreInitCmd->SetParameterName("IgnoreInit",true);
ignoreInitCmd->SetDefaultValue(true);
ignoreInitCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
}
G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger()
@@ -104,6 +112,7 @@ G4LocalThreadCoutMessenger::~G4LocalThreadCoutMessenger()
delete bufferCoutCmd;
delete prefixCmd;
delete ignoreCmd;
delete ignoreInitCmd;
delete coutDir;
}
@@ -130,5 +139,7 @@ void G4LocalThreadCoutMessenger::SetNewValue(G4UIcommand* command,G4String newVa
{ UI->SetThreadPrefixString(newVal); }
else if(command == ignoreCmd)
{ UI->SetThreadIgnore(StoI(newVal)); }
else if(command == ignoreInitCmd)
{ UI->SetThreadIgnoreInit(StoB(newVal)); }
}
+3 -3
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4UIbatch.cc 67965 2013-03-13 09:35:29Z gcosmo $
// $Id: G4UIbatch.cc 83401 2014-08-21 15:03:26Z gcosmo $
//
// ====================================================================
// G4UIbatch.cc
@@ -72,8 +72,8 @@ G4UIbatch::G4UIbatch(const char* fileName, G4UIsession* prevSession)
{
macroStream.open(fileName, std::ios::in);
if(macroStream.fail()) {
G4cerr << "***** Can not open a macro file <"
<< fileName << ">"
G4cerr << "ERROR: Can not open a macro file <"
<< fileName << ">. Set macro path with \"/control/macroPath\" if needed."
<< G4endl;
} else {
isOpened= true;
+16 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UIcommand.cc 77563 2013-11-26 09:03:18Z gcosmo $
// $Id: G4UIcommand.cc 84281 2014-10-13 07:21:50Z gcosmo $
//
//
@@ -71,6 +71,10 @@ token(IDENTIFIER),paramERR(0)
availabelStateList.push_back(G4State_Abort);
}
#ifdef G4MULTITHREADED
#include "G4Threading.hh"
#endif
void G4UIcommand::G4UIcommandCommonConstructorCode
(const char * theCommandPath)
{
@@ -78,8 +82,18 @@ void G4UIcommand::G4UIcommandCommonConstructorCode
commandName = theCommandPath;
G4int commandNameIndex = commandName.last('/');
commandName.remove(0,commandNameIndex+1);
#ifdef G4MULTITHREADED
if(messenger && messenger->CommandsShouldBeInMaster()
&& G4Threading::IsWorkerThread())
{
toBeBroadcasted = false;
G4UImanager::GetMasterUIpointer()->AddNewCommand(this);
}
else
{ G4UImanager::GetUIpointer()->AddNewCommand(this); }
#else
G4UImanager::GetUIpointer()->AddNewCommand(this);
#endif
}
G4UIcommand::~G4UIcommand()
+77 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UIcontrolMessenger.cc 68725 2013-04-05 09:27:45Z gcosmo $
// $Id: G4UIcontrolMessenger.cc 80641 2014-05-05 15:10:28Z gcosmo $
//
#include <stdlib.h>
@@ -138,6 +138,15 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
getEnvCmd = new G4UIcmdWithAString("/control/getEnv",this);
getEnvCmd->SetGuidance("Get a shell environment variable and define it as an alias.");
getValCmd = new G4UIcommand("/control/getVal",this);
getValCmd->SetGuidance("Get the current value of the UI command and define it as an alias.");
getValCmd->SetGuidance("Command is ignored if the UI command does not support GetCurrentValue().");
getValCmd->SetGuidance(" Syntax : <alias_name> <UI_command>");
G4UIparameter* aliName = new G4UIparameter("alias_name",'s',false);
getValCmd->SetParameter(aliName);
G4UIparameter* comName = new G4UIparameter("UI_command",'s',false);
getValCmd->SetParameter(comName);
echoCmd = new G4UIcmdWithAString("/control/echo",this);
echoCmd->SetGuidance("Display the aliased value.");
@@ -177,6 +186,20 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
ifCommand->SetParameter(macroFileParam);
ifCommand->SetToBeBroadcasted(false);
doifCommand = new G4UIcommand("/control/doif",this);
doifCommand->SetGuidance("Execute a macro file if the expression is true.");
doifCommand->SetGuidance(" Syntax : <double> <comp> <double> <UI_command>");
G4UIparameter* doleftParam = new G4UIparameter("left",'d',false);
doifCommand->SetParameter(doleftParam);
G4UIparameter* docompParam = new G4UIparameter("comp",'s',false);
docompParam->SetParameterCandidates("> >= < <= == !=");
doifCommand->SetParameter(docompParam);
G4UIparameter* dorightParam = new G4UIparameter("right",'d',false);
doifCommand->SetParameter(dorightParam);
G4UIparameter* comParam = new G4UIparameter("UI_command",'s',false);
doifCommand->SetParameter(comParam);
doifCommand->SetToBeBroadcasted(false);
addCommand = new G4UIcommand("/control/add",this);
addCommand->SetGuidance("Define a new alias as the sum of two values.");
addCommand->SetGuidance(" Syntax : <new_alias> <value1> <value2>");
@@ -188,6 +211,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
addCommand->SetParameter(val1a);
G4UIparameter* val1b = new G4UIparameter("value2",'d',false);
addCommand->SetParameter(val1b);
addCommand->SetToBeBroadcasted(false);
subtractCommand = new G4UIcommand("/control/subtract",this);
subtractCommand->SetGuidance("Define a new alias as the subtraction of two values.");
@@ -200,6 +224,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
subtractCommand->SetParameter(val2a);
G4UIparameter* val2b = new G4UIparameter("value2",'d',false);
subtractCommand->SetParameter(val2b);
subtractCommand->SetToBeBroadcasted(false);
multiplyCommand = new G4UIcommand("/control/multiply",this);
multiplyCommand->SetGuidance("Define a new alias as the multiplification of two values.");
@@ -212,6 +237,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
multiplyCommand->SetParameter(val3a);
G4UIparameter* val3b = new G4UIparameter("value2",'d',false);
multiplyCommand->SetParameter(val3b);
multiplyCommand->SetToBeBroadcasted(false);
divideCommand = new G4UIcommand("/control/divide",this);
divideCommand->SetGuidance("Define a new alias as the division of two values.");
@@ -225,6 +251,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
G4UIparameter* val4b = new G4UIparameter("value2",'d',false);
val4b->SetParameterRange("value2 != 0.");
divideCommand->SetParameter(val4b);
divideCommand->SetToBeBroadcasted(false);
remainderCommand = new G4UIcommand("/control/remainder",this);
remainderCommand->SetGuidance("Define a new alias as the remainder of two values.");
@@ -238,6 +265,7 @@ G4UIcontrolMessenger::G4UIcontrolMessenger()
G4UIparameter* val5b = new G4UIparameter("value2",'i',false);
val4b->SetParameterRange("value2 != 0");
remainderCommand->SetParameter(val5b);
remainderCommand->SetToBeBroadcasted(false);
}
@@ -254,6 +282,7 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
delete unaliasCommand;
delete listAliasCommand;
delete getEnvCmd;
delete getValCmd;
delete echoCmd;
delete shellCommand;
delete loopCommand;
@@ -261,6 +290,7 @@ G4UIcontrolMessenger::~G4UIcontrolMessenger()
delete HTMLCommand;
delete maxStoredHistCommand;
delete ifCommand;
delete doifCommand;
delete addCommand;
delete subtractCommand;
delete multiplyCommand;
@@ -327,6 +357,19 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
else
{ G4cerr << "<" << newValue << "> is not defined as a shell variable. Command ignored." << G4endl; }
}
if(command==getValCmd)
{
G4Tokenizer next(newValue);
G4String aliName = next();
G4String com = next();
G4String curVal = UI->GetCurrentValues(com);
if(!(curVal.isNull()))
{
G4String st = "/control/alias ";
st += aliName + " " + curVal;
UI->ApplyCommand(st);
}
}
if(command==echoCmd)
{ G4cout << UI->SolveAlias(newValue) << G4endl; }
if(command==shellCommand)
@@ -365,6 +408,39 @@ void G4UIcontrolMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
else if(comp=="!=") x = (l!=r);
if(x) UI->ExecuteMacroFile(mac);
}
if(command==doifCommand)
{
G4Tokenizer next(newValue);
G4double l = StoD(next());
G4String comp = next();
G4double r = StoD(next());
G4String c1 = next();
G4String ca;
while(!((ca=next()).isNull()))
{
c1 += " ";
c1 += ca;
}
if(c1(0)=='"')
{
G4String strippedValue;
if(c1(c1.length()-1)=='"')
{ strippedValue = c1(1,c1.length()-2); }
else
{ strippedValue = c1(1,c1.length()-1); }
c1 = strippedValue;
}
G4bool x = false;
if(comp==">") x = (l>r);
else if(comp==">=") x = (l>=r);
else if(comp=="<") x = (l<r);
else if(comp=="<=") x = (l<=r);
else if(comp=="==") x = (l==r);
else if(comp=="!=") x = (l!=r);
if(x) UI->ApplyCommand(c1);
}
if(command==addCommand)
{
G4Tokenizer next(newValue);
+33 -3
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UImanager.cc 77651 2013-11-27 08:47:55Z gcosmo $
// $Id: G4UImanager.cc 85249 2014-10-27 08:28:57Z gcosmo $
//
//
// ---------------------------------------------------------------------
@@ -341,7 +341,20 @@ void G4UImanager::ForeachS(const char* valueList)
c1 += " ";
c1 += ca;
}
Foreach(mf,vn,c1);
G4String aliasValue = c1;
if(aliasValue(0)=='"')
{
G4String strippedValue;
if(aliasValue(aliasValue.length()-1)=='"')
{ strippedValue = aliasValue(1,aliasValue.length()-2); }
else
{ strippedValue = aliasValue(1,aliasValue.length()-1); }
aliasValue = strippedValue;
}
// Foreach(mf,vn,c1);
Foreach(mf,vn,aliasValue);
}
void G4UImanager::Foreach(const char * macroFile,const char * variableName,
@@ -356,7 +369,7 @@ void G4UImanager::Foreach(const char * macroFile,const char * variableName,
vl += " ";
vl += cd;
SetAlias(vl);
ExecuteMacroFile(macroFile);
ExecuteMacroFile(FindMacroPath(macroFile));
}
}
@@ -705,6 +718,16 @@ void G4UImanager::SetUpForAThread(G4int tId)
threadCout->SetIgnoreCout(igThreadID);
}
void G4UImanager::SetUpForSpecialThread(G4String pref)
{
threadID = G4Threading::GENERICTHREAD_ID;
G4Threading::G4SetThreadId(threadID);
G4iosInitialization();
threadCout = new G4MTcoutDestination(threadID);
threadCout->SetPrefixString(pref);
threadCout->SetIgnoreCout(igThreadID);
}
void G4UImanager::SetCoutFileName(const G4String& fileN, G4bool ifAppend)
{
// for sequential mode, ignore this method.
@@ -760,3 +783,10 @@ void G4UImanager::SetThreadIgnore(G4int tid)
threadCout->SetIgnoreCout(tid);
}
void G4UImanager::SetThreadIgnoreInit(G4bool flg)
{
// for sequential mode, ignore this method.
if(threadID<0) { return; }
threadCout->SetIgnoreInit(flg);
}
+3 -3
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UImessenger.cc 74278 2013-10-02 15:04:18Z gcosmo $
// $Id: G4UImessenger.cc 84281 2014-10-13 07:21:50Z gcosmo $
//
#include "G4UImessenger.hh"
@@ -36,13 +36,13 @@
#include <sstream>
G4UImessenger::G4UImessenger()
: baseDir(NULL), baseDirName("")
: baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
{
}
G4UImessenger::G4UImessenger(const G4String& path, const G4String& dsc,
G4bool commandsToBeBroadcasted)
: baseDir(NULL), baseDirName("")
: baseDir(NULL), baseDirName(""), commandsShouldBeInMaster(false)
{
CreateDirectory(path, dsc, commandsToBeBroadcasted);
}
+3 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4UIparameter.cc 67965 2013-03-13 09:35:29Z gcosmo $
// $Id: G4UIparameter.cc 79626 2014-03-10 11:18:47Z gcosmo $
//
#include "G4UIparameter.hh"
@@ -157,7 +157,8 @@ CandidateCheck(const char* newValue) {
iToken++;
if(aToken==newValue) return iToken;
}
G4cerr << "parameter value is not listed in the candidate List." << G4endl;
G4cerr << "parameter value (" << newValue
<< ") is not listed in the candidate List." << G4endl;
return 0;
}