![]() |
HepPDT Reference DocumentationHepPDT |
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[25] = { 5, 25, 15, 213, -3214, 10213, 9050225, -200543, 129050225, 00031 2000025, 3101, 3301, -2212, 1000020040, -1000060120, 555, 00032 5100005, 24, 5100024, 5100025, 9221132, 00033 1000652, 1009333, 1006313, 1092214 }; 00034 int it; 00035 int nr, nx; 00036 int chg, sid, extra; 00037 int js, ls; 00038 for( it=0; it < 25; it++ ) { 00039 int pid = id[it]; 00040 nx = HepPID::digit(HepPID::n,pid); 00041 nr = HepPID::digit(HepPID::nr,pid); 00042 extra = HepPID::extraBits(pid); 00043 os << std::endl; 00044 os << setw(21) << pid << ": " << nx << " " << nr 00045 << " " << HepPID::digit(HepPID::nl,pid) 00046 << " " << HepPID::digit(HepPID::nq1,pid) 00047 << " " << HepPID::digit(HepPID::nq2,pid) 00048 << " " << HepPID::digit(HepPID::nq3,pid) 00049 << " " << HepPID::digit(HepPID::nj,pid) 00050 << " extra bits " << extra << std::endl; 00051 js = HepPID::jSpin(pid); 00052 ls = HepPID::lSpin(pid); 00053 sid = HepPID::fundamentalID(pid); 00054 chg = HepPID::threeCharge(pid); 00055 if( !HepPID::isValid(pid) ) { 00056 os << "**** Invalid PID: " << pid << " ****" << std::endl; 00057 } else { 00058 if( HepPID::isHadron(pid) ) { 00059 if( HepPID::isMeson(pid) ) { 00060 os << "meson " << setw(10) << pid << ": " << nx 00061 << " " << nr << " " << ls << " " 00062 << js << " " << sid << " " << chg 00063 << " extra bits " << extra << std::endl; 00064 } else if( HepPID::isBaryon(pid) ) { 00065 os << "baryon " << setw(10) << pid << ": " << nx 00066 << " " << nr << " " << ls << " " 00067 << js << " " << sid << " " << chg 00068 << " extra bits " << extra << std::endl; 00069 } else if( HepPID::isRhadron(pid) ) { 00070 os << "Rhadron " << setw(10) << pid << ": " << nx 00071 << " " << nr << " " << ls << " " 00072 << js << " " << sid << " " << chg 00073 << " extra bits " << extra << std::endl; 00074 } else if( HepPID::isPentaquark(pid) ) { 00075 os << "pentaquark " << setw(10) << pid << ": " << nx 00076 << " " << nr << " " << ls << " " 00077 << js << " " << sid << " " << chg 00078 << " extra bits " << extra << std::endl; 00079 } else { 00080 os << "**** undefined hadron: " << pid 00081 << " ****" << std::endl; 00082 } 00083 } 00084 if( HepPID::isLepton(pid) ) { 00085 os << "lepton " << setw(10) << pid << ": " << nx 00086 << " " << nr << " " << ls << " " 00087 << js << " " << sid << " " << chg 00088 << " extra bits " << extra << std::endl; 00089 } 00090 if( HepPID::isDiQuark(pid) ) { 00091 os << "diquark " << setw(10) << pid << ": " << nx 00092 << " " << nr << " " << ls << " " 00093 << js << " " << sid << " " << chg 00094 << " extra bits " << extra << std::endl; 00095 } 00096 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 } 00102 if( HepPID::isNucleus(pid) ) { 00103 os << "ion " << setw(11) << pid 00104 << ": " << HepPID::digit(HepPID::n10,pid) 00105 << " " << setw(3) << HepPID::A(pid) 00106 << " " << setw(3) << HepPID::Z(pid) 00107 << " " << setw(3) << HepPID::lambda(pid) 00108 << " " << js << " " << sid << " " << chg 00109 << " extra bits " << extra << std::endl; 00110 } 00111 if( HepPID::isHadron(pid) || HepPID::isLepton(pid) 00112 || HepPID::isDiQuark(pid) || HepPID::isNucleus(pid) 00113 || HepPID::isSUSY(pid) ) { 00114 } else { 00115 os << "unknown " << setw(10) << pid << ": " << nx 00116 << " " << nr << " " << ls << " " 00117 << js << " " << sid << " " << chg 00118 << " extra bits " << extra << std::endl; 00119 } 00120 } 00121 if( HepPID::isValid(pid) ) { 00122 js = HepPID::jSpin(pid); 00123 chg = HepPID::threeCharge(pid); 00124 os << "total spin: " << js ; 00125 os << " orbital angular momentum: " << HepPID::lSpin(pid) ; 00126 os << " spin: " << HepPID::sSpin(pid) ; 00127 os << " charge: " << chg << " " << double(chg)/3.0 << std::endl; 00128 // quark content 00129 if( HepPID::hasUp(pid) ) { 00130 os << "Particle " << HepPID::particleName(pid) << " " << pid 00131 << " has an up quark" << std::endl; 00132 } 00133 if( HepPID::hasDown(pid) ) { 00134 os << "Particle " << HepPID::particleName(pid) << " " << pid 00135 << " has a down quark" << std::endl; 00136 } 00137 if( HepPID::hasStrange(pid) ) { 00138 os << "Particle " << HepPID::particleName(pid) << " " << pid 00139 << " has a strange quark" << std::endl; 00140 } 00141 if( HepPID::hasCharm(pid) ) { 00142 os << "Particle " << HepPID::particleName(pid) << " " << pid 00143 << " has a charm quark" << std::endl; 00144 } 00145 if( HepPID::hasBottom(pid) ) { 00146 os << "Particle " << HepPID::particleName(pid) << " " << pid 00147 << " has a bottom quark" << std::endl; 00148 } 00149 if( HepPID::hasTop(pid) ) { 00150 os << "Particle " << HepPID::particleName(pid) << " " << pid 00151 << " has a top quark" << std::endl; 00152 } 00153 } 00154 // checking abspid 00155 int apid = HepPID::abspid(pid); 00156 int abpid = abs(pid); 00157 if( apid != abpid ) { 00158 os << "Error: Abspid returns " << apid 00159 << " instead of " << abpid 00160 << " for " << pid << std::endl; 00161 } 00162 } 00163 return 0; 00164 }