![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ---------------------------------------------------------------------- 00002 // 00003 // TableBuilder.icc 00004 // Author: Lynn Garren 00005 // 00006 // ---------------------------------------------------------------------- 00007 00008 #include <sstream> 00009 00010 namespace HepPDT { 00011 00013 void TableBuilder::fillPDT() 00014 { ; } 00015 00018 void TableBuilder::reverseEngineer() 00019 { ; } 00020 00021 TempParticleData & TableBuilder::getParticleData( ParticleID pid ) 00022 { 00023 TempMap::iterator it = tempPDT.find( pid ); 00024 // for some reason, Solaris CC can't cope with the more compact code 00025 if ( it == tempPDT.end() ) { 00026 return tempPDT[pid] = TempParticleData(pid); 00027 } else { 00028 return it->second; 00029 } 00030 //return ( it == tempPDT.end() ) 00031 // ? tempPDT[pid] = TempParticleData(pid) // new one 00032 // : it->second; // old one 00033 } 00034 00035 TempParticleData & TableBuilder::getParticleData( std::string const & name ) 00036 { 00037 TempIDMap::iterator it = tempIDT.find( name ); 00038 if( it == tempIDT.end() ) { 00039 // can neither build nor return a proper TempParticleData 00040 os << "HepPDT::TableBuilder.getParticleData: There is no entry for " << name << std::endl; 00041 exit(-3); 00042 } 00043 ParticleID pid = it->second; 00044 return getParticleData( pid ); 00045 } 00046 00047 TempParticleData & TableBuilder::getAntiParticle( ParticleID pid, 00048 const std::string & aname ) 00049 { 00050 // is it already here? 00051 ParticleID apid = ParticleID( -pid.pid() ); 00052 TempMap::iterator it = tempPDT.find( apid ); 00053 if( it != tempPDT.end() ) { 00054 return it->second; 00055 } 00056 // check for original particle to copy 00057 it = tempPDT.find( pid ); 00058 if( it == tempPDT.end() ) { 00059 // no particle to copy 00060 TempParticleData atpd = getParticleData( apid ); 00061 atpd.tempParticleName = aname; 00062 return tempPDT[apid] = atpd; // getParticleData already added it to the map 00063 } else { 00064 // copy original 00065 TempParticleData tpd = it->second; 00066 TempParticleData atpd = tpd.antiparticle( aname ); 00067 return tempPDT[apid] = atpd; // add to map and return 00068 } 00069 } 00070 00071 bool TableBuilder::hasParticleData( std::string const & name ) 00072 { 00073 TempIDMap::iterator it = tempIDT.find( name ); 00074 return ( it == tempIDT.end() ) ? false : true; 00075 } 00076 00077 bool TableBuilder::hasAlias( std::string const & alias ) 00078 { 00079 TempAliasMap::iterator it = tempAliases.find( alias ); 00080 return ( it == tempAliases.end() ) ? false : true; 00081 } 00082 00083 void TableBuilder::addParticle( TempParticleData const & pd ) { 00084 getParticleData( pd.tempID ) = pd; 00085 if( !hasParticleData( pd.tempParticleName ) ) { 00086 tempIDT[pd.tempParticleName] = pd.tempID; 00087 } 00088 } 00089 00090 00091 void TableBuilder::addAlias( TempAliasData const & ad ) 00092 { 00093 std::string alias = ad.tempAlias; 00094 tempAliases[alias] = ad; 00095 } 00096 00097 TempAliasData& TableBuilder::aliasData( std::string const & alias ) 00098 { 00099 TempAliasMap::iterator it = tempAliases.find( alias ); 00100 if( it == tempAliases.end() ) { 00101 // can neither build nor return a proper TempParticleData 00102 os << "HepPDT::TableBuilder.aliasData: There is no entry for " 00103 << alias << std::endl; 00104 exit(-4); 00105 } 00106 return it->second; 00107 } 00108 00109 } // namespace HepPDT