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

#include <G4ParticleHPNames.hh>

Public Member Functions

 G4ParticleHPNames (G4int maxOffSet=5)
 
 ~G4ParticleHPNames ()=default
 
G4ParticleHPDataUsed GetName (G4int A, G4int Z, const G4String &base, const G4String &rest, G4bool &active)
 
G4ParticleHPDataUsed GetName (G4int A, G4int Z, G4int M, const G4String &base, const G4String &rest, G4bool &active)
 
G4String GetName (G4int i)
 
G4String itoa (G4int current)
 
void SetMaxOffSet (G4int anOffset)
 
 G4ParticleHPNames (G4ParticleHPNames &)=delete
 
G4ParticleHPNamesoperator= (const G4ParticleHPNames &right)=delete
 

Detailed Description

Definition at line 38 of file G4ParticleHPNames.hh.

Constructor & Destructor Documentation

◆ G4ParticleHPNames() [1/2]

G4ParticleHPNames::G4ParticleHPNames ( G4int maxOffSet = 5)
explicit

Definition at line 74 of file G4ParticleHPNames.cc.

74 : theMaxOffSet(maxOffSet)
75{
77}
static G4ParticleHPManager * GetInstance()

◆ ~G4ParticleHPNames()

G4ParticleHPNames::~G4ParticleHPNames ( )
default

◆ G4ParticleHPNames() [2/2]

G4ParticleHPNames::G4ParticleHPNames ( G4ParticleHPNames & )
delete

Member Function Documentation

◆ GetName() [1/3]

◆ GetName() [2/3]

G4ParticleHPDataUsed G4ParticleHPNames::GetName ( G4int A,
G4int Z,
G4int M,
const G4String & base,
const G4String & rest,
G4bool & active )

Definition at line 97 of file G4ParticleHPNames.cc.

99{
100 // G4cout << Z << " " << A << " " << M << " " << base << " " << rest << G4endl;
101
102 // Excited isomer indicator
103 std::stringstream ss;
104 G4String sM;
105 if (M > 0) {
106 ss << "m";
107 ss << M;
108 ss >> sM;
109 ss.clear();
110 }
111
113 aFlag = true;
114
115#ifdef G4VERBOSE
116 if (fManager->GetDEBUG())
117 G4cout << "Names::GetName entered for Z = " << Z << ", A = " << A << G4endl;
118#endif
119
120 G4int myA = A;
121 G4int myZ = Z;
122
123 G4String* theName = nullptr;
124 G4String theFileName("");
125
126 // G4int inc = 1;
127
128 G4int flip_Z = 1;
129 G4int delta_Z = 0;
130
131 G4int flip_A = 1;
132 G4int delta_A = 0;
133
134 std::istringstream* check = nullptr;
135 G4bool first = true;
136
137#ifdef G4VERBOSE
138 if (fManager->GetDEBUG())
139 G4cout << "entered GetName!!!" << G4endl;
140#endif
141
142 do {
143 aFlag = true;
144 auto biff = new G4String(); // delete here as theName
145 *biff = base + "/CrossSection/" + itoa(myZ) + "_" + itoa(myA) + sM + "_" + theString[myZ - 1];
146
147 delete theName;
148 theName = biff;
149 result.SetName(*theName);
150 result.SetA(myA);
151 result.SetZ(myZ);
152 result.SetM(M);
153 delete check;
154
155 check = new std::istringstream(std::ios::in);
156 fManager->GetDataStream2(*theName, *check);
157 if (!(*check)) {
158 delete check;
159 check = nullptr;
160 aFlag = false;
161 if (first) {
162 aFlag = true;
163 first = false;
164 biff = new G4String(); // delete here as theName
165 *biff = base + "/CrossSection/" + itoa(myZ) + "_" + "nat" + "_" + theString[myZ - 1];
166 delete theName;
167 theName = biff;
168 result.SetName(*theName);
169 G4double natA = myZ / G4SandiaTable::GetZtoA(myZ);
170 result.SetA(natA);
171 result.SetZ(myZ);
172 result.SetM(M);
173 // check = new std::ifstream(*theName);
174 check = new std::istringstream(std::ios::in);
175 fManager->GetDataStream2(*theName, *check);
176 if (!(*check)) {
177 // check->close();
178 delete check;
179 check = nullptr;
180 aFlag = false;
181 }
182 else {
183 biff = new G4String(); // delete here as theName
184 *biff = base + "/" + rest + "/" + itoa(myZ) + "_" + "nat" + "_" + theString[myZ - 1];
185 if (rest == "/CrossSection")
186 *biff = base + rest + "/" + itoa(myZ) + "_" + "nat" + "_" + theString[myZ - 1];
187 delete theName;
188 theName = biff;
189 result.SetName(*theName);
190 natA = myZ / G4SandiaTable::GetZtoA(myZ);
191 result.SetA(natA);
192 result.SetZ(myZ);
193 result.SetM(M);
195 }
196 }
197 }
198 else {
199 G4double tmpA = myA;
200 std::istringstream* file = nullptr;
201 G4String fileName;
202
203 if (rest == "/CrossSection") {
204 fileName = base + rest + "/" + itoa(myZ) + "_" + itoa(myA) + sM + "_" + theString[myZ - 1];
205 // if(fManager->GetDEBUG()) G4cout <<"HPWD 4a "<<*theName<<G4endl;
206 }
207 else {
208 // For FS
209 fileName =
210 base + "/" + rest + "/" + itoa(myZ) + "_" + itoa(myA) + sM + "_" + theString[myZ - 1];
211 file = new std::istringstream(std::ios::in);
212 fManager->GetDataStream2(fileName, *file);
213
214 if (*file) {
215 // isotope FS
216 // if(fManager->GetDEBUG()) G4cout <<"HPWD 4b1 "<<*theName<<G4endl;
217 }
218 else {
219 // _nat_ FS
220 fileName = base + "/" + rest + "/" + itoa(myZ) + "_" + "nat" + "_" + theString[myZ - 1];
221
222 delete file;
223 file = new std::istringstream(std::ios::in);
225 if (*file) {
226 // FS neither isotope nor _nat_
227 // if(fManager->GetDEBUG()) G4cout <<"HPWD 4b2a "<<*theName<<G4endl;
228 G4double natA = myZ / G4SandiaTable::GetZtoA(myZ);
229 tmpA = natA;
230 }
231 else {
232 // if(fManager->GetDEBUG()) G4cout <<"HPWD 4b2c "<<*theName<<G4endl;
233 fileName = "INVALID";
234 }
235 }
236 delete file;
237 }
238
239 result.SetName(fileName);
240 result.SetA(tmpA);
241 result.SetZ(myZ);
242 result.SetM(M);
243 }
244
245 do {
246 if (delta_Z > theMaxOffSet) {
247 if (!fManager->GetSkipMissingIsotopes()) {
248#ifdef G4VERBOSE
249 if (fManager->GetVerboseLevel() > 0) {
250 G4cout << "G4ParticleHPNames: There are no data available for some isotopes in this "
251 "material "
252 << G4endl;
253 G4cout << "G4ParticleHPNames: nor are there data for nearby isotopes." << G4endl;
254 G4cout << "G4ParticleHPNames: Please make sure G4NEUTRONHPDATA points to the directory "
255 << G4endl;
256 G4cout << "G4ParticleHPNames: in which the neutron scattering data are located."
257 << G4endl;
258 G4cout << "G4ParticleHPNames: The material was A = " << A << ", Z = " << Z << G4endl;
259 }
260#endif
262 ed << "Data for Z=" << Z << " A=" << A << " M=" << M << " does not exist in G4NEUTRONHPDATA";
263 G4Exception("G4ParticleHPName::Init(...)","hadhp01",
264 JustWarning, ed, "");
265 }
266 check = new std::istringstream(std::ios::in);
267 break;
268 }
269 if (delta_A > 2 * theMaxOffSet) {
270 delta_A = 0;
271 flip_A = 1;
272
273 first = true;
274
275 if (flip_Z > 0) {
276 delta_Z += 1;
277 }
278 myZ = Z + flip_Z * delta_Z;
279 flip_Z *= -1;
280
281 myA = A;
282 if (myZ > 100) {
283 myZ = 100;
284 }
285 if (myZ < 1) {
286 myZ = 1;
287 }
288
289 // myZ += inc;
290 }
291 else {
292 if (flip_A > 0) {
293 delta_A += 1;
294 }
295 myA = A + flip_A * delta_A;
296 flip_A *= -1;
297
298 if (myA < 1) {
299 myA = 1;
300 }
301
302 // myA += inc;
303 }
304
305 } while (myZ == 0 || myA == 0); // No meaning // Loop checking, 11.05.2015, T. Koi
306
307 } while ((check == nullptr) || (!(*check))); // Loop checking, 11.05.2015, T. Koi
308
309#ifdef G4VERBOSE
310 if (fManager->GetDEBUG())
311 {
312 G4cout << "Names::GetName: last theName proposal = " << G4endl;
313 G4cout << *theName << " " << A << " " << Z << " " << result.GetName() << G4endl;
314 }
315#endif
316
317 // administration and anouncement for lacking of exact data in NDL
318 if (Z != result.GetZ() || A != result.GetA()) {
319 if (rest == "/CrossSection") {
320 G4String reac = base;
321 G4String dir = fManager->GetNeutronHPPath();
322 reac.erase(0, dir.length());
323 if (fManager->GetSkipMissingIsotopes()
324 && (Z != result.GetZ() || !result.IsThisNaturalAbundance()))
325 {
326#ifdef G4VERBOSE
327 if (fManager->GetVerboseLevel() > 0) {
328 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A
329 << " is not found and CrossSection set to 0." << G4endl;
330 }
331#endif
332 G4String new_name = base + "/" + rest + "/" + "0_0_Zero";
333 result.SetName(new_name);
334 }
335 else {
336 // 080901 Add protection that deuteron data do not selected for hydrogen and so on by T. Koi
337 // 160216 Increase protencted isotopes for fixing problem on charged particle HP
338 if ((reac.find("Inelastic") != reac.size()
339 && ((Z == 1 && A == 1) || (Z == 1 && A == 2) || (Z == 1 && A == 3)
340 || (Z == 2 && A == 3) || (Z == 2 && A == 4)))
341 || (reac.find("Capture") != reac.size() && ((Z == 1 && A == 3) || (Z == 2 && A == 4)))
342 || (reac.find("Fission") != reac.size()
343 && ((Z == 88 && A == 224) || (Z == 88 && A == 225) || (Z == 89 && A == 225)
344 || (Z == 88 && A == 226))))
345
346 {
347 G4String new_name = base + "/" + rest + "/" + "0_0_Zero";
348 result.SetName(new_name);
349 }
350 else {
351#ifdef G4VERBOSE
352 if (fManager->GetVerboseLevel() > 0) {
353 G4cout << "NeutronHP: " << reac << " file for Z = " << Z << ", A = " << A
354 << " is not found and NeutronHP will use " << result.GetName() << G4endl;
355 }
356#endif
357 }
358 }
359 }
360 }
361
362 delete theName;
363 delete check;
364
365 return result;
366}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define M(row, col)
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
void SetName(const G4String &aName)
void GetDataStream2(const G4String &, std::istringstream &iss)
const G4String & GetNeutronHPPath() const
G4bool GetSkipMissingIsotopes() const
G4String itoa(G4int current)
static G4double GetZtoA(G4int Z)

◆ GetName() [3/3]

G4String G4ParticleHPNames::GetName ( G4int i)

Definition at line 79 of file G4ParticleHPNames.cc.

80{
81 return (i > 0 && i < 100) ? theString[i] : G4String("");
82}

◆ itoa()

G4String G4ParticleHPNames::itoa ( G4int current)

Definition at line 84 of file G4ParticleHPNames.cc.

85{
86 const char theDigits[11] = "0123456789";
87 G4String result;
88 G4int digit;
89 do {
90 digit = current - 10 * (current / 10);
91 result = theDigits[digit] + result;
92 current /= 10;
93 } while (current != 0); // Loop checking, 11.05.2015, T. Koi
94 return result;
95}

Referenced by GetName().

◆ operator=()

G4ParticleHPNames & G4ParticleHPNames::operator= ( const G4ParticleHPNames & right)
delete

◆ SetMaxOffSet()

void G4ParticleHPNames::SetMaxOffSet ( G4int anOffset)
inline

Definition at line 55 of file G4ParticleHPNames.hh.

55{ theMaxOffSet = anOffset; }

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