00001
00002
00003
00005
00006 #include "HepMC/IO_HERWIG.h"
00007 #include "HepMC/GenEvent.h"
00008 #include <cstdio>
00009
00010 namespace HepMC {
00011
00012 IO_HERWIG::IO_HERWIG() : m_trust_mothers_before_daughters(false),
00013 m_trust_both_mothers_and_daughters(true),
00014 m_print_inconsistency_errors(true),
00015 m_no_gaps_in_barcodes(true),
00016 m_herwig_to_pdg_id(100,0)
00017 {
00018
00019
00020
00021 m_herwig_to_pdg_id[1] =1;
00022 m_herwig_to_pdg_id[2] =2;
00023 m_herwig_to_pdg_id[3] =3;
00024 m_herwig_to_pdg_id[4] =4;
00025 m_herwig_to_pdg_id[5] =5;
00026 m_herwig_to_pdg_id[6] =6;
00027 m_herwig_to_pdg_id[7] =7;
00028 m_herwig_to_pdg_id[8] =8;
00029
00030 m_herwig_to_pdg_id[11] =11;
00031 m_herwig_to_pdg_id[12] =12;
00032 m_herwig_to_pdg_id[13] =13;
00033 m_herwig_to_pdg_id[14] =14;
00034 m_herwig_to_pdg_id[15] =15;
00035 m_herwig_to_pdg_id[16] =16;
00036
00037 m_herwig_to_pdg_id[21] =21;
00038 m_herwig_to_pdg_id[22] =22;
00039 m_herwig_to_pdg_id[23] =23;
00040 m_herwig_to_pdg_id[24] =24;
00041 m_herwig_to_pdg_id[25] =25;
00042 m_herwig_to_pdg_id[26] =51;
00043
00044 m_herwig_to_pdg_id[32] =32;
00045 m_herwig_to_pdg_id[35] =35;
00046 m_herwig_to_pdg_id[36] =36;
00047 m_herwig_to_pdg_id[37] =37;
00048 m_herwig_to_pdg_id[39] =39;
00049
00050 m_herwig_to_pdg_id[40] =40;
00051
00052 m_herwig_to_pdg_id[81] =81;
00053 m_herwig_to_pdg_id[82] =82;
00054 m_herwig_to_pdg_id[83] =83;
00055 m_herwig_to_pdg_id[84] =84;
00056 m_herwig_to_pdg_id[85] =85;
00057 m_herwig_to_pdg_id[86] =86;
00058 m_herwig_to_pdg_id[87] =87;
00059 m_herwig_to_pdg_id[88] =88;
00060 m_herwig_to_pdg_id[89] =89;
00061 m_herwig_to_pdg_id[90] =90;
00062
00063 m_herwig_to_pdg_id[91] =91;
00064 m_herwig_to_pdg_id[92] =92;
00065 m_herwig_to_pdg_id[93] =93;
00066 m_herwig_to_pdg_id[94] =94;
00067 m_herwig_to_pdg_id[95] =95;
00068 m_herwig_to_pdg_id[96] =96;
00069 m_herwig_to_pdg_id[97] =97;
00070 m_herwig_to_pdg_id[98] =9920022;
00071 m_herwig_to_pdg_id[99] =9922212;
00072
00073
00074 m_no_antiparticles.insert(-21);
00075 m_no_antiparticles.insert(-22);
00076 m_no_antiparticles.insert(-23);
00077 m_no_antiparticles.insert(-25);
00078 m_no_antiparticles.insert(-51);
00079 m_no_antiparticles.insert(-35);
00080 m_no_antiparticles.insert(-36);
00081 }
00082
00083 IO_HERWIG::~IO_HERWIG(){}
00084
00085 void IO_HERWIG::print( std::ostream& ostr ) const {
00086 ostr << "IO_HERWIG: reads an event from the FORTRAN Herwig HEPEVT "
00087 << "common block. \n"
00088 << " trust_mothers_before_daughters = "
00089 << m_trust_mothers_before_daughters
00090 << " trust_both_mothers_and_daughters = "
00091 << m_trust_both_mothers_and_daughters
00092 << " print_inconsistency_errors = "
00093 << m_print_inconsistency_errors << std::endl;
00094 }
00095
00096 bool IO_HERWIG::fill_next_event( GenEvent* evt ) {
00099
00100
00101 if ( !evt ) {
00102 std::cerr
00103 << "IO_HERWIG::fill_next_event error - passed null event."
00104 << std::endl;
00105 return 0;
00106 }
00107
00108
00109
00110 repair_hepevt();
00111
00112 evt->set_event_number( HEPEVT_Wrapper::event_number() );
00113
00114
00115
00116
00117
00118 std::vector<GenParticle*> hepevt_particle(
00119 HEPEVT_Wrapper::number_entries()+1 );
00120 hepevt_particle[0] = 0;
00121 for ( int i1 = 1; i1 <= HEPEVT_Wrapper::number_entries(); ++i1 ) {
00122 hepevt_particle[i1] = build_particle(i1);
00123 }
00124 std::set<GenVertex*> new_vertices;
00125
00126
00127
00128
00129 evt->set_beam_particles( hepevt_particle[1], hepevt_particle[2] );
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 int index_121 = 0;
00140 int index_122 = 0;
00141 for ( int i = 1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00142 if ( HEPEVT_Wrapper::status(i)==121 ) index_121=i;
00143 if ( HEPEVT_Wrapper::status(i)==122 ) index_122=i;
00144 if ( index_121!=0 && index_122!=0 ) break;
00145 }
00146 if ( index_121 && index_122 ) {
00147 GenVertex* hard_vtx = new GenVertex();
00148 hard_vtx->add_particle_in( hepevt_particle[index_121] );
00149 hard_vtx->add_particle_in( hepevt_particle[index_122] );
00150
00151
00152
00153 int index_hard = 0;
00154 for ( int i = 1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00155 if ( HEPEVT_Wrapper::status(i)==120 ) index_hard=i;
00156 if ( index_hard!=0 ) break;
00157 }
00158
00159 if ( index_hard!=0) {
00160 hard_vtx->add_particle_out( hepevt_particle[index_hard] );
00161 GenVertex* hard_vtx2 = new GenVertex();
00162 hard_vtx2->add_particle_in( hepevt_particle[index_hard] );
00163 for ( int i = 1; i <= HEPEVT_Wrapper::number_entries(); ++i ) {
00164 if ( HEPEVT_Wrapper::first_parent(i)==index_hard ) {
00165 hard_vtx2->add_particle_out( hepevt_particle[i] );
00166 }
00167 }
00168 evt->set_signal_process_vertex( hard_vtx );
00169 evt->set_signal_process_vertex( hard_vtx2 );
00170 }
00171 else {
00172 evt->set_signal_process_vertex( hard_vtx );
00173 }
00174
00175 }
00176
00177
00178 for ( int i = 1; i <= HEPEVT_Wrapper::number_entries(); ++i ) {
00179
00180
00181
00182
00184
00185
00186 if ( m_trust_mothers_before_daughters ||
00187 m_trust_both_mothers_and_daughters ) {
00188 build_production_vertex( i, hepevt_particle, evt );
00189 }
00190
00191
00192
00193 if ( !m_trust_mothers_before_daughters ||
00194 m_trust_both_mothers_and_daughters ) {
00195 build_end_vertex( i, hepevt_particle, evt );
00196 }
00197 }
00198
00199
00200
00201
00202
00203 for ( int i3 = 1; i3 <= HEPEVT_Wrapper::number_entries(); ++i3 ) {
00204
00205
00206
00207
00208 if ( hepevt_particle[i3] && !hepevt_particle[i3]->parent_event()
00209 && !hepevt_particle[i3]->pdg_id()
00210 && !hepevt_particle[i3]->status() ) {
00211
00212
00213
00214 delete hepevt_particle[i3];
00215 } else if ( hepevt_particle[i3] &&
00216 !hepevt_particle[i3]->end_vertex() &&
00217 !hepevt_particle[i3]->production_vertex() ) {
00218 GenVertex* prod_vtx = new GenVertex();
00219 prod_vtx->add_particle_out( hepevt_particle[i3] );
00220 evt->add_vertex( prod_vtx );
00221 }
00222 }
00223 return true;
00224 }
00225
00226 void IO_HERWIG::build_production_vertex(int i,
00227 std::vector<GenParticle*>&
00228 hepevt_particle,
00229 GenEvent* evt ) {
00233 GenParticle* p = hepevt_particle[i];
00234
00235 int mother = HEPEVT_Wrapper::first_parent(i);
00236 GenVertex* prod_vtx = p->production_vertex();
00237 while ( !prod_vtx && mother > 0 ) {
00238 prod_vtx = hepevt_particle[mother]->end_vertex();
00239 if ( prod_vtx ) prod_vtx->add_particle_out( p );
00240
00241 if ( ++mother > HEPEVT_Wrapper::last_parent(i) ) mother = 0;
00242 }
00243
00244
00245
00246 FourVector prod_pos( HEPEVT_Wrapper::x(i), HEPEVT_Wrapper::y(i),
00247 HEPEVT_Wrapper::z(i), HEPEVT_Wrapper::t(i)
00248 );
00249 if ( !prod_vtx && (HEPEVT_Wrapper::number_parents(i)>0
00250 || prod_pos!=FourVector(0,0,0,0)) )
00251 {
00252 prod_vtx = new GenVertex();
00253 prod_vtx->add_particle_out( p );
00254 evt->add_vertex( prod_vtx );
00255 }
00256
00257 if ( prod_vtx && prod_vtx->position()==FourVector(0,0,0,0) ) {
00258 prod_vtx->set_position( prod_pos );
00259 }
00260
00261
00262 mother = HEPEVT_Wrapper::first_parent(i);
00263 while ( prod_vtx && mother > 0 ) {
00264 if ( !hepevt_particle[mother]->end_vertex() ) {
00265
00266 prod_vtx->add_particle_in( hepevt_particle[mother] );
00267 } else if (hepevt_particle[mother]->end_vertex() != prod_vtx ) {
00268
00269
00270
00271
00272
00273
00274
00275
00276 if ( m_print_inconsistency_errors ) {
00277 std::cerr
00278 << "HepMC::IO_HERWIG: inconsistent mother/daugher "
00279 << "information in HEPEVT event "
00280 << HEPEVT_Wrapper::event_number()
00281 << ". \n I recommend you try "
00282 << "inspecting the event first with "
00283 << "\n\tHEPEVT_Wrapper::check_hepevt_consistency()"
00284 << "\n This warning can be turned off with the "
00285 << "IO_HERWIG::print_inconsistency_errors switch."
00286 << std::endl;
00287 hepevt_particle[mother]->print(std::cerr);
00288 std::cerr
00289 << "problem vertices are: (prod_vtx, mother)" << std::endl;
00290 if ( prod_vtx ) prod_vtx->print(std::cerr);
00291 hepevt_particle[mother]->end_vertex()->print(std::cerr);
00292 }
00293 }
00294 if ( ++mother > HEPEVT_Wrapper::last_parent(i) ) mother = 0;
00295 }
00296 }
00297
00298 void IO_HERWIG::build_end_vertex
00299 ( int i, std::vector<GenParticle*>& hepevt_particle, GenEvent* evt )
00300 {
00304
00305 GenParticle* p = hepevt_particle[i];
00306
00307 int daughter = HEPEVT_Wrapper::first_child(i);
00308 GenVertex* end_vtx = p->end_vertex();
00309 while ( !end_vtx && daughter > 0 ) {
00310 end_vtx = hepevt_particle[daughter]->production_vertex();
00311 if ( end_vtx ) end_vtx->add_particle_in( p );
00312 if ( ++daughter > HEPEVT_Wrapper::last_child(i) ) daughter = 0;
00313 }
00314
00315
00316 if ( !end_vtx && HEPEVT_Wrapper::number_children(i)>0 ) {
00317 end_vtx = new GenVertex();
00318 end_vtx->add_particle_in( p );
00319 evt->add_vertex( end_vtx );
00320 }
00321
00322
00323
00324 daughter = HEPEVT_Wrapper::first_child(i);
00325 while ( end_vtx && daughter > 0 ) {
00326 if ( !hepevt_particle[daughter]->production_vertex() ) {
00327
00328 end_vtx->add_particle_out( hepevt_particle[daughter] );
00329
00330
00331 if ( end_vtx->position()==FourVector(0,0,0,0) ) {
00332 FourVector prod_pos( HEPEVT_Wrapper::x(daughter),
00333 HEPEVT_Wrapper::y(daughter),
00334 HEPEVT_Wrapper::z(daughter),
00335 HEPEVT_Wrapper::t(daughter)
00336 );
00337 if ( prod_pos != FourVector(0,0,0,0) ) {
00338 end_vtx->set_position( prod_pos );
00339 }
00340 }
00341 } else if (hepevt_particle[daughter]->production_vertex()
00342 != end_vtx){
00343
00344
00345
00346
00347
00348 if ( m_print_inconsistency_errors ) std::cerr
00349 << "HepMC::IO_HERWIG: inconsistent mother/daugher "
00350 << "information in HEPEVT event "
00351 << HEPEVT_Wrapper::event_number()
00352 << ". \n I recommend you try "
00353 << "inspecting the event first with "
00354 << "\n\tHEPEVT_Wrapper::check_hepevt_consistency()"
00355 << "\n This warning can be turned off with the "
00356 << "IO_HERWIG::print_inconsistency_errors switch."
00357 << std::endl;
00358 }
00359 if ( ++daughter > HEPEVT_Wrapper::last_child(i) ) daughter = 0;
00360 }
00361 if ( !p->end_vertex() && !p->production_vertex() ) {
00362
00363 build_production_vertex( i, hepevt_particle, evt );
00364 }
00365 }
00366
00367 GenParticle* IO_HERWIG::build_particle( int index ) {
00369
00370 GenParticle* p
00371 = new GenParticle( FourVector( HEPEVT_Wrapper::px(index),
00372 HEPEVT_Wrapper::py(index),
00373 HEPEVT_Wrapper::pz(index),
00374 HEPEVT_Wrapper::e(index) ),
00375 HEPEVT_Wrapper::id(index),
00376 HEPEVT_Wrapper::status(index) );
00377 p->setGeneratedMass( HEPEVT_Wrapper::m(index) );
00378 p->suggest_barcode( index );
00379 return p;
00380 }
00381
00382 int IO_HERWIG::find_in_map( const std::map<GenParticle*,int>& m,
00383 GenParticle* p) const {
00384 std::map<GenParticle*,int>::const_iterator iter = m.find(p);
00385 if ( iter == m.end() ) return 0;
00386 return iter->second;
00387 }
00388
00389 void IO_HERWIG::repair_hepevt() const {
00412
00413
00414 if ( HEPEVT_Wrapper::number_entries() <= 0 ) return;
00415
00416
00417
00418
00419
00420
00421
00422 int index_collision = 0;
00423 int index_hard = 0;
00424 int index_101 = 0;
00425 int index_102 = 0;
00426 int index_121 = 0;
00427 int index_122 = 0;
00428
00429 for ( int i = 1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00430 if ( HEPEVT_Wrapper::status(i)==101 ) index_101=i;
00431 if ( HEPEVT_Wrapper::status(i)==102 ) index_102=i;
00432 if ( HEPEVT_Wrapper::status(i)==103 ) index_collision=i;
00433 if ( HEPEVT_Wrapper::status(i)==120 ) index_hard=i;
00434 if ( HEPEVT_Wrapper::status(i)==121 ) index_121=i;
00435 if ( HEPEVT_Wrapper::status(i)==122 ) index_122=i;
00436 if ( index_collision!=0 && index_hard!=0 && index_101!=0 &&
00437 index_102!=0 && index_121!=0 && index_122!=0 ) break;
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451 if (index_121) HEPEVT_Wrapper::set_parents(index_121, index_101, 0 );
00452 if (index_121) HEPEVT_Wrapper::set_children( index_121, 0, 0 );
00453 if (index_122) HEPEVT_Wrapper::set_parents(index_122, index_102, 0 );
00454 if (index_122) HEPEVT_Wrapper::set_children( index_122, 0, 0 );
00455
00456 for ( int i = HEPEVT_Wrapper::first_child(index_hard);
00457 i <= HEPEVT_Wrapper::last_child(index_hard); i++ ) {
00458
00459 if (index_hard && HEPEVT_Wrapper::id(index_hard) == 0 ) {
00460 HEPEVT_Wrapper::set_parents(
00461 i, HEPEVT_Wrapper::first_parent(index_hard),
00462 HEPEVT_Wrapper::last_parent(index_hard) );
00463 }
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473 if ( HEPEVT_Wrapper::status(i) != 195 ) {
00474 HEPEVT_Wrapper::set_children(i,HEPEVT_Wrapper::first_child(i),0);
00475 }
00476 }
00477
00478
00479
00480 if (index_hard && HEPEVT_Wrapper::id(index_hard) == 0 ) zero_hepevt_entry(index_hard);
00481 if (index_hard && HEPEVT_Wrapper::id(index_collision) == 0 ) zero_hepevt_entry(index_collision);
00482
00483
00484
00485 for ( int i=1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00486
00487
00488
00489 if ( HEPEVT_Wrapper::id(i)==94 ) {
00490 HEPEVT_Wrapper::set_id(
00491 i, HEPEVT_Wrapper::id( HEPEVT_Wrapper::first_parent(i) ) );
00492 }
00493
00494
00495
00496
00497 if ( HEPEVT_Wrapper::status(i)==100 ) zero_hepevt_entry(i);
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512 if ( HEPEVT_Wrapper::last_parent(i)==index_hard ) {
00513 HEPEVT_Wrapper::set_parents(
00514 i, HEPEVT_Wrapper::first_parent(i), 0 );
00515 }
00516
00517
00518
00519 if ( HEPEVT_Wrapper::first_parent(i) >= i ) {
00520 HEPEVT_Wrapper::set_parents( i, 0, 0 );
00521 }
00522 if ( HEPEVT_Wrapper::last_parent(i) >= i ) {
00523 HEPEVT_Wrapper::set_parents(
00524 i, HEPEVT_Wrapper::first_parent(i), 0 );
00525 }
00526
00527
00528
00529
00530 if ( HEPEVT_Wrapper::last_parent(i) <=
00531 HEPEVT_Wrapper::first_parent(i) ) {
00532 HEPEVT_Wrapper::set_parents(
00533 i, HEPEVT_Wrapper::first_parent(i), 0 );
00534 }
00535
00536 if ( HEPEVT_Wrapper::last_child(i) <=
00537 HEPEVT_Wrapper::first_child(i) ) {
00538 HEPEVT_Wrapper::set_children(
00539 i, HEPEVT_Wrapper::first_child(i), 0 );
00540 }
00541
00542
00543
00544
00545
00546 if ( HEPEVT_Wrapper::status(i) == 170 ) {
00547 HEPEVT_Wrapper::set_parents( i, 0, 0 );
00548 HEPEVT_Wrapper::set_children( i, 0, 0 );
00549 }
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569 if ( HEPEVT_Wrapper::id(i)==91 ) {
00570
00571 if ( HEPEVT_Wrapper::status(HEPEVT_Wrapper::first_parent(i))
00572 == 170 ) {
00573 ;
00574 } else {
00575 HEPEVT_Wrapper::set_parents( i, 0, 0 );
00576 }
00577 }
00578 }
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 for ( int i=1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00590
00591 int ifirst = HEPEVT_Wrapper::first_parent(i);
00592 int ilast = HEPEVT_Wrapper::last_parent(i);
00593 if ( ilast == 0 ) ilast = HEPEVT_Wrapper::first_parent(i);
00594 bool first_is_acceptable = true;
00595 bool last_is_acceptable = true;
00596
00597 if ( ifirst>=i || ifirst<0 ) first_is_acceptable = false;
00598 if ( ilast>=i || ilast<ifirst || ilast<0 )last_is_acceptable=false;
00599 if ( first_is_acceptable ) {
00600 for ( int j = ifirst; j<=ilast; j++ ) {
00601
00602 if ( HEPEVT_Wrapper::first_child(j)==i ) {;}
00603
00604 else if ( HEPEVT_Wrapper::first_child(j) <=i &&
00605 HEPEVT_Wrapper::last_child(j) >=i ) {;}
00606 else if ( HEPEVT_Wrapper::first_child(j) ==0 &&
00607 HEPEVT_Wrapper::last_child(j) ==0 ) {;}
00608
00609
00610
00611
00612
00613 else if (j==ifirst) { first_is_acceptable = false; break; }
00614 else { last_is_acceptable = false; break; }
00615 }
00616 }
00617
00618
00619
00620 if ( HEPEVT_Wrapper::id(i) == 22 && HEPEVT_Wrapper::status(i) == 1 )
00621 { first_is_acceptable = true; }
00622
00623 if ( !first_is_acceptable ) {
00624 HEPEVT_Wrapper::set_parents( i, 0, 0 );
00625 } else if ( !last_is_acceptable ) {
00626 HEPEVT_Wrapper::set_parents(i,HEPEVT_Wrapper::first_parent(i),0);
00627 }
00628 }
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638 for ( int i=1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00639
00640 int ifirst = HEPEVT_Wrapper::first_child(i);
00641 int ilast = HEPEVT_Wrapper::last_child(i);
00642 if ( ilast==0 ) ilast = HEPEVT_Wrapper::first_child(i);
00643 bool is_acceptable = true;
00644
00645 if ( ifirst<=i || ifirst<0 ) is_acceptable = false;
00646 if ( ilast<=i || ilast<ifirst || ilast<0 ) is_acceptable = false;
00647 if ( is_acceptable ) {
00648 for ( int j = ifirst; j<=ilast; j++ ) {
00649
00650 if ( HEPEVT_Wrapper::first_parent(j)==i ) {;}
00651 else if ( HEPEVT_Wrapper::first_parent(j) <=i &&
00652 HEPEVT_Wrapper::last_parent(j) >=i ) {;}
00653 else if ( HEPEVT_Wrapper::first_parent(j) ==0 &&
00654 HEPEVT_Wrapper::last_parent(j) ==0 ) {;}
00655 else { is_acceptable = false; }
00656 }
00657 }
00658
00659 if ( !is_acceptable ) HEPEVT_Wrapper::set_children( i, 0, 0 );
00660 }
00661
00662
00663
00664 for ( int i=1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00665 HEPEVT_Wrapper::set_id(
00666 i, translate_herwig_to_pdg_id(HEPEVT_Wrapper::id(i)) );
00667 }
00668
00669
00670 if ( m_no_gaps_in_barcodes ) remove_gaps_in_hepevt();
00671 }
00672
00673 void IO_HERWIG::remove_gaps_in_hepevt() const {
00679 std::vector<int> mymap(HEPEVT_Wrapper::number_entries()+1,0);
00680 int ilast = 0;
00681 for ( int i=1; i <=HEPEVT_Wrapper::number_entries(); i++ ) {
00682 if (HEPEVT_Wrapper::status(i)==0 && HEPEVT_Wrapper::id(i)==0) {
00683
00684 mymap[i]=0;
00685 } else {
00686 ilast += 1;
00687 if ( ilast != i ) {
00688 HEPEVT_Wrapper::set_status(ilast,
00689 HEPEVT_Wrapper::status(i) );
00690 HEPEVT_Wrapper::set_id(ilast, HEPEVT_Wrapper::id(i) );
00691 HEPEVT_Wrapper::set_parents(
00692 ilast,
00693 HEPEVT_Wrapper::first_parent(i),
00694 HEPEVT_Wrapper::last_parent(i) );
00695 HEPEVT_Wrapper::set_children(
00696 ilast,
00697 HEPEVT_Wrapper::first_child(i),
00698 HEPEVT_Wrapper::last_child(i) );
00699 HEPEVT_Wrapper::set_momentum(
00700 ilast,
00701 HEPEVT_Wrapper::px(i), HEPEVT_Wrapper::py(i),
00702 HEPEVT_Wrapper::pz(i), HEPEVT_Wrapper::e(i) );
00703 HEPEVT_Wrapper::set_mass(ilast, HEPEVT_Wrapper::m(i) );
00704 HEPEVT_Wrapper::set_position(
00705 ilast, HEPEVT_Wrapper::x(i),HEPEVT_Wrapper::y(i),
00706 HEPEVT_Wrapper::z(i),HEPEVT_Wrapper::t(i) );
00707 }
00708 mymap[i]=ilast;
00709 }
00710 }
00711
00712
00713
00714
00715
00716
00717 for ( int i=1; i <=ilast; i++ ) {
00718
00719 HEPEVT_Wrapper::set_parents(
00720 i,
00721 mymap[HEPEVT_Wrapper::first_parent(i)],
00722 mymap[HEPEVT_Wrapper::last_parent(i)] );
00723 HEPEVT_Wrapper::set_children(
00724 i,
00725 mymap[HEPEVT_Wrapper::first_child(i)],
00726 mymap[HEPEVT_Wrapper::last_child(i)] );
00727 }
00728
00729
00730 HEPEVT_Wrapper::set_number_entries( ilast );
00731 }
00732
00733 void IO_HERWIG::zero_hepevt_entry( int i ) const {
00734 if ( i <=0 || i > HepMC::HEPEVT_Wrapper::max_number_entries() ) return;
00735 HEPEVT_Wrapper::set_status( i, 0 );
00736 HEPEVT_Wrapper::set_id( i, 0 );
00737 HEPEVT_Wrapper::set_parents( i, 0, 0 );
00738 HEPEVT_Wrapper::set_children( i, 0, 0 );
00739 HEPEVT_Wrapper::set_momentum( i, 0, 0, 0, 0 );
00740 HEPEVT_Wrapper::set_mass( i, 0 );
00741 HEPEVT_Wrapper::set_position( i, 0, 0, 0, 0 );
00742 }
00743
00744 int IO_HERWIG::translate_herwig_to_pdg_id( int id ) const {
00747
00748
00749 int hwtran = id;
00750 int ida = abs(id);
00751 int j1 = ida%10;
00752 int i1 = (ida/10)%10;
00753 int i2 = (ida/100)%10;
00754 int i3 = (ida/1000)%10;
00755
00756
00757
00758 int ksusy = (ida/1000000)%10;
00759
00760 int kqn = (ida/1000000000)%10;
00761
00762 if ( kqn==1 ) {
00763
00764 hwtran=0;
00765 if ( m_print_inconsistency_errors ) {
00766 std::cerr << "IO_HERWIG::translate_herwig_to_pdg_id " << id
00767 << "nonallowed ion" << std::endl;
00768 }
00769 }
00770 else if (ida < 100) {
00771
00772 hwtran = m_herwig_to_pdg_id[ida];
00773 if ( id < 0 ) hwtran *= -1;
00774
00775 if ( id < 0 ) {
00776 if ( hwtran>=-99 && hwtran<=-81) hwtran=0;
00777 if ( m_no_antiparticles.count(hwtran) ) hwtran=0;
00778 }
00779 }
00780 else if ( ksusy==1 || ksusy==2 ) { ; }
00781
00782 else if ( i1!=0 && i3!=0 && j1==2 ) {;}
00783
00784 else if ( i1!=0 && i3!=0 && j1==4 ) {;}
00785
00786 else if ( i1!=0 && i2!=0 && i3==0 ) {
00787
00788
00789 if ( i1==i2 && id<0) hwtran=0;
00790 }
00791 else if ( i2!=0 && i3!=0 && i1==0 ) {;}
00792
00793 else {
00794
00795 hwtran=0;
00796 }
00797
00798
00799 if ( id==-130 || id==-310 ) hwtran=0;
00800
00801 if ( hwtran==0 && ida!=0 && m_print_inconsistency_errors ) {
00802 std::cerr
00803 << "IO_HERWIG::translate_herwig_to_pdg_id HERWIG particle "
00804 << id << " translates to zero." << std::endl;
00805 }
00806
00807 return hwtran;
00808 }
00809
00810 }
00811
00812
00813
00814