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

Last change on this file since 1110 was 992, checked in by garnier, 17 years ago

fichiers oublies

File size: 10.8 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.11 2008/06/08 12:43:19 kurasige Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
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{
46 code = 0;
47 verboseLevel = 1;
48}
49
50/////////////
51G4int G4PDGCodeChecker::CheckPDGCode( G4int PDGcode,
52 G4String particleType)
53{
54 code = PDGcode;
55 theParticleType = particleType;
56
57 // clear QuarkContents
58 G4int flavor;
59 for (flavor=0; flavor<NumberOfQuarkFlavor; flavor++){
60 theQuarkContent[flavor] =0;
61 theAntiQuarkContent[flavor] =0;
62 }
63
64 // check code for nuclei
65 if (theParticleType == "nucleus"){
66 return CheckForNuclei();
67 }
68
69 // get each digit number
70 GetDigits(code);
71
72 // check code
73 if (theParticleType =="quarks") {
74 return CheckForQuarks();
75
76 } else if (theParticleType =="diquarks") {
77 return CheckForDiQuarks();
78
79 } else if (theParticleType =="gluons") {
80 // gluons
81 // do not care about
82 return code;
83
84 } else if (theParticleType == "meson") {
85 return CheckForMesons();
86
87 } else if (theParticleType == "baryon"){
88 return CheckForBaryons();
89
90
91 }
92 // No check
93 return code;
94}
95
96/////////////
97G4int G4PDGCodeChecker::CheckForBaryons()
98{
99 G4int tempPDGcode = code;
100
101 if ((quark1==0)||(quark2==0)||(quark3==0)){
102#ifdef G4VERBOSE
103 if (verboseLevel>0) {
104 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
105 G4cout << " meson has three quark ";
106 G4cout << " PDG code=" << code <<G4endl;
107 }
108#endif
109 return 0;
110 }
111
112 //exceptions
113 if (std::abs(tempPDGcode)%10000 == 3122) {
114 // Lambda
115 quark2=2; quark3 = 1; spin = 1;
116 } else if (std::abs(tempPDGcode)%10000 == 3124) {
117 // Lambda*
118 quark2=2; quark3 = 1; spin = 3;
119 } else if (std::abs(tempPDGcode)%10000 == 3126) {
120 // Lambda*
121 quark2=2; quark3 = 1; spin = 5;
122 } else if (std::abs(tempPDGcode)%10000 == 3128) {
123 // Lambda*
124 quark2=2; quark3 = 1; spin = 7;
125 } else if (std::abs(tempPDGcode)%10000 == 4122) {
126 // Lambda_c
127 quark2=2; quark3 = 1; spin = 1;
128 } else if (std::abs(tempPDGcode)%10000 == 4132) {
129 // Xi_c0
130 quark2=3; quark3 = 1; spin = 1;
131 } else if (std::abs(tempPDGcode)%10000 == 4232) {
132 // Xi_c+
133 quark2=3; quark3 = 2; spin = 1;
134 } else if (std::abs(tempPDGcode)%10000 == 2122) {
135 // Delta+ (spin 1/2)
136 quark2=2; quark3 = 1; spin = 1;
137 } else if (std::abs(tempPDGcode)%10000 == 1212) {
138 // Delta0 (spin 1/2)
139 quark1=2; quark2 = 1; spin = 1;
140 } else if (std::abs(tempPDGcode)%10000 == 2126) {
141 // Delta+ (spin 5/2)
142 quark2=2; quark3 = 1; spin = 5;
143 } else if (std::abs(tempPDGcode)%10000 == 1216) {
144 // Delta0 (spin 5/2)
145 quark1=2; quark2 = 1; spin = 5;
146 } else if (std::abs(tempPDGcode)%10000 == 2128) {
147 // Delta+ (spin 7/2)
148 quark2=2; quark3 = 1; spin = 7;
149 } else if (std::abs(tempPDGcode)%10000 == 1218) {
150 // Delta0 (spin 7/2)
151 quark1=2; quark2 = 1; spin = 7;
152 } else if (std::abs(tempPDGcode)%10000 == 2124) {
153 // N*+ (spin 3/2)
154 quark2=2; quark3 = 1; spin = 3;
155 } else if (std::abs(tempPDGcode)%10000 == 1214) {
156 // N*0 (spin 3/2)
157 quark1=2; quark2 = 1; spin = 3;
158 }
159
160 // check quark flavor
161 if ((quark1<quark2)||(quark2<quark3)||(quark1<quark3)) {
162#ifdef G4VERBOSE
163 if (verboseLevel>0) {
164 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
165 G4cout << " illegal code for baryon ";
166 G4cout << " PDG code=" << code <<G4endl;
167 }
168#endif
169 return 0;
170 }
171 if (quark1> NumberOfQuarkFlavor) {
172#ifdef G4VERBOSE
173 if (verboseLevel>0) {
174 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
175 G4cout << " ??? unknown quark ";
176 G4cout << " PDG code=" << code <<G4endl;
177 }
178#endif
179 return 0;
180 }
181
182
183 // Fill Quark contents
184 if (tempPDGcode >0) {
185 theQuarkContent[quark1-1] ++;
186 theQuarkContent[quark2-1] ++;
187 theQuarkContent[quark3-1] ++;
188 } else {
189 theAntiQuarkContent[quark1-1] ++;
190 theAntiQuarkContent[quark2-1] ++;
191 theAntiQuarkContent[quark3-1] ++;
192 }
193
194 return code;
195}
196
197/////////////
198G4int G4PDGCodeChecker::CheckForMesons()
199{
200 G4int tempPDGcode = code;
201
202 // -- exceptions --
203 if (tempPDGcode == 310) spin = 0; //K0s
204 if (tempPDGcode == 130) { //K0l
205 spin = 0;
206 quark2 = 3;
207 quark3 = 1;
208 }
209
210 //
211 if ((quark1 !=0)||(quark2==0)||(quark3==0)){
212#ifdef G4VERBOSE
213 if (verboseLevel>0) {
214 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
215 G4cout << " meson has only quark and anti-quark pair";
216 G4cout << " PDG code=" << code <<G4endl;
217 }
218#endif
219 return 0;
220 }
221 if (quark2<quark3) {
222#ifdef G4VERBOSE
223 if (verboseLevel>0) {
224 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
225 G4cout << " illegal code for meson ";
226 G4cout << " PDG code=" << code <<G4endl;
227 }
228#endif
229 return 0;
230 }
231
232 // check quark flavor
233 if (quark2> NumberOfQuarkFlavor){
234#ifdef G4VERBOSE
235 if (verboseLevel>0) {
236 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
237 G4cout << " ??? unknown quark ";
238 G4cout << " PDG code=" << code <<G4endl;
239 }
240#endif
241 return 0;
242 }
243
244
245 // check heavier quark type
246 if (quark2 & 1) {
247 // down type qurak
248 if (tempPDGcode >0) {
249 theQuarkContent[quark3-1] =1;
250 theAntiQuarkContent[quark2-1] =1;
251 } else {
252 theQuarkContent[quark2-1] =1;
253 theAntiQuarkContent[quark3-1] =1;
254 }
255 } else {
256 // up type quark
257 if (tempPDGcode >0) {
258 theQuarkContent[quark2-1] =1;
259 theAntiQuarkContent[quark3-1] =1;
260 } else {
261 theQuarkContent[quark3-1] =1;
262 theAntiQuarkContent[quark2-1] =1;
263 }
264 }
265 return code;
266}
267
268
269
270/////////////
271G4int G4PDGCodeChecker::CheckForDiQuarks()
272{
273 if ((quark1 ==0) || (quark2 ==0) || (quark3 !=0)) {
274 // quark3 should be 0
275 // --- code is wrong
276 return 0;
277
278 } else if (quark1 < quark2) {
279 // --- code is wrong
280 return 0;
281
282 } else if (quark2>NumberOfQuarkFlavor){
283#ifdef G4VERBOSE
284 if (verboseLevel>0) {
285 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
286 G4cout << " ??? unknown quark ";
287 G4cout << " PDG code=" << code <<G4endl;
288 }
289#endif
290 return 0;
291
292 }
293
294 // Fill Quark Contents
295 if (code>0){
296 theQuarkContent[quark1-1] +=1;
297 theQuarkContent[quark2-1] +=1;
298 } else {
299 theAntiQuarkContent[quark1-1] +=1;
300 theAntiQuarkContent[quark2-1] +=1;
301 }
302
303 return code;
304}
305
306/////////////
307G4int G4PDGCodeChecker::CheckForQuarks()
308{
309 if ( std::abs(quark1)>NumberOfQuarkFlavor ) {
310#ifdef G4VERBOSE
311 if (verboseLevel>0) {
312 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
313 G4cout << " ??? unknown quark ";
314 G4cout << " PDG code=" << code <<G4endl;
315 }
316#endif
317 // --- code is wrong
318 return 0;
319
320 }
321
322 quark1 = std::abs(code);
323
324 // Fill Quark Contents
325 if (code>0){
326 theQuarkContent[quark1-1] =1;
327 } else {
328 theAntiQuarkContent[quark1-1] =1;
329 }
330 return code;
331}
332
333/////////////
334G4bool G4PDGCodeChecker::CheckCharge(G4double thePDGCharge) const
335{
336 // check charge
337 G4double totalCharge = 0.0;
338 for (G4int flavor= 0; flavor<NumberOfQuarkFlavor-1; flavor+=2){
339 totalCharge += (-1./3.)*eplus*theQuarkContent[flavor];
340 totalCharge += 1./3.*eplus*theAntiQuarkContent[flavor];
341 totalCharge += 2./3.*eplus*theQuarkContent[flavor+1];
342 totalCharge += (-2./3.)*eplus*theAntiQuarkContent[flavor+1];
343 }
344
345 if (std::abs(totalCharge-thePDGCharge)>0.1*eplus) {
346#ifdef G4VERBOSE
347 if (verboseLevel>0) {
348 G4cout << " G4PDGCodeChecker::CheckCharge : ";
349 G4cout << " illegal electric charge " << thePDGCharge/eplus;
350 G4cout << " PDG code=" << code <<G4endl;
351 }
352#endif
353 return false;
354 }
355 return true;
356}
357
358/////////////
359G4int G4PDGCodeChecker::CheckForNuclei()
360{
361 G4int pcode = code;
362 if (pcode < 1000000000) {
363 // anti particle
364 return 0;
365 }
366
367 pcode -= 1000000000;
368 G4int L = pcode/10000000;
369 pcode -= 10000000*L;
370 G4int Z = pcode/10000;
371 pcode -= 10000*Z;
372 G4int A = pcode/10;
373
374 if (A < 2 || Z > A-L || L>A || Z<=0 ) {
375#ifdef G4VERBOSE
376 if (verboseLevel>0) {
377 G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
378 G4cout << " ??? Illegal PDG encoding for nucleus ";
379 G4cout << " PDG code=" << code <<G4endl;
380 }
381#endif
382 return 0;
383 }
384
385 G4int n_up = 2*Z + (A-Z-L) + L;
386 G4int n_down = Z + 2*(A-Z-L) + L;
387 G4int n_s = L;
388
389 // Fill Quark contents
390 theQuarkContent[0] = n_up;
391 theQuarkContent[1] = n_down;
392 theQuarkContent[2] = n_s;
393
394 return code;
395}
396
397/////////////
398void G4PDGCodeChecker::GetDigits(G4int PDGcode)
399{
400 G4int temp = std::abs(PDGcode);
401
402 higherSpin = temp/10000000;
403 temp -= G4int(higherSpin*10000000);
404
405 exotic = temp/1000000;
406 temp -= G4int(exotic*1000000);
407
408 radial = temp/100000;
409 temp -= G4int(radial*100000);
410
411 multiplet = temp/10000;
412 temp -= G4int(multiplet*10000);
413
414 quark1 = temp/1000;
415 temp -= G4int(quark1*1000);
416
417 quark2 = temp/100;
418 temp -= G4int(quark2*100);
419
420 quark3 = temp/10;
421 temp -= G4int(quark3*10);
422
423 spin= temp;
424 if ((spin ==0) && ( higherSpin !=0 )) {
425 spin = higherSpin-1;
426 } else {
427 spin -= 1;
428 }
429}
Note: See TracBrowser for help on using the repository browser.