source: trunk/source/particles/management/src/G4PDGCodeChecker.cc@ 1353

Last change on this file since 1353 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 11.3 KB
Line 
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,v 1.15 2010/10/30 07:55:00 kurasige Exp $
28// GEANT4 tag $Name: particles-V09-03-15 $
29//
30//
31// ----------------------------------------------------------------------
32// GEANT 4 class implementation file
33//
34// History: first implementation, based on object model of
35// 17 Aug 1999 H.Kurashige
36// **********************************************************************
37
38#include <fstream>
39#include <iomanip>
40
41#include "G4PDGCodeChecker.hh"
42
43/////////////
44G4PDGCodeChecker::G4PDGCodeChecker()
45 :code(0),theParticleType(""),
46 thePDGiSpin(0),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
59/////////////
60G4int G4PDGCodeChecker::CheckPDGCode( G4int PDGcode,
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
105/////////////
106G4int G4PDGCodeChecker::CheckForBaryons()
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 == 4132) {
138 // Xi_c0
139 quark2=3; quark3 = 1; spin = 1;
140 } else if (std::abs(tempPDGcode)%10000 == 4232) {
141 // Xi_c+
142 quark2=3; quark3 = 2; spin = 1;
143 } else if (std::abs(tempPDGcode)%10000 == 2122) {
144 // Delta+ (spin 1/2)
145 quark2=2; quark3 = 1; spin = 1;
146 } else if (std::abs(tempPDGcode)%10000 == 1212) {
147 // Delta0 (spin 1/2)
148 quark1=2; quark2 = 1; spin = 1;
149 } else if (std::abs(tempPDGcode)%10000 == 2126) {
150 // Delta+ (spin 5/2)
151 quark2=2; quark3 = 1; spin = 5;
152 } else if (std::abs(tempPDGcode)%10000 == 1216) {
153 // Delta0 (spin 5/2)
154 quark1=2; quark2 = 1; spin = 5;
155 } else if (std::abs(tempPDGcode)%10000 == 2128) {
156 // Delta+ (spin 7/2)
157 quark2=2; quark3 = 1; spin = 7;
158 } else if (std::abs(tempPDGcode)%10000 == 1218) {
159 // Delta0 (spin 7/2)
160 quark1=2; quark2 = 1; spin = 7;
161 } else if (std::abs(tempPDGcode)%10000 == 2124) {
162 // N*+ (spin 3/2)
163 quark2=2; quark3 = 1; spin = 3;
164 } else if (std::abs(tempPDGcode)%10000 == 1214) {
165 // N*0 (spin 3/2)
166 quark1=2; quark2 = 1; spin = 3;
167 }
168
169 // check quark flavor
170 if ((quark1<quark2)||(quark2<quark3)||(quark1<quark3)) {
171#ifdef G4VERBOSE
172 if (verboseLevel>0) {
173 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
174 G4cout << " illegal code for baryon ";
175 G4cout << " PDG code=" << code <<G4endl;
176 }
177#endif
178 return 0;
179 }
180 if (quark1> NumberOfQuarkFlavor) {
181#ifdef G4VERBOSE
182 if (verboseLevel>0) {
183 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
184 G4cout << " ??? unknown quark ";
185 G4cout << " PDG code=" << code <<G4endl;
186 }
187#endif
188 return 0;
189 }
190
191
192 // Fill Quark contents
193 if (tempPDGcode >0) {
194 theQuarkContent[quark1-1] ++;
195 theQuarkContent[quark2-1] ++;
196 theQuarkContent[quark3-1] ++;
197 } else {
198 theAntiQuarkContent[quark1-1] ++;
199 theAntiQuarkContent[quark2-1] ++;
200 theAntiQuarkContent[quark3-1] ++;
201 }
202
203 return code;
204}
205
206/////////////
207G4int G4PDGCodeChecker::CheckForMesons()
208{
209 G4int tempPDGcode = code;
210
211 // -- exceptions --
212 if (tempPDGcode == 310) spin = 0; //K0s
213 if (tempPDGcode == 130) { //K0l
214 spin = 0;
215 quark2 = 3;
216 quark3 = 1;
217 }
218
219 //
220 if ((quark1 !=0)||(quark2==0)||(quark3==0)){
221#ifdef G4VERBOSE
222 if (verboseLevel>0) {
223 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
224 G4cout << " meson has only quark and anti-quark pair";
225 G4cout << " PDG code=" << code <<G4endl;
226 }
227#endif
228 return 0;
229 }
230 if (quark2<quark3) {
231#ifdef G4VERBOSE
232 if (verboseLevel>0) {
233 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
234 G4cout << " illegal code for meson ";
235 G4cout << " PDG code=" << code <<G4endl;
236 }
237#endif
238 return 0;
239 }
240
241 // check quark flavor
242 if (quark2> NumberOfQuarkFlavor){
243#ifdef G4VERBOSE
244 if (verboseLevel>0) {
245 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
246 G4cout << " ??? unknown quark ";
247 G4cout << " PDG code=" << code <<G4endl;
248 }
249#endif
250 return 0;
251 }
252
253
254 // check heavier quark type
255 if (quark2 & 1) {
256 // down type qurak
257 if (tempPDGcode >0) {
258 theQuarkContent[quark3-1] =1;
259 theAntiQuarkContent[quark2-1] =1;
260 } else {
261 theQuarkContent[quark2-1] =1;
262 theAntiQuarkContent[quark3-1] =1;
263 }
264 } else {
265 // up type quark
266 if (tempPDGcode >0) {
267 theQuarkContent[quark2-1] =1;
268 theAntiQuarkContent[quark3-1] =1;
269 } else {
270 theQuarkContent[quark3-1] =1;
271 theAntiQuarkContent[quark2-1] =1;
272 }
273 }
274 return code;
275}
276
277
278
279/////////////
280G4int G4PDGCodeChecker::CheckForDiQuarks()
281{
282 if ((quark1 ==0) || (quark2 ==0) || (quark3 !=0)) {
283 // quark3 should be 0
284 // --- code is wrong
285 return 0;
286
287 } else if (quark1 < quark2) {
288 // --- code is wrong
289 return 0;
290
291 } else if (quark2>NumberOfQuarkFlavor){
292#ifdef G4VERBOSE
293 if (verboseLevel>0) {
294 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
295 G4cout << " ??? unknown quark ";
296 G4cout << " PDG code=" << code <<G4endl;
297 }
298#endif
299 return 0;
300
301 }
302
303 // Fill Quark Contents
304 if (code>0){
305 theQuarkContent[quark1-1] +=1;
306 theQuarkContent[quark2-1] +=1;
307 } else {
308 theAntiQuarkContent[quark1-1] +=1;
309 theAntiQuarkContent[quark2-1] +=1;
310 }
311
312 return code;
313}
314
315/////////////
316G4int G4PDGCodeChecker::CheckForQuarks()
317{
318 if ( std::abs(quark1)>NumberOfQuarkFlavor ) {
319#ifdef G4VERBOSE
320 if (verboseLevel>0) {
321 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
322 G4cout << " ??? unknown quark ";
323 G4cout << " PDG code=" << code <<G4endl;
324 }
325#endif
326 // --- code is wrong
327 return 0;
328
329 }
330
331 quark1 = std::abs(code);
332
333 // Fill Quark Contents
334 if (code>0){
335 theQuarkContent[quark1-1] =1;
336 } else {
337 theAntiQuarkContent[quark1-1] =1;
338 }
339 return code;
340}
341
342/////////////
343G4bool G4PDGCodeChecker::CheckCharge(G4double thePDGCharge) const
344{
345 // check charge
346 G4double totalCharge = 0.0;
347 for (G4int flavor= 0; flavor<NumberOfQuarkFlavor-1; flavor+=2){
348 totalCharge += (-1./3.)*eplus*theQuarkContent[flavor];
349 totalCharge += 1./3.*eplus*theAntiQuarkContent[flavor];
350 totalCharge += 2./3.*eplus*theQuarkContent[flavor+1];
351 totalCharge += (-2./3.)*eplus*theAntiQuarkContent[flavor+1];
352 }
353
354 if (std::fabs(totalCharge-thePDGCharge)>0.1*eplus) {
355#ifdef G4VERBOSE
356 if (verboseLevel>0) {
357 G4cout << " G4PDGCodeChecker::CheckCharge : ";
358 G4cout << " illegal electric charge " << thePDGCharge/eplus;
359 G4cout << " PDG code=" << code <<G4endl;
360 }
361#endif
362 return false;
363 }
364 return true;
365}
366
367/////////////
368G4int G4PDGCodeChecker::CheckForNuclei()
369{
370 G4int pcode = abs(code);
371 if (pcode < 1000000000) {
372 // non-nuclei
373 return 0;
374 }
375
376 pcode -= 1000000000;
377 G4int L = pcode/10000000;
378 pcode -= 10000000*L;
379 G4int Z = pcode/10000;
380 pcode -= 10000*Z;
381 G4int A = pcode/10;
382
383 if (A < 2 || Z > A-L || L>A || Z<=0 ) {
384#ifdef G4VERBOSE
385 if (verboseLevel>0) {
386 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
387 G4cout << " ??? Illegal PDG encoding for nucleus ";
388 G4cout << " PDG code=" << code <<G4endl;
389 }
390#endif
391 return 0;
392 }
393
394 G4int n_up = 2*Z + (A-Z-L) + L;
395 G4int n_down = Z + 2*(A-Z-L) + L;
396 G4int n_s = L;
397
398 // Fill Quark contents
399 if (code>0) {
400 theQuarkContent[0] = n_up;
401 theQuarkContent[1] = n_down;
402 theQuarkContent[2] = n_s;
403 } else {
404 // anti_nucleus
405 theAntiQuarkContent[0] = n_up;
406 theAntiQuarkContent[1] = n_down;
407 theAntiQuarkContent[2] = n_s;
408 }
409 return code;
410}
411
412/////////////
413void G4PDGCodeChecker::GetDigits(G4int PDGcode)
414{
415 G4int temp = std::abs(PDGcode);
416
417 higherSpin = temp/10000000;
418 temp -= G4int(higherSpin*10000000);
419
420 exotic = temp/1000000;
421 temp -= G4int(exotic*1000000);
422
423 radial = temp/100000;
424 temp -= G4int(radial*100000);
425
426 multiplet = temp/10000;
427 temp -= G4int(multiplet*10000);
428
429 quark1 = temp/1000;
430 temp -= G4int(quark1*1000);
431
432 quark2 = temp/100;
433 temp -= G4int(quark2*100);
434
435 quark3 = temp/10;
436 temp -= G4int(quark3*10);
437
438 spin= temp;
439 if ((spin ==0) && ( higherSpin !=0 )) {
440 spin = higherSpin-1;
441 } else {
442 spin -= 1;
443 }
444}
Note: See TracBrowser for help on using the repository browser.