61 delete theEvaluator; theEvaluator = 0;
68 char nonCharacters[7] = {
"()+-*/"};
69 for(
size_t ii = 0; ii < 6; ii++ )
71 if( ch == nonCharacters[ii] )
85 for(
size_t ii=0; ii<str.length(); ii++)
87 if(!isdigit(str[ii]) && (str[ii]!=
'.') && (str[ii]!=
'-') && (str[ii]!=
'+'))
90 if(str[ii] ==
'E' || str[ii] ==
'e' )
92 if( ii == 0 ) {
return 0; }
93 if(numE != 0 || ii == str.length()-1)
114 if(
G4int(val) / val - 1 > precision )
128 G4cout << msg << std::setprecision(8)
129 << vec << std::setprecision(6) <<
G4endl;
137 <<
" xx=" << rm.
xx() <<
" yx=" << rm.
yx() <<
" zx=" << rm.
zx() <<
G4endl
138 <<
" xy=" << rm.
xy() <<
" yy=" << rm.
yy() <<
" zy=" << rm.
zy() <<
G4endl
139 <<
" xz=" << rm.
xz() <<
" yz=" << rm.
yz() <<
" zz=" << rm.
zz() <<
G4endl;
145 const char* msg, std::ostream& outs )
148 std::vector<G4String>::const_iterator ite;
149 for( ite = wl.begin(); ite != wl.end(); ite++ )
167 if( str.find(
':') != 0 )
169 G4String ErrMessage =
"Trying to subtract leading colon from a word\n"
170 +
G4String(
"that has no leading colon: ") + str;
171 G4Exception(
"G4tgrUtils::SubColon()",
"ParseError",
174 G4String strt = str.substr(1,str.size()-1);
183 const char* cstr = str.c_str();
189 G4cout <<
" G4tgrUtils::GetString() - Substitute parameter: "
211 G4cout <<
"G4tgrUtils::GetDouble() - Processing: "
212 << str <<
" default unit " << unitval <<
G4endl;
215 if( str ==
"DBL_MAX" ) {
217 }
else if( str ==
"DBL_MIN" ) {
219 }
else if( str ==
"FLT_MAX" ) {
221 }
else if( str ==
"FLT_MIN" ) {
223 }
else if( str ==
"INT_MAX" ) {
225 }
else if( str ==
"INT_MIN" ) {
229 const char* cstr = str.c_str();
230 std::set<G4int> separators;
231 separators.insert(-1);
233 for(
G4int ii=0; ii<strlen; ii++)
236 if( cs ==
'*' || cs ==
'/' || cs ==
'(' || cs ==
')' )
238 separators.insert(ii);
240 else if( cs ==
'+' || cs ==
'-' )
245 || ( (cstr[ii-1] !=
'E') && (cstr[ii-1] !=
'e') )
248 separators.insert(ii);
252 separators.insert(strlen);
257 std::set<G4int>::const_iterator site, site2;
258 site = separators.begin();
259 site2 = site; site2++;
260 for( ; site2 != separators.end(); site++,site2++)
265 G4cout <<
" Loop to find word between " << *site
266 <<
" " << *site2 <<
G4endl;
270 if( *site != -1 ) { strnew += str.substr(*site,1); }
272 G4int wlen = (*site2)-(*site)-1;
276 word = str.substr((*site)+1,(*site2)-(*site)-1);
292 const char* cword = word.c_str();
293 if( cword[0] ==
'$' )
297 if( parstr.substr(0,1) ==
"-" )
302 if( parstr.substr(0,1) ==
"-" )
309 G4cout <<
" G4tgrutils::GetDouble() - Param found: "
310 << word <<
" in string " << str
311 <<
" , substituted by " << parstr <<
G4endl;
321 if( (*site != -1) && (cstr[*site] ==
')') )
323 G4String ErrMessage =
"There cannot be a ')' before a number: "
324 + word +
" in string: " + str;
325 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
329 if( (*site2 != strlen) && (cstr[*site2] ==
'(') )
331 G4String ErrMessage =
"There cannot be a '(' after a number: "
332 + word +
" in string: " + str;
333 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
343 if( isdigit(word[0]) )
345 G4String ErrMessage =
"String words cannot start with a digit: "
346 + word +
" in string: " + str;
347 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
356 if( (*site2 == strlen) || (cstr[*site2] !=
'(') )
358 G4String ErrMessage =
"There must be a '(' after a function: "
359 + word +
" in string: " + str;
360 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
371 || ( (cstr[*site] !=
'*') && (cstr[*site] !=
'/') ) )
373 G4String ErrMess =
"There must be a '*' before a unit definition: "
374 + word +
" in string " + str;
375 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
395 G4String ErrMess =
"String word is not a parameter, nor a unit\n";
396 +
G4String(
"definition nor a function: ") + word
398 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
409 G4String ErrMessage =
"Evaluator error: " + strnew;
410 G4Exception(
"G4tgrUtils::GetDouble()",
"ParseError",
414 if( nUnits == 0 ) { val *= unitval; }
419 G4cout <<
" G4tgrUtils::GetDouble() - RESULT= " << val <<
G4endl
420 <<
" from string: " << str <<
" converted to: " << strnew.c_str()
421 <<
" with unit val: " << unitval <<
G4endl;
439 +
G4String(
" which is not an integer ") + str;
453 if( (str ==
"ON") || (str ==
"TRUE") )
457 else if( (str ==
"OFF") || (str ==
"FALSE") )
464 +
G4String(
" which is not 'ON'/'OFF'/'TRUE'/'FALSE' ")
479 G4String outStr = methodName +
G4String(
". Line read with number of words ");
480 unsigned int wlsize = wl.size();
487 outStr += chartmp + G4String(
" words");
488 DumpVS( wl, outStr.c_str() );
489 G4String ErrMessage =
" NUMBER OF WORDS: "
491 G4Exception(
"G4tgrUtils::CheckWLsize()",
"ParseError",
504 if( nWreal != nWcheck )
507 outStr +=
G4String(
"not equal than ");
511 if( nWreal == nWcheck )
518 if( nWreal > nWcheck )
521 outStr +=
G4String(
"greater than ");
525 if( nWreal >= nWcheck )
528 outStr +=
G4String(
"greater or equal than ");
532 if( nWreal < nWcheck )
539 if( nWreal <= nWcheck )
542 outStr +=
G4String(
"less or equal than ");
546 G4cerr <<
" ERROR!! - G4tgrUtils::CheckListSize()" <<
G4endl
547 <<
" Type of WLSIZE type not found " << st <<
G4endl;
563 || word ==
"millimeter"
564 || word ==
"centimeter"
566 || word ==
"kilometer"
568 || word ==
"micrometer"
569 || word ==
"nanometer"
570 || word ==
"angstrom"
576 || word ==
"milliradian"
582 || word ==
"becquerel"
633 G4String WarMessage =
"Direction cosines have been normalized to one.\n"
634 +
G4String(
"They were normalized to ")
636 G4Exception(
"G4tgrUtils::GetRotationFromDirection()",
"WrongArgument",
650 else if( dir.
y() == 0. )
656 angy = std::asin( dir.
x()/std::sqrt(1-dir.
y()*dir.
y()) );
660 if( dir.
z() * std::cos(angx)*std::cos(angy) < 0 )
676 std::vector< std::pair<size_t,size_t> > stringPairs;
684 size_t cAster = word1.find(
"*",cStart);
685 if( cAster != std::string::npos )
687 if( cAster == cStart )
692 "A word has two asterisks together, please correct it",
698 if(word1.size() == 1 ) {
return true; }
701 if( cAster!= cStart )
703 stringPairs.push_back( std::pair<size_t,size_t>(cStart, cAster-cStart) );
712 return word1 == word2;
719 if( cStart <= word1.length() )
721 if( word1.length() != cStart )
723 stringPairs.push_back( std::pair<size_t,size_t>(cStart,
724 word1.length()-cStart) );
729 if( stringPairs.size() == 0 )
743 for(
size_t ii = 0; ii < stringPairs.size(); ii++ )
745 std::pair<size_t,size_t> spair = stringPairs[ii];
746 size_t sFound = word2.find(word1.substr(spair.first, spair.second),cStart);
747 if( sFound == std::string::npos )
756 if( spair.first == 0 && sFound != 0 )
763 else if( (spair.first+spair.second-1 == word1.length())
764 && (sFound+spair.second-1 != word2.length()) )
769 cStart += spair.second;
HepRotation & rotateX(double delta)
G4String FindParameter(const G4String &name, G4bool exists=true)
G4double GetSurfaceTolerance() const
static void Dump3v(const G4ThreeVector &vec, const char *msg)
static void CheckWLsize(const std::vector< G4String > &wl, unsigned int nWCheck, WLSIZEtype st, const G4String &methodName)
static G4String ConvertToString(G4bool boolVal)
HepRotation & rotateY(double delta)
static G4bool AreWordsEquivalent(const G4String &word1, const G4String &word2)
static G4bool IsInteger(const G4double val, const G4double precision=1.e-6)
static G4bool IsNumber(const G4String &str)
static G4double GetValueOf(const G4String &)
G4GLOB_DLL std::ostream G4cout
static G4int GetVerboseLevel()
static G4tgrParameterMgr * GetInstance()
static G4bool IsFunction(const G4String &word)
static void Dumprm(const G4RotationMatrix &rm, const char *msg)
static G4int GetInt(const G4String &str)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4double GetDouble(const G4String &str, G4double unitval=1.)
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
static G4bool WordIsUnit(const G4String &word)
static G4String GetString(const G4String &str)
static G4String SubColon(const G4String &str)
static G4bool IsSeparator(char)
void print_error(G4int status) const
static G4GeometryTolerance * GetInstance()
static G4bool CheckListSize(unsigned int nWreal, unsigned int nWcheck, WLSIZEtype st, G4String &outstr)
G4GLOB_DLL std::ostream G4cerr
static G4bool GetBool(const G4String &str)
static G4RotationMatrix GetRotationFromDirection(G4ThreeVector dir)