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