Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
TG4Globals.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Geant4 Virtual Monte Carlo package
3
// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
14
15
#include "
TG4Globals.h
"
16
17
#include <stdlib.h>
18
19
const
TString
TG4Globals::fgkEndl
=
"x\n"
;
20
const
char
TG4Globals::fgkTokenSeparator
=
'+'
;
21
22
//_____________________________________________________________________________
23
TG4Globals::~TG4Globals
()
24
{
26
}
27
28
//
29
// public static methods
30
//
31
32
//_____________________________________________________________________________
33
void
TG4Globals::Exception
(
34
const
TString& className,
const
TString& methodName,
const
TString& text)
35
{
37
38
TString newText =
"x\n"
+ className +
"::"
+ methodName +
":x\n"
;
39
newText += text +
"\n"
;
40
newText +=
"*** TG4Exception: Aborting execution ***"
;
41
newText.ReplaceAll(
"x\n"
,
"\n "
);
42
43
G4cerr << newText.Data() << G4endl << G4endl;
44
abort();
45
}
46
47
//_____________________________________________________________________________
48
void
TG4Globals::Warning
(
49
const
TString& className,
const
TString& methodName,
const
TString& text)
50
{
52
53
TString newText =
"++++ TG4Warning: ++++x\n"
;
54
newText += className +
"::"
+ methodName +
":x\n"
;
55
newText += text +
"\n"
;
56
newText +=
"+++++++++++++++++++++++"
;
57
newText.ReplaceAll(
"x\n"
,
"\n "
);
58
59
G4cerr << newText.Data() << G4endl << G4endl;
60
}
61
62
//_____________________________________________________________________________
63
void
TG4Globals::AppendNumberToString
(G4String& s, G4int a)
64
{
66
67
const
char
* kpNumber =
"0123456789"
;
68
G4String p =
""
;
69
G4String q =
""
;
70
do
{
71
G4int b = a / 10;
72
G4int c = a % 10;
73
p = kpNumber[c];
74
q = p.append(q);
75
a = b;
76
}
while
(a > 0);
77
s.append(q);
78
}
79
80
//_____________________________________________________________________________
81
G4bool
TG4Globals::Compare
(G4bool activation,
TG4G3ControlValue
controlValue)
82
{
86
87
if
(controlValue ==
kUnsetControlValue
) {
88
TG4Globals::Warning
(
"TG4Globals"
,
"Compare"
,
"Control value = kUnset."
);
89
return
false
;
90
}
91
92
if
(controlValue ==
kActivate
|| controlValue ==
kActivate2
)
93
return
activation;
94
else
95
return
!activation;
96
}
97
98
//_____________________________________________________________________________
99
void
TG4Globals::PrintStars
(G4bool emptyLineFirst)
100
{
102
103
if
(emptyLineFirst) G4cout << G4endl;
104
105
G4cout <<
"**********************************************"
<< G4endl;
106
107
if
(!emptyLineFirst) G4cout << G4endl;
108
}
109
110
//_____________________________________________________________________________
111
G4String
TG4Globals::Help
()
112
{
114
115
return
G4String(
"vmc@root.cern.ch"
);
116
}
117
118
//_____________________________________________________________________________
119
G4String
TG4Globals::GetToken
(Int_t i,
const
TString& s)
120
{
122
123
std::vector<G4String> tokens;
124
std::string ss = s.Data();
125
126
/*
127
std::string::size_type idx0 = 0;
128
std::string::size_type idx1 = ss.find(fgkTokenSeparator,idx0);
129
if ( idx1 == std::string::npos ) idx1 = ss.length();
130
do {
131
tokens.push_back(TString(ss.substr(idx0, idx1-idx0)));
132
idx0 = idx1+1;
133
idx1 = ss.find(fgkTokenSeparator,idx0);
134
if ( idx1 == std::string::npos ) idx1 = ss.length();
135
}
136
while ( idx0 <= ss.length() );
137
*/
138
std::string::size_type idx0 = 0;
139
do
{
140
std::string::size_type idx1 = ss.find(
fgkTokenSeparator
, idx0);
141
if
(idx1 == std::string::npos) idx1 = ss.length();
142
tokens.push_back(G4String(ss.substr(idx0, idx1 - idx0)));
143
idx0 = idx1 + 1;
144
}
while
(idx0 <= ss.length());
145
146
if
(i < 0 || i >= Int_t(tokens.size()))
147
return
""
;
148
else
149
return
tokens[i];
150
}
151
152
//_____________________________________________________________________________
153
G4bool
TG4Globals::Contains
(
const
G4String& name,
const
G4String& nameList)
154
{
159
160
if
(nameList.empty())
return
false
;
161
162
G4String checkName(name);
163
checkName.append(
" "
);
164
165
G4String checkNameList(nameList);
166
checkNameList.append(
" "
);
167
168
return
(checkNameList.find(checkName) != std::string::npos);
169
}
TG4Globals.h
Definition of the TG4Globals class and basic container types.
TG4Globals::AppendNumberToString
static void AppendNumberToString(G4String &string, G4int number)
Definition
TG4Globals.cxx:63
TG4Globals::GetToken
static G4String GetToken(Int_t i, const TString &s)
Definition
TG4Globals.cxx:119
TG4Globals::Help
static G4String Help()
Definition
TG4Globals.cxx:111
TG4Globals::fgkEndl
static const TString fgkEndl
Special endl.
Definition
TG4Globals.h:95
TG4Globals::PrintStars
static void PrintStars(G4bool emptyLineFirst)
Definition
TG4Globals.cxx:99
TG4Globals::Warning
static void Warning(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:48
TG4Globals::Exception
static void Exception(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:33
TG4Globals::Compare
static G4bool Compare(G4bool activation, TG4G3ControlValue controlValue)
Definition
TG4Globals.cxx:81
TG4Globals::~TG4Globals
~TG4Globals()
Definition
TG4Globals.cxx:23
TG4Globals::fgkTokenSeparator
static const char fgkTokenSeparator
Separator in GetToken() method.
Definition
TG4Globals.h:96
TG4Globals::Contains
static G4bool Contains(const G4String &name, const G4String &nameList)
Definition
TG4Globals.cxx:153
TG4G3ControlValue
TG4G3ControlValue
Enumeration for G3 processes control values.
Definition
TG4G3Control.h:176
kActivate
@ kActivate
process is activated WITH generation of secondaries
Definition
TG4G3Control.h:184
kUnsetControlValue
@ kUnsetControlValue
value not set
Definition
TG4G3Control.h:178
kActivate2
@ kActivate2
process is activated WITHOUT generation of secondaries
Definition
TG4G3Control.h:187
Generated on
for Geant4 VMC by
1.17.0