HepPDT Reference Documentation

HepPDT

translatePDG.cc

Go to the documentation of this file.
00001 // ------------------------------------
00002 //
00003 // translatePDG.cc
00004 // Author: Lynn Garren
00005 //
00006 // translate an ID number to or from the standard numbering scheme and the PDG table
00007 // use static maps
00008 //
00009 //  The maps are initialized if and only if the public functions are called.
00010 //  Because the maps are static, the initialization happens only once.
00011 //
00012 //  The user NEVER calls PDGtoPDTMapInit()
00013 //  We use a data table (struct SList) so that compile time is not impacted.
00014 //
00015 //  public functions:
00016 //        int translatePDGtabletoPDT( const int id )
00017 //        int translatePDTtoPDGtable( const int id )
00018 //        PDGtoPDTMap const & getPDGtoPDTMap()
00019 //        PDTtoPDGMap const & getPDTtoPDGMap()
00020 //
00021 // ------------------------------------
00022 
00023 #include <map>
00024 #include <utility>      // make_pair
00025 
00026 #include "HepPID/Version.hh"
00027 #include "HepPID/ParticleIDTranslations.hh"
00028 #include "HepPID/ParticleIDMethods.hh"
00029 #include "HepPID/ParticleName.hh"
00030 
00031 namespace HepPID {
00032 
00033  typedef  std::map< int, int >  PDGtoPDTMap;
00034  typedef  std::map< int, int >  PDTtoPDGMap;
00035 
00036 namespace {     // PDGtoPDTMapInit is private
00037 
00038  PDGtoPDTMap const & getPDGtoPDTMap();
00039  PDTtoPDGMap const & getPDTtoPDGMap();
00040 
00041 PDGtoPDTMap const & PDGtoPDTMapInit()
00042 {
00043 
00044   static PDGtoPDTMap  m;
00045 
00046   static const struct {
00047       int hid;  // PDG
00048       int pid;  // PDT
00049   } SList[] = {
00050     {            1,            1 },
00051     {           -1,           -1 },
00052     {            2,            2 },
00053     {           -2,           -2 },
00054     {            3,            3 },
00055     {           -3,           -3 },
00056     {            4,            4 },
00057     {           -4,           -4 },
00058     {            5,            5 },
00059     {           -5,           -5 },
00060     {            6,            6 },
00061     {           -6,           -6 },
00062     {            7,            7 },
00063     {           -7,           -7 },
00064     {            8,            8 },
00065     {           -8,           -8 },
00066     {           11,           11 },
00067     {          -11,          -11 },
00068     {           12,           12 },
00069     {          -12,          -12 },
00070     {           13,           13 },
00071     {          -13,          -13 },
00072     {           14,           14 },
00073     {          -14,          -14 },
00074     {           15,           15 },
00075     {          -15,          -15 },
00076     {           16,           16 },
00077     {          -16,          -16 },
00078     {           17,           17 },
00079     {          -17,          -17 },
00080     {           18,           18 },
00081     {          -18,          -18 },
00082     {           21,           21 },
00083     {           22,           22 },
00084     {           23,           23 },
00085     {           24,           24 },
00086     {          -24,          -24 },
00087     {           25,           25 },
00088     {           32,           32 },
00089     {           33,           33 },
00090     {           34,           34 },
00091     {          -34,          -34 },
00092     {           35,           35 },
00093     {           36,           36 },
00094     {           37,           37 },
00095     {          -37,          -37 },
00096     {           39,           39 },
00097     {           41,           41 },
00098     {          -41,          -41 },
00099     {           42,           42 },
00100     {          -42,          -42 },
00101     {          110,          110 },
00102     {          990,          990 },
00103     {         9990,         9990 },
00104     {          130,          130 },
00105     {          310,          310 },
00106     {          211,          211},
00107     {          111,          111},
00108     {          221,          221},
00109     {          113,          113},
00110     {          213,          213},
00111     {          223,          223},
00112     {          331,          331},
00113     {      9010221,      9010221},
00114     {      9000111,      9000111},
00115     {      9000211,      9000211},
00116     {          333,          333},
00117     {        10223,        10223},
00118     {        10113,        10113},
00119     {        10213,        10213},
00120     {        20113,        20113},
00121     {        20213,        20213},
00122     {          225,          225},
00123     {        20223,        20223},
00124     {       100221,       100221},
00125     {       100111,       100111},
00126     {       100211,       100211},
00127     {          115,          115},
00128     {          215,          215},
00129     {      9000113,      9000113},
00130     {      9000213,      9000213},
00131     {      9020221,      9020221},
00132     {        20333,        20333},
00133     {        10111,        10111},
00134     {        10211,        10211},
00135     {       100113,       100113},
00136     {       100213,       100213},
00137     {       100331,       100331},
00138     {      9030221,      9030221},
00139     {          335,          335},
00140     {      9010113,      9010113},
00141     {      9010213,      9010213},
00142     {        10225,        10225},
00143     {        30223,        30223},
00144     {          227,          227},
00145     {        10115,        10115},
00146     {        10215,        10215},
00147     {       100333,       100333},
00148     {          117,          117},
00149     {          217,          217},
00150     {        30113,        30113},
00151     {        30213,        30213},
00152     {        10331,        10331},
00153     {      9010111,      9010111},
00154     {      9010211,      9010211},
00155     {          337,          337},
00156     {      9050225,      9050225},
00157     {      9060225,      9060225},
00158     {          119,          119},
00159     {          219,          219},
00160     {          229,          229},
00161     {      9080225,      9080225},
00162     {      9090225,      9090225},
00163     {          321,          321},
00164     {          311,          311},
00165     {          323,          323},
00166     {          313,          313},
00167     {        10313,        10313},
00168     {        10323,        10323},
00169     {        20313,        20313},
00170     {        20323,        20323},
00171     {       100313,       100313},
00172     {       100323,       100323},
00173     {        10311,        10311},
00174     {        10321,        10321},
00175     {          325,          325},
00176     {          315,          315},
00177     {        30313,        30313},
00178     {        30323,        30323},
00179     {        10315,        10315},
00180     {        10325,        10325},
00181     {          317,          317},
00182     {          327,          327},
00183     {        20315,        20315},
00184     {        20325,        20325},
00185     {          319,          319},
00186     {          329,          329},
00187     {          411,          411},
00188     {          421,          421},
00189     {          423,          423},
00190     {          413,          413},
00191     {        10423,        10423},
00192     {          425,          425},
00193     {          415,          415},
00194     {          431,          431},
00195     {          433,          433},
00196     {        10431,        10431},
00197     {        20433,        20433},
00198     {        10433,        10433},
00199     {          435,          435},
00200     {          521,          521},
00201     {          511,          511},
00202     {          513,          513},
00203     {          523,          523},
00204     {          531,          531},
00205     {          541,          541},
00206     {          441,          441},
00207     {          443,          443},
00208     {        10441,        10441},
00209     {        20443,        20443},
00210     {          445,          445},
00211     {       100443,       100443},
00212     {        30443,        30443},
00213     {      9000443,      9000443},
00214     {      9010443,      9010443},
00215     {      9020443,      9020443},
00216     {          553,          553},
00217     {        10551,        10551},
00218     {        20553,        20553},
00219     {          555,          555},
00220     {       100553,       100553},
00221     {       110551,       110551},
00222     {       120553,       120553},
00223     {       100555,       100555},
00224     {       200553,       200553},
00225     {       300553,       300553},
00226     {      9000553,      9000553},
00227     {      9010553,      9010553},
00228     {         2212,         2212},
00229     {        12212,        12212},
00230     {        22212,        22212},
00231     {        32212,        32212},
00232     {        42212,        42212},
00233     {         2112,         2112},
00234     {        12112,        12112},
00235     {        22112,        22112},
00236     {        32112,        32112},
00237     {        42112,        42112},
00238     {         1114,         1114},
00239     {         2114,         2114},
00240     {         2214,         2214},
00241     {         2224,         2224},
00242     {        31114,         31114},
00243     {        32114,         32114},
00244     {        32214,         32214},
00245     {        32224,         32224},
00246     {         1112,         1112},
00247     {         1212,         1212},
00248     {         2122,         2122},
00249     {         2222,         2222},
00250     {        11114,         11114},
00251     {        12114,         12114},
00252     {        12214,         12214},
00253     {        12224,         12224},
00254     {         1116,         1116},
00255     {         1216,         1216},
00256     {         2126,         2126},
00257     {         2226,         2226},
00258     {        21112,        21112},
00259     {        21212,        21212},
00260     {        22122,        22122},
00261     {        22222,        22222},
00262     {        21114,        21114},
00263     {        22114,        22114},
00264     {        22214,        22214},
00265     {        22224,        22224},
00266     {        11116,        11116},
00267     {        11216,        11216},
00268     {        12126,        12126},
00269     {        12226,        12226},
00270     {         1118,         1118},
00271     {         2118,         2118},
00272     {         2218,         2218},
00273     {         2228,         2228},
00274     {         1214,         1214},
00275     {         2124,         2124},
00276     {        21214,        21214},
00277     {        22124,        22124},
00278     {        31214,        31214},
00279     {        32124,        32124},
00280     {         2116,         2116},
00281     {         2216,         2216},
00282     {        12116,        12116},
00283     {        12216,        12216},
00284     {         1218,         1218},
00285     {         2128,         2128},
00286     {         3122,         3122},
00287     {    13122,    13122 },
00288     {    23122,    23122 },
00289     {    33122,    33122 },
00290     {    43122,    43122 },
00291     {    53122,    53122 },
00292     {     3124,     3124 },
00293     {    13124,    13124 },
00294     {    23124,    23124 },
00295     {     3126,     3126 },
00296     {    13126,    13126 },
00297     {     3128,     3128 },
00298     {    23126,    23126 },
00299     {         3222,         3222},
00300     {         3212,         3212},
00301     {         3112,         3112},
00302     {    13112,    13112 },
00303     {    13212,    13212 },
00304     {    13222,    13222 },
00305     {    23112,    23112 },
00306     {    23212,    23212 },
00307     {    23222,    23222 },
00308     {         3224,         3224},
00309     {         3214,         3214},
00310     {         3114,         3114},
00311     {    13224,    13224 },
00312     {    13214,    13214 },
00313     {    13114,    13114 },
00314     {    23224,    23224 },
00315     {    23214,    23214 },
00316     {    23114,    23114 },
00317     {     3226,     3226 },
00318     {     3216,     3216 },
00319     {     3116,     3116 },
00320     {    13226,    13226 },
00321     {    13216,    13216 },
00322     {    13116,    13116 },
00323     {     3228,     3228 },
00324     {     3218,     3218 },
00325     {     3118,     3118 },
00326     {         3322,         3322},
00327     {         3312,         3312},
00328     {         3324,         3324},
00329     {        13314,        13314},
00330     {        13324,        13324},
00331     {         3314,         3314},
00332     {         3334,         3334},
00333     {         4122,         4122},
00334     {        14122,        14122},
00335     {         4222,         4222},
00336     {         4212,         4212},
00337     {         4112,         4112},
00338     {         4232,         4232},
00339     {         4132,         4132},
00340     {         4322,         4322},
00341     {         4312,         4312},
00342     {         4332,         4332},
00343     {         5122,         5122},
00344     {      9221132,      9221132},
00345     {      9331122,      9331122}
00346   };
00347 
00348   int listSize = sizeof(SList)/sizeof(SList[0]);
00349   for( int k=0; k!=listSize; ++k) {
00350       m.insert( std::make_pair( SList[k].hid, SList[k].pid) );
00351   }
00352   return m;
00353 }  // PDGtoPDTMapInit()
00354 
00355 PDTtoPDGMap const & PDTtoPDGMapInit()
00356 {
00357     static PDTtoPDGMap m;
00358     static PDGtoPDTMap const & hmap = getPDGtoPDTMap();
00359     
00360     for(PDGtoPDTMap::const_iterator cit=hmap.begin(), mend=hmap.end(); cit!=mend; ++cit ) {
00361         m.insert( std::make_pair( cit->second, cit->first ));
00362     }
00363     return m;
00364 }
00365   
00366 //
00367 // getPDGtoPDTMap is the ONLY function allowed to call PDGtoPDTMapInit
00368 //
00369 PDGtoPDTMap const & getPDGtoPDTMap()
00370 {
00371   static PDGtoPDTMap const & hmap = PDGtoPDTMapInit();
00372   return hmap;
00373 }  // getPDGtoPDTMap()
00374 
00375 //
00376 // getPDTtoPDGMap is the ONLY function allowed to call PDGtoPDTMapInit
00377 //
00378 PDTtoPDGMap const & getPDTtoPDGMap()
00379 {
00380   static PDTtoPDGMap const & hmap = PDTtoPDGMapInit();
00381   return hmap;
00382 }  // getPDTtoPDGMap()
00383  
00384 } // unnamed namespace
00385   
00386 int translatePDGtabletoPDT( const int id )
00387 {
00388     static PDGtoPDTMap const & hmap = getPDGtoPDTMap();
00389 
00390     PDGtoPDTMap::const_iterator const cit = hmap.find( id );
00391     // found it in the map
00392     if ( cit != hmap.end() ) { return cit->second; }
00393     // check to see if someone has defined a valid particle type
00394     // that isn't in the map
00395     if( isValid(id) ) { return id; }
00396     return 0;
00397 }
00398 
00399 int translatePDTtoPDGtable( const int id )
00400 {
00401     static PDTtoPDGMap const & pmap = getPDTtoPDGMap();
00402 
00403     PDTtoPDGMap::const_iterator const cit = pmap.find( id );
00404     // found it in the map
00405     if ( cit != pmap.end() ) { return cit->second; }
00406     // check to see if someone has defined a valid particle type
00407     // that isn't in the map
00408     if( isValid(id) ) { return id; }
00409     return 0;
00410 }
00411 
00412 void writePDGTranslationLine( int i, std::ostream & os  )
00413 {
00414     // only write map entries
00415     static PDGtoPDTMap const & hmap = getPDGtoPDTMap();
00416 
00417     PDGtoPDTMap::const_iterator const cit = hmap.find( i );
00418     // found it in the map
00419     if ( cit != hmap.end() ) { 
00420         int id = cit->second;
00421         os << " PDG number: " ;
00422         os.width(10);
00423         os << i << "  HepPID number: " ;
00424         os.width(11);
00425         os << id << "  " << particleName(id) << std::endl;
00426         // check reverse translation
00427         int iback =  translatePDTtoPDGtable(id);
00428         if(iback != i) {
00429             os << " WARNING: " << id << " translates back to " 
00430                << iback << " not to " << i << std::endl;
00431         }
00432     }
00433     return;
00434 }  // writePDGTranslationLine()
00435 
00436 void  writePDGTranslation( std::ostream & os )
00437 {
00438     writeVersion( os );
00439     os << "     HepPID Particle List" << std::endl;
00440     os << std::endl;
00441 
00442     int id, i, j, q1, q2, q3, l, m;
00443     // special cases
00444     for( id=1; id<102; ++id) {
00445         writePDGTranslationLine(  id, os );
00446         writePDGTranslationLine( -id, os );
00447     }
00448     for( i=11; i<1000; ++i) {
00449         id = i*10;
00450         writePDGTranslationLine(  id, os );
00451         writePDGTranslationLine( -id, os );
00452     }
00453     // diquark
00454     for( q2=1; q2<7; ++q2) {
00455         for( q1=1; q1<7; ++q1) {
00456             for( j=1; j<4; ++j) {
00457                 id = 1000*q2+100*q1+j;
00458                 writePDGTranslationLine(  id, os );
00459                 writePDGTranslationLine( -id, os );
00460             }
00461         }
00462     }
00463     // mesons
00464     for( q2=1; q2<10; ++q2) {
00465         for( q1=1; q1<10; ++q1) {
00466             for( j=1; j<10; ++j) {
00467                 for( m=0; m<9; ++m) {
00468                     for( l=0; l<10; ++l) {
00469                         id = 100000*m+10000*l+100*q2+10*q1+j;
00470                         writePDGTranslationLine(  id, os );
00471                         writePDGTranslationLine( -id, os );
00472                     }
00473                 }
00474             }
00475         }
00476     }
00477     // baryons
00478     for( q3=1; q3<10; ++q3) {
00479         for( q2=1; q2<10; ++q2) {
00480             for( q1=1; q1<10; ++q1) {
00481                 for( j=1; j<10; ++j) {
00482                     for( m=0; m<9; ++m) {
00483                         id = 10000*m+1000*q3+100*q2+10*q1+j;
00484                         writePDGTranslationLine(  id, os );
00485                         writePDGTranslationLine( -id, os );
00486                     }
00487                 }
00488             }
00489         }
00490     }
00491     // ions
00492     for( i=1; i<3; ++i) {
00493         for( m=1; m<3; ++m) {
00494             id = 1000+10*i+m;
00495             writePDGTranslationLine(  id, os );
00496             writePDGTranslationLine( -id, os );
00497         }
00498     }
00499 
00500     return;
00501 }  // writePDGTranslation()
00502 
00503 }       // HepPID

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