![]() |
HepPDT Reference DocumentationHepPDT |
00001 // ------------------------------------ 00002 // 00003 // translateHerwig.cc 00004 // Author: Lynn Garren 00005 // 00006 // ..convert from HERWIG numbering scheme to PDT numbering scheme 00007 // use a static map for both translateHerwigtoPDT and translatePDTtoHerwig 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 HerwigPDTMapInit() 00013 // We use a data table (struct SList) so that compile time is not impacted. 00014 // 00015 // public functions: 00016 // int translateHerwigtoPDT( const int id ) 00017 // int translatePDTtoHerwig( const int id ) 00018 // HerwigPDTMap const & getHerwigPDTMap() 00019 // PDTHerwigMap const & getPDTHerwigMap() 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 > HerwigPDTMap; 00034 typedef std::map< int, int > PDTHerwigMap; 00035 00036 namespace { // HerwigPDTMapInit is private 00037 00038 HerwigPDTMap const & getHerwigPDTMap(); 00039 PDTHerwigMap const & getPDTHerwigMap(); 00040 00041 HerwigPDTMap const & HerwigPDTMapInit() 00042 { 00043 00044 static HerwigPDTMap m; 00045 00046 static const struct { 00047 int hid; // Herwig 00048 int pid; // PDT 00049 } SList[] = { 00050 { 1, 1 }, 00051 { 2, 2 }, 00052 { 3, 3 }, 00053 { 4, 4 }, 00054 { 5, 5 }, 00055 { 6, 6 }, 00056 { 7, 7 }, 00057 { 8, 8 }, 00058 { -1, -1 }, 00059 { -2, -2 }, 00060 { -3, -3 }, 00061 { -4, -4 }, 00062 { -5, -5 }, 00063 { -6, -6 }, 00064 { -7, -7 }, 00065 { -8, -8 }, 00066 { 11, 11 }, 00067 { 12, 12 }, 00068 { 13, 13 }, 00069 { 14, 14 }, 00070 { 15, 15 }, 00071 { 16, 16 }, 00072 { -11, -11 }, 00073 { -12, -12 }, 00074 { -13, -13 }, 00075 { -14, -14 }, 00076 { -15, -15 }, 00077 { -16, -16 }, 00078 { 21, 21 }, 00079 { 22, 22 }, 00080 { 23, 23 }, 00081 { 24, 24 }, 00082 { -24, -24 }, 00083 { 25, 25 }, 00084 { 26, 51 }, 00085 { 32, 32 }, 00086 { 35, 35 }, 00087 { 36, 36 }, 00088 { 37, 37 }, 00089 { -37, -37 }, 00090 { 39, 39 }, 00091 { 91, 91 }, 00092 { 98, 9920022 }, 00093 { 99, 9922212 }, 00094 { -99, -9922212 }, 00095 { 111, 111 }, 00096 { 221, 221 }, 00097 { 113, 113 }, 00098 { 223, 223 }, 00099 { 331, 331 }, 00100 { 225, 225 }, 00101 { 20113, 20113 }, 00102 { 20223, 20223 }, 00103 { 115, 115 }, 00104 { -211, -211 }, 00105 { -213, -213 }, 00106 { -20213, -20213 }, 00107 { -215, -215 }, 00108 { -321, -321 }, 00109 { -323, -323 }, 00110 { -20323, -20323 }, 00111 { -325, -325 }, 00112 { 211, 211 }, 00113 { 213, 213 }, 00114 { 20213, 20213 }, 00115 { 215, 215 }, 00116 { -311, -311 }, 00117 { -313, -313 }, 00118 { -20313, -20313 }, 00119 { -315, -315 }, 00120 { 321, 321 }, 00121 { 323, 323 }, 00122 { 20323, 20323 }, 00123 { 325, 325 }, 00124 { 311, 311 }, 00125 { 313, 313 }, 00126 { 20313, 20313 }, 00127 { 315, 315 }, 00128 { 333, 333 }, 00129 { 20333, 20333 }, 00130 { 335, 335 }, 00131 { 310, 310 }, 00132 { 130, 130 }, 00133 { 10111, 10111 }, 00134 { 10211, 10211 }, 00135 { -10211, -10211 }, 00136 { 2212, 2212 }, 00137 { 2214, 2214 }, 00138 { 2112, 2112 }, 00139 { 2114, 2114 }, 00140 { 1114, 1114 }, 00141 { 3122, 3122 }, 00142 { 3212, 3212 }, 00143 { 3214, 3214 }, 00144 { 3112, 3112 }, 00145 { 3114, 3114 }, 00146 { 3312, 3312 }, 00147 { 3314, 3314 }, 00148 { 2224, 2224 }, 00149 { 3222, 3222 }, 00150 { 3224, 3224 }, 00151 { 3322, 3322 }, 00152 { 3324, 3324 }, 00153 { 3334, 3334 }, 00154 { -2212, -2212 }, 00155 { -2214, -2214 }, 00156 { -2112, -2112 }, 00157 { -2114, -2114 }, 00158 { -1114, -1114 }, 00159 { -3122, -3122 }, 00160 { -3212, -3212 }, 00161 { -3214, -3214 }, 00162 { -3112, -3112 }, 00163 { -3114, -3114 }, 00164 { -3312, -3312 }, 00165 { -3314, -3314 }, 00166 { -2224, -2224 }, 00167 { -3222, -3222 }, 00168 { -3224, -3224 }, 00169 { -3322, -3322 }, 00170 { -3324, -3324 }, 00171 { -3334, -3334 }, 00172 { 2203, 2203 }, 00173 { 2101, 2101 }, 00174 { 1103, 1103 }, 00175 { 3201, 3201 }, 00176 { 3101, 3101 }, 00177 { 3303, 3303 }, 00178 { -2203, -2203 }, 00179 { -2101, -2101 }, 00180 { -1103, -1103 }, 00181 { -3201, -3201 }, 00182 { -3101, -3101 }, 00183 { -3303, -3303 }, 00184 { 411, 411 }, 00185 { 413, 413 }, 00186 { 20413, 20413 }, 00187 { 415, 415 }, 00188 { 421, 421 }, 00189 { 423, 423 }, 00190 { 20423, 20423 }, 00191 { 425, 425 }, 00192 { 431, 431 }, 00193 { 433, 433 }, 00194 { 20433, 20433 }, 00195 { 435, 435 }, 00196 { 4222, 4222 }, 00197 { 4224, 4224 }, 00198 { 4122, 4122 }, 00199 { 4212, 4212 }, 00200 { 4214, 4214 }, 00201 { 4112, 4112 }, 00202 { 4114, 4114 }, 00203 { 4232, 4232 }, 00204 { 4322, 4322 }, 00205 { 4324, 4324 }, 00206 { 4132, 4132 }, 00207 { 4312, 4312 }, 00208 { 4314, 4314 }, 00209 { 4332, 4332 }, 00210 { 4334, 4334 }, 00211 { 441, 441 }, 00212 { 443, 443 }, 00213 { 10441, 10441 }, 00214 { 100443, 100443 }, 00215 { 30443, 30443 }, 00216 { -411, -411 }, 00217 { -413, -413 }, 00218 { -20413, -20413 }, 00219 { -415, -415 }, 00220 { -421, -421 }, 00221 { -423, -423 }, 00222 { -20423, -20423 }, 00223 { -425, -425 }, 00224 { -431, -431 }, 00225 { -433, -433 }, 00226 { -20433, -20433 }, 00227 { -435, -435 }, 00228 { -4222, -4222 }, 00229 { -4224, -4224 }, 00230 { -4122, -4122 }, 00231 { -4212, -4212 }, 00232 { -4214, -4214 }, 00233 { -4112, -4112 }, 00234 { -4114, -4114 }, 00235 { -4232, -4232 }, 00236 { -4322, -4322 }, 00237 { -4324, -4324 }, 00238 { -4132, -4132 }, 00239 { -4312, -4312 }, 00240 { -4314, -4314 }, 00241 { -4332, -4332 }, 00242 { -4334, -4334 }, 00243 { -511, -511 }, 00244 { -521, -521 }, 00245 { -531, -531 }, 00246 { 5222, 5222 }, 00247 { 5122, 5122 }, 00248 { 5112, 5112 }, 00249 { 5232, 5232 }, 00250 { 5132, 5132 }, 00251 { 5332, 5332 }, 00252 { -541, -541 }, 00253 { 553, 553 }, 00254 { -651, -651 }, 00255 { 611, 611 }, 00256 { 621, 621 }, 00257 { 631, 631 }, 00258 { 6222, 6222 }, 00259 { 6122, 6122 }, 00260 { 6112, 6112 }, 00261 { 6232, 6232 }, 00262 { 6132, 6132 }, 00263 { 6332, 6332 }, 00264 { 641, 641 }, 00265 { 651, 651 }, 00266 { 663, 663 }, 00267 { 511, 511 }, 00268 { 521, 521 }, 00269 { 531, 531 }, 00270 { -5222, -5222 }, 00271 { -5122, -5122 }, 00272 { -5112, -5112 }, 00273 { -5232, -5232 }, 00274 { -5132, -5132 }, 00275 { -5332, -5332 }, 00276 { 541, 541 }, 00277 { -611, -611 }, 00278 { -621, -621 }, 00279 { -631, -631 }, 00280 { -6222, -6222 }, 00281 { -6122, -6122 }, 00282 { -6112, -6112 }, 00283 { -6232, -6232 }, 00284 { -6132, -6132 }, 00285 { -6332, -6332 }, 00286 { -641, -641 }, 00287 { -513, -513 }, 00288 { -523, -523 }, 00289 { -533, -533 }, 00290 { -20513, -20513 }, 00291 { -20523, -20523 }, 00292 { -20533, -20533 }, 00293 { -515, -515 }, 00294 { -525, -525 }, 00295 { -535, -535 }, 00296 { 513, 513 }, 00297 { 523, 523 }, 00298 { 533, 533 }, 00299 { 20513, 20513 }, 00300 { 20523, 20523 }, 00301 { 20533, 20533 }, 00302 { 515, 515 }, 00303 { 525, 525 }, 00304 { 535, 535 }, 00305 { 10113, 10113 }, 00306 { 10213, 10213 }, 00307 { -10213, -10213 }, 00308 { 10223, 10223 }, 00309 { 10333, 10333 }, 00310 { 9000111, 9000111 }, 00311 { 9000211, 9000211 }, 00312 { -9000211, -9000211 }, 00313 { 9010221, 9010221 }, 00314 { 10221, 10221 }, 00315 { 543, 543 }, 00316 { -543, -543 }, 00317 { 20543, 20543 }, 00318 { -20543, -20543 }, 00319 { 545, 545 }, 00320 { -545, -545 }, 00321 { 10443, 10443 }, 00322 { 20443, 20443 }, 00323 { 445, 445 }, 00324 { 551, 551 }, 00325 { 10553, 10553 }, 00326 { 10551, 10551 }, 00327 { 20553, 20553 }, 00328 { 555, 555 }, 00329 { 10313, 10313 }, 00330 { 10323, 10323 }, 00331 { -10313, -10313 }, 00332 { -10323, -10323 }, 00333 { 10413, 10413 }, 00334 { 10423, 10423 }, 00335 { 10433, 10433 }, 00336 { -10413, -10413 }, 00337 { -10423, -10423 }, 00338 { -10433, -10433 }, 00339 { 10513, 10513 }, 00340 { 10523, 10523 }, 00341 { 10533, 10533 }, 00342 { 10543, 10543 }, 00343 { -10513, -10513 }, 00344 { -10523, -10523 }, 00345 { -10533, -10533 }, 00346 { -10543, -10543 }, 00347 { 10321, 10321 }, 00348 { 10311, 10311 }, 00349 { -10311, -10311 }, 00350 { -10321, -10321 }, 00351 { 10411, 10411 }, 00352 { 10421, 10421 }, 00353 { 10431, 10431 }, 00354 { -10411, -10411 }, 00355 { -10421, -10421 }, 00356 { -10431, -10431 }, 00357 { 10511, 10511 }, 00358 { 10521, 10521 }, 00359 { 10531, 10531 }, 00360 { 10541, 10541 }, 00361 { -10511, -10511 }, 00362 { -10521, -10521 }, 00363 { -10531, -10531 }, 00364 { -10541, -10541 }, 00365 { 5114, 5114 }, 00366 { 5212, 5212 }, 00367 { 5214, 5214 }, 00368 { 5224, 5224 }, 00369 { 5322, 5322 }, 00370 { 5324, 5324 }, 00371 { 5312, 5312 }, 00372 { 5314, 5314 }, 00373 { 5334, 5334 }, 00374 { -5114, -5114 }, 00375 { -5212, -5212 }, 00376 { -5214, -5214 }, 00377 { -5224, -5224 }, 00378 { -5322, -5322 }, 00379 { -5324, -5324 }, 00380 { -5312, -5312 }, 00381 { -5314, -5314 }, 00382 { -5334, -5334 }, 00383 { 10325, 10325 }, 00384 { 10315, 10315 }, 00385 { -10315, -10315 }, 00386 { -10325, -10325 }, 00387 { 30323, 30323 }, 00388 { 30313, 30313 }, 00389 { -30313, -30313 }, 00390 { -30323, -30323 }, 00391 { 20325, 20325 }, 00392 { 20315, 20315 }, 00393 { -20315, -20315 }, 00394 { -20325, -20325 }, 00395 { 327, 327 }, 00396 { 317, 317 }, 00397 { -317, -317 }, 00398 { -327, -327 }, 00399 { 10215, 10215 }, 00400 { 10115, 10115 }, 00401 { -10215, -10215 }, 00402 { 30213, 30213 }, 00403 { 30113, 30113 }, 00404 { -30213, -30213 }, 00405 { 217, 217 }, 00406 { 117, 117 }, 00407 { -217, -217 }, 00408 { 100553, 100553 }, 00409 { 110551, 110551 }, 00410 { 120553, 120553 }, 00411 { 100555, 100555 }, 00412 { 200553, 200553 }, 00413 { 300553, 300553 }, 00414 { 227, 227 }, 00415 { 337, 337 }, 00416 { 10225, 10225 }, 00417 { 10335, 10335 }, 00418 { 30223, 30223 }, 00419 { 1000001, 1000001 }, 00420 { 1000002, 1000002 }, 00421 { 1000003, 1000003 }, 00422 { 1000004, 1000004 }, 00423 { 1000005, 1000005 }, 00424 { 1000006, 1000006 }, 00425 { -1000001, -1000001 }, 00426 { -1000002, -1000002 }, 00427 { -1000003, -1000003 }, 00428 { -1000004, -1000004 }, 00429 { -1000005, -1000005 }, 00430 { -1000006, -1000006 }, 00431 { 2000001, 2000001 }, 00432 { 2000002, 2000002 }, 00433 { 2000003, 2000003 }, 00434 { 2000004, 2000004 }, 00435 { 2000005, 2000005 }, 00436 { 2000006, 2000006 }, 00437 { -2000001, -2000001 }, 00438 { -2000002, -2000002 }, 00439 { -2000003, -2000003 }, 00440 { -2000004, -2000004 }, 00441 { -2000005, -2000005 }, 00442 { -2000006, -2000006 }, 00443 { 1000011, 1000011 }, 00444 { 1000012, 1000012 }, 00445 { 1000013, 1000013 }, 00446 { 1000014, 1000014 }, 00447 { 1000015, 1000015 }, 00448 { 1000016, 1000016 }, 00449 { -1000011, -1000011 }, 00450 { -1000012, -1000012 }, 00451 { -1000013, -1000013 }, 00452 { -1000014, -1000014 }, 00453 { -1000015, -1000015 }, 00454 { -1000016, -1000016 }, 00455 { 2000011, 2000011 }, 00456 { 2000012, 2000012 }, 00457 { 2000013, 2000013 }, 00458 { 2000014, 2000014 }, 00459 { 2000015, 2000015 }, 00460 { 2000016, 2000016 }, 00461 { -2000011, -2000011 }, 00462 { -2000012, -2000012 }, 00463 { -2000013, -2000013 }, 00464 { -2000014, -2000014 }, 00465 { -2000015, -2000015 }, 00466 { -2000016, -2000016 }, 00467 { 1000021, 1000021 }, 00468 { 1000022, 1000022 }, 00469 { 1000023, 1000023 }, 00470 { 1000025, 1000025 }, 00471 { 1000035, 1000035 }, 00472 { 1000024, 1000024 }, 00473 { 1000037, 1000037 }, 00474 { -1000024, -1000024 }, 00475 { -1000037, -1000037 }, 00476 { 1000039, 1000039 } 00477 }; 00478 00479 int listSize = sizeof(SList)/sizeof(SList[0]); 00480 for( int k=0; k!=listSize; ++k) { 00481 m.insert( std::make_pair( SList[k].hid, SList[k].pid) ); 00482 } 00483 return m; 00484 } // HerwigPDTMapInit() 00485 00486 PDTHerwigMap const & PDTHerwigMapInit() 00487 { 00488 static PDTHerwigMap m; 00489 static HerwigPDTMap const & hmap = getHerwigPDTMap(); 00490 00491 for(HerwigPDTMap::const_iterator cit=hmap.begin(), mend=hmap.end(); cit!=mend; ++cit ) { 00492 m.insert( std::make_pair( cit->second, cit->first )); 00493 } 00494 return m; 00495 } 00496 00497 // 00498 // getHerwigPDTMap is the ONLY function allowed to call HerwigPDTMapInit 00499 // 00500 HerwigPDTMap const & getHerwigPDTMap() 00501 { 00502 static HerwigPDTMap const & hmap = HerwigPDTMapInit(); 00503 return hmap; 00504 } // getHerwigPDTMap() 00505 00506 // 00507 // getPDTHerwigMap is the ONLY function allowed to call HerwigPDTMapInit 00508 // 00509 PDTHerwigMap const & getPDTHerwigMap() 00510 { 00511 static PDTHerwigMap const & hmap = PDTHerwigMapInit(); 00512 return hmap; 00513 } // getPDTHerwigMap() 00514 00515 } // unnamed namespace 00516 00517 int translateHerwigtoPDT( const int id ) 00518 { 00519 static HerwigPDTMap const & hmap = getHerwigPDTMap(); 00520 00521 HerwigPDTMap::const_iterator const cit = hmap.find( id ); 00522 // found it in the map 00523 if ( cit != hmap.end() ) { return cit->second; } 00524 // check to see if someone has defined a valid particle type 00525 // that isn't in the map 00526 if( isValid(id) ) { return id; } 00527 return 0; 00528 } 00529 00530 int translatePDTtoHerwig( const int id ) 00531 { 00532 static PDTHerwigMap const & pmap = getPDTHerwigMap(); 00533 00534 PDTHerwigMap::const_iterator const cit = pmap.find( id ); 00535 // found it in the map 00536 if ( cit != pmap.end() ) { return cit->second; } 00537 // check to see if someone has defined a valid particle type 00538 // that isn't in the map 00539 if( isValid(id) ) { return id; } 00540 return 0; 00541 } 00542 00543 void writeHerwigTranslationLine( int i, std::ostream & os ) 00544 { 00545 // only write map entries 00546 static HerwigPDTMap const & hmap = getHerwigPDTMap(); 00547 00548 HerwigPDTMap::const_iterator const cit = hmap.find( i ); 00549 // found it in the map 00550 if ( cit != hmap.end() ) { 00551 int id = cit->second; 00552 os << " Herwig number: " ; 00553 os.width(10); 00554 os << i << " HepPID number: " ; 00555 os.width(10); 00556 os << id << " " << particleName(id) << std::endl; 00557 // check reverse translation 00558 int iback = translatePDTtoHerwig(id); 00559 if(iback != i) { 00560 os << " WARNING: " << id << " translates back to " 00561 << iback << " not to " << i << std::endl; 00562 } 00563 } 00564 return; 00565 } // writeHerwigTranslationLine() 00566 00567 void writeHerwigTranslation( std::ostream & os ) 00568 { 00569 writeVersion( os ); 00570 os << " HepPID Particle List" << std::endl; 00571 os << std::endl; 00572 00573 int id, i, j, q1, q2, q3, l, m, n; 00574 // special cases 00575 for( id=1; id<101; ++id) { 00576 writeHerwigTranslationLine( id, os ); 00577 writeHerwigTranslationLine( -id, os ); 00578 } 00579 // SUSY 00580 for( n=1; n<3; ++n) { 00581 for( i=1; i<40; ++i) { 00582 id = 1000000*n+i; 00583 writeHerwigTranslationLine( id, os ); 00584 writeHerwigTranslationLine( -id, os ); 00585 } 00586 } 00587 // diquark 00588 for( i=11; i<100; ++i) { 00589 for( j=0; j<10; ++j) { 00590 id = 100*i+j; 00591 writeHerwigTranslationLine( id, os ); 00592 writeHerwigTranslationLine( -id, os ); 00593 } 00594 } 00595 // mesons 00596 for( q2=1; q2<10; ++q2) { 00597 for( q1=1; q1<10; ++q1) { 00598 for( j=1; j<10; ++j) { 00599 for( m=0; m<9; ++m) { 00600 for( l=0; l<10; ++l) { 00601 id = 100000*m+10000*l+100*q2+10*q1+j; 00602 writeHerwigTranslationLine( id, os ); 00603 writeHerwigTranslationLine( -id, os ); 00604 id = 9000000+100000*m+10000*l+100*q2+10*q1+j; 00605 writeHerwigTranslationLine( id, os ); 00606 writeHerwigTranslationLine( -id, os ); 00607 } 00608 } 00609 } 00610 } 00611 } 00612 // baryons 00613 for( q3=1; q3<10; ++q3) { 00614 for( q2=1; q2<10; ++q2) { 00615 for( q1=1; q1<10; ++q1) { 00616 for( j=1; j<10; ++j) { 00617 id = 1000*q3+100*q2+10*q1+j; 00618 writeHerwigTranslationLine( id, os ); 00619 writeHerwigTranslationLine( -id, os ); 00620 } 00621 } 00622 } 00623 } 00624 // pentaquarks 00625 for( l=1; l<9; ++l ) { 00626 for ( m=1; m<9; ++m ) { 00627 for( q3=1; q3<9; ++q3) { 00628 for( q2=1; q2<9; ++q2) { 00629 for( q1=1; q1<9; ++q1) { 00630 id = 9*1000000+l*100000+m*10000+1000*q3+100*q2+10*q1+2; 00631 writeHerwigTranslationLine( id, os ); 00632 writeHerwigTranslationLine( -id, os ); 00633 } 00634 } 00635 } 00636 } 00637 } 00638 return; 00639 } // writeHerwigTranslation() 00640 00641 } // HepPID