HepPDT Reference Documentation

HepPDT

testPID.cc

The HepPDT tests are also useful examples

test ParticleID methods

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[16] = { 5, 25, 15, 213, -3214, 10213, 9050225, -200543, 129050225,
00026                    2000025, 3101, 3301, -2212, 1000020040, -1000060120, 555 };
00027     int it;
00028     int nr, nx;
00029     int chg, sid, extra;
00030     int js, ls;
00031     for( it=0; it < 16; it++ ) {
00032         HepPDT::ParticleID pid( id[it] );
00033         nx = pid.digit(HepPDT::n);
00034         nr = pid.digit(HepPDT::nr);
00035         extra = pid.extraBits();
00036         std::cout << std::endl;
00037         std::cout << std::setw(18) << id[it] << ": " << nx << " " << nr 
00038                      << " " << pid.digit(HepPDT::nl)
00039                      << " " << pid.digit(HepPDT::nq1) << " " 
00040                      << pid.digit(HepPDT::nq2) << " " << pid.digit(HepPDT::nq3)
00041                      << " " <<  pid.digit(HepPDT::nj)
00042                      << " extra bits " << extra << std::endl;
00043         js = pid.jSpin();
00044         HepPDT::Quarks cqks = pid.quarks( );
00045         ls = pid.lSpin();
00046         sid = pid.fundamentalID();
00047         chg = pid.threeCharge();
00048         if( !pid.isValid() ) {
00049            std::cout << "**** Invalid PID: " << pid.pid() 
00050                      << " ****" << std::endl;
00051         } else  {
00052           testHadron( pid, id[it] );
00053           testLepton( pid, id[it] );
00054           testDiQuark( pid, id[it] );
00055           testNucleus( pid, id[it] );
00056           testUnknown( pid, id[it] );
00057         }
00058         testValid( pid );
00059         testHasMethods( pid, id[it] );
00060     }
00061 }
00062 
00063 void testHadron( HepPDT::ParticleID& pid, int& idn )
00064 {
00065         int nx = pid.digit(HepPDT::n);
00066         int nr = pid.digit(HepPDT::nr);
00067         int extra = pid.extraBits();
00068         int js = pid.jSpin();
00069         int ls = pid.lSpin();
00070         int sid = pid.fundamentalID();
00071         int chg = pid.threeCharge();
00072         HepPDT::Quarks cqks = pid.quarks( );
00073           if( pid.isHadron() ) {
00074             if( pid.isMeson() ) {
00075                std::cout << "meson   " << std::setw(10) << idn << ": " << nx
00076                          << " " << nr << " "  << ls << " " 
00077                          << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3
00078                          << " " << js << " " << sid << " " << chg
00079                          << " extra bits " << extra << std::endl;
00080             } else if( pid.isBaryon() ) {
00081                std::cout << "baryon  " << std::setw(10) << idn << ": " << nx
00082                          << " " << nr << " "  << ls << " " 
00083                          << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00084                          << " " << js << " " << sid << " " << chg
00085                          << " extra bits " << extra << std::endl;
00086             } else {
00087                 std::cout << "**** undefined hadron: " << pid.pid() 
00088                           << " ****" << std::endl;
00089             }
00090           }
00091 }
00092 
00093 void testLepton( HepPDT::ParticleID& pid, int& idn )
00094 {
00095         HepPDT::Quarks cqks = pid.quarks( );
00096           if( pid.isLepton() ) {
00097            std::cout << "lepton  " << std::setw(10) << idn 
00098                      << ": " << pid.digit(HepPDT::n)
00099                      << " "  << pid.digit(HepPDT::nr)
00100                      << " "  << pid.lSpin() << " " 
00101                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3
00102                      << " " <<  pid.jSpin()
00103                      << " " <<  pid.fundamentalID()
00104                      << " " <<  pid.threeCharge()
00105                      << " extra bits " <<  pid.extraBits() << std::endl;
00106           }
00107 }
00108 
00109 void testDiQuark( HepPDT::ParticleID& pid, int& idn )
00110 {
00111         HepPDT::Quarks cqks = pid.quarks( );
00112           if( pid.isDiQuark() ) {
00113            std::cout << "diquark " << std::setw(10) << idn 
00114                      << ": " << pid.digit(HepPDT::n)
00115                      << " "  << pid.digit(HepPDT::nr)
00116                      << " "  << pid.lSpin() << " " 
00117                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00118                      << " " <<  pid.jSpin()
00119                      << " " <<  pid.fundamentalID()
00120                      << " " <<  pid.threeCharge()
00121                      << " extra bits " <<  pid.extraBits() << std::endl;
00122           }
00123 }
00124 
00125 void testNucleus( HepPDT::ParticleID& pid, int& idn )
00126 {
00127         HepPDT::Quarks cqks = pid.quarks( );
00128           if( pid.isNucleus() ) {
00129            std::cout << "ion    " << std::setw(11) << idn 
00130                      << ": " << pid.digit(HepPDT::n10)
00131                      << " " << std::setw(3) << pid.A() 
00132                      << " " << std::setw(3) << pid.Z() 
00133                      << " " << std::setw(3) << pid.lambda() 
00134                      << " " <<  pid.jSpin()
00135                      << " " <<  pid.fundamentalID()
00136                      << " " <<  pid.threeCharge()
00137                      << " extra bits " <<  pid.extraBits() << std::endl;
00138           }
00139 }
00140 
00141 void testUnknown( HepPDT::ParticleID& pid, int& idn )
00142 {
00143         HepPDT::Quarks cqks = pid.quarks( );
00144           if( pid.isHadron() || pid.isLepton() || 
00145               pid.isDiQuark() || pid.isNucleus() ) {
00146           } else {
00147            std::cout << "unknown " << std::setw(10) << idn 
00148                      << ": " << pid.digit(HepPDT::n)
00149                      << " "  << pid.digit(HepPDT::nr)
00150                      << " "  << pid.lSpin() << " " 
00151                      << cqks.nq1 << " " << cqks.nq2 << " " << cqks.nq3 
00152                      << " " <<  pid.jSpin()
00153                      << " " <<  pid.fundamentalID()
00154                      << " " <<  pid.threeCharge()
00155                      << " extra bits " <<  pid.extraBits() << std::endl;
00156           }
00157 }
00158 
00159 void testValid( HepPDT::ParticleID& pid )
00160 {
00161         if( pid.isValid() ) {
00162             int js = pid.jSpin();
00163             int chg = pid.threeCharge();
00164             std::cout << "total spin: " << js << " " << HepPDT::spinitod(js) ;
00165             std::cout << " orbital angular momentum: " <<  pid.lSpin() ;
00166             std::cout << " spin: " <<  pid.sSpin() ; 
00167             std::cout << " charge: " << chg 
00168                       << " " << double(chg)/3.0 << std::endl;
00169             HepPDT::Quarks qlist = pid.quarks( );
00170             std::cout <<  "quarks: " << qlist.nq1 
00171                       << " " << qlist.nq2 << " " << qlist.nq3 << std::endl;
00172         }
00173 }
00174 
00175 void testHasMethods( HepPDT::ParticleID& pid, int& idn )
00176 {
00177   if( pid.hasUp() ) {
00178       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00179                 << " has an up quark" << std::endl;
00180   }
00181   if( pid.hasDown() ) {
00182       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00183                 << " has a down quark" << std::endl;
00184   }
00185   if( pid.hasStrange() ) {
00186       std::cout << "Particle " << pid.PDTname()  << " " << pid.pid() 
00187                 << " has a strange quark" << std::endl;
00188   }
00189   if( pid.hasCharm() ) {
00190       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00191                 << " has a charmed quark" << std::endl;
00192   }
00193   if( pid.hasBottom() ) {
00194       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00195                 << " has a bottom quark" << std::endl;
00196   }
00197   if( pid.hasTop() ) {
00198       std::cout << "Particle " << pid.PDTname() << " " << pid.pid() 
00199                 << " has a top quark" << std::endl;
00200   }
00201 } 
00202 

Generated on Fri Oct 24 13:41:35 2008 for HepPDT by  doxygen 1.5.1-3