00001
00002
00003
00005
00006 #include "HepMC/GenParticle.h"
00007 #include "HepMC/GenVertex.h"
00008 #include "HepMC/GenEvent.h"
00009 #include "HepMC/SearchVector.h"
00010 #include <iomanip>
00011
00012 namespace HepMC {
00013
00014 GenVertex::GenVertex( const FourVector& position,
00015 int id, const WeightContainer& weights )
00016 : m_position(position), m_id(id), m_weights(weights), m_event(0),
00017 m_barcode(0)
00018 {}
00019
00020
00021
00022
00023 GenVertex::GenVertex( const GenVertex& invertex )
00024 : m_position( invertex.position() ),
00025 m_particles_in(),
00026 m_particles_out(),
00027 m_id( invertex.id() ),
00028 m_weights( invertex.weights() ),
00029 m_event(0),
00030 m_barcode(0)
00031 {
00043
00044 for ( particles_in_const_iterator
00045 part1 = invertex.particles_in_const_begin();
00046 part1 != invertex.particles_in_const_end(); ++part1 ) {
00047 if ( !(*part1)->production_vertex() ) {
00048 GenParticle* pin = new GenParticle(**part1);
00049 add_particle_in(pin);
00050 }
00051 }
00052 for ( particles_out_const_iterator
00053 part2 = invertex.particles_out_const_begin();
00054 part2 != invertex.particles_out_const_end(); part2++ ) {
00055 GenParticle* pin = new GenParticle(**part2);
00056 add_particle_out(pin);
00057 }
00058 suggest_barcode( invertex.barcode() );
00059
00060
00061 }
00062
00063 GenVertex::~GenVertex() {
00064
00065
00066 if ( parent_event() ) parent_event()->remove_barcode(this);
00067 delete_adopted_particles();
00068
00069 }
00070
00071 void GenVertex::swap( GenVertex & other)
00072 {
00073 m_position.swap( other.m_position );
00074 m_particles_in.swap( other.m_particles_in );
00075 m_particles_out.swap( other.m_particles_out );
00076 std::swap( m_id, other.m_id );
00077 m_weights.swap( other.m_weights );
00078 std::swap( m_event, other.m_event );
00079 std::swap( m_barcode, other.m_barcode );
00080 }
00081
00082 GenVertex& GenVertex::operator=( const GenVertex& invertex ) {
00096
00097
00098 GenVertex tmp( invertex );
00099 swap( tmp );
00100 return *this;
00101 }
00102
00103 bool GenVertex::operator==( const GenVertex& a ) const {
00109
00110 if ( a.position() != this->position() ) return false;
00111
00112 if ( a.particles_in_size() != this->particles_in_size() ) return false;
00113
00114 if ( a.particles_out_size() != this->particles_out_size() ) return false;
00115
00116
00117
00118 if ( a.particles_in_const_begin() != a.particles_in_const_end() ) {
00119 for ( GenVertex::particles_in_const_iterator
00120 ia = a.particles_in_const_begin(),
00121 ib = this->particles_in_const_begin();
00122 ia != a.particles_in_const_end(); ia++, ib++ ){
00123 if ( **ia != **ib ) return false;
00124 }
00125 }
00126
00127
00128
00129 if ( a.particles_out_const_begin() != a.particles_out_const_end() ) {
00130 for ( GenVertex::particles_out_const_iterator
00131 ia = a.particles_out_const_begin(),
00132 ib = this->particles_out_const_begin();
00133 ia != a.particles_out_const_end(); ia++, ib++ ){
00134 if ( **ia != **ib ) return false;
00135 }
00136 }
00137 return true;
00138 }
00139
00140 bool GenVertex::operator!=( const GenVertex& a ) const {
00141
00142 return !( a == *this );
00143 }
00144
00145 void GenVertex::print( std::ostream& ostr ) const {
00146 if ( barcode()!=0 ) {
00147 if ( position() != FourVector(0,0,0,0) ) {
00148 ostr << "Vertex:";
00149 ostr.width(9);
00150 ostr << barcode();
00151 ostr << " ID:";
00152 ostr.width(5);
00153 ostr << id();
00154 ostr << " (X,cT)=";
00155 ostr.width(9);
00156 ostr.precision(2);
00157 ostr.setf(std::ios::scientific, std::ios::floatfield);
00158 ostr.setf(std::ios_base::showpos);
00159 ostr << position().x() << ",";
00160 ostr.width(9);
00161 ostr.precision(2);
00162 ostr << position().y() << ",";
00163 ostr.width(9);
00164 ostr.precision(2);
00165 ostr << position().z() << ",";
00166 ostr.width(9);
00167 ostr.precision(2);
00168 ostr << position().t();
00169 ostr.setf(std::ios::fmtflags(0), std::ios::floatfield);
00170 ostr.unsetf(std::ios_base::showpos);
00171 ostr << std::endl;
00172 } else {
00173 ostr << "GenVertex:";
00174 ostr.width(9);
00175 ostr << barcode();
00176 ostr << " ID:";
00177 ostr.width(5);
00178 ostr << id();
00179 ostr << " (X,cT):0";
00180 ostr << std::endl;
00181 }
00182 } else {
00183
00184
00185
00186 if ( position() != FourVector(0,0,0,0) ) {
00187 ostr << "Vertex:";
00188 ostr.width(9);
00189 ostr << (void*)this;
00190 ostr << " ID:";
00191 ostr.width(5);
00192 ostr << id();
00193 ostr << " (X,cT)=";
00194 ostr.width(9);
00195 ostr.precision(2);
00196 ostr.setf(std::ios::scientific, std::ios::floatfield);
00197 ostr.setf(std::ios_base::showpos);
00198 ostr << position().x();
00199 ostr.width(9);
00200 ostr.precision(2);
00201 ostr << position().y();
00202 ostr.width(9);
00203 ostr.precision(2);
00204 ostr << position().z();
00205 ostr.width(9);
00206 ostr.precision(2);
00207 ostr << position().t();
00208 ostr.setf(std::ios::fmtflags(0), std::ios::floatfield);
00209 ostr.unsetf(std::ios_base::showpos);
00210 ostr << std::endl;
00211 } else {
00212 ostr << "GenVertex:";
00213 ostr.width(9);
00214 ostr << (void*)this;
00215 ostr << " ID:";
00216 ostr.width(5);
00217 ostr << id();
00218 ostr << " (X,cT):0";
00219 ostr << std::endl;
00220 }
00221 }
00222
00223
00224 if ( ! weights().empty() ) {
00225 ostr << " Wgts(" << weights().size() << ")=";
00226 for ( WeightContainer::const_iterator wgt = weights().begin();
00227 wgt != weights().end(); wgt++ ) { ostr << *wgt << " "; }
00228 ostr << std::endl;
00229 }
00230
00231 for ( particles_in_const_iterator part1 = particles_in_const_begin();
00232 part1 != particles_in_const_end(); part1++ ) {
00233 if ( part1 == particles_in_const_begin() ) {
00234 ostr << " I:";
00235 ostr.width(2);
00236 ostr << m_particles_in.size();
00237 } else { ostr << " "; }
00238
00239 ostr << **part1 << std::endl;
00240 }
00241 for ( particles_out_const_iterator part2 = particles_out_const_begin();
00242 part2 != particles_out_const_end(); part2++ ) {
00243 if ( part2 == particles_out_const_begin() ) {
00244 ostr << " O:";
00245 ostr.width(2);
00246 ostr << m_particles_out.size();
00247 } else { ostr << " "; }
00248
00249 ostr << **part2 << std::endl;
00250 }
00251 }
00252
00253 double GenVertex::check_momentum_conservation() const {
00257 double sumpx = 0, sumpy = 0, sumpz = 0;
00258 for ( particles_in_const_iterator part1 = particles_in_const_begin();
00259 part1 != particles_in_const_end(); part1++ ) {
00260 sumpx += (*part1)->momentum().px();
00261 sumpy += (*part1)->momentum().py();
00262 sumpz += (*part1)->momentum().pz();
00263 }
00264 for ( particles_out_const_iterator part2 = particles_out_const_begin();
00265 part2 != particles_out_const_end(); part2++ ) {
00266 sumpx -= (*part2)->momentum().px();
00267 sumpy -= (*part2)->momentum().py();
00268 sumpz -= (*part2)->momentum().pz();
00269 }
00270 return sqrt( sumpx*sumpx + sumpy*sumpy + sumpz*sumpz );
00271 }
00272
00273 void GenVertex::add_particle_in( GenParticle* inparticle ) {
00274 if ( !inparticle ) return;
00275
00276
00277 if ( inparticle->end_vertex() ) {
00278 inparticle->end_vertex()->remove_particle_in( inparticle );
00279 }
00280 m_particles_in.push_back( inparticle );
00281 inparticle->set_end_vertex_( this );
00282 }
00283
00284 void GenVertex::add_particle_out( GenParticle* outparticle ) {
00285 if ( !outparticle ) return;
00286
00287
00288 if ( outparticle->production_vertex() ) {
00289 outparticle->production_vertex()->remove_particle_out( outparticle );
00290 }
00291 m_particles_out.push_back( outparticle );
00292 outparticle->set_production_vertex_( this );
00293 }
00294
00295 GenParticle* GenVertex::remove_particle( GenParticle* particle ) {
00305 if ( !particle ) return 0;
00306 if ( particle->end_vertex() == this ) {
00307 particle->set_end_vertex_( 0 );
00308 remove_particle_in(particle);
00309 }
00310 if ( particle->production_vertex() == this ) {
00311 particle->set_production_vertex_(0);
00312 remove_particle_out(particle);
00313 }
00314 return particle;
00315 }
00316
00317 void GenVertex::remove_particle_in( GenParticle* particle ) {
00319 if ( !particle ) return;
00320 m_particles_in.erase( already_in_vector( &m_particles_in, particle ) );
00321 }
00322
00323 void GenVertex::remove_particle_out( GenParticle* particle ) {
00325 if ( !particle ) return;
00326 m_particles_out.erase( already_in_vector( &m_particles_out, particle ) );
00327 }
00328
00329 void GenVertex::delete_adopted_particles() {
00332
00333 if ( m_particles_out.empty() && m_particles_in.empty() ) return;
00334
00335
00336
00337 for ( std::vector<GenParticle*>::iterator part1 = m_particles_out.begin();
00338 part1 != m_particles_out.end(); ) {
00339 if ( !(*part1)->end_vertex() ) {
00340 delete *(part1++);
00341 } else {
00342 (*part1)->set_production_vertex_(0);
00343 ++part1;
00344 }
00345 }
00346 m_particles_out.clear();
00347
00348
00349
00350
00351 for ( std::vector<GenParticle*>::iterator part2 = m_particles_in.begin();
00352 part2 != m_particles_in.end(); ) {
00353 if ( !(*part2)->production_vertex() ) {
00354 delete *(part2++);
00355 } else {
00356 (*part2)->set_end_vertex_(0);
00357 ++part2;
00358 }
00359 }
00360 m_particles_in.clear();
00361 }
00362
00363 bool GenVertex::suggest_barcode( int the_bar_code )
00364 {
00374 if ( the_bar_code >0 ) {
00375 std::cerr << "GenVertex::suggest_barcode WARNING, vertex bar codes"
00376 << "\n MUST be negative integers. Positive integers "
00377 << "\n are reserved for particles only. Your suggestion "
00378 << "\n has been rejected." << std::endl;
00379 return false;
00380 }
00381 bool success = false;
00382 if ( parent_event() ) {
00383 success = parent_event()->set_barcode( this, the_bar_code );
00384 } else { set_barcode_( the_bar_code ); }
00385 return success;
00386 }
00387
00388 void GenVertex::set_parent_event_( GenEvent* new_evt )
00389 {
00390 GenEvent* orig_evt = m_event;
00391 m_event = new_evt;
00392
00393
00394
00395
00396 if ( orig_evt != new_evt ) {
00397 if (new_evt) new_evt->set_barcode( this, barcode() );
00398 if (orig_evt) orig_evt->remove_barcode( this );
00399
00400
00401 for ( particles_in_const_iterator part1=particles_in_const_begin();
00402 part1 != particles_in_const_end(); part1++ ) {
00403 if ( !(*part1)->production_vertex() ) {
00404 if ( orig_evt ) orig_evt->remove_barcode( *part1 );
00405 if ( new_evt ) new_evt->set_barcode( *part1,
00406 (*part1)->barcode() );
00407 }
00408 }
00409 for ( particles_out_const_iterator
00410 part2 = particles_out_const_begin();
00411 part2 != particles_out_const_end(); part2++ ) {
00412 if ( orig_evt ) orig_evt->remove_barcode( *part2 );
00413 if ( new_evt ) new_evt->set_barcode( *part2,
00414 (*part2)->barcode() );
00415 }
00416 }
00417 }
00418
00419 void GenVertex::change_parent_event_( GenEvent* new_evt )
00420 {
00421
00422
00423
00424
00425
00426 m_event = new_evt;
00427 }
00428
00430
00432
00433
00434
00436
00438
00440 std::ostream& operator<<( std::ostream& ostr, const GenVertex& vtx ) {
00441 if ( vtx.barcode()!=0 ) ostr << "BarCode " << vtx.barcode();
00442 else ostr << "Address " << &vtx;
00443 ostr << " (X,cT)=";
00444 if ( vtx.position() != FourVector(0,0,0,0)) {
00445 ostr << vtx.position().x() << ","
00446 << vtx.position().y() << ","
00447 << vtx.position().z() << ","
00448 << vtx.position().t();
00449 } else { ostr << 0; }
00450 ostr << " #in:" << vtx.particles_in_size()
00451 << " #out:" << vtx.particles_out_size();
00452 return ostr;
00453 }
00454
00456
00458
00459
00460
00461
00462 GenVertex::edge_iterator::edge_iterator() : m_vertex(0), m_range(family),
00463 m_is_inparticle_iter(false), m_is_past_end(true)
00464 {}
00465
00466 GenVertex::edge_iterator::edge_iterator( const GenVertex& vtx,
00467 IteratorRange range ) :
00468 m_vertex(&vtx), m_range(family)
00469 {
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482 if ( range == descendants || range == children ) m_range = children;
00483 if ( range == ancestors || range == parents ) m_range = parents;
00484
00485 if ( m_vertex->m_particles_in.empty() &&
00486 m_vertex->m_particles_out.empty() ) {
00487
00488 m_is_inparticle_iter = false;
00489 m_is_past_end = true;
00490 } else if ( m_range == parents && m_vertex->m_particles_in.empty() ){
00491
00492 m_is_inparticle_iter = true;
00493 m_is_past_end = true;
00494 } else if ( m_range == children && m_vertex->m_particles_out.empty() ){
00495
00496 m_is_inparticle_iter = false;
00497 m_is_past_end = true;
00498 } else if ( m_range == children ) {
00499
00500 m_set_iter = m_vertex->m_particles_out.begin();
00501 m_is_inparticle_iter = false;
00502 m_is_past_end = false;
00503 } else if ( m_range == family && m_vertex->m_particles_in.empty() ) {
00504
00505
00506 m_set_iter = m_vertex->m_particles_out.begin();
00507 m_is_inparticle_iter = false;
00508 m_is_past_end = false;
00509 } else {
00510
00511 m_set_iter = m_vertex->m_particles_in.begin();
00512 m_is_inparticle_iter = true;
00513 m_is_past_end = false;
00514 }
00515 }
00516
00517 GenVertex::edge_iterator::edge_iterator( const edge_iterator& p ) {
00518 *this = p;
00519 }
00520
00521 GenVertex::edge_iterator::~edge_iterator() {}
00522
00523 GenVertex::edge_iterator& GenVertex::edge_iterator::operator=(
00524 const edge_iterator& p ) {
00525 m_vertex = p.m_vertex;
00526 m_range = p.m_range;
00527 m_set_iter = p.m_set_iter;
00528 m_is_inparticle_iter = p.m_is_inparticle_iter;
00529 m_is_past_end = p.m_is_past_end;
00530 return *this;
00531 }
00532
00533 GenParticle* GenVertex::edge_iterator::operator*(void) const {
00534 if ( !m_vertex || m_is_past_end ) return 0;
00535 return *m_set_iter;
00536 }
00537
00538 GenVertex::edge_iterator& GenVertex::edge_iterator::operator++(void){
00539
00540
00541
00542 if ( m_is_past_end ) return *this;
00543 ++m_set_iter;
00544
00545 if ( m_range == family && m_is_inparticle_iter &&
00546 m_set_iter == m_vertex->m_particles_in.end() ) {
00547
00548
00549 m_set_iter = m_vertex->m_particles_out.begin();
00550 m_is_inparticle_iter = false;
00551 } else if ( m_range == parents &&
00552 m_set_iter == m_vertex->m_particles_in.end() ) {
00553
00554
00555 m_is_past_end = true;
00556
00557 return *this;
00558 }
00559
00560 if( m_is_inparticle_iter ) {
00561
00562
00563 if ( m_set_iter == m_vertex->m_particles_in.end() ) {
00564
00565 m_is_past_end = true;
00566 }
00567 } else {
00568
00569
00570 if ( m_set_iter == m_vertex->m_particles_out.end() ) {
00571
00572 m_is_past_end = true;
00573 }
00574 }
00575 return *this;
00576 }
00577
00578 GenVertex::edge_iterator GenVertex::edge_iterator::operator++(int){
00579
00580 edge_iterator returnvalue = *this;
00581 ++*this;
00582 return returnvalue;
00583 }
00584
00585 bool GenVertex::edge_iterator::is_parent() const {
00586 if ( **this && (**this)->end_vertex() == m_vertex ) return true;
00587 return false;
00588 }
00589
00590 bool GenVertex::edge_iterator::is_child() const {
00591 if ( **this && (**this)->production_vertex() == m_vertex ) return true;
00592 return false;
00593 }
00594
00595 int GenVertex::edges_size( IteratorRange range ) const {
00596 if ( range == children ) return m_particles_out.size();
00597 if ( range == parents ) return m_particles_in.size();
00598 if ( range == family ) return m_particles_out.size()
00599 + m_particles_in.size();
00600 return 0;
00601 }
00602
00604
00606
00607 GenVertex::vertex_iterator::vertex_iterator()
00608 : m_vertex(0), m_range(), m_visited_vertices(0), m_it_owns_set(0),
00609 m_recursive_iterator(0)
00610 {}
00611
00612 GenVertex::vertex_iterator::vertex_iterator( GenVertex& vtx_root,
00613 IteratorRange range )
00614 : m_vertex(&vtx_root), m_range(range)
00615 {
00616
00617
00618 m_visited_vertices = new std::set<const GenVertex*>;
00619 m_it_owns_set = 1;
00620 m_visited_vertices->insert( m_vertex );
00621 m_recursive_iterator = 0;
00622 m_edge = m_vertex->edges_begin( m_range );
00623
00624 if ( !follow_edge_() &&
00625 m_edge != m_vertex->edges_end( m_range )) ++*this;
00626 }
00627
00628 GenVertex::vertex_iterator::vertex_iterator( GenVertex& vtx_root,
00629 IteratorRange range, std::set<const HepMC::GenVertex*>& visited_vertices ) :
00630 m_vertex(&vtx_root), m_range(range),
00631 m_visited_vertices(&visited_vertices), m_it_owns_set(0),
00632 m_recursive_iterator(0)
00633 {
00634
00635
00636
00637
00638
00639 m_edge = m_vertex->edges_begin( m_range );
00640
00641 if ( !follow_edge_() &&
00642 m_edge != m_vertex->edges_end( m_range )) ++*this;
00643 }
00644
00645 GenVertex::vertex_iterator::vertex_iterator( const vertex_iterator& v_iter)
00646 : m_vertex(0), m_visited_vertices(0), m_it_owns_set(0),
00647 m_recursive_iterator(0)
00648 {
00649 *this = v_iter;
00650 }
00651
00652 GenVertex::vertex_iterator::~vertex_iterator() {
00653 if ( m_recursive_iterator ) delete m_recursive_iterator;
00654 if ( m_it_owns_set ) delete m_visited_vertices;
00655 }
00656
00657 GenVertex::vertex_iterator& GenVertex::vertex_iterator::operator=(
00658 const vertex_iterator& v_iter )
00659 {
00660
00661
00662
00663
00664
00665
00666
00667 if ( m_recursive_iterator ) delete m_recursive_iterator;
00668 m_recursive_iterator = 0;
00669 if ( m_it_owns_set ) delete m_visited_vertices;
00670 m_visited_vertices = 0;
00671 m_it_owns_set = 0;
00672
00673 m_vertex = v_iter.m_vertex;
00674 m_range = v_iter.m_range;
00675 if ( v_iter.m_it_owns_set ) {
00676
00677
00678 m_visited_vertices =
00679 new std::set<const GenVertex*>(*v_iter.m_visited_vertices);
00680 m_it_owns_set = 1;
00681 } else {
00682 m_visited_vertices = v_iter.m_visited_vertices;
00683 m_it_owns_set = 0;
00684 }
00685
00686
00687
00688
00689 m_edge = v_iter.m_edge;
00690 copy_recursive_iterator_( v_iter.m_recursive_iterator );
00691 return *this;
00692 }
00693
00694 GenVertex* GenVertex::vertex_iterator::operator*(void) const {
00695
00696
00697
00698
00699 if ( m_recursive_iterator ) return **m_recursive_iterator;
00700
00701
00702
00703
00704
00705 if ( m_vertex ) return m_vertex;
00706 return 0;
00707 }
00708
00709 GenVertex::vertex_iterator& GenVertex::vertex_iterator::operator++(void) {
00710
00711
00712
00713 if ( !m_vertex ) return *this;
00714
00715 if ( m_edge == m_vertex->edges_end( m_range ) ) {
00716 m_vertex = 0;
00717 return *this;
00718 }
00719
00720
00721
00722 if ( follow_edge_() ) {
00723 return *this;
00724 }
00725
00726
00727
00728
00729
00730
00731 if ( m_recursive_iterator ) {
00732 ++(*m_recursive_iterator);
00733 if ( **m_recursive_iterator ) {
00734 return *this;
00735 } else {
00736 delete m_recursive_iterator;
00737 m_recursive_iterator = 0;
00738 }
00739 }
00740
00741
00742 ++m_edge;
00743
00744
00745
00746 if ( m_edge == m_vertex->edges_end( m_range ) ) return *this;
00747
00748 return ++(*this);
00749 }
00750
00751 GenVertex::vertex_iterator GenVertex::vertex_iterator::operator++(int) {
00752
00753 vertex_iterator returnvalue(*this);
00754 ++(*this);
00755 return returnvalue;
00756 }
00757
00758 void GenVertex::vertex_iterator::copy_with_own_set(
00759 const vertex_iterator& v_iter,
00760 std::set<const HepMC::GenVertex*>& visited_vertices ) {
00765
00766
00767 if ( m_recursive_iterator ) delete m_recursive_iterator;
00768 m_recursive_iterator = 0;
00769 if ( m_it_owns_set ) delete m_visited_vertices;
00770 m_visited_vertices = 0;
00771 m_it_owns_set = false;
00772
00773 m_vertex = v_iter.m_vertex;
00774 m_range = v_iter.m_range;
00775 m_visited_vertices = &visited_vertices;
00776 m_it_owns_set = false;
00777 m_edge = v_iter.m_edge;
00778 copy_recursive_iterator_( v_iter.m_recursive_iterator );
00779 }
00780
00781 GenVertex* GenVertex::vertex_iterator::follow_edge_() {
00782
00783
00784
00785
00786
00787
00788
00789 if ( m_recursive_iterator || !m_vertex || !*m_edge ) return 0;
00790
00791
00792
00793
00794
00795 if ( m_range <= family && m_it_owns_set == 0 ) return 0;
00796
00797
00798
00799
00800 if ( (*m_edge)->production_vertex() ==
00801 (*m_edge)->end_vertex() ) return 0;
00802
00803
00804 GenVertex* vtx = ( m_edge.is_parent() ?
00805 (*m_edge)->production_vertex() :
00806 (*m_edge)->end_vertex() );
00807
00808
00809 if ( !vtx || !(m_visited_vertices->insert(vtx).second) ) return 0;
00810
00811 m_recursive_iterator = new vertex_iterator( *vtx, m_range,
00812 *m_visited_vertices);
00813
00814 return **m_recursive_iterator;
00815 }
00816
00817 void GenVertex::vertex_iterator::copy_recursive_iterator_(
00818 const vertex_iterator* recursive_v_iter ) {
00819
00820
00821
00822
00823 if ( !recursive_v_iter ) return;
00824 m_recursive_iterator = new vertex_iterator();
00825 m_recursive_iterator->m_vertex = recursive_v_iter->m_vertex;
00826 m_recursive_iterator->m_range = recursive_v_iter->m_range;
00827 m_recursive_iterator->m_visited_vertices = m_visited_vertices;
00828 m_recursive_iterator->m_it_owns_set = 0;
00829 m_recursive_iterator->m_edge = recursive_v_iter->m_edge;
00830 m_recursive_iterator->copy_recursive_iterator_(
00831 recursive_v_iter->m_recursive_iterator );
00832 }
00833
00835
00837
00838 GenVertex::particle_iterator::particle_iterator() {}
00839
00840 GenVertex::particle_iterator::particle_iterator( GenVertex& vertex_root,
00841 IteratorRange range ) {
00842
00843
00844 if ( range <= family ) {
00845 m_edge = GenVertex::edge_iterator( vertex_root, range );
00846 } else {
00847 m_vertex_iterator = GenVertex::vertex_iterator(vertex_root, range);
00848 m_edge = GenVertex::edge_iterator( **m_vertex_iterator,
00849 m_vertex_iterator.range() );
00850 }
00851 advance_to_first_();
00852 }
00853
00854 GenVertex::particle_iterator::particle_iterator(
00855 const particle_iterator& p_iter ){
00856 *this = p_iter;
00857 }
00858
00859 GenVertex::particle_iterator::~particle_iterator() {}
00860
00861 GenVertex::particle_iterator&
00862 GenVertex::particle_iterator::operator=( const particle_iterator& p_iter )
00863 {
00864 m_vertex_iterator = p_iter.m_vertex_iterator;
00865 m_edge = p_iter.m_edge;
00866 return *this;
00867 }
00868
00869 GenParticle* GenVertex::particle_iterator::operator*(void) const {
00870 return *m_edge;
00871 }
00872
00873 GenVertex::particle_iterator&
00874 GenVertex::particle_iterator::operator++(void) {
00875
00876
00877 if ( *m_edge ) {
00878 ++m_edge;
00879 } else if ( *m_vertex_iterator ) {
00880
00881
00882 if ( !*(++m_vertex_iterator) ) return *this;
00883 m_edge = GenVertex::edge_iterator( **m_vertex_iterator,
00884 m_vertex_iterator.range() );
00885 } else {
00886
00887 return *this;
00888 }
00889 advance_to_first_();
00890 return *this;
00891 }
00892
00893 GenVertex::particle_iterator GenVertex::particle_iterator::operator++(int){
00894
00895 particle_iterator returnvalue(*this);
00896 ++(*this);
00897 return returnvalue;
00898 }
00899
00900 GenParticle* GenVertex::particle_iterator::advance_to_first_() {
00904 if ( !*m_edge ) return *(++*this);
00905
00906
00907
00908 if ( m_vertex_iterator.range() == relatives &&
00909 m_edge.is_parent() &&
00910 (*m_edge)->production_vertex() ) return *(++*this);
00911 return *m_edge;
00912 }
00913
00918 void GenVertex::convert_position( const double& f ) {
00919 m_position = FourVector( f*m_position.x(),
00920 f*m_position.y(),
00921 f*m_position.z(),
00922 f*m_position.t() );
00923 }
00924
00925 }