Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -49,13 +49,18 @@ G3EleTable::~G3EleTable(){
|
||||
|
||||
G4Element*
|
||||
G3EleTable::GetEle(G4double Z){
|
||||
G4double A;
|
||||
G4double A = 0.;
|
||||
char name[20], sym[3];
|
||||
G4int index = (G4int) Z-1;
|
||||
if (!parse(Z, name, sym, A)) {
|
||||
G4String na(name);
|
||||
G4String sy(sym);
|
||||
if (_Ele[index] == 0) {
|
||||
if ( A == 0. ) {
|
||||
// Cannot create element with A = 0.
|
||||
G4String text = "Failed to get element Z = " + std::to_string(Z);
|
||||
G4Exception("G3EleTable::GetEle", "G3toG40016", FatalException, text);
|
||||
}
|
||||
// add an element to the element table here
|
||||
_Ele[index] = new G4Element(na, sy, Z, A*g/mole);
|
||||
}
|
||||
@@ -68,8 +73,17 @@ G3EleTable::parse(G4double& Z, char* name, char* sym, G4double& A){
|
||||
G4int rc = 0;
|
||||
if (Z>0 && Z <=_MaxEle){
|
||||
G4int z = (G4int) Z-1;
|
||||
std::istringstream in(_EleNames[z]);
|
||||
in >> name >> sym >> A;
|
||||
G4String str(_EleNames[z]);
|
||||
char* cstr = new char [str.length()+1];
|
||||
std::strcpy(cstr, str.c_str());
|
||||
char* p = std::strtok(cstr," ");
|
||||
std::strcpy(name, p);
|
||||
p = std::strtok(NULL," ");
|
||||
std::strcpy(sym, p);
|
||||
p = std::strtok(NULL," ");
|
||||
std::istringstream in(p);
|
||||
in >> A;
|
||||
delete [] cstr;
|
||||
} else {
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
@@ -339,8 +339,8 @@ G3VolTableEntry*
|
||||
G3VolTableEntry::GetMasterClone(){
|
||||
G3VolTableEntry* master;
|
||||
G4String name = fVname;
|
||||
if (name.contains(gSeparator)) {
|
||||
name = name(0, name.first(gSeparator));
|
||||
if (G4StrUtil::contains(name, gSeparator)) {
|
||||
name = name.substr(0, name.find(gSeparator));
|
||||
master = G3Vol.GetVTE(name);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -64,7 +64,8 @@ void G4CreateCloneVTEWithDivision(G4String vname, G3VolTableEntry* mvte,
|
||||
G4String newName = vname;
|
||||
if (i>0) {
|
||||
char index[12]; sprintf(index, "%d", i);
|
||||
newName.append(gSeparator); newName = newName + index;
|
||||
newName += gSeparator;
|
||||
newName = newName + index;
|
||||
}
|
||||
|
||||
// create new VTE with 0 solid
|
||||
|
||||
@@ -113,7 +113,7 @@ void G4gsmate(G4int imate, G4String name, G4double ain, G4double zin,
|
||||
|
||||
G4Material* material=0;
|
||||
|
||||
G4String sname = name.strip(G4String::both);
|
||||
G4String sname = G4StrUtil::strip_copy(name);
|
||||
if (sname == "AIR") {
|
||||
// handle the built in AIR mixture
|
||||
G4double aa[2], zz[2], wmat[2];
|
||||
|
||||
@@ -144,7 +144,8 @@ void G4CloneDaughters(G3VolTableEntry* vte, G3VolTableEntry* vteClone)
|
||||
G4int cloneNo = dvteMaster->GetNoClones();
|
||||
char index[5]; sprintf(index,"%d",cloneNo);
|
||||
G4String newName = dvteMaster->GetName();
|
||||
newName.append(gSeparator); newName = newName + index;
|
||||
newName += gSeparator;
|
||||
newName = newName + index;
|
||||
|
||||
// create dvteClone
|
||||
G4String dvteShape = dvte->GetShape();
|
||||
@@ -268,7 +269,8 @@ void G4CreateCloneVTE(G3VolTableEntry* vte, G3VolTableEntry* mvte,
|
||||
G4int cloneNo = vte->GetNoClones();
|
||||
char index[5]; sprintf(index,"%d",cloneNo);
|
||||
G4String newName = vte->GetName();
|
||||
newName.append(gSeparator); newName = newName + index;
|
||||
newName += gSeparator;
|
||||
newName = newName + index;
|
||||
|
||||
// update vteClone
|
||||
vteClone->SetName(newName);
|
||||
|
||||
@@ -115,7 +115,7 @@ void G3CLRead(G4String & fname, char *select = 0)
|
||||
G4int ntokens = 0;
|
||||
std::ifstream istr(fname);
|
||||
|
||||
while (line.readLine(istr) && ! istr.eof())
|
||||
while (G4StrUtil::readline(istr, line) && ! istr.eof())
|
||||
{
|
||||
count++;
|
||||
ntokens = G3CLTokens(&line,tokens); // tokenize the line
|
||||
@@ -146,7 +146,7 @@ G4int G3CLTokens(G4String *line, G4String tokens[])
|
||||
G4int itok = 0;
|
||||
G4int ntokens = 0;
|
||||
G4String token1, token2;
|
||||
while (!(token1=next("\"")).isNull())
|
||||
while (!(token1=next("\"")).empty())
|
||||
{
|
||||
itok++;
|
||||
if (itok%2 == 0 ) // even: inside a string
|
||||
@@ -156,7 +156,7 @@ G4int G3CLTokens(G4String *line, G4String tokens[])
|
||||
else // not in a quoted string: finish tokenization
|
||||
{
|
||||
G4Tokenizer lev2(token1);
|
||||
while (!(token2=lev2()).isNull())
|
||||
while (!(token2=lev2()).empty())
|
||||
{
|
||||
tokens[ntokens] = token2;
|
||||
ntokens++;
|
||||
|
||||
Reference in New Issue
Block a user