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