Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:11:35

0001 // ----------------------------------------------------------------------
0002 //
0003 // TableBuilder.icc
0004 // Author: Lynn Garren
0005 //
0006 // ----------------------------------------------------------------------
0007 
0008 #include <sstream>
0009 
0010 namespace HepPDT {
0011 
0012 /// not implemented
0013 void TableBuilder::fillPDT()
0014 { ; }
0015 
0016 /// unpack existing PDT so its contents can be modified and added to a new PDT
0017 /// not implemented
0018 void  TableBuilder::reverseEngineer()
0019 { ; }
0020 
0021 TempParticleData &   TableBuilder::getParticleData( ParticleID pid )  
0022 {
0023   TempMap::iterator it = tempPDT.find( pid );
0024   // for some reason, Solaris CC can't cope with the more compact code
0025   if ( it == tempPDT.end() ) {
0026      return tempPDT[pid] = TempParticleData(pid);
0027   } else {
0028      return it->second;   
0029   }
0030   //return ( it == tempPDT.end() )
0031   //     ?  tempPDT[pid] = TempParticleData(pid)  // new one
0032   //     :  it->second;                           // old one
0033 }
0034 
0035 TempParticleData &  TableBuilder::getParticleData( std::string const & name )  
0036 {
0037     TempIDMap::iterator it = tempIDT.find( name );
0038     if( it == tempIDT.end() ) {
0039         // can neither build nor return a proper TempParticleData
0040     os << "HepPDT::TableBuilder.getParticleData: There is no entry for " << name << std::endl;
0041         exit(-3);
0042     }
0043     ParticleID pid = it->second;
0044     return getParticleData( pid );
0045 }
0046 
0047 TempParticleData &  TableBuilder::getAntiParticle( ParticleID pid, 
0048                                                     const std::string & aname )
0049 {
0050     // is it already here?
0051     ParticleID apid = ParticleID( -pid.pid() );
0052     TempMap::iterator it = tempPDT.find( apid );
0053     if( it != tempPDT.end() ) {
0054         return it->second;
0055     }
0056     // check for original particle to copy
0057     it = tempPDT.find( pid );
0058     if( it == tempPDT.end() ) {
0059         // no particle to copy
0060     TempParticleData atpd = getParticleData( apid );
0061     atpd.tempParticleName = aname;
0062     return tempPDT[apid] = atpd;    // getParticleData already added it to the map
0063     } else {
0064         // copy original
0065     TempParticleData tpd = it->second;
0066     TempParticleData atpd = tpd.antiparticle( aname );
0067         return tempPDT[apid] = atpd;    // add to map and return
0068     }
0069 }
0070 
0071 bool TableBuilder::hasParticleData( std::string const & name )
0072 {
0073     TempIDMap::iterator it = tempIDT.find( name );
0074     return ( it == tempIDT.end() ) ?  false  : true;
0075 }
0076 
0077 bool TableBuilder::hasAlias( std::string const & alias )
0078 {
0079     TempAliasMap::iterator it = tempAliases.find( alias );
0080     return ( it == tempAliases.end() ) ?  false  : true;
0081 }
0082 
0083 void  TableBuilder::addParticle( TempParticleData const & pd )  {
0084   getParticleData( pd.tempID ) = pd;
0085   if( !hasParticleData( pd.tempParticleName ) ) {
0086       tempIDT[pd.tempParticleName] = pd.tempID;
0087   }
0088 }
0089 
0090 
0091 void TableBuilder::addAlias( TempAliasData const & ad )
0092 {
0093     std::string alias = ad.tempAlias;
0094     tempAliases[alias] = ad;
0095 }
0096 
0097 TempAliasData& TableBuilder::aliasData( std::string const & alias )
0098 {
0099     TempAliasMap::iterator it = tempAliases.find( alias );
0100     if( it == tempAliases.end() ) {
0101         // can neither build nor return a proper TempParticleData
0102     os << "HepPDT::TableBuilder.aliasData: There is no entry for " 
0103                        << alias << std::endl;
0104         exit(-4);
0105     }
0106     return it->second;
0107 }
0108 
0109 }  // namespace HepPDT