G4PDGCodeChecker.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id: G4PDGCodeChecker.cc 69798 2013-05-15 13:36:02Z gcosmo $
00028 //
00029 // 
00030 // ----------------------------------------------------------------------
00031 //      GEANT 4 class implementation file
00032 //
00033 //      History: first implementation, based on object model of
00034 //      17 Aug 1999 H.Kurashige
00035 // **********************************************************************
00036 
00037 #include <fstream>
00038 #include <iomanip>
00039 
00040 #include "G4PDGCodeChecker.hh"
00041 #include "G4PhysicalConstants.hh"
00042 #include "G4SystemOfUnits.hh"
00043 
00045 G4PDGCodeChecker::G4PDGCodeChecker()
00046   :code(0),theParticleType(""),
00047    higherSpin(0),
00048    exotic(0),radial(0),multiplet(0),
00049    quark1(0),quark2(0),quark3(0),spin(0)
00050 {
00051   verboseLevel = 1;
00052   // clear QuarkContents
00053   G4int flavor;
00054   for (flavor=0; flavor<NumberOfQuarkFlavor; flavor++){
00055     theQuarkContent[flavor] =0;
00056     theAntiQuarkContent[flavor] =0;
00057   }
00058 }
00059 
00061 G4int  G4PDGCodeChecker::CheckPDGCode( G4int    PDGcode, 
00062                                        G4String particleType)
00063 {
00064   code = PDGcode;
00065   theParticleType = particleType;
00066 
00067   // clear QuarkContents
00068   G4int flavor;
00069   for (flavor=0; flavor<NumberOfQuarkFlavor; flavor++){
00070     theQuarkContent[flavor] =0;
00071     theAntiQuarkContent[flavor] =0;
00072   }
00073 
00074   // check code for nuclei
00075   if ((theParticleType == "nucleus")||(theParticleType == "anti_nucleus")) {
00076     return CheckForNuclei();
00077   }
00078 
00079   // get each digit number
00080   GetDigits(code);
00081 
00082   // check code
00083   if (theParticleType =="quarks") {
00084     return CheckForQuarks();
00085 
00086   } else if  (theParticleType =="diquarks") {
00087     return CheckForDiQuarks();
00088 
00089   } else if (theParticleType =="gluons") {
00090     // gluons 
00091     //   do not care about
00092     return code;
00093 
00094   } else if (theParticleType == "meson") {
00095     return CheckForMesons();
00096 
00097   } else if (theParticleType == "baryon"){
00098     return CheckForBaryons();
00099 
00100 
00101   }
00102   // No check
00103   return code;
00104 }
00105  
00107 G4int G4PDGCodeChecker::CheckForBaryons()
00108 {
00109   G4int   tempPDGcode = code;
00110 
00111   if ((quark1==0)||(quark2==0)||(quark3==0)){ 
00112 #ifdef G4VERBOSE
00113     if (verboseLevel>0) {
00114       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00115       G4cout << " meson has three quark ";
00116       G4cout << " PDG code=" << code <<G4endl;
00117     }
00118 #endif
00119     return 0;
00120   }
00121  
00122  //exceptions
00123   if (std::abs(tempPDGcode)%10000 == 3122) { 
00124     // Lambda
00125     quark2=2;  quark3 = 1; spin = 1;
00126   } else if (std::abs(tempPDGcode)%10000 == 3124) { 
00127     // Lambda*
00128     quark2=2;  quark3 = 1; spin = 3;
00129   } else if (std::abs(tempPDGcode)%10000 == 3126) { 
00130     // Lambda*
00131     quark2=2;  quark3 = 1; spin = 5;
00132   } else if (std::abs(tempPDGcode)%10000 == 3128) { 
00133     // Lambda*
00134     quark2=2;  quark3 = 1; spin = 7;
00135   } else if (std::abs(tempPDGcode)%10000 == 4122) { 
00136     // Lambda_c
00137     quark2=2;  quark3 = 1; spin = 1;
00138   } else if (std::abs(tempPDGcode)%10000 == 5122) { 
00139     // Lambda_b
00140     quark2=2;  quark3 = 1; spin = 1;
00141   } else if (std::abs(tempPDGcode)%10000 == 4132) { 
00142     // Xi_c0
00143     quark2=3;  quark3 = 1; spin = 1;
00144   } else if (std::abs(tempPDGcode)%10000 == 4232) { 
00145     // Xi_c+
00146     quark2=3;  quark3 = 2; spin = 1;
00147   } else if (std::abs(tempPDGcode)%10000 == 5132) { 
00148     // Xi_b0
00149     quark2=3;  quark3 = 1; spin = 1;
00150   } else if (std::abs(tempPDGcode)%10000 == 5232) { 
00151     // Xi_b+
00152     quark2=3;  quark3 = 2; spin = 1;
00153   } else if (std::abs(tempPDGcode)%10000 == 2122) { 
00154     // Delta+ (spin 1/2) 
00155     quark2=2;  quark3 = 1; spin = 1;
00156   } else if (std::abs(tempPDGcode)%10000 == 1212) { 
00157     // Delta0 (spin 1/2) 
00158     quark1=2;  quark2 = 1; spin = 1;
00159   } else if (std::abs(tempPDGcode)%10000 == 2126) { 
00160     // Delta+ (spin 5/2) 
00161     quark2=2;  quark3 = 1; spin = 5;
00162   } else if (std::abs(tempPDGcode)%10000 == 1216) { 
00163     // Delta0 (spin 5/2) 
00164     quark1=2;  quark2 = 1; spin = 5;
00165   } else if (std::abs(tempPDGcode)%10000 == 2128) { 
00166     // Delta+ (spin 7/2) 
00167     quark2=2;  quark3 = 1; spin = 7;
00168   } else if (std::abs(tempPDGcode)%10000 == 1218) { 
00169     // Delta0 (spin 7/2) 
00170     quark1=2;  quark2 = 1; spin = 7;
00171   } else if (std::abs(tempPDGcode)%10000 == 2124) { 
00172     // N*+ (spin 3/2) 
00173     quark2=2;  quark3 = 1; spin = 3;
00174   } else if (std::abs(tempPDGcode)%10000 == 1214) { 
00175     // N*0 (spin 3/2) 
00176     quark1=2;  quark2 = 1; spin = 3;
00177   } 
00178 
00179     // check quark flavor
00180   if ((quark1<quark2)||(quark2<quark3)||(quark1<quark3)) { 
00181 #ifdef G4VERBOSE
00182     if (verboseLevel>0) {
00183       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00184       G4cout << " illegal code for baryon ";
00185       G4cout << " PDG code=" << code <<G4endl;
00186     }
00187 #endif
00188     return 0;
00189   }
00190   if (quark1> NumberOfQuarkFlavor) {
00191 #ifdef G4VERBOSE
00192     if (verboseLevel>0) {
00193       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00194       G4cout << " ??? unknown quark ";
00195       G4cout << " PDG code=" << code <<G4endl;
00196     }
00197 #endif
00198     return 0;
00199   }
00200   
00201 
00202   // Fill Quark contents
00203   if (tempPDGcode >0) {
00204     theQuarkContent[quark1-1] ++;
00205     theQuarkContent[quark2-1] ++;
00206     theQuarkContent[quark3-1] ++;
00207   } else {
00208     theAntiQuarkContent[quark1-1] ++;
00209     theAntiQuarkContent[quark2-1] ++;
00210     theAntiQuarkContent[quark3-1] ++;
00211   }
00212 
00213   return code;
00214 }
00215  
00217 G4int G4PDGCodeChecker::CheckForMesons()
00218 {
00219   G4int   tempPDGcode = code;
00220 
00221   //   -- exceptions --
00222   if (tempPDGcode == 310) spin = 0;        //K0s
00223   if (tempPDGcode == 130) {     //K0l
00224     spin = 0;        
00225     quark2 = 3;
00226     quark3 = 1;
00227   }
00228   
00229   // 
00230   if ((quark1 !=0)||(quark2==0)||(quark3==0)){ 
00231 #ifdef G4VERBOSE
00232     if (verboseLevel>0) {
00233       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00234       G4cout << " meson has only quark and anti-quark pair";
00235       G4cout << " PDG code=" << code <<G4endl;
00236     }
00237 #endif
00238     return 0;
00239   } 
00240   if (quark2<quark3) { 
00241 #ifdef G4VERBOSE
00242     if (verboseLevel>0) {
00243       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00244       G4cout << " illegal code for meson ";
00245       G4cout << " PDG code=" << code <<G4endl;
00246     }
00247 #endif
00248     return 0;
00249   }
00250 
00251   // check quark flavor
00252   if (quark2> NumberOfQuarkFlavor){
00253 #ifdef G4VERBOSE
00254     if (verboseLevel>0) {
00255       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00256       G4cout << " ??? unknown quark ";
00257       G4cout << " PDG code=" << code <<G4endl;
00258     }
00259 #endif
00260     return 0;
00261   }
00262 
00263  
00264   // check heavier quark type
00265   if (quark2 & 1) {
00266     // down type qurak
00267     if (tempPDGcode >0) {
00268       theQuarkContent[quark3-1] =1;
00269       theAntiQuarkContent[quark2-1] =1;
00270     } else {
00271       theQuarkContent[quark2-1] =1;
00272       theAntiQuarkContent[quark3-1] =1;
00273     }
00274   } else {
00275     // up type quark
00276     if (tempPDGcode >0) {
00277       theQuarkContent[quark2-1] =1;
00278       theAntiQuarkContent[quark3-1] =1;
00279     } else {
00280       theQuarkContent[quark3-1] =1;
00281       theAntiQuarkContent[quark2-1] =1;
00282     }
00283   }
00284   return code;
00285 }
00286 
00287   
00288 
00290 G4int G4PDGCodeChecker::CheckForDiQuarks()
00291 {
00292   if ((quark1 ==0) || (quark2 ==0) || (quark3 !=0)) {
00293     // quark3 should be 0
00294     //  --- code is wrong 
00295     return 0;
00296 
00297   } else if (quark1 < quark2) {
00298     //  --- code is wrong 
00299     return 0;
00300 
00301   } else if (quark2>NumberOfQuarkFlavor){
00302 #ifdef G4VERBOSE
00303     if (verboseLevel>0) {
00304       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00305       G4cout << " ??? unknown quark ";
00306       G4cout << " PDG code=" << code <<G4endl;
00307     }
00308 #endif
00309     return 0;
00310 
00311   }
00312 
00313   // Fill Quark Contents
00314   if (code>0){
00315     theQuarkContent[quark1-1] +=1;
00316     theQuarkContent[quark2-1] +=1;
00317   } else {
00318     theAntiQuarkContent[quark1-1] +=1;
00319     theAntiQuarkContent[quark2-1] +=1;
00320   }
00321 
00322   return code;
00323 }
00324  
00326 G4int G4PDGCodeChecker::CheckForQuarks()
00327 {
00328   if ( std::abs(quark1)>NumberOfQuarkFlavor ) {
00329 #ifdef G4VERBOSE
00330     if (verboseLevel>0) {
00331       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00332       G4cout << " ??? unknown quark ";
00333       G4cout << " PDG code=" << code <<G4endl;
00334     }
00335 #endif
00336     //  --- code is wrong 
00337     return 0;
00338 
00339   } 
00340 
00341   quark1 = std::abs(code);
00342 
00343   // Fill Quark Contents
00344   if (code>0){
00345     theQuarkContent[quark1-1] =1;
00346   } else {
00347     theAntiQuarkContent[quark1-1] =1;
00348   }
00349   return code;
00350 }
00351 
00353 G4bool G4PDGCodeChecker::CheckCharge(G4double thePDGCharge) const
00354 {
00355   // check charge
00356   G4double totalCharge = 0.0;
00357   for (G4int flavor= 0; flavor<NumberOfQuarkFlavor-1; flavor+=2){
00358     totalCharge += (-1./3.)*eplus*theQuarkContent[flavor];
00359     totalCharge += 1./3.*eplus*theAntiQuarkContent[flavor];
00360     totalCharge += 2./3.*eplus*theQuarkContent[flavor+1];
00361     totalCharge += (-2./3.)*eplus*theAntiQuarkContent[flavor+1];
00362   }
00363 
00364   if (std::fabs(totalCharge-thePDGCharge)>0.1*eplus) { 
00365 #ifdef G4VERBOSE
00366     if (verboseLevel>0) {
00367       G4cout << " G4PDGCodeChecker::CheckCharge  : ";
00368       G4cout << " illegal electric charge " << thePDGCharge/eplus;
00369       G4cout << " PDG code=" << code <<G4endl;
00370     }
00371 #endif
00372     return false;
00373   }
00374   return true;
00375 }
00376 
00378 G4int G4PDGCodeChecker::CheckForNuclei()
00379 {
00380   G4int pcode = std::abs(code);
00381   if (pcode < 1000000000) {
00382     // non-nuclei   
00383     return 0;
00384   }
00385 
00386   pcode -= 1000000000;
00387   G4int L = pcode/10000000;
00388   pcode -= 10000000*L;
00389   G4int Z = pcode/10000;
00390   pcode -= 10000*Z;
00391   G4int A = pcode/10;
00392   
00393   // Allow neutron balls
00394   // if (A < 2 || Z > A-L || L>A || Z<=0 ) {
00395   if (A < 2 || Z > A-L || L>A ) {
00396 #ifdef G4VERBOSE
00397     if (verboseLevel>0) {
00398       G4cout << " G4PDGCodeChecker::CheckPDGCode : ";
00399       G4cout << " ???  Illegal PDG encoding for nucleus ";
00400       G4cout << " PDG code=" << code <<G4endl;
00401     }
00402 #endif
00403     return 0;
00404   }
00405 
00406   G4int n_up   = 2*Z +   (A-Z-L) + L;
00407   G4int n_down =   Z + 2*(A-Z-L) + L;
00408   G4int n_s    =   L;
00409 
00410   // Fill Quark contents
00411   if (code>0) {
00412     theQuarkContent[0] = n_up;
00413     theQuarkContent[1] = n_down;
00414     theQuarkContent[2] = n_s;
00415    } else {
00416     // anti_nucleus
00417     theAntiQuarkContent[0] = n_up;
00418     theAntiQuarkContent[1] = n_down;
00419     theAntiQuarkContent[2] = n_s;
00420   }
00421   return code;
00422 }
00423  
00425 void G4PDGCodeChecker::GetDigits(G4int PDGcode)
00426 {
00427   G4int temp = std::abs(PDGcode);
00428   
00429   higherSpin = temp/10000000;
00430   temp -= G4int(higherSpin*10000000);
00431 
00432   exotic = temp/1000000;
00433   temp -= G4int(exotic*1000000);
00434 
00435   radial = temp/100000;
00436   temp -= G4int(radial*100000);
00437 
00438   multiplet = temp/10000;
00439   temp -= G4int(multiplet*10000);
00440 
00441   quark1 = temp/1000;
00442   temp -= G4int(quark1*1000);
00443 
00444   quark2 = temp/100;
00445   temp -= G4int(quark2*100);
00446 
00447   quark3 = temp/10;
00448   temp -= G4int(quark3*10);
00449 
00450   spin= temp;
00451   if ((spin ==0) && ( higherSpin !=0 )) {
00452     spin =  higherSpin-1;
00453   } else {
00454     spin -= 1;
00455   }
00456 }

Generated on Mon May 27 17:49:17 2013 for Geant4 by  doxygen 1.4.7