HepPDT Reference Documentation

HepPDT

testPID.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 // TestPID.cc
00003 // Author: Lynn Garren
00004 //
00005 // test ParticleID
00006 //
00007 // ----------------------------------------------------------------------
00008 
00009 #include <iostream>
00010 #include <iomanip>
00011 
00012 #include "HepPDT/defs.h"
00013 #include "HepPDT/ParticleID.hh"
00014 
00015 void testHadron( HepPDT::ParticleID&, int& );
00016 void testLepton( HepPDT::ParticleID&, int& );
00017 void testDiQuark( HepPDT::ParticleID&, int& );
00018 void testNucleus( HepPDT::ParticleID&, int& );
00019 void testUnknown( HepPDT::ParticleID&, int& );
00020 void testHasMethods( HepPDT::ParticleID&, int& );
00021 void testValid( HepPDT::ParticleID& );
00022 
00023 int main()
00024 {
00025     int id[40] = { 5, 25, 15, 213, -3214, 10213, 9050225, -200543, 129050225,
00026                    2000025, 3101, 3301, -2212, 1000020040, -1000060120, 555,
00027                    5000040, 5100005, 24, 5100024, 5100025, 9221132, 
00028                    4111370, -4120240, 4110050, 10013730,
00029                    1000993, 1000612, 1000622, 1000632, 1006213, 1000652, 
00030                    1009113, 1009213, 1009323,
00031                    1093114, 1009333, 1006313, 1092214, 1006223 };
00032     int it;
00033     int nr, nx;
00034     int chg, sid, extra;
00035     int js, ls;
00036     for( it=0; it < 40; it++ ) {
00037         HepPDT::ParticleID pid( id[it] );
00038         nx = pid.digit(HepPDT::n);
00039         nr = pid.digit(HepPDT::nr);
00040         extra = pid.extraBits();
00041         std::cout << std::endl;
00042         std::cout << std::setw(18) << id[it] << ": " << nx << " " << nr 
00043                      << " " << pid.digit(HepPDT::nl)
00044                      << " " << pid.digit(HepPDT::nq1) << " " 
00045                      << pid.digit(HepPDT::nq2) << " " << pid.digit(HepPDT::nq3)
00046                      << " " <<  pid.digit(HepPDT::nj)
00047                      << " extra bits " << extra << std::endl;
00048         js = pid.jSpin();
00049         ls = pid.lSpin();
00050         sid = pid.fundamentalID();
00051         chg = pid.threeCharge();
00052         if( !pid.isValid() ) {
00053            std::cout << "**** Invalid PID: " << pid.pid() 
00054                      << " ****" << std::endl;
00055         } else  {
00056           testHadron( pid, id[it] );
00057           testLepton( pid, id[it] );
00058           testDiQuark( pid, id[it] );
00059           testNucleus( pid, id[it] );
00060           testUnknown( pid, id[it] );
00061         }
00062         testValid( pid );
00063         testHasMethods( pid, id[it] );
00064     }
00065 }
00066 
00067 void testHadron( HepPDT::ParticleID& pid, int& idn )
00068 {
00069         int nx = pid.digit(HepPDT::n);
00070         int nr = pid.digit(HepPDT::nr);
00071         int extra = pid.extraBits();
00072         int js = pid.jSpin();
00073         int ls = pid.lSpin();
00074         int sid = pid.fundamentalID();
00075         int chg = pid.threeCharge();
00076         HepPDT::Quarks cqks = pid.quarks( );
00077           if( pid.isHadron() ) {
00078             if( pid.isMeson() ) {
00079                std::cout << "meson   " << std::setw(10) << idn << ": " << nx
00080                          << " " << nr << " "  << ls << " " 
00081                          << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3
00082                          << " " << js << " " << sid << " " << chg
00083                          << " extra bits " << extra << std::endl;
00084             } else if( pid.isRhadron() ) {
00085                std::cout << "Rhadron " << std::setw(10) << idn << ": " << nx
00086                          << " " << nr << " "  << ls << " " 
00087                          << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00088                          << " " << js << " " << sid << " " << chg
00089                          << " extra bits " << extra << std::endl;
00090             } else if( pid.isBaryon() ) {
00091                std::cout << "baryon  " << std::setw(10) << idn << ": " << nx
00092                          << " " << nr << " "  << ls << " " 
00093                          << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00094                          << " " << js << " " << sid << " " << chg
00095                          << " extra bits " << extra << std::endl;
00096             } else {
00097                 std::cout << "**** undefined hadron: " << pid.pid() 
00098                           << " ****" << std::endl;
00099             }
00100           }
00101 }
00102 
00103 void testLepton( HepPDT::ParticleID& pid, int& idn )
00104 {
00105         HepPDT::Quarks cqks = pid.quarks( );
00106           if( pid.isLepton() ) {
00107            std::cout << "lepton  " << std::setw(10) << idn 
00108                      << ": " << pid.digit(HepPDT::n)
00109                      << " "  << pid.digit(HepPDT::nr)
00110                      << " "  << pid.lSpin() << " " 
00111                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3
00112                      << " " <<  pid.jSpin()
00113                      << " " <<  pid.fundamentalID()
00114                      << " " <<  pid.threeCharge()
00115                      << " extra bits " <<  pid.extraBits() << std::endl;
00116           }
00117 }
00118 
00119 void testDiQuark( HepPDT::ParticleID& pid, int& idn )
00120 {
00121         HepPDT::Quarks cqks = pid.quarks( );
00122           if( pid.isDiQuark() ) {
00123            std::cout << "diquark " << std::setw(10) << idn 
00124                      << ": " << pid.digit(HepPDT::n)
00125                      << " "  << pid.digit(HepPDT::nr)
00126                      << " "  << pid.lSpin() << " " 
00127                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00128                      << " " <<  pid.jSpin()
00129                      << " " <<  pid.fundamentalID()
00130                      << " " <<  pid.threeCharge()
00131                      << " extra bits " <<  pid.extraBits() << std::endl;
00132           }
00133 }
00134 
00135 void testNucleus( HepPDT::ParticleID& pid, int& idn )
00136 {
00137           if( pid.isNucleus() ) {
00138            std::cout << "ion    " << std::setw(11) << idn 
00139                      << ": " << pid.digit(HepPDT::n10)
00140                      << " " << std::setw(3) << pid.A() 
00141                      << " " << std::setw(3) << pid.Z() 
00142                      << " " << std::setw(3) << pid.lambda() 
00143                      << " " <<  pid.jSpin()
00144                      << " " <<  pid.fundamentalID()
00145                      << " " <<  pid.threeCharge()
00146                      << " extra bits " <<  pid.extraBits() << std::endl;
00147           }
00148 }
00149 
00150 void testUnknown( HepPDT::ParticleID& pid, int& idn )
00151 {
00152         HepPDT::Quarks cqks = pid.quarks( );
00153           if( pid.isHadron() || pid.isLepton() || 
00154               pid.isDiQuark() || pid.isNucleus() ) {
00155           } else if( pid.isSUSY()  ) {
00156            std::cout << "SUSY    " << std::setw(10) << idn 
00157                      << ": " << pid.digit(HepPDT::n)
00158                      << " "  << pid.digit(HepPDT::nr)
00159                      << " "  << pid.lSpin() << " " 
00160                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00161                      << " " <<  pid.jSpin()
00162                      << " " <<  pid.fundamentalID()
00163                      << " " <<  pid.threeCharge()
00164                      << " extra bits " <<  pid.extraBits() << std::endl;
00165           } else if( pid.isDyon()  ) {
00166            std::cout << "Dyon    " << std::setw(10) << idn 
00167                      << ": " << pid.digit(HepPDT::n)
00168                      << " "  << pid.digit(HepPDT::nr)
00169                      << " "  << pid.lSpin() << " " 
00170                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00171                      << " " <<  pid.jSpin()
00172                      << " " <<  pid.fundamentalID()
00173                      << " " <<  pid.threeCharge()
00174                      << " extra bits " <<  pid.extraBits() << std::endl;
00175           } else if( pid.abspid() < 100 ) {
00176            std::cout << "quark/lepton/boson " << std::setw(2) << idn 
00177                      << ": " << pid.digit(HepPDT::n)
00178                      << " "  << pid.digit(HepPDT::nr)
00179                      << " "  << pid.lSpin() << " " 
00180                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00181                      << " " <<  pid.jSpin()
00182                      << " " <<  pid.fundamentalID()
00183                      << " " <<  pid.threeCharge()
00184                      << " extra bits " <<  pid.extraBits() << std::endl;
00185           } else {
00186            std::cout << "unknown " << std::setw(10) << idn 
00187                      << ": " << pid.digit(HepPDT::n)
00188                      << " "  << pid.digit(HepPDT::nr)
00189                      << " "  << pid.lSpin() << " " 
00190                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00191                      << " " <<  pid.jSpin()
00192                      << " " <<  pid.fundamentalID()
00193                      << " " <<  pid.threeCharge()
00194                      << " extra bits " <<  pid.extraBits() << std::endl;
00195           }
00196 }
00197 
00198 void testValid( HepPDT::ParticleID& pid )
00199 {
00200         if( pid.isValid() ) {
00201             int js = pid.jSpin();
00202             int chg = pid.threeCharge();
00203             std::cout << "total spin: " << js << " " << HepPDT::spinitod(js) ;
00204             std::cout << " orbital angular momentum: " <<  pid.lSpin() ;
00205             std::cout << " spin: " <<  pid.sSpin() ; 
00206             std::cout << " charge: " << chg 
00207                       << " " << pid.charge() << std::endl;
00208             HepPDT::Quarks qlist = pid.quarks( );
00209             std::cout <<  "quarks: " << qlist.nq1 
00210                       << " " << qlist.nq2 << " " << qlist.nq3 << std::endl;
00211         }
00212 }
00213 
00214 void testHasMethods( HepPDT::ParticleID& pid, int& idn )
00215 {
00216   if( pid.hasUp() ) {
00217       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00218                 << " has an up quark" << std::endl;
00219   }
00220   if( pid.hasDown() ) {
00221       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00222                 << " has a down quark" << std::endl;
00223   }
00224   if( pid.hasStrange() ) {
00225       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00226                 << " has a strange quark" << std::endl;
00227   }
00228   if( pid.hasCharm() ) {
00229       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00230                 << " has a charmed quark" << std::endl;
00231   }
00232   if( pid.hasBottom() ) {
00233       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00234                 << " has a bottom quark" << std::endl;
00235   }
00236   if( pid.hasTop() ) {
00237       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00238                 << " has a top quark" << std::endl;
00239   }
00240 } 
00241 

Generated on Fri Dec 4 14:05:24 2009 for HepPDT by  doxygen 1.4.7