![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ---------------------------------------------------------------------- 00002 // 00003 // getPythiaid.cc 00004 // Author: Lynn Garren 00005 // 00006 // return pythia particle ID from a line in the table 00007 // 00008 // ---------------------------------------------------------------------- 00009 00010 #include <iostream> 00011 #include <string> 00012 #include <sstream> 00013 00014 #include "HepPDT/defs.h" 00015 #include "HepPDT/TableBuilder.hh" 00016 00017 namespace HepPDT { 00018 00019 namespace detail { 00020 bool getPythiaid( int & id, const std::string & pdline ) 00021 { 00022 int sl = pdline.length(); 00023 id = 0; 00024 // line is too short 00025 if( sl < 30 ) return false; 00026 // now check for various comments to avoid problems with Solaris 00027 std::string stars = pdline.substr(1,2); 00028 std::string kfline = pdline.substr(0,10); 00029 if( stars == "**" || kfline == " KF" ) return false; 00030 // try to read the kf number 00031 std::string firstc = pdline.substr(0,1); 00032 if( firstc == " " ){ 00033 std::istringstream var1( pdline.substr(0,10).c_str() ); 00034 var1 >> id; // if var1 is blank, id is not changed 00035 return true; 00036 } else { 00037 return false; 00038 } 00039 } 00040 } // namespace detail 00041 00042 } // HepPDT