![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ---------------------------------------------------------------------- 00002 // 00003 // addIsajetParticles.cc 00004 // Author: Lynn Garren 00005 // 00006 // ---------------------------------------------------------------------- 00007 00008 #include "HepPDT/defs.h" 00009 #include "HepPDT/TempParticleData.hh" 00010 #include "HepPDT/TableBuilder.hh" 00011 00012 namespace HepPDT { 00013 00014 bool addIsajetParticles( std::istream & pdfile, TableBuilder & tb ) 00015 { 00016 // this function should only be called on isaparticles.dat, not on isadecay.dat 00017 std::string pdline; 00018 int id, isaid; 00019 // read and parse each line 00020 while( std::getline( pdfile, pdline) ) { 00021 if( detail::getIsajetID( isaid, pdline ) ) { 00022 // this is a new particle definition 00023 id = HepPID::translateIsajettoPDT( isaid ); 00024 TempParticleData& tpd = tb.getParticleData( ParticleID( id ) ); 00025 detail::parseIsajetLine( tpd, pdline ); 00026 } 00027 } 00028 std::cout << "found " << tb.size() << " particles" << std::endl; 00029 return true; 00030 } 00031 00032 namespace detail { 00033 void parseIsajetLine( TempParticleData & tpd, const std::string & pdline ) 00034 { 00035 // this line defines a particle 00036 std::string isaname; 00037 int isaid, fl1, fl2, fl3, spin, idx, blank; 00038 double mass, chg; 00039 00040 // check for valid TempParticleData 00041 int sl = pdline.length(); 00042 if( tpd.tempID.pid() == 0 ) { return; } 00043 // have a valid PID, so proceed 00044 std::istringstream pids( pdline.substr(0,17).c_str() ); 00045 pids >> isaid ; // must access this before getting another stream 00046 // unfortunately, the istrstream trick does not work with strings in KCC 00047 //std::istringstream pnames( pdline.substr(21,32).c_str() ); 00048 //pnames >> isaname >> aname; 00049 blank = pdline.substr(11,10).find(" "); 00050 isaname = pdline.substr(11,blank); 00051 std::istringstream particle( pdline.substr(21,sl-20).c_str() ); 00052 particle >> mass >> chg >> fl1 >> fl2 >> fl3 >> spin >> idx ; 00053 // std::cout << isaid << " " << tpd.tempID.pid() << " " 00054 // << isaname << " " << chg 00055 // << " " << mass << " " << fl1 << " " << fl2 << " " << fl3 00056 // << " " << spin << " " << idx << std::endl; 00057 tpd.tempParticleName = isaname; 00058 tpd.tempCharge = chg; 00059 tpd.tempSpin = SpinState(0.,double(spin),0.); 00060 tpd.tempMass = Measurement( mass, 0.0 ); 00061 } 00062 } // namespace detail 00063 00064 } // namespace HepPDT