Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4tgrUtils Class Reference

#include <G4tgrUtils.hh>

Public Member Functions

 G4tgrUtils ()
 
 ~G4tgrUtils ()
 

Static Public Member Functions

static G4bool IsSeparator (char)
 
static G4bool IsNumber (const G4String &str)
 
static G4bool IsInteger (const G4double val, const G4double precision=1.e-6)
 
static G4bool IsFunction (const G4String &word)
 
static G4bool WordIsUnit (const G4String &word)
 
static void Dump3v (const G4ThreeVector &vec, const char *msg)
 
static void Dumprm (const G4RotationMatrix &rm, const char *msg)
 
static void DumpVS (const std::vector< G4String > &wl, const char *msg)
 
static void DumpVS (const std::vector< G4String > &wl, const char *msg, std::ostream &outs)
 
static void CheckWLsize (const std::vector< G4String > &wl, unsigned int nWCheck, WLSIZEtype st, const G4String &methodName)
 
static G4bool CheckListSize (unsigned int nWreal, unsigned int nWcheck, WLSIZEtype st, G4String &outstr)
 
static G4String SubColon (const G4String &str)
 
static G4String GetString (const G4String &str)
 
static G4double GetDouble (const G4String &str, G4double unitval=1.)
 
static G4int GetInt (const G4String &str)
 
static G4bool GetBool (const G4String &str)
 
static G4RotationMatrix GetRotationFromDirection (G4ThreeVector dir)
 
static G4bool AreWordsEquivalent (const G4String &word1, const G4String &word2)
 

Detailed Description

Definition at line 54 of file G4tgrUtils.hh.

Constructor & Destructor Documentation

◆ G4tgrUtils()

G4tgrUtils::G4tgrUtils ( )

Definition at line 52 of file G4tgrUtils.cc.

53{
54}

◆ ~G4tgrUtils()

G4tgrUtils::~G4tgrUtils ( )

Definition at line 58 of file G4tgrUtils.cc.

59{
60}

Member Function Documentation

◆ AreWordsEquivalent()

G4bool G4tgrUtils::AreWordsEquivalent ( const G4String word1,
const G4String word2 
)
static

Definition at line 670 of file G4tgrUtils.cc.

672{
673 G4bool bEqual = true;
674 std::vector< std::pair<size_t,size_t> > stringPairs;
675 // start of substring, number of characters
676
677 //--- Get string limits between asterisks in word1
678
679 size_t cStart = 0;
680 for( ;; )
681 {
682 size_t cAster = word1.find("*",cStart);
683 if( cAster != std::string::npos )
684 {
685 if( cAster == cStart )
686 {
687 if( cAster != 0 )
688 {
689 G4Exception("G4tgrUtils::AreWordsEquivalent()",
690 "A word has two asterisks together, please correct it",
691 FatalException,("Offending word is: " + word1).c_str() );
692 }
693 else
694 {
695 // word1 == *
696 if(word1.size() == 1 ) { return true; }
697 }
698 }
699 if( cAster!= cStart )
700 {
701 stringPairs.push_back( std::pair<size_t,size_t>(cStart, cAster-cStart) );
702 }
703 cStart = cAster+1;
704 }
705 else
706 {
707 if( cStart == 0 )
708 {
709 //--- If there is no asterisk check if they are the same
710 return word1 == word2;
711 }
712 break;
713 }
714 }
715
716 //---- Add characters after last asterisk as string pair
717 if( cStart <= word1.length() )
718 {
719 if( word1.length() != cStart )
720 {
721 stringPairs.push_back( std::pair<size_t,size_t>(cStart,
722 word1.length()-cStart) );
723 }
724 }
725
726 //--- If there are not asterisk, simple comparison
727 if( stringPairs.size() == 0 )
728 {
729 if( word1 == word2 )
730 {
731 return true;
732 }
733 else
734 {
735 return false;
736 }
737 }
738
739 //--- Find substrings in word2, in same order as in word1
740 cStart = 0;
741 for( size_t ii = 0; ii < stringPairs.size(); ii++ )
742 {
743 std::pair<size_t,size_t> spair = stringPairs[ii];
744 size_t sFound = word2.find(word1.substr(spair.first, spair.second),cStart);
745 if( sFound == std::string::npos )
746 {
747 bEqual = false;
748 break;
749 }
750 else
751 {
752 //---- If there is no asterisk before first character,
753 // the fisrt string pair found has to start at the first character
754 if( spair.first == 0 && sFound != 0 )
755 {
756 bEqual = false;
757 break;
758 //---- If there is no asterisk after last character,
759 // the last string pair found has to end at the last character
760 }
761 else if( (spair.first+spair.second-1 == word1.length())
762 && (sFound+spair.second-1 != word2.length()) )
763 {
764 bEqual = false;
765 break;
766 }
767 cStart += spair.second;
768 }
769 }
770
771 return bEqual;
772}
@ FatalException
bool G4bool
Definition: G4Types.hh:67
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by G4tgrVolumeMgr::FindVolumes().

◆ CheckListSize()

G4bool G4tgrUtils::CheckListSize ( unsigned int  nWreal,
unsigned int  nWcheck,
WLSIZEtype  st,
G4String outstr 
)
static

Definition at line 495 of file G4tgrUtils.cc.

497{
498 G4bool isOK = true;
499 switch (st)
500 {
501 case WLSIZE_EQ:
502 if( nWreal != nWcheck )
503 {
504 isOK = false;
505 outStr += G4String("not equal than ");
506 }
507 break;
508 case WLSIZE_NE:
509 if( nWreal == nWcheck )
510 {
511 isOK = false;
512 outStr += G4String("equal than ");
513 }
514 break;
515 case WLSIZE_LE:
516 if( nWreal > nWcheck )
517 {
518 isOK = false;
519 outStr += G4String("greater than ");
520 }
521 break;
522 case WLSIZE_LT:
523 if( nWreal >= nWcheck )
524 {
525 isOK = false;
526 outStr += G4String("greater or equal than ");
527 }
528 break;
529 case WLSIZE_GE:
530 if( nWreal < nWcheck )
531 {
532 isOK = false;
533 outStr += G4String("less than ");
534 }
535 break;
536 case WLSIZE_GT:
537 if( nWreal <= nWcheck )
538 {
539 isOK = false;
540 outStr += G4String("less or equal than ");
541 }
542 break;
543 default:
544 G4cerr << " ERROR!! - G4tgrUtils::CheckListSize()" << G4endl
545 << " Type of WLSIZE type not found " << st << G4endl;
546 break;
547 }
548
549 return isOK;
550}
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr
@ WLSIZE_NE
Definition: G4tgrUtils.hh:52
@ WLSIZE_EQ
Definition: G4tgrUtils.hh:52
@ WLSIZE_GE
Definition: G4tgrUtils.hh:52
@ WLSIZE_LT
Definition: G4tgrUtils.hh:52
@ WLSIZE_LE
Definition: G4tgrUtils.hh:52
@ WLSIZE_GT
Definition: G4tgrUtils.hh:52

Referenced by G4tgbPlaceParameterisation::CheckNExtraData(), and CheckWLsize().

◆ CheckWLsize()

void G4tgrUtils::CheckWLsize ( const std::vector< G4String > &  wl,
unsigned int  nWCheck,
WLSIZEtype  st,
const G4String methodName 
)
static

Definition at line 472 of file G4tgrUtils.cc.

475{
476
477 G4String outStr = methodName + G4String(". Line read with number of words ");
478 unsigned int wlsize = wl.size();
479
480 G4bool isOK = CheckListSize( wlsize, nWcheck, st, outStr );
481
482 if( !isOK )
483 {
484 G4String chartmp = G4UIcommand::ConvertToString( G4int(nWcheck) );
485 outStr += chartmp + G4String(" words");
486 DumpVS( wl, outStr.c_str() );
487 G4String ErrMessage = " NUMBER OF WORDS: "
489 G4Exception("G4tgrUtils::CheckWLsize()", "ParseError",
490 FatalException, ErrMessage);
491 }
492}
int G4int
Definition: G4Types.hh:66
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
static void DumpVS(const std::vector< G4String > &wl, const char *msg)
Definition: G4tgrUtils.cc:156
static G4bool CheckListSize(unsigned int nWreal, unsigned int nWcheck, WLSIZEtype st, G4String &outstr)
Definition: G4tgrUtils.cc:495

Referenced by G4tgrVolume::AddCheckOverlaps(), G4tgrVolume::AddPlace(), G4tgrVolumeAssembly::AddPlace(), G4tgrVolume::AddPlaceReplica(), G4tgrVolume::AddRGBColour(), G4tgrVolume::AddVisibility(), G4tgrParameterMgr::CheckIfNewParameter(), G4tgrElementFromIsotopes::G4tgrElementFromIsotopes(), G4tgrElementSimple::G4tgrElementSimple(), G4tgrIsotope::G4tgrIsotope(), G4tgrMaterialMixture::G4tgrMaterialMixture(), G4tgrMaterialSimple::G4tgrMaterialSimple(), G4tgrPlaceDivRep::G4tgrPlaceDivRep(), G4tgrPlaceParameterisation::G4tgrPlaceParameterisation(), G4tgrVolumeAssembly::G4tgrVolumeAssembly(), and G4tgrVolumeDivision::G4tgrVolumeDivision().

◆ Dump3v()

void G4tgrUtils::Dump3v ( const G4ThreeVector vec,
const char *  msg 
)
static

Definition at line 124 of file G4tgrUtils.cc.

125{
126 G4cout << msg << std::setprecision(8)
127 << vec << std::setprecision(6) << G4endl;
128}
G4DLLIMPORT std::ostream G4cout

◆ Dumprm()

void G4tgrUtils::Dumprm ( const G4RotationMatrix rm,
const char *  msg 
)
static

Definition at line 132 of file G4tgrUtils.cc.

133{
134 G4cout << msg << G4endl
135 << " xx=" << rm.xx() << " yx=" << rm.yx() << " zx=" << rm.zx() << G4endl
136 << " xy=" << rm.xy() << " yy=" << rm.yy() << " zy=" << rm.zy() << G4endl
137 << " xz=" << rm.xz() << " yz=" << rm.yz() << " zz=" << rm.zz() << G4endl;
138}
double zz() const
double yz() const
double zx() const
double yx() const
double zy() const
double xx() const
double yy() const
double xz() const
double xy() const

◆ DumpVS() [1/2]

void G4tgrUtils::DumpVS ( const std::vector< G4String > &  wl,
const char *  msg 
)
static

◆ DumpVS() [2/2]

void G4tgrUtils::DumpVS ( const std::vector< G4String > &  wl,
const char *  msg,
std::ostream &  outs 
)
static

Definition at line 142 of file G4tgrUtils.cc.

144{
145 outs << msg << G4endl;
146 std::vector<G4String>::const_iterator ite;
147 for( ite = wl.begin(); ite != wl.end(); ite++ )
148 {
149 outs << *ite << " ";
150 }
151 outs << G4endl;
152}

◆ GetBool()

G4bool G4tgrUtils::GetBool ( const G4String str)
static

Definition at line 445 of file G4tgrUtils.cc.

446{
447 G4bool val = false;
448
449 //----------- first check that it is a not number
450 if( (str == "ON") || (str == "TRUE") )
451 {
452 val = true;
453 }
454 else if( (str == "OFF") || (str == "FALSE") )
455 {
456 val = false;
457 }
458 else
459 {
460 G4String ErrMessage = G4String("Trying to get a float from a string")
461 + G4String(" which is not 'ON'/'OFF'/'TRUE'/'FALSE' ")
462 + str;
463 G4Exception("G4tgrUtils::GetBool()", "ParseError",
464 FatalException, ErrMessage );
465 }
466
467 return val;
468}

Referenced by G4tgrVolume::AddCheckOverlaps(), and G4tgrVolume::AddVisibility().

◆ GetDouble()

G4double G4tgrUtils::GetDouble ( const G4String str,
G4double  unitval = 1. 
)
static

Definition at line 203 of file G4tgrUtils.cc.

204{
205#ifdef G4VERBOSE
207 {
208 G4cout << "G4tgrUtils::GetDouble() - Processing: "
209 << str << " default unit " << unitval << G4endl;
210 }
211#endif
212 if( str == "DBL_MAX" ) {
213 return DBL_MAX;
214 }else if( str == "DBL_MIN" ) {
215 return DBL_MIN;
216 }else if( str == "FLT_MAX" ) {
217 return FLT_MAX;
218 }else if( str == "FLT_MIN" ) {
219 return FLT_MIN;
220 }else if( str == "INT_MAX" ) {
221 return INT_MAX;
222 }else if( str == "INT_MIN" ) {
223 return INT_MIN;
224 }
225 //----- Look for arithmetic symbols, (, )
226 const char* cstr = str.c_str();
227 std::set<G4int> separators;
228 separators.insert(-1);
229 G4int strlen = G4int(str.length());
230 for(G4int ii=0; ii<strlen; ii++)
231 {
232 char cs = cstr[ii];
233 if( cs == '*' || cs == '/' || cs == '(' || cs == ')' )
234 {
235 separators.insert(ii);
236 }
237 else if( cs == '+' || cs == '-' )
238 {
239 // Check if it is not an exponential
240 //
241 if( (ii < 2)
242 || ( (cstr[ii-1] != 'E') && (cstr[ii-1] != 'e') )
243 || !IsNumber(cstr[ii-2]) )
244 {
245 separators.insert(ii);
246 }
247 }
248 }
249 separators.insert(strlen);
250 std::string strnew; // build a new word with Parameters
251 // and units substituted by values
252 //----- Process words, defined as characters between two separators
253 G4int nUnits = 0;
254 std::set<G4int>::const_iterator site, site2;
255 site = separators.begin();
256 site2 = site; site2++;
257 for( ; site2 != separators.end(); site++,site2++)
258 {
259#ifdef G4VERBOSE
261 {
262 G4cout << " Loop to find word between " << *site
263 << " " << *site2 << G4endl;
264 }
265#endif
266
267 if( *site != -1 ) { strnew += str.substr(*site,1); }
268
269 G4int wlen = (*site2)-(*site)-1; //do not count contiguous separators
270 std::string word;
271 if(wlen != 0)
272 {
273 word = str.substr((*site)+1,(*site2)-(*site)-1);
274 }
275 else
276 {
277 //--- Check combination of separators
278 //--- Check number of parentheses
279 continue;
280 }
281
282#ifdef G4VERBOSE
284 {
285 G4cout << " Processing word: " << word << G4endl;
286 }
287#endif
288 //----------- first check if it is parameter
289 const char* cword = word.c_str();
290 if( cword[0] == '$' )
291 {
293 ->FindParameter( word.substr(1,word.size()));
294 if( parstr.substr(0,1) == "-" )
295 {
296 strnew += "(";
297 }
298 strnew += parstr;
299 if( parstr.substr(0,1) == "-" )
300 {
301 strnew += ")";
302 }
303#ifdef G4VERBOSE
305 {
306 G4cout << " G4tgrutils::GetDouble() - Param found: "
307 << word << " in string " << str
308 << " , substituted by " << parstr << G4endl;
309 }
310#endif
311 }
312 else
313 {
314 //----- Get if it is a number
315 if( IsNumber(word) )
316 {
317 //--- left separator cannot be ')'
318 if( (*site != -1) && (cstr[*site] == ')') )
319 {
320 G4String ErrMessage = "There cannot be a ')' before a number: "
321 + word + " in string: " + str;
322 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
323 FatalException, ErrMessage);
324 }
325 //--- right separator cannot be '('
326 if( (*site2 != strlen) && (cstr[*site2] == '(') )
327 {
328 G4String ErrMessage = "There cannot be a '(' after a number: "
329 + word + " in string: " + str;
330 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
331 FatalException, ErrMessage);
332 }
333 strnew += word;
334
335 //------ If it is an string, check if it is a unit
336 }
337 else
338 {
339 //--- First character cannot be a digit
340 if( isdigit(word[0]) )
341 {
342 G4String ErrMessage = "String words cannot start with a digit: "
343 + word + " in string: " + str;
344 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
345 FatalException, ErrMessage );
346 }
347
348 //----- Check if it is a function
349 G4bool bWordOK = false;
350 if( G4tgrUtils::IsFunction( word ) )
351 {
352 //--- It must be followed by '('
353 if( (*site2 == strlen) || (cstr[*site2] != '(') )
354 {
355 G4String ErrMessage = "There must be a '(' after a function: "
356 + word + " in string: " + str;
357 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
358 FatalException, ErrMessage );
359 }
360 strnew += word;
361 bWordOK = true;
362 //----- Check if it is a unit
363 }
364 else if( G4tgrUtils::WordIsUnit( word ) )
365 {
366 //--- It must be preceded by a *
367 if( (*site == -1)
368 || ( (cstr[*site] != '*') && (cstr[*site] != '/') ) )
369 {
370 G4String ErrMess = "There must be a '*' before a unit definition: "
371 + word + " in string " + str;
372 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
373 FatalException, ErrMess );
374 }
375 //--- check that it is indeed a CLHEP unit
376 if( G4UnitDefinition::GetValueOf(word) != 0. )
377 {
378 bWordOK = true;
379 nUnits++;
380 if( nUnits > 1 )
381 {
382 // G4String ErrMess = "There cannot be two unit definitions: "
383 // + word + " in string " + str;
384 // G4Exception("G4tgrUtils::GetDouble()", "ParseError",
385 // FatalException, ErrMess );
386 }
388 }
389 }
390 if( !bWordOK )
391 {
392 G4String ErrMess = "String word is not a parameter, nor a unit\n";
393 + G4String("definition nor a function: ") + word
394 + G4String(" in string: ") + str;
395 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
396 FatalException, ErrMess );
397 }
398 }
399 }
400 }
401
402 G4double val = theEvaluator->evaluate( strnew.c_str() );
403 if (theEvaluator->status() != HepTool::Evaluator::OK)
404 {
405 theEvaluator->print_error(theEvaluator->status());
406 G4String ErrMessage = "Evaluator error: " + strnew;
407 G4Exception("G4tgrUtils::GetDouble()", "ParseError",
408 FatalException, ErrMessage );
409 }
410
411 if( nUnits == 0 ) { val *= unitval; }
412
413#ifdef G4VERBOSE
415 {
416 G4cout << " G4tgrUtils::GetDouble() - RESULT= " << val << G4endl
417 << " from string: " << str << " converted to: " << strnew.c_str()
418 << " with unit val: " << unitval << G4endl;
419 }
420#endif
421
422 return val;
423}
double G4double
Definition: G4Types.hh:64
static G4double GetValueOf(const G4String &)
void print_error(G4int status) const
static G4int GetVerboseLevel()
G4String FindParameter(const G4String &name, G4bool exists=true)
static G4tgrParameterMgr * GetInstance()
static G4bool IsNumber(const G4String &str)
Definition: G4tgrUtils.cc:79
static G4bool IsFunction(const G4String &word)
Definition: G4tgrUtils.cc:593
static G4bool WordIsUnit(const G4String &word)
Definition: G4tgrUtils.cc:554
double evaluate(const char *expression)
Definition: Evaluator.cc:611
int status() const
Definition: Evaluator.cc:631
#define INT_MIN
Definition: templates.hh:115
#define FLT_MAX
Definition: templates.hh:99
#define FLT_MIN
Definition: templates.hh:91
#define INT_MAX
Definition: templates.hh:111
#define DBL_MIN
Definition: templates.hh:75
#define DBL_MAX
Definition: templates.hh:83

Referenced by G4tgrParameterMgr::AddParameterNumber(), G4tgrVolume::AddPlaceReplica(), G4tgrVolume::AddRGBColour(), G4tgrElementFromIsotopes::G4tgrElementFromIsotopes(), G4tgrElementSimple::G4tgrElementSimple(), G4tgrIsotope::G4tgrIsotope(), G4tgrMaterialMixture::G4tgrMaterialMixture(), G4tgrMaterialSimple::G4tgrMaterialSimple(), G4tgrPlaceDivRep::G4tgrPlaceDivRep(), G4tgrPlaceParameterisation::G4tgrPlaceParameterisation(), G4tgrPlaceSimple::G4tgrPlaceSimple(), G4tgrRotationMatrix::G4tgrRotationMatrix(), G4tgrSolidBoolean::G4tgrSolidBoolean(), G4tgrVolumeAssembly::G4tgrVolumeAssembly(), G4tgrVolumeDivision::G4tgrVolumeDivision(), GetInt(), and G4tgrLineProcessor::ProcessLine().

◆ GetInt()

G4int G4tgrUtils::GetInt ( const G4String str)
static

Definition at line 427 of file G4tgrUtils.cc.

428{
429 //----- Convert it to a number (it can be a parameter)
430 G4double val = GetDouble(str);
431
432 //----- Check it is an integer
433 if( !IsInteger(val) )
434 {
435 G4String ErrMessage = G4String("Trying to get the integer from a number")
436 + G4String(" which is not an integer ") + str;
437 G4Exception("G4tgrUtils::GetInt()", "ParseError",
438 FatalException, ErrMessage );
439 }
440 return G4int( val );
441}
static G4bool IsInteger(const G4double val, const G4double precision=1.e-6)
Definition: G4tgrUtils.cc:110
static G4double GetDouble(const G4String &str, G4double unitval=1.)
Definition: G4tgrUtils.cc:203

Referenced by G4tgrElementFromIsotopes::G4tgrElementFromIsotopes(), G4tgrElementSimple::G4tgrElementSimple(), G4tgrIsotope::G4tgrIsotope(), G4tgrMaterialMixture::G4tgrMaterialMixture(), G4tgrPlaceDivRep::G4tgrPlaceDivRep(), G4tgrPlaceParameterisation::G4tgrPlaceParameterisation(), G4tgrPlaceSimple::G4tgrPlaceSimple(), G4tgrVolumeAssembly::G4tgrVolumeAssembly(), and G4tgrVolumeDivision::G4tgrVolumeDivision().

◆ GetRotationFromDirection()

G4RotationMatrix G4tgrUtils::GetRotationFromDirection ( G4ThreeVector  dir)
static

Definition at line 624 of file G4tgrUtils.cc.

625{
626 G4RotationMatrix rotation;
627
628 if( std::fabs(dir.mag()-1.) > G4GeometryTolerance::GetInstance()
630 {
631 G4String WarMessage = "Direction cosines have been normalized to one.\n"
632 + G4String("They were normalized to ")
634 G4Exception("G4tgrUtils::GetRotationFromDirection()", "WrongArgument",
635 JustWarning, WarMessage);
636 dir /= dir.mag();
637 }
638 G4double angx = -std::asin(dir.y());
639
640 // There are always two solutions angx, angy and PI-angx,
641 // PI+angy, choose first
642 //
643 G4double angy;
644 if( dir.y() == 1. )
645 {
646 angy = 0.;
647 }
648 else if( dir.y() == 0. )
649 {
650 angy = 0.;
651 }
652 else
653 {
654 angy = std::asin( dir.x()/std::sqrt(1-dir.y()*dir.y()) );
655 }
656
657 // choose between angy and PI-angy
658 if( dir.z() * std::cos(angx)*std::cos(angy) < 0 )
659 {
660 angy = pi - angy;
661 }
662 rotation.rotateX( angx );
663 rotation.rotateY( angy );
664
665 return rotation;
666}
@ JustWarning
double z() const
double x() const
double y() const
double mag() const
HepRotation & rotateX(double delta)
Definition: Rotation.cc:66
HepRotation & rotateY(double delta)
Definition: Rotation.cc:79
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
const G4double pi

◆ GetString()

G4String G4tgrUtils::GetString ( const G4String str)
static

◆ IsFunction()

G4bool G4tgrUtils::IsFunction ( const G4String word)
static

Definition at line 593 of file G4tgrUtils.cc.

594{
595 if( word == "sin"
596 || word == "cos"
597 || word == "tan"
598 || word == "asin"
599 || word == "acos"
600 || word == "atan"
601 || word == "atan2"
602 || word == "sinh"
603 || word == "cosh"
604 || word == "tanh"
605 || word == "asinh"
606 || word == "acosh"
607 || word == "atanh"
608 || word == "sqrt"
609 || word == "exp"
610 || word == "log"
611 || word == "log10"
612 || word == "pow" )
613 {
614 return true;
615 }
616 else
617 {
618 return false;
619 }
620}

Referenced by GetDouble().

◆ IsInteger()

G4bool G4tgrUtils::IsInteger ( const G4double  val,
const G4double  precision = 1.e-6 
)
static

Definition at line 110 of file G4tgrUtils.cc.

111{
112 if( G4int(val) / val - 1 > precision )
113 {
114 return 0;
115 }
116 else
117 {
118 return 1;
119 }
120}

Referenced by GetInt().

◆ IsNumber()

G4bool G4tgrUtils::IsNumber ( const G4String str)
static

Definition at line 79 of file G4tgrUtils.cc.

80{
81 G4int isnum = 1;
82 G4int numE = 0;
83 for(size_t ii=0; ii<str.length(); ii++)
84 {
85 if(!isdigit(str[ii]) && (str[ii]!='.') && (str[ii]!='-') && (str[ii]!='+'))
86 {
87 //--- check for E(xponential)
88 if(str[ii] == 'E' || str[ii] == 'e' )
89 {
90 if( ii == 0 ) { return 0; }
91 if(numE != 0 || ii == str.length()-1)
92 {
93 isnum = 0;
94 break;
95 }
96 numE++;
97 }
98 else
99 {
100 isnum = 0;
101 break;
102 }
103 }
104 }
105 return isnum;
106}

Referenced by GetDouble(), and WordIsUnit().

◆ IsSeparator()

G4bool G4tgrUtils::IsSeparator ( char  ch)
static

Definition at line 64 of file G4tgrUtils.cc.

65{
66 char nonCharacters[7] = {"()+-*/"};
67 for( size_t ii = 0; ii < 6; ii++ )
68 {
69 if( ch == nonCharacters[ii] )
70 {
71 return true;
72 }
73 }
74 return false;
75}

◆ SubColon()

G4String G4tgrUtils::SubColon ( const G4String str)
static

Definition at line 163 of file G4tgrUtils.cc.

164{
165 if( str.find(':') != 0 )
166 {
167 G4String ErrMessage = "Trying to subtract leading colon from a word\n"
168 + G4String("that has no leading colon: ") + str;
169 G4Exception("G4tgrUtils::SubColon()", "ParseError",
170 FatalException, ErrMessage);
171 }
172 G4String strt = str.substr(1,str.size()-1);
173 return strt;
174}

◆ WordIsUnit()

G4bool G4tgrUtils::WordIsUnit ( const G4String word)
static

Definition at line 554 of file G4tgrUtils.cc.

555{
556 return !IsNumber(word);
557 if( word == "mm"
558 || word == "cm"
559 || word == "m"
560 || word == "km"
561 || word == "millimeter"
562 || word == "centimeter"
563 || word == "meter"
564 || word == "kilometer"
565 || word == "parsec"
566 || word == "micrometer"
567 || word == "nanometer"
568 || word == "angstrom"
569 || word == "fermi"
570 || word == "nm"
571 || word == "um"
572 || word == "pc"
573 || word == "radian"
574 || word == "milliradian"
575 || word == "degree"
576 || word == "rad"
577 || word == "mrad"
578 || word == "deg"
579 || word == "ns"
580 || word == "curie"
581 || word == "curie" )
582 {
583 return true;
584 }
585 else
586 {
587 return false;
588 }
589}

Referenced by GetDouble().


The documentation for this class was generated from the following files: