![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ---------------------------------------------------------------------- 00002 // 00003 // addPythiaParticles.cc 00004 // Author: Lynn Garren 00005 // 00006 // this has the functions used by addPythiaParticles 00007 // 00008 // ---------------------------------------------------------------------- 00009 00010 #include <iostream> 00011 #include <string> 00012 #include <sstream> 00013 00014 #include "HepPDT/defs.h" 00015 #include "HepPDT/TempParticleData.hh" 00016 #include "HepPDT/TableBuilder.hh" 00017 00018 namespace HepPDT { 00019 00020 bool addPythiaParticles( std::istream & pdfile, TableBuilder & tb ) 00021 { 00022 std::string pdline, aname; 00023 int id, kf; 00024 int saveid=0; 00025 int anti=0; 00026 // read and parse each line 00027 while( std::getline( pdfile, pdline) ) { 00028 if( detail::getPythiaid( kf, pdline ) ) { 00029 if( kf != 0 ) { 00030 // this is a new particle definition 00031 saveid = id = HepPID::translatePythiatoPDT( kf ); 00032 TempParticleData& tpd = tb.getParticleData( ParticleID( id ) ); 00033 detail::parsePythiaLine( tpd, anti, aname, pdline ); 00034 if( anti > 0 ) { 00035 // code here to define antiparticles 00036 TempParticleData& atpd = tb.getAntiParticle( ParticleID( id ), aname ); 00037 // use this variable (fake out the compiler) 00038 atpd.tempSource = tpd.tempSource; 00039 atpd.tempOriginalID = -tpd.tempOriginalID; 00040 atpd.tempMass = tpd.tempMass; 00041 } 00042 } else if( saveid != 0 ) { 00043 TempParticleData& tpd = tb.getParticleData( ParticleID( saveid ) ); 00044 detail::parsePythiaDecayLine( tpd, pdline ); 00045 if( anti > 0 ) { 00046 // code here to append antiparticle decays 00047 } 00048 } 00049 } 00050 } 00051 std::cout << "found " << tb.size() << " particles" << std::endl; 00052 return true; 00053 } 00054 00055 namespace detail { 00056 void parsePythiaLine( TempParticleData & tpd, int & anti, std::string & aname, const std::string & pdline ) 00057 { 00058 // this line defines a particle 00059 std::string name1; 00060 int kf, kc, chg, col, decay, blank; 00061 double mass, width, wcut, lifet; 00062 00063 // check for valid TempParticleData 00064 anti = 0; 00065 int sl = pdline.length(); 00066 if( tpd.tempID.pid() == 0 ) { return; } 00067 // have a valid PID, so proceed 00068 std::istringstream pids( pdline.substr(0,17).c_str() ); 00069 pids >> kf >> kc; // must access this before getting another stream 00070 // unfortunately, the istrstream trick does not work with strings in KCC 00071 aname = ""; 00072 //std::istringstream pnames( pdline.substr(21,32).c_str() ); 00073 //pnames >> name1 >> aname; 00074 blank = pdline.substr(21,16).find(" "); 00075 name1 = pdline.substr(21,blank); 00076 blank = pdline.substr(37,16).find(" "); 00077 aname = pdline.substr(37,blank); 00078 std::istringstream particle( pdline.substr(54,sl-53).c_str() ); 00079 particle >> chg >> col >> anti >> mass >> width >> wcut >> lifet >> decay ; 00080 // std::cout << kf << " " << kc << " " << tpd.tempID.pid() << " " 00081 // << name1 << " " << aname << " " << chg 00082 // << " " << mass << " " << width << std::endl; 00083 tpd.tempParticleName = name1; 00084 tpd.tempSource = "Pythia"; 00085 tpd.tempOriginalID = kf; 00086 tpd.tempCharge = double(chg)/3.0; 00087 tpd.tempColorCharge = col; 00088 tpd.tempMass = Measurement( mass, 0.0 ); 00089 tpd.tempHighCutoff = wcut; 00090 // either width or lifetime is defined - not both 00091 if( width > 0. ) { 00092 tpd.tempWidth = Measurement( width, 0.0 ); 00093 } else if( lifet > 0. ) { 00094 tpd.tempWidth = Measurement( calculateWidthFromLifetime( lifet ), 0.0 ); 00095 } 00096 } 00097 00098 void parsePythiaDecayLine( TempParticleData & tpd, const std::string & ) 00099 { 00100 // check for valid TempParticleData 00101 if( tpd.tempID.pid() == 0 ) { return; } 00102 } 00103 00104 } // namespace detail 00105 00106 } // HepPDT