| /branches/HEPMC_02_03_branch/test/testHepMCIteration.dat |
| @@ -4,10 +4,12 @@ |
| GenParticle: 9 ID:22 (P,E)=-35.8473,-6.12284,-383.843,385.562 Stat:1 PV:-6 EV:0 Pol:(0,0) F:0 |
| A W boson has been found in event: 9 |
| GenParticle: 8 ID:-24 (P,E)=36.3222,9.30234,-331.044,343.109 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 5 ID:-2 (P,E)=0.216419,2.15858,6.72107,7.06251 Stat:3 PV:-3 EV:-5 Pol:(0,0) F:0 |
| GenParticle: 6 ID:1 (P,E)=0.258424,1.02092,-721.608,721.609 Stat:3 PV:-4 EV:-5 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) -24 10 2 |
| Its descendants are: |
| GenParticle: 348 ID:-211 (P,E)=6.93515,-9.95716,-54.4707,55.8061 Stat:1 PV:-23 EV:0 Pol:(0,0) F:0 |
| GenParticle: 349 ID:211 (P,E)=1.18151,-1.97831,-11.941,12.1621 Stat:1 PV:-23 EV:0 Pol:(0,0) F:0 |
| GenParticle: 681 ID:22 (P,E)=0.752791,-0.806798,-4.68143,4.80972 Stat:1 PV:-182 EV:0 Pol:(0,0) F:0 |
| @@ -77,9 +79,16 @@ |
| GenParticle: 10 ID:-24 (P,E)=36.3222,9.30234,-331.044,343.109 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| A W boson has been found in event: 9 |
| GenParticle: 10 ID:-24 (P,E)=36.3222,9.30234,-331.044,343.109 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 8 ID:-24 (P,E)=36.3222,9.30234,-331.044,343.109 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) 3 13 2 |
| (id,barcode,status) 21 14 2 |
| (id,barcode,status) 21 15 2 |
| (id,barcode,status) 21 16 2 |
| (id,barcode,status) 21 17 2 |
| (id,barcode,status) -4 18 2 |
| Its descendants are: |
| GenParticle: 348 ID:-211 (P,E)=6.93515,-9.95716,-54.4707,55.8061 Stat:1 PV:-23 EV:0 Pol:(0,0) F:0 |
| GenParticle: 349 ID:211 (P,E)=1.18151,-1.97831,-11.941,12.1621 Stat:1 PV:-23 EV:0 Pol:(0,0) F:0 |
| GenParticle: 681 ID:22 (P,E)=0.752791,-0.806798,-4.68143,4.80972 Stat:1 PV:-182 EV:0 Pol:(0,0) F:0 |
| @@ -152,10 +161,12 @@ |
| GenParticle: 9 ID:22 (P,E)=23.7859,34.5098,42.0174,59.3478 Stat:1 PV:-6 EV:0 Pol:(0,0) F:0 |
| A W boson has been found in event: 18 |
| GenParticle: 8 ID:24 (P,E)=-22.4676,-32.3496,651.024,657.947 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 5 ID:2 (P,E)=-0.3102,4.06731,705.033,705.044 Stat:3 PV:-3 EV:-5 Pol:(0,0) F:0 |
| GenParticle: 6 ID:-1 (P,E)=1.62851,-1.90715,-11.9913,12.2508 Stat:3 PV:-4 EV:-5 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) 24 10 2 |
| Its descendants are: |
| GenParticle: 524 ID:22 (P,E)=0.289314,0.55118,8.87858,8.90038 Stat:1 PV:-142 EV:0 Pol:(0,0) F:0 |
| GenParticle: 525 ID:22 (P,E)=1.08563,2.28815,32.6894,32.7874 Stat:1 PV:-142 EV:0 Pol:(0,0) F:0 |
| GenParticle: 283 ID:211 (P,E)=5.69759,11.3309,150.218,150.753 Stat:1 PV:-30 EV:0 Pol:(0,0) F:0 |
| @@ -167,9 +178,12 @@ |
| GenParticle: 10 ID:24 (P,E)=-22.4676,-32.3496,651.024,657.947 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| A W boson has been found in event: 18 |
| GenParticle: 10 ID:24 (P,E)=-22.4676,-32.3496,651.024,657.947 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 8 ID:24 (P,E)=-22.4676,-32.3496,651.024,657.947 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) -15 11 2 |
| (id,barcode,status) 16 12 1 |
| Its descendants are: |
| GenParticle: 524 ID:22 (P,E)=0.289314,0.55118,8.87858,8.90038 Stat:1 PV:-142 EV:0 Pol:(0,0) F:0 |
| GenParticle: 525 ID:22 (P,E)=1.08563,2.28815,32.6894,32.7874 Stat:1 PV:-142 EV:0 Pol:(0,0) F:0 |
| GenParticle: 283 ID:211 (P,E)=5.69759,11.3309,150.218,150.753 Stat:1 PV:-30 EV:0 Pol:(0,0) F:0 |
| @@ -184,17 +198,22 @@ |
| GenParticle: 9 ID:22 (P,E)=7.92316,-57.3898,-530.978,534.129 Stat:1 PV:-6 EV:0 Pol:(0,0) F:0 |
| A W boson has been found in event: 56 |
| GenParticle: 8 ID:-24 (P,E)=3.24583,59.0393,-1247.75,1252.04 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 5 ID:-2 (P,E)=10.0036,-1.02577,-3.08057,10.5173 Stat:3 PV:-3 EV:-5 Pol:(0,0) F:0 |
| GenParticle: 6 ID:1 (P,E)=1.16537,2.67523,-1775.65,1775.65 Stat:3 PV:-4 EV:-5 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) -24 10 2 |
| Its descendants are: |
| GenParticle: 11 ID:11 (P,E)=38.8894,9.95748,-643.488,644.739 Stat:1 PV:-8 EV:0 Pol:(0,0) F:0 |
| GenParticle: 12 ID:-12 (P,E)=-35.6436,49.0818,-604.26,607.297 Stat:1 PV:-8 EV:0 Pol:(0,0) F:0 |
| GenParticle: 10 ID:-24 (P,E)=3.24583,59.0393,-1247.75,1252.04 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| A W boson has been found in event: 56 |
| GenParticle: 10 ID:-24 (P,E)=3.24583,59.0393,-1247.75,1252.04 Stat:2 PV:-7 EV:-8 Pol:(0,0) F:0 |
| Its parents are: |
| Its parents are: |
| GenParticle: 8 ID:-24 (P,E)=3.24583,59.0393,-1247.75,1252.04 Stat:3 PV:-5 EV:-7 Pol:(0,0) F:0 |
| Its descendants are: |
| Its children are: |
| (id,barcode,status) 11 11 1 |
| (id,barcode,status) -12 12 1 |
| Its descendants are: |
| GenParticle: 11 ID:11 (P,E)=38.8894,9.95748,-643.488,644.739 Stat:1 PV:-8 EV:0 Pol:(0,0) F:0 |
| GenParticle: 12 ID:-12 (P,E)=-35.6436,49.0818,-604.26,607.297 Stat:1 PV:-8 EV:0 Pol:(0,0) F:0 |
| /branches/HEPMC_02_03_branch/test/testHepMCIteration.cc.in |
| @@ -106,50 +106,67 @@ |
| bool findW( HepMC::GenEvent* evt, std::ofstream& os ) |
| { |
| int num_W=0; |
| // use GenEvent::particle_iterator to find all W's in the event, |
| // then |
| // (1) for each W user the GenVertex::particle_iterator with a range of |
| // parents to return and print the immediate mothers of these W's. |
| // (2) for each W user the GenVertex::particle_iterator with a range of |
| // descendants to return and print all descendants of these W's. |
| for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); |
| p != evt->particles_end(); ++p ) { |
| if ( IsWBoson(*p) ) { |
| ++num_W; |
| os << "A W boson has been found in event: " << evt->event_number() << std::endl; |
| (*p)->print( os ); |
| // return all parents |
| // we do this by pointing to the production vertex of the W |
| // particle and asking for all particle parents of that vertex |
| os << "\t Its parents are: " << std::endl; |
| if ( (*p)->production_vertex() ) { |
| for ( HepMC::GenVertex::particle_iterator mother |
| = (*p)->production_vertex()-> |
| particles_begin(HepMC::parents); |
| mother != (*p)->production_vertex()-> |
| particles_end(HepMC::parents); |
| ++mother ) { |
| os << "\t"; |
| (*mother)->print( os ); |
| } |
| // use GenEvent::particle_iterator to find all W's in the event, |
| // then |
| // (1) for each W user the GenVertex::particle_iterator with a range of |
| // parents to return and print the immediate mothers of these W's. |
| // (2) for each W user the GenVertex::particle_iterator with a range of |
| // descendants to return and print all descendants of these W's. |
| for ( HepMC::GenEvent::particle_iterator p = evt->particles_begin(); |
| p != evt->particles_end(); ++p ) { |
| if ( IsWBoson(*p) ) { |
| ++num_W; |
| os << "A W boson has been found in event: " << evt->event_number() << std::endl; |
| (*p)->print( os ); |
| // return all parents |
| // we do this by pointing to the production vertex of the W |
| // particle and asking for all particle parents of that vertex |
| os << "\t" << "Its parents are: " << std::endl; |
| if ( (*p)->production_vertex() ) { |
| for ( HepMC::GenVertex::particle_iterator mother |
| = (*p)->production_vertex()-> |
| particles_begin(HepMC::parents); |
| mother != (*p)->production_vertex()-> |
| particles_end(HepMC::parents); |
| ++mother ) { |
| os << "\t"; |
| (*mother)->print( os ); |
| } |
| // return all descendants |
| // we do this by pointing to the end vertex of the W |
| // particle and asking for all particle descendants of that vertex |
| os << "\t\t Its descendants are: " << std::endl; |
| if ( (*p)->end_vertex() ) { |
| for ( HepMC::GenVertex::particle_iterator des |
| =(*p)->end_vertex()-> |
| particles_begin(HepMC::descendants); |
| des != (*p)->end_vertex()-> |
| particles_end(HepMC::descendants); |
| ++des ) { |
| os << "\t\t"; |
| (*des)->print( os ); |
| } |
| } |
| |
| // return immediate children |
| os << "\t\t" << "Its children are: " << std::endl; |
| if ( (*p)->end_vertex() ) { |
| for ( HepMC::GenVertex::particle_iterator child = |
| (*p)->end_vertex()->particles_begin(HepMC::children); |
| child != (*p)->end_vertex()->particles_end(HepMC::children); |
| ++child ) { |
| // make a copy |
| HepMC::GenVertex::particle_iterator cp = child; |
| // use the copy and the original |
| os << "\t\t\t (id,barcode,status) " |
| << (*cp)->pdg_id() << " " |
| << (*child)->barcode() << " " |
| << (*cp)->status() << std::endl; |
| } |
| } |
| } |
| return true; |
| |
| // return all descendants |
| // we do this by pointing to the end vertex of the W |
| // particle and asking for all particle descendants of that vertex |
| os << "\t\t" << "Its descendants are: " << std::endl; |
| if ( (*p)->end_vertex() ) { |
| for ( HepMC::GenVertex::particle_iterator des |
| =(*p)->end_vertex()-> |
| particles_begin(HepMC::descendants); |
| des != (*p)->end_vertex()-> |
| particles_end(HepMC::descendants); |
| ++des ) { |
| os << "\t\t"; |
| (*des)->print( os ); |
| } |
| } |
| } // if IsWBoson |
| } // end particle loop |
| return true; |
| } |
| |