HepPDT Reference Documentation

HepPDT

testParticleIDMethods.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 // testParticleIDMethods.cc
00003 // Author: Lynn Garren
00004 //
00005 // test ParticleID
00006 //
00007 // ----------------------------------------------------------------------
00008 
00009 #include <fstream>
00010 #include <iostream>
00011 #include <iomanip>
00012 #include <cstdlib>
00013 
00014 #include "HepPID/ParticleIDMethods.hh"
00015 #include "HepPID/ParticleName.hh"
00016 
00017 using std::setw;
00018 
00019 int main()
00020 {
00021     // open an output file
00022     //
00023     const char outfile[] = "testParticleIDMethods.out";
00024     std::ofstream os( outfile );
00025     if( !os ) {
00026       std::cerr << "cannot open " << outfile << std::endl;
00027       exit(-1);
00028     }
00029     // define numbers to check
00030     int id[40] = { 5, 25, 15, 213, -3214, 10213, 9050225, -200543, 129050225,
00031                    2000025, 3101, 3301, -2212, 1000020040, -1000060120, 555,
00032                    5000040, 5100005, 24, 5100024, 5100025, 9221132, 
00033                    4111370, -4120240, 4110050, 10013730,
00034                    1000993, 1000612, 1000622, 1000632, 1006213, 1000652, 
00035                    1009113, 1009213, 1009323,
00036                    1093114, 1009333, 1006313, 1092214, 1006223 };
00037     int it;
00038     int nr, nx;
00039     int chg, sid, extra;
00040     int js, ls;
00041     for( it=0; it < 40; it++ ) {
00042         int pid = id[it];
00043         nx = HepPID::digit(HepPID::n,pid);
00044         nr = HepPID::digit(HepPID::nr,pid);
00045         extra = HepPID::extraBits(pid);
00046         os << std::endl;
00047         os << setw(21) << pid << ": " << nx << " " << nr 
00048                      << " " << HepPID::digit(HepPID::nl,pid)
00049                      << " " << HepPID::digit(HepPID::nq1,pid) 
00050                      << " " << HepPID::digit(HepPID::nq2,pid) 
00051                      << " " << HepPID::digit(HepPID::nq3,pid)
00052                      << " " << HepPID::digit(HepPID::nj,pid)
00053                      << " extra bits " << extra << std::endl;
00054         js = HepPID::jSpin(pid);
00055         ls = HepPID::lSpin(pid);
00056         sid = HepPID::fundamentalID(pid);
00057         chg = HepPID::threeCharge(pid);
00058         if( !HepPID::isValid(pid) ) {
00059            os << "**** Invalid PID: " << pid << " ****" << std::endl;
00060         } else  {
00061           if( HepPID::isHadron(pid) ) {
00062             if( HepPID::isMeson(pid) ) {
00063                os << "meson      " << setw(10) << pid << ": " << nx
00064                          << " " << nr << " "  << ls << " " 
00065                          << js << " " << sid << " " << chg
00066                          << " extra bits " << extra << std::endl;
00067             } else if( HepPID::isBaryon(pid) ) {
00068                os << "baryon     " << setw(10) << pid << ": " << nx
00069                          << " " << nr << " "  << ls << " " 
00070                          << js << " " << sid << " " << chg
00071                          << " extra bits " << extra << std::endl;
00072             } else if( HepPID::isRhadron(pid) ) {
00073              os << "Rhadron    " << setw(10) << pid << ": " << nx 
00074                        << " " << nr << " "  << ls << " " 
00075                        << js << " " << sid << " " << chg
00076                        << " extra bits " << extra << std::endl;
00077             } else if( HepPID::isPentaquark(pid) ) {
00078              os << "pentaquark " << setw(10) << pid << ": " << nx 
00079                        << " " << nr << " "  << ls << " " 
00080                        << js << " " << sid << " " << chg
00081                        << " extra bits " << extra << std::endl;
00082             } else {
00083                 os << "**** undefined hadron: " << pid
00084                           << " ****" << std::endl;
00085             }
00086           } else if( HepPID::isLepton(pid) ) {
00087            os << "lepton     " << setw(10) << pid << ": " << nx 
00088                      << " " << nr << " "  << ls << " " 
00089                      << js << " " << sid << " " << chg
00090                      << " extra bits " << extra << std::endl;
00091           } else if( HepPID::isDiQuark(pid) ) {
00092            os << "diquark    " << setw(10) << pid << ": " << nx 
00093                      << " " << nr << " "  << ls << " " 
00094                      << js << " " << sid << " " << chg
00095                      << " extra bits " << extra << std::endl;
00096           } else if( HepPID::isSUSY(pid) ) {
00097            os << "SUSY       " << setw(10) << pid << ": " << nx 
00098                      << " " << nr << " "  << ls << " " 
00099                      << js << " " << sid << " " << chg
00100                      << " extra bits " << extra << std::endl;
00101           } else if( HepPID::isDyon(pid) ) {
00102            os << "Dyon       " << setw(10) << pid << ": " << nx 
00103                      << " " << nr << " "  << ls << " " 
00104                      << js << " " << sid << " " << chg
00105                      << " extra bits " << extra << std::endl;
00106           } else if( HepPID::isQBall(pid) ) {
00107            os << "QBall      " << setw(10) << pid << ": " << nx 
00108                      << " " << nr << " "  << ls << " " 
00109                      << js << " " << sid << " " << chg
00110                      << " extra bits " << extra << std::endl;
00111           } else if( HepPID::isNucleus(pid) ) {
00112            os << "ion       " << setw(11) << pid 
00113                      << ": " << HepPID::digit(HepPID::n10,pid)
00114                      << " " << setw(3) << HepPID::A(pid) 
00115                      << " " << setw(3) << HepPID::Z(pid) 
00116                      << " " << setw(3) << HepPID::lambda(pid) 
00117                      << " " << js << " " << sid << " " << chg
00118                      << " extra bits " << extra << std::endl;
00119           } else if( sid > 0 && HepPID::abspid(pid) < 100 ) {
00120            os << "quark/lepton/boson " << setw(2) << pid << ": " << nx 
00121                      << " " << nr << " "  << ls << " " 
00122                      << js << " " << sid << " " << chg
00123                      << " extra bits " << extra << std::endl;
00124           } else {
00125            os << "unknown    " << setw(10) << pid << ": " << nx 
00126                      << " " << nr << " "  << ls << " " 
00127                      << js << " " << sid << " " << chg
00128                      << " extra bits " << extra << std::endl;
00129           }
00130           // special case where a baryon is also a nucleus
00131           if( HepPID::isNucleus(pid) && HepPID::isBaryon(pid)) {
00132            os << "ion       " << setw(11) << pid 
00133                      << ": " << HepPID::digit(HepPID::n10,pid)
00134                      << " " << setw(3) << HepPID::A(pid) 
00135                      << " " << setw(3) << HepPID::Z(pid) 
00136                      << " " << setw(3) << HepPID::lambda(pid) 
00137                      << " " << js << " " << sid << " " << chg
00138                      << " extra bits " << extra << std::endl;
00139           }
00140         }
00141         if( HepPID::isValid(pid) ) {
00142             os << "total spin: " << HepPID::jSpin(pid) ;
00143             os << " orbital angular momentum: " <<  HepPID::lSpin(pid) ;
00144             os << " spin: " <<  HepPID::sSpin(pid) ; 
00145             os << " charge: " << HepPID::threeCharge(pid) 
00146                << " " << HepPID::charge(pid) << std::endl;
00147             os << "Particle " <<  HepPID::particleName(pid) << std::endl;
00148             // quark content
00149             if( HepPID::hasUp(pid) ) {
00150                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00151                    << " has an up quark"  << std::endl;
00152             }
00153             if( HepPID::hasDown(pid) ) {
00154                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00155                    << " has a down quark"  << std::endl;
00156             }
00157             if( HepPID::hasStrange(pid) ) {
00158                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00159                    << " has a strange quark"  << std::endl;
00160             }
00161             if( HepPID::hasCharm(pid) ) {
00162                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00163                    << " has a charm quark"  << std::endl;
00164             }
00165             if( HepPID::hasBottom(pid) ) {
00166                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00167                    << " has a bottom quark"  << std::endl;
00168             }
00169             if( HepPID::hasTop(pid) ) {
00170                 os << "Particle " <<  HepPID::particleName(pid) << " " << pid
00171                    << " has a top quark"  << std::endl;
00172             }
00173         }
00174         // checking abspid
00175         int apid = HepPID::abspid(pid);
00176         int abpid = abs(pid);
00177         if( apid != abpid ) {
00178             os << "Error: Abspid returns " << apid 
00179                  << " instead of " << abpid 
00180                  << " for " << pid << std::endl;
00181         }
00182     }
00183     return 0;
00184 }

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