00001
00002
00003
00004
00005
00006
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
00027 while( std::getline( pdfile, pdline) ) {
00028 if( detail::getPythiaid( kf, pdline ) ) {
00029 if( kf != 0 ) {
00030
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
00036 TempParticleData& atpd = tb.getAntiParticle( ParticleID( id ), aname );
00037
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
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
00059 std::string name1;
00060 int kf, kc, chg, col, decay, blank;
00061 double mass, width, wcut, lifet;
00062
00063
00064 anti = 0;
00065 int sl = pdline.length();
00066 if( tpd.tempID.pid() == 0 ) { return; }
00067
00068 std::istringstream pids( pdline.substr(0,17).c_str() );
00069 pids >> kf >> kc;
00070
00071 aname = "";
00072
00073
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
00081
00082
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
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 & pdline )
00099 {
00100
00101 if( tpd.tempID.pid() == 0 ) { return; }
00102 }
00103
00104 }
00105
00106 }