00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <map>
00024 #include <utility>
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 > EvtGenPDTMap;
00034 typedef std::map< int, int > PDTEvtGenMap;
00035
00036 namespace {
00037
00038 EvtGenPDTMap const & getEvtGenPDTMap();
00039 PDTEvtGenMap const & getPDTEvtGenMap();
00040
00041 EvtGenPDTMap const & EvtGenPDTMapInit()
00042 {
00043
00044 static EvtGenPDTMap m;
00045
00046 static const struct {
00047 int hid;
00048 int pid;
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 { 21, 21 },
00067 { 11, 11 },
00068 { -11, -11 },
00069 { 12, 12 },
00070 { -12, -12 },
00071 { 13, 13 },
00072 { -13, -13 },
00073 { 14, 14 },
00074 { -14, -14 },
00075 { 15, 15 },
00076 { -15, -15 },
00077 { 16, 16 },
00078 { -16, -16 },
00079 { 17, 17 },
00080 { -17, -17 },
00081 { 18, 18 },
00082 { -18, -18 },
00083 { 22, 22 },
00084 { 10022, 10022 },
00085 { 20022, 20022 },
00086 { 23, 23 },
00087 { 24, 24 },
00088 { -24, -24 },
00089 { 25, 25 },
00090 { 110, 110 },
00091 { 990, 990 },
00092 { 32, 32 },
00093 { 33, 33 },
00094 { 34, 34 },
00095 { -34, -34 },
00096 { 35, 35 },
00097 { 36, 36 },
00098 { 37, 37 },
00099 { -37, -37 },
00100 { 41, 41 },
00101 { -41, -41 },
00102 { 43, 43 },
00103 { 44, 44 },
00104 { -44, -44 },
00105 { 81, 81 },
00106 { 82, 82 },
00107 { -82, -82 },
00108 { 83, 83 },
00109 { 84, 84 },
00110 { -84, -84 },
00111 { 85, 85 },
00112 { -85, -85 },
00113 { 86, 86 },
00114 { -86, -86 },
00115 { 87, 87 },
00116 { -87, -87 },
00117 { 88, 88 },
00118 { -88, -88 },
00119 { 89, 89 },
00120 { -89, -89 },
00121 { 90, 90 },
00122 { -90, -90 },
00123 { 91, 91 },
00124 { 92, 92 },
00125 { 93, 93 },
00126 { 94, 94 },
00127 { 95, 95 },
00128 { 96, 96 },
00129 { 97, 97 },
00130 { 98, 98 },
00131 { 99, 99 },
00132 { 111, 111 },
00133 { 211, 211 },
00134 { -211, -211 },
00135 { 9910211, 9910211 },
00136 { -9910211, -9910211 },
00137 { 100111, 100111 },
00138 { 100211, 100211 },
00139 { -100211, -100211 },
00140 { 221, 221 },
00141 { 100221, 100221 },
00142 { 331, 331 },
00143 { 113, 113 },
00144 { 9910113, 9910113 },
00145 { 213, 213 },
00146 { -213, -213 },
00147 { 100113, 100113 },
00148 { 100213, 100213 },
00149 { -100213, -100213 },
00150 { 30113, 30113 },
00151 { 30213, 30213 },
00152 { -30213, -30213 },
00153 { 223, 223 },
00154 { 9910223, 9910223 },
00155 { 100223, 100223 },
00156 { 333, 333 },
00157 { 9910333, 9910333 },
00158 { 9000111, 9000111 },
00159 { 9000211, 9000211 },
00160 { -9000211, -9000211 },
00161 { 9010221, 9010221 },
00162 { 10221, 10221 },
00163 { 10113, 10113 },
00164 { 10213, 10213 },
00165 { -10213, -10213 },
00166 { 10223, 10223 },
00167 { 10333, 10333 },
00168 { 20113, 20113 },
00169 { 20213, 20213 },
00170 { -20213, -20213 },
00171 { 20223, 20223 },
00172 { 20333, 20333 },
00173 { 115, 115 },
00174 { 215, 215 },
00175 { -215, -215 },
00176 { 225, 225 },
00177 { 9020221, 9030221 },
00178 { 335, 335 },
00179 { 311, 311 },
00180 { -311, -311 },
00181 { 310, 310 },
00182 { 130, 130 },
00183 { 321, 321 },
00184 { -321, -321 },
00185 { 313, 313 },
00186 { -313, -313 },
00187 { 323, 323 },
00188 { -323, -323 },
00189 { 10311, 10311 },
00190 { -10311, -10311 },
00191 { 10321, 10321 },
00192 { -10321, -10321 },
00193 { 10313, 10313 },
00194 { -10313, -10313 },
00195 { 10323, 10323 },
00196 { -10323, -10323 },
00197 { 315, 315 },
00198 { -315, -315 },
00199 { 325, 325 },
00200 { -325, -325 },
00201 { 20313, 20313 },
00202 { -20313, -20313 },
00203 { 20323, 20323 },
00204 { -20323, -20323 },
00205 { 100313, 100313 },
00206 { -100313, -100313 },
00207 { 100323, 100323 },
00208 { -100323, -100323 },
00209 { 30313, 30313 },
00210 { -30313, -30313 },
00211 { 30323, 30323 },
00212 { -30323, -30323 },
00213 { 317, 317 },
00214 { -317, -317 },
00215 { 327, 327 },
00216 { -327, -327 },
00217 { 319, 319 },
00218 { -319, -319 },
00219 { 329, 329 },
00220 { -329, -329 },
00221 { 411, 411 },
00222 { -411, -411 },
00223 { 421, 421 },
00224 { -421, -421 },
00225 { 413, 413 },
00226 { -413, -413 },
00227 { 423, 423 },
00228 { -423, -423 },
00229 { 10411, 10411 },
00230 { -10411, -10411 },
00231 { 10421, 10421 },
00232 { -10421, -10421 },
00233 { 10413, 10413 },
00234 { -10413, -10413 },
00235 { 10423, 10423 },
00236 { -10423, -10423 },
00237 { 415, 415 },
00238 { -415, -415 },
00239 { 425, 425 },
00240 { -425, -425 },
00241 { 20413, 20413 },
00242 { -20413, -20413 },
00243 { 20423, 20423 },
00244 { -20423, -20423 },
00245 { 431, 431 },
00246 { -431, -431 },
00247 { 433, 433 },
00248 { -433, -433 },
00249 { 10431, 10431 },
00250 { -10431, -10431 },
00251 { 10433, 10433 },
00252 { -10433, -10433 },
00253 { 435, 435 },
00254 { -435, -435 },
00255 { 20433, 20433 },
00256 { -20433, -20433 },
00257 { 30411, 100411 },
00258 { -30411, -100411 },
00259 { 30421, 100421 },
00260 { -30421, -100421 },
00261 { 30413, 100413 },
00262 { -30413, -100413 },
00263 { 30423, 100423 },
00264 { -30423, -100423 },
00265 { 511, 511 },
00266 { -511, -511 },
00267 { 521, 521 },
00268 { -521, -521 },
00269 { 513, 513 },
00270 { -513, -513 },
00271 { 523, 523 },
00272 { -523, -523 },
00273 { 10511, 10511 },
00274 { -10511, -10511 },
00275 { 10521, 10521 },
00276 { -10521, -10521 },
00277 { 10513, 10513 },
00278 { -10513, -10513 },
00279 { 10523, 10523 },
00280 { -10523, -10523 },
00281 { 515, 515 },
00282 { -515, -515 },
00283 { 525, 525 },
00284 { -525, -525 },
00285 { 20513, 20513 },
00286 { -20513, -20513 },
00287 { 20523, 20523 },
00288 { -20523, -20523 },
00289 { 531, 531 },
00290 { -531, -531 },
00291 { 533, 533 },
00292 { -533, -533 },
00293 { 10531, 10531 },
00294 { -10531, -10531 },
00295 { 10533, 10533 },
00296 { -10533, -10533 },
00297 { 535, 535 },
00298 { -535, -535 },
00299 { 20533, 20533 },
00300 { -20533, -20533 },
00301 { 541, 541 },
00302 { -541, -541 },
00303 { 543, 543 },
00304 { -543, -543 },
00305 { 10541, 10541 },
00306 { -10541, -10541 },
00307 { 10543, 10543 },
00308 { -10543, -10543 },
00309 { 545, 545 },
00310 { -545, -545 },
00311 { 20543, 20543 },
00312 { -20543, -20543 },
00313 { 441, 441 },
00314 { 100441, 100441 },
00315 { 443, 443 },
00316 { 9910443, 9910443 },
00317 { 100443, 100443 },
00318 { 30443, 30443 },
00319 { 9000443, 9000443 },
00320 { 9010443, 9010443 },
00321 { 9020443, 9020443 },
00322 { 10443, 10443 },
00323 { 10441, 10441 },
00324 { 20443, 20443 },
00325 { 445, 445 },
00326 { 551, 551 },
00327 { 100551, 100551 },
00328 { 200551, 200551 },
00329 { 553, 553 },
00330 { 100553, 100553 },
00331 { 200553, 200553 },
00332 { 300553, 300553 },
00333 { 9000553, 9000553 },
00334 { 10553, 10553 },
00335 { 110553, 110553 },
00336 { 210553, 210553 },
00337 { 10551, 10551 },
00338 { 20553, 20553 },
00339 { 555, 555 },
00340 { 110551, 110551 },
00341 { 120553, 120553 },
00342 { 100555, 100555 },
00343 { 210551, 210551 },
00344 { 220553, 220553 },
00345 { 200555, 200555 },
00346 { 10555, 10555 },
00347 { 110555, 110555 },
00348 { 30553, 30553 },
00349 { 20555, 20555 },
00350 { 557, 557 },
00351 { 130553, 130553 },
00352 { 120555, 120555 },
00353 { 100557, 100557 },
00354 { 9000221, 9090221 },
00355 { 1114, 1114 },
00356 { -1114, -1114 },
00357 { 9912112, 9912112 },
00358 { -9912112, -9912112 },
00359 { 2112, 2112 },
00360 { -2112, -2112 },
00361 { 2114, 2114 },
00362 { -2114, -2114 },
00363 { 9912212, 9912212 },
00364 { -9912212, -9912212 },
00365 { 2212, 2212 },
00366 { -2212, -2212 },
00367 { 2214, 2214 },
00368 { -2214, -2214 },
00369 { 2224, 2224 },
00370 { -2224, -2224 },
00371 { 3112, 3112 },
00372 { -3112, -3112 },
00373 { 3114, 3114 },
00374 { -3114, -3114 },
00375 { 3122, 3122 },
00376 { -3122, -3122 },
00377 { 13122, 13122 },
00378 { -13122, -13122 },
00379 { 3124, 3124 },
00380 { -3124, -3124 },
00381 { 23122, 23122 },
00382 { -23122, -23122 },
00383 { 33122, 33122 },
00384 { -33122, -33122 },
00385 { 13124, 13124 },
00386 { -13124, -13124 },
00387 { 43122, 43122 },
00388 { -43122, -43122 },
00389 { 53122, 53122 },
00390 { -53122, -53122 },
00391 { 3126, 3126 },
00392 { -3126, -3126 },
00393 { 13126, 13126 },
00394 { -13126, -13126 },
00395 { 13212, 13212 },
00396 { -13212, -13212 },
00397 { 13214, 13214 },
00398 { -13214, -13214 },
00399 { 23212, 23212 },
00400 { -23212, -23212 },
00401 { 3216, 3216 },
00402 { -3216, -3216 },
00403 { 3212, 3212 },
00404 { -3212, -3212 },
00405 { 3214, 3214 },
00406 { -3214, -3214 },
00407 { 3222, 3222 },
00408 { -3222, -3222 },
00409 { 3224, 3224 },
00410 { -3224, -3224 },
00411 { 3312, 3312 },
00412 { -3312, -3312 },
00413 { 3314, 3314 },
00414 { -3314, -3314 },
00415 { 3322, 3322 },
00416 { -3322, -3322 },
00417 { 3324, 3324 },
00418 { -3324, -3324 },
00419 { 3334, 3334 },
00420 { -3334, -3334 },
00421 { 14122, 14122 },
00422 { -14122, -14122 },
00423 { 14124, 14124 },
00424 { -14124, -14124 },
00425 { 4112, 4112 },
00426 { -4112, -4112 },
00427 { 4114, 4114 },
00428 { -4114, -4114 },
00429 { 4212, 4212 },
00430 { -4212, -4212 },
00431 { 4214, 4214 },
00432 { -4214, -4214 },
00433 { 4222, 4222 },
00434 { -4222, -4222 },
00435 { 4224, 4224 },
00436 { -4224, -4224 },
00437 { 4312, 4312 },
00438 { -4312, -4312 },
00439 { 4322, 4322 },
00440 { -4322, -4322 },
00441 { 4324, 4324 },
00442 { -4324, -4324 },
00443 { 4122, 4122 },
00444 { -4122, -4122 },
00445 { 4132, 4132 },
00446 { -4132, -4132 },
00447 { 4232, 4232 },
00448 { -4232, -4232 },
00449 { 4314, 4314 },
00450 { -4314, -4314 },
00451 { 4332, 4332 },
00452 { -4332, -4332 },
00453 { 4334, 4334 },
00454 { -4334, -4334 },
00455 { 4412, 4412 },
00456 { -4412, -4412 },
00457 { 4414, 4414 },
00458 { -4414, -4414 },
00459 { 4422, 4422 },
00460 { -4422, -4422 },
00461 { 4424, 4424 },
00462 { -4424, -4424 },
00463 { 4432, 4432 },
00464 { -4432, -4432 },
00465 { 4434, 4434 },
00466 { -4434, -4434 },
00467 { 5112, 5112 },
00468 { -5112, -5112 },
00469 { 5114, 5114 },
00470 { -5114, -5114 },
00471 { 5122, 5122 },
00472 { -5122, -5122 },
00473 { 5132, 5132 },
00474 { -5132, -5132 },
00475 { 5212, 5212 },
00476 { -5212, -5212 },
00477 { 5214, 5214 },
00478 { -5214, -5214 },
00479 { 5222, 5222 },
00480 { -5222, -5222 },
00481 { 5224, 5224 },
00482 { -5224, -5224 },
00483 { 5232, 5232 },
00484 { -5232, -5232 },
00485 { 5312, 5312 },
00486 { -5312, -5312 },
00487 { 5314, 5314 },
00488 { -5314, -5314 },
00489 { 5322, 5322 },
00490 { -5322, -5322 },
00491 { 5324, 5324 },
00492 { -5324, -5324 },
00493 { 5332, 5332 },
00494 { -5332, -5332 },
00495 { 5334, 5334 },
00496 { -5334, -5334 },
00497 { 2101, 2101 },
00498 { -2101, -2101 },
00499 { 3101, 3101 },
00500 { -3101, -3101 },
00501 { 3201, 3201 },
00502 { -3201, -3201 },
00503 { 4101, 4101 },
00504 { -4101, -4101 },
00505 { 4201, 4201 },
00506 { -4201, -4201 },
00507 { 4301, 4301 },
00508 { -4301, -4301 },
00509 { 5101, 5101 },
00510 { -5101, -5101 },
00511 { 5201, 5201 },
00512 { -5201, -5201 },
00513 { 5301, 5301 },
00514 { -5301, -5301 },
00515 { 5401, 5401 },
00516 { -5401, -5401 },
00517 { 1103, 1103 },
00518 { -1103, -1103 },
00519 { 2103, 2103 },
00520 { -2103, -2103 },
00521 { 2203, 2203 },
00522 { -2203, -2203 },
00523 { 3103, 3103 },
00524 { -3103, -3103 },
00525 { 3203, 3203 },
00526 { -3203, -3203 },
00527 { 3303, 3303 },
00528 { -3303, -3303 },
00529 { 4103, 4103 },
00530 { -4103, -4103 },
00531 { 4203, 4203 },
00532 { -4203, -4203 },
00533 { 4303, 4303 },
00534 { -4303, -4303 },
00535 { 4403, 4403 },
00536 { -4403, -4403 },
00537 { 5103, 5103 },
00538 { -5103, -5103 },
00539 { 5203, 5203 },
00540 { -5203, -5203 },
00541 { 5303, 5303 },
00542 { -5303, -5303 },
00543 { 5403, 5403 },
00544 { -5403, -5403 },
00545 { 5503, 5503 },
00546 { -5503, -5503 },
00547 { 30343, 30343 },
00548 { -30343, -30343 },
00549 { 30353, 30353 },
00550 { -30353, -30353 },
00551 { 30373, 30373 },
00552 { -30373, -30373 },
00553 { 30383, 30383 },
00554 { -30383, -30383 },
00555 { 30363, 30363 },
00556 { -30363, -30363 },
00557 { 450000000, 1000010020 },
00558 { -450000000, -1000010020 },
00559 { 460000000, 1000010030 },
00560 { -460000000, -1000010030 },
00561 { 470000000, 1000020040 },
00562 { -470000000, -1000020040 },
00563 { 490000000, 1000020030 },
00564 { -490000000, -1000020030 },
00565 { 480000000, 101 }
00566 };
00567
00568 int listSize = sizeof(SList)/sizeof(SList[0]);
00569 for( int k=0; k!=listSize; ++k) {
00570 m.insert( std::make_pair( SList[k].hid, SList[k].pid) );
00571 }
00572 return m;
00573 }
00574
00575 PDTEvtGenMap const & PDTEvtGenMapInit()
00576 {
00577 static PDTEvtGenMap m;
00578 static EvtGenPDTMap const & hmap = getEvtGenPDTMap();
00579
00580 for(EvtGenPDTMap::const_iterator cit=hmap.begin(), mend=hmap.end(); cit!=mend; ++cit ) {
00581 m.insert( std::make_pair( cit->second, cit->first ));
00582 }
00583 return m;
00584 }
00585
00586
00587
00588
00589 EvtGenPDTMap const & getEvtGenPDTMap()
00590 {
00591 static EvtGenPDTMap const & hmap = EvtGenPDTMapInit();
00592 return hmap;
00593 }
00594
00595
00596
00597
00598 PDTEvtGenMap const & getPDTEvtGenMap()
00599 {
00600 static PDTEvtGenMap const & hmap = PDTEvtGenMapInit();
00601 return hmap;
00602 }
00603
00604 }
00605
00606 int translateEvtGentoPDT( const int id )
00607 {
00608 static EvtGenPDTMap const & hmap = getEvtGenPDTMap();
00609
00610 EvtGenPDTMap::const_iterator const cit = hmap.find( id );
00611
00612 if ( cit != hmap.end() ) { return cit->second; }
00613
00614
00615 if( isValid(id) ) { return id; }
00616 return 0;
00617 }
00618
00619 int translatePDTtoEvtGen( const int id )
00620 {
00621 static PDTEvtGenMap const & pmap = getPDTEvtGenMap();
00622
00623 PDTEvtGenMap::const_iterator const cit = pmap.find( id );
00624
00625 if ( cit != pmap.end() ) { return cit->second; }
00626
00627
00628 if( isValid(id) ) { return id; }
00629 return 0;
00630 }
00631
00632 void writeEvtGenTranslationLine( int i, std::ostream & os )
00633 {
00634
00635 static EvtGenPDTMap const & hmap = getEvtGenPDTMap();
00636
00637 EvtGenPDTMap::const_iterator const cit = hmap.find( i );
00638
00639 if ( cit != hmap.end() ) {
00640 int id = cit->second;
00641 os << " EvtGen number: " ;
00642 os.width(10);
00643 os << i << " HepPID number: " ;
00644 os.width(11);
00645 os << id << " " << particleName(id) << std::endl;
00646
00647 int iback = translatePDTtoEvtGen(id);
00648 if(iback != i) {
00649 os << " WARNING: " << id << " translates back to "
00650 << iback << " not to " << i << std::endl;
00651 }
00652 }
00653 return;
00654 }
00655
00656 void writeEvtGenTranslation( std::ostream & os )
00657 {
00658 writeVersion( os );
00659 os << " HepPID Particle List" << std::endl;
00660 os << std::endl;
00661
00662 int id, i, j, q1, q2, q3, l, m;
00663
00664 for( id=1; id<102; ++id) {
00665 writeEvtGenTranslationLine( id, os );
00666 writeEvtGenTranslationLine( -id, os );
00667 }
00668 for( i=11; i<1000; ++i) {
00669 id = i*10;
00670 writeEvtGenTranslationLine( id, os );
00671 writeEvtGenTranslationLine( -id, os );
00672 }
00673
00674 for( q2=1; q2<7; ++q2) {
00675 for( q1=1; q1<7; ++q1) {
00676 for( j=1; j<4; ++j) {
00677 id = 1000*q2+100*q1+j;
00678 writeEvtGenTranslationLine( id, os );
00679 writeEvtGenTranslationLine( -id, os );
00680 }
00681 }
00682 }
00683
00684 for( q2=1; q2<10; ++q2) {
00685 for( q1=1; q1<10; ++q1) {
00686 for( j=1; j<10; ++j) {
00687 for( m=0; m<9; ++m) {
00688 for( l=0; l<10; ++l) {
00689 id = 100000*m+10000*l+100*q2+10*q1+j;
00690 writeEvtGenTranslationLine( id, os );
00691 writeEvtGenTranslationLine( -id, os );
00692 id = 9000000+100000*m+10000*l+100*q2+10*q1+j;
00693 writeEvtGenTranslationLine( id, os );
00694 writeEvtGenTranslationLine( -id, os );
00695 }
00696 }
00697 }
00698 }
00699 }
00700
00701 for( q3=1; q3<10; ++q3) {
00702 for( q2=1; q2<10; ++q2) {
00703 for( q1=1; q1<10; ++q1) {
00704 for( j=1; j<10; ++j) {
00705 for( m=0; m<9; ++m) {
00706 id = 10000*m+1000*q3+100*q2+10*q1+j;
00707 writeEvtGenTranslationLine( id, os );
00708 writeEvtGenTranslationLine( -id, os );
00709 }
00710 }
00711 }
00712 }
00713 }
00714
00715 for( i=1; i<=9; ++i) {
00716 id = 400000000+10000000*i;
00717 writeEvtGenTranslationLine( id, os );
00718 writeEvtGenTranslationLine( -id, os );
00719 }
00720
00721 return;
00722 }
00723
00724 }