Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PDGCodeChecker.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4PDGCodeChecker
27//
28// Author: Hisaya Kurashige, 17 August 1999
29// --------------------------------------------------------------------
30
31#include "G4PDGCodeChecker.hh"
32
34#include "G4SystemOfUnits.hh"
35
36#include <fstream>
37#include <iomanip>
38
40{
41 // clear QuarkContents
42 for (G4int flavor = 0; flavor < NumberOfQuarkFlavor; ++flavor) {
43 theQuarkContent[flavor] = 0;
44 theAntiQuarkContent[flavor] = 0;
45 }
46}
47
49{
50 code = PDGcode;
51 theParticleType = particleType;
52
53 // clear QuarkContents
54 for (G4int flavor = 0; flavor < NumberOfQuarkFlavor; ++flavor) {
55 theQuarkContent[flavor] = 0;
56 theAntiQuarkContent[flavor] = 0;
57 }
58
59 // check code for nuclei
60 if ((theParticleType == "nucleus") || (theParticleType == "anti_nucleus")) {
61 return CheckForNuclei();
62 }
63
64 // get each digit number
65 GetDigits(code);
66
67 // check code
68 if (theParticleType == "quarks") {
69 return CheckForQuarks();
70 }
71 if (theParticleType == "diquarks") {
72 return CheckForDiQuarks();
73 }
74 if (theParticleType == "gluons") {
75 return code; // gluons, do not care about
76 }
77 if (theParticleType == "meson") {
78 return CheckForMesons();
79 }
80 if (theParticleType == "baryon") {
81 return CheckForBaryons();
82 }
83 // No check
84 return code;
85}
86
87G4int G4PDGCodeChecker::CheckForBaryons()
88{
89 G4int tempPDGcode = code;
90
91 if ((quark1 == 0) || (quark2 == 0) || (quark3 == 0)) {
92#ifdef G4VERBOSE
93 if (verboseLevel > 0) {
94 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
95 G4cout << " meson has three quark ";
96 G4cout << " PDG code=" << code << G4endl;
97 }
98#endif
99 return 0;
100 }
101
102 // exceptions
103 if (std::abs(tempPDGcode) % 10000 == 3122) {
104 // Lambda
105 quark2 = 2;
106 quark3 = 1;
107 spin = 1;
108 }
109 else if (std::abs(tempPDGcode) % 10000 == 3124) {
110 // Lambda*
111 quark2 = 2;
112 quark3 = 1;
113 spin = 3;
114 }
115 else if (std::abs(tempPDGcode) % 10000 == 3126) {
116 // Lambda*
117 quark2 = 2;
118 quark3 = 1;
119 spin = 5;
120 }
121 else if (std::abs(tempPDGcode) % 10000 == 3128) {
122 // Lambda*
123 quark2 = 2;
124 quark3 = 1;
125 spin = 7;
126 }
127 else if (std::abs(tempPDGcode) % 10000 == 4122) {
128 // Lambda_c
129 quark2 = 2;
130 quark3 = 1;
131 spin = 1;
132 }
133 else if (std::abs(tempPDGcode) % 10000 == 5122) {
134 // Lambda_b
135 quark2 = 2;
136 quark3 = 1;
137 spin = 1;
138 }
139 else if (std::abs(tempPDGcode) % 10000 == 4132) {
140 // Xi_c0
141 quark2 = 3;
142 quark3 = 1;
143 spin = 1;
144 }
145 else if (std::abs(tempPDGcode) % 10000 == 4232) {
146 // Xi_c+
147 quark2 = 3;
148 quark3 = 2;
149 spin = 1;
150 }
151 else if (std::abs(tempPDGcode) % 10000 == 5132) {
152 // Xi_b0
153 quark2 = 3;
154 quark3 = 1;
155 spin = 1;
156 }
157 else if (std::abs(tempPDGcode) % 10000 == 5232) {
158 // Xi_b+
159 quark2 = 3;
160 quark3 = 2;
161 spin = 1;
162 }
163 else if (std::abs(tempPDGcode) % 10000 == 2122) {
164 // Delta+ (spin 1/2)
165 quark2 = 2;
166 quark3 = 1;
167 spin = 1;
168 }
169 else if (std::abs(tempPDGcode) % 10000 == 1212) {
170 // Delta0 (spin 1/2)
171 quark1 = 2;
172 quark2 = 1;
173 spin = 1;
174 }
175 else if (std::abs(tempPDGcode) % 10000 == 2126) {
176 // Delta+ (spin 5/2)
177 quark2 = 2;
178 quark3 = 1;
179 spin = 5;
180 }
181 else if (std::abs(tempPDGcode) % 10000 == 1216) {
182 // Delta0 (spin 5/2)
183 quark1 = 2;
184 quark2 = 1;
185 spin = 5;
186 }
187 else if (std::abs(tempPDGcode) % 10000 == 2128) {
188 // Delta+ (spin 7/2)
189 quark2 = 2;
190 quark3 = 1;
191 spin = 7;
192 }
193 else if (std::abs(tempPDGcode) % 10000 == 1218) {
194 // Delta0 (spin 7/2)
195 quark1 = 2;
196 quark2 = 1;
197 spin = 7;
198 }
199 else if (std::abs(tempPDGcode) % 10000 == 2124) {
200 // N*+ (spin 3/2)
201 quark2 = 2;
202 quark3 = 1;
203 spin = 3;
204 }
205 else if (std::abs(tempPDGcode) % 10000 == 1214) {
206 // N*0 (spin 3/2)
207 quark1 = 2;
208 quark2 = 1;
209 spin = 3;
210 }
211
212 // check quark flavor
213 if ((quark1 < quark2) || (quark2 < quark3) || (quark1 < quark3)) {
214#ifdef G4VERBOSE
215 if (verboseLevel > 0) {
216 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
217 G4cout << " illegal code for baryon ";
218 G4cout << " PDG code=" << code << G4endl;
219 }
220#endif
221 return 0;
222 }
223 if (quark1 > NumberOfQuarkFlavor) {
224#ifdef G4VERBOSE
225 if (verboseLevel > 0) {
226 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
227 G4cout << " ??? unknown quark ";
228 G4cout << " PDG code=" << code << G4endl;
229 }
230#endif
231 return 0;
232 }
233
234 // Fill Quark contents
235 if (tempPDGcode > 0) {
236 theQuarkContent[quark1 - 1]++;
237 theQuarkContent[quark2 - 1]++;
238 theQuarkContent[quark3 - 1]++;
239 }
240 else {
241 theAntiQuarkContent[quark1 - 1]++;
242 theAntiQuarkContent[quark2 - 1]++;
243 theAntiQuarkContent[quark3 - 1]++;
244 }
245
246 return code;
247}
248
249G4int G4PDGCodeChecker::CheckForMesons()
250{
251 G4int tempPDGcode = code;
252
253 // -- exceptions --
254 if (tempPDGcode == 310) spin = 0; // K0s
255 if (tempPDGcode == 130) // K0l
256 {
257 spin = 0;
258 quark2 = 3;
259 quark3 = 1;
260 }
261
262 if ((quark1 != 0) || (quark2 == 0) || (quark3 == 0)) {
263#ifdef G4VERBOSE
264 if (verboseLevel > 0) {
265 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
266 G4cout << " meson has only quark and anti-quark pair";
267 G4cout << " PDG code=" << code << G4endl;
268 }
269#endif
270 return 0;
271 }
272 if (quark2 < quark3) {
273#ifdef G4VERBOSE
274 if (verboseLevel > 0) {
275 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
276 G4cout << " illegal code for meson ";
277 G4cout << " PDG code=" << code << G4endl;
278 }
279#endif
280 return 0;
281 }
282
283 // check quark flavor
284 if (quark2 > NumberOfQuarkFlavor) {
285#ifdef G4VERBOSE
286 if (verboseLevel > 0) {
287 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
288 G4cout << " ??? unknown quark ";
289 G4cout << " PDG code=" << code << G4endl;
290 }
291#endif
292 return 0;
293 }
294
295 // check heavier quark type
296 if ((quark2 & 1) != 0) {
297 // down type qurak
298 if (tempPDGcode > 0) {
299 theQuarkContent[quark3 - 1] = 1;
300 theAntiQuarkContent[quark2 - 1] = 1;
301 }
302 else {
303 theQuarkContent[quark2 - 1] = 1;
304 theAntiQuarkContent[quark3 - 1] = 1;
305 }
306 }
307 else {
308 // up type quark
309 if (tempPDGcode > 0) {
310 theQuarkContent[quark2 - 1] = 1;
311 theAntiQuarkContent[quark3 - 1] = 1;
312 }
313 else {
314 theQuarkContent[quark3 - 1] = 1;
315 theAntiQuarkContent[quark2 - 1] = 1;
316 }
317 }
318 return code;
319}
320
321G4int G4PDGCodeChecker::CheckForDiQuarks()
322{
323 if ((quark1 == 0) || (quark2 == 0) || (quark3 != 0)) {
324 // quark3 should be 0
325 // --- code is wrong
326 return 0;
327 }
328 if (quark1 < quark2) {
329 // --- code is wrong
330 return 0;
331 }
332 if (quark2 > NumberOfQuarkFlavor) {
333#ifdef G4VERBOSE
334 if (verboseLevel > 0) {
335 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
336 G4cout << " ??? unknown quark ";
337 G4cout << " PDG code=" << code << G4endl;
338 }
339#endif
340 return 0;
341 }
342
343 // Fill Quark Contents
344 if (code > 0) {
345 theQuarkContent[quark1 - 1] += 1;
346 theQuarkContent[quark2 - 1] += 1;
347 }
348 else {
349 theAntiQuarkContent[quark1 - 1] += 1;
350 theAntiQuarkContent[quark2 - 1] += 1;
351 }
352
353 return code;
354}
355
356G4int G4PDGCodeChecker::CheckForQuarks()
357{
358 quark1 = std::abs(code);
359
360 if (std::abs(quark1) > NumberOfQuarkFlavor) {
361#ifdef G4VERBOSE
362 if (verboseLevel > 0) {
363 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
364 G4cout << " ??? unknown quark ";
365 G4cout << " PDG code=" << code << G4endl;
366 }
367#endif
368 // --- code is wrong
369 return 0;
370 }
371
372 // Fill Quark Contents
373 if (code > 0) {
374 theQuarkContent[quark1 - 1] = 1;
375 }
376 else {
377 theAntiQuarkContent[quark1 - 1] = 1;
378 }
379 return code;
380}
381
383{
384 // check charge
385 G4double totalCharge = 0.0;
386 for (G4int flavor = 0; flavor < NumberOfQuarkFlavor - 1; flavor += 2) {
387 totalCharge += (-1. / 3.) * eplus * theQuarkContent[flavor];
388 totalCharge += 1. / 3. * eplus * theAntiQuarkContent[flavor];
389 totalCharge += 2. / 3. * eplus * theQuarkContent[flavor + 1];
390 totalCharge += (-2. / 3.) * eplus * theAntiQuarkContent[flavor + 1];
391 }
392
393 if (std::fabs(totalCharge - thePDGCharge) > 0.1 * eplus) {
394#ifdef G4VERBOSE
395 if (verboseLevel > 0) {
396 G4cout << " G4PDGCodeChecker::CheckCharge : ";
397 G4cout << " illegal electric charge " << thePDGCharge / eplus;
398 G4cout << " PDG code=" << code << G4endl;
399 }
400#endif
401 return false;
402 }
403 return true;
404}
405
406G4int G4PDGCodeChecker::CheckForNuclei()
407{
408 G4int pcode = std::abs(code);
409 if (pcode < 1000000000) {
410 // non-nuclei
411 return 0;
412 }
413
414 pcode -= 1000000000;
415 G4int LL = pcode / 10000000;
416 pcode -= 10000000 * LL;
417 G4int Z = pcode / 10000;
418 pcode -= 10000 * Z;
419 G4int A = pcode / 10;
420
421 // Allow neutron balls
422 // if (A < 2 || Z > A-LL || LL>A || Z<=0 ) {
423 if (A < 2 || Z > A - LL || LL > A) {
424#ifdef G4VERBOSE
425 if (verboseLevel > 0) {
426 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
427 G4cout << " ??? Illegal PDG encoding for nucleus ";
428 G4cout << " PDG code=" << code << G4endl;
429 }
430#endif
431 return 0;
432 }
433
434 G4int n_up = 2 * Z + (A - Z - LL) + LL;
435 G4int n_down = Z + 2 * (A - Z - LL) + LL;
436 G4int n_s = LL;
437
438 // Fill Quark contents
439 if (code > 0) {
440 theQuarkContent[0] = n_up;
441 theQuarkContent[1] = n_down;
442 theQuarkContent[2] = n_s;
443 }
444 else {
445 // anti_nucleus
446 theAntiQuarkContent[0] = n_up;
447 theAntiQuarkContent[1] = n_down;
448 theAntiQuarkContent[2] = n_s;
449 }
450 return code;
451}
452
453void G4PDGCodeChecker::GetDigits(G4int PDGcode)
454{
455 G4int temp = std::abs(PDGcode);
456
457 higherSpin = temp / 10000000;
458 temp -= G4int(higherSpin * 10000000);
459
460 exotic = temp / 1000000;
461 temp -= G4int(exotic * 1000000);
462
463 radial = temp / 100000;
464 temp -= G4int(radial * 100000);
465
466 multiplet = temp / 10000;
467 temp -= G4int(multiplet * 10000);
468
469 quark1 = temp / 1000;
470 temp -= G4int(quark1 * 1000);
471
472 quark2 = temp / 100;
473 temp -= G4int(quark2 * 100);
474
475 quark3 = temp / 10;
476 temp -= G4int(quark3 * 10);
477
478 spin = temp;
479 if ((spin == 0) && (higherSpin != 0)) {
480 spin = higherSpin - 1;
481 }
482 else {
483 spin -= 1;
484 }
485}
double G4double
Definition G4Types.hh:83
bool G4bool
Definition G4Types.hh:86
int G4int
Definition G4Types.hh:85
const G4double A[17]
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout
G4int CheckPDGCode(G4int code, const G4String &type)
G4bool CheckCharge(G4double charge) const