00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <sstream>
00011 #include <string>
00012 #include <iostream>
00013
00014 #include "HepPDT/defs.h"
00015 #include "HepPDT/TableBuilder.hh"
00016 #include "HepPDT/TempParticleData.hh"
00017 #include "HepPID/ParticleIDTranslations.hh"
00018
00019 namespace HepPDT {
00020
00021
00022 bool getQQLineType( std::string & ltype, int & id, std::string & name,
00023 const std::string & pdline );
00024 bool parseQQDecayLine( const std::string & pdline );
00025 void parseQQParticle( TempParticleData & tpd, const std::string & pdline );
00026
00027 bool addQQParticles( std::istream & pdfile, TableBuilder & tb )
00028 {
00029 std::string pdline, ltype, def, name, cname;
00030 int id, eid;
00031 std::string genName = "QQ";
00032
00033 while( std::getline( pdfile, pdline) ) {
00034 if( getQQLineType( ltype, eid, name, pdline ) ) {
00035 if( ltype == "PARTICLE" ) {
00036
00037 id = HepPID::translateQQtoPDT( eid );
00038 if( id != 0 ) {
00039 TempParticleData& tpd = tb.getParticleData( ParticleID( id ) );
00040 parseQQParticle( tpd, pdline );
00041 tpd.tempSource = genName;
00042 tb.addParticle( tpd );
00043 }
00044 } else if( ltype=="QQBAR" ) {
00045
00046 id = HepPID::translateQQbar( eid );
00047 TempParticleData& tpd = tb.getParticleData( ParticleID( id ) );
00048 tpd.tempParticleName = name;
00049 tpd.tempOriginalID = eid;
00050 tpd.tempSource = genName;
00051 tb.addParticle( tpd );
00052 } else if( ltype=="VERSION" ) {
00053 genName += ' ';
00054 genName += name;
00055 } else if( ltype=="HIDE" ) {
00056 } else if( ltype=="PDG" ) {
00057 } else if( ltype=="PARITY" ) {
00058 } else if( ltype=="DECAY" ) {
00059
00060
00061 if( tb.hasParticleData( name ) ) {
00062
00063 while( parseQQDecayLine( pdline ) ) {
00064 std::getline( pdfile, pdline);
00065 }
00066 } else {
00067 std::cout << "HepPDT TableBuilder: could not match QQ name " << name << std::endl;
00068 }
00069 }
00070 }
00071 }
00072 std::cout << "found " << tb.size() << " particles" << std::endl;
00073 return true;
00074 }
00075
00076 bool getQQLineType( std::string & ltype, int & id, std::string & name,
00077 const std::string & pdline )
00078 {
00079 std::string s1, s2;
00080 int sl = pdline.length();
00081 std::string firstc = pdline.substr(0,1);
00082 id = 0;
00083 name = "";
00084 ltype = "";
00085
00086 if( firstc == "*" || firstc == ";" ) { return false; }
00087
00088
00089 if( sl > 5 ){
00090 std::istringstream thisline( pdline.substr(0,sl).c_str() );
00091 thisline >> ltype;
00092 if( ltype == "PARTICLE" ) {
00093 thisline >> name >> id;
00094 } else if( ltype=="QQBAR" ) {
00095 thisline >> name >> id;
00096 } else if( ltype=="PDG" ) {
00097 thisline >> name >> id;
00098 } else if( ltype=="PARITY" ) {
00099 thisline >> name >> id;
00100 } else if( ltype=="CPARITY" ) {
00101 thisline >> name >> id;
00102 } else if( ltype == "HIDE" ) {
00103 thisline >> name;
00104 } else if( ltype == "DECAY" ) {
00105 thisline >> name;
00106 } else if( ltype == "MIXING" ) {
00107 thisline >> name;
00108 } else if( ltype == "VERSION" ) {
00109 thisline >> name;
00110 }
00111 return true;
00112 } else {
00113 return false;
00114 }
00115 }
00116
00117 void parseQQParticle( TempParticleData & tpd, const std::string & pdline )
00118 {
00119
00120 std::string s1, s2, ltype, name;
00121 int id, sid;
00122 double chg, spin;
00123 double mass, width, mmax, lifet, mmin;
00124
00125
00126 if( tpd.tempID.pid() == 0 ) { return; }
00127
00128 int sl = pdline.length();
00129 std::istringstream thisline( pdline.substr(0,sl).c_str() );
00130 thisline >> ltype >> name >> id >> sid >> mass >> chg >> spin >> lifet;
00131 width = mmin = mmax = 0.;
00132 if( !thisline.eof() ) {
00133 thisline >> width >> mmin >> mmax;
00134 }
00135 if( ltype != "PARTICLE" ) {
00136 std::cout << "called parseQQParticle with wrong line type" << std::endl;
00137 return;
00138 }
00139 tpd.tempParticleName = name;
00140 tpd.tempOriginalID = id;
00141 tpd.tempCharge = chg;
00142 tpd.tempMass = Measurement( mass, 0.0 );
00143 tpd.tempLowCutoff = mmin;
00144 tpd.tempHighCutoff = mmax;
00145 if( width > 0. ) {
00146 tpd.tempWidth = Measurement( width, 0.0 );
00147 } else {
00148 tpd.tempWidth = Measurement( calculateWidthFromLifetime(lifet), 0.0 );
00149 }
00150 if( tpd.tempSpin.totalSpin() != spin ) {
00151
00152
00153
00154 tpd.tempSpin.setTotalSpin( spin );
00155 }
00156 }
00157
00158 bool parseQQDecayLine( const std::string & pdline)
00159 {
00160 std::string ltype;
00161 int sl = pdline.length();
00162 std::istringstream thisline( pdline.substr(0,sl).c_str() );
00163
00164 if( sl < 5 ) { return true; }
00165 std::string firstc = pdline.substr(0,1);
00166 if( firstc == "*" || firstc == ";" ) { return true; }
00167
00168 thisline >> ltype;
00169 if( ltype == "DECAY" ) {
00170
00171 return true;
00172 } else if( ltype == "ENDDECAY" ) {
00173
00174 return false;
00175 }
00176
00177
00178 return true;
00179 }
00180
00181
00182 }