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