HepPDT Reference Documentation

HepPDT

getPDGpid.cc

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------
00002 //
00003 // getPDGpid.cc
00004 // Author:  Lynn Garren
00005 //
00006 // parse a line in the PDG table and return the particle ID numbers
00007 //
00008 // ----------------------------------------------------------------------
00009 
00010 #include <string>
00011 #include <vector>
00012 #include <sstream>
00013 
00014 #include "HepPDT/defs.h"
00015 #include "HepPDT/TableBuilder.hh"
00016 
00017 namespace HepPDT {
00018 
00019 namespace detail {
00020 void getPDGpid( std::vector<int> & idlist,  std::string & pdline )
00021 {
00022     int sl, cl, id1, id2, id3, id4;
00023     sl = pdline.length();
00024     cl = pdline.find('*');
00025     // make sure the vector is empty
00026     idlist.clear();
00027     if( cl != 0 && sl > 80 ){
00028       // this is a valid line, so parse it
00029       // initialize possible ID's to zero
00030       id1 = id2 = id3 = id4 = 0;
00031       std::istringstream idnet( pdline.substr(1,32).c_str() );
00032       idnet >> id1 >> id2 >> id3 >> id4;
00033       if( id1 > 0 ) { idlist.push_back( id1 ); }
00034       if( id2 > 0 ) { idlist.push_back( id2 ); }
00035       if( id3 > 0 ) { idlist.push_back( id3 ); }
00036       if( id4 > 0 ) { idlist.push_back( id4 ); }
00037     }
00038 }
00039 
00040 void getPDGnames( std::vector<std::string> & namelst, std::string & pdline )
00041 {
00042     int sl, cl;
00043     std::string name, charges, fullname;
00044     sl = pdline.length();
00045     cl = pdline.find('*');
00046     // make sure the vector is empty
00047     namelst.clear();
00048     if( cl != 0 && sl > 80 ){
00049        // this is a valid line, so parse it
00050        std::istringstream namelist( pdline.substr(68,21).c_str() );
00051        namelist >> name >> charges;
00052        // parse the charge list and add charge to base name
00053        char buf[20];
00054        std::istringstream chglst(charges);
00055        while( chglst ) {
00056           chglst.getline(buf,20,',');
00057           if( chglst.gcount() > 0 ) {
00058               fullname = name + buf;
00059               namelst.push_back( fullname );
00060           }
00061        }
00062     }
00063 }
00064 
00065 
00066 }  // namespace detail
00067 
00068 } // namespace HepPDT
00069 

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