![]() |
HepMC Reference DocumentationHepMC |
00001 //-------------------------------------------------------------------------- 00002 #ifndef HEPMC_GEN_EVENT_H 00003 #define HEPMC_GEN_EVENT_H 00004 00006 // Matt.Dobbs@Cern.CH, September 1999, refer to: 00007 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for 00008 // High Energy Physics", Computer Physics Communications (to be published). 00009 // 00010 // Event record for MC generators (for use at any stage of generation) 00012 // 00013 // This class is intended as both a "container class" ( to store a MC 00014 // event for interface between MC generators and detector simulation ) 00015 // and also as a "work in progress class" ( that could be used inside 00016 // a generator and modified as the event is built ). 00017 // 00018 // Iterators are provided which allow the user to easily obtain a 00019 // list of particles or vertices in an event --- this list can be filled 00020 // subject to some sort of selection criteria. Examples are given below 00021 // ( see HepMC::copy_if and std::copy ) 00022 00027 namespace HepMC { 00028 00029 // To create a list from an iterator, use: (i.e. for a list of particles); 00030 // #include <algorithm> 00031 // list<GenParticle*> thelist; 00032 // copy( evt->particles_begin(), evt->particles_end(), 00033 // back_inserter(thelist) ); 00034 // to create a list subject to a condition (predicate) use: 00035 // list<GenParticle*> thelist; 00036 // HepMC::copy_if( evt->particles_begin(), evt->particles_end(), 00037 // back_inserter(thelist), is_photon() ); 00038 // where is_photon() is a predicate like: 00039 // class is_photon { 00040 // public: 00041 // bool operator() ( GenParticle const * p ) { 00042 // if ( p && p->pdg_id() == 22 ) return true; 00043 // return false; 00044 // } 00045 // }; 00046 // which the user defines herself. 00047 00049 template <class InputIterator, class OutputIterator, class Predicate> 00050 void copy_if( InputIterator first, InputIterator last, OutputIterator out, 00051 Predicate pred ) { 00052 for ( ; first != last; ++first ) { if ( pred(*first) ) out = *first; } 00053 } 00054 } // HepMC 00055 00056 // Since a container of all vertices in the event is maintained, the time 00057 // required to loop over all vertices (or particles) is very fast -- and 00058 // the user does not gain much by first making his own list. 00059 // (this is not true for the GenVertex:: versions of these iterators, which 00060 // allow you to specify the vertex starting point and range) 00061 00062 // Data Members: 00063 // signal_process_id() The integer ID that uniquely specifies this signal 00064 // process, i.e. MSUB in Pythia. It is necessary to 00065 // package this with each event rather than with the run 00066 // because many processes may be generated within one 00067 // run. 00068 // event_number() Strictly speaking we cannot think of any reason that 00069 // an event would need to know its own event number, it 00070 // is more likely something that would be assigned by 00071 // a database. It is included anyway (tradition?) since 00072 // we expect it may be useful for debugging. It can 00073 // be reset later by a database. 00074 // mpi() The number of multi parton interactions in the event. 00075 // This is NOT beam pileup. Set to -1 by default. 00076 // beam_particles() A pair of pointers to the incoming beam particles. 00077 // signal_process_vertex() pointer to the vertex containing the signal process 00078 // weights() Vector of doubles which specify th weight of the evnt, 00079 // the first entry will be the "event weight" used for 00080 // hit and miss etc., but a general vector is used to 00081 // allow for reweighting etc. We envision a list of 00082 // WeightTags to be included with a run class which 00083 // would specify the meaning of the Weights . 00084 // random_states() Vector of integers which specify the random number 00085 // generator's state for this event. It is left to the 00086 // generator to make use of this. We envision a vector of 00087 // RndmStatesTags to be included with a run class which 00088 // would specify the meaning of the random_states. 00089 // 00091 // Memory allocation // 00093 // -When a vertex (particle) is added to a event (vertex), it is "adopted" 00094 // and becomes the responsibility of the event (vertex) to delete that 00095 // particle. 00096 // -objects responsible for deleting memory: 00097 // -events delete included vertices 00098 // -each vertex deletes its outgoing particles which do not have decay 00099 // vertices 00100 // -each vertex deletes its incoming particles which do not 00101 // have creation vertices 00102 // 00104 // About the Barcodes // 00106 // - each vertex or particle has a barcode, which is just an integer which 00107 // uniquely identifies it inside the event (i.e. there is a one to one 00108 // mapping between particle memory addresses and particle barcodes... and 00109 // the same applied for vertices) 00110 // - The value of a barcode has NO MEANING and NO ORDER! 00111 // For the user's convenience, when an event is read in via an IO_method 00112 // from an indexed list (like the HEPEVT common block), then the index will 00113 // become the barcode for that particle. 00114 // - particle barcodes are always positive integers 00115 // vertex barcodes are always negative integers 00116 // The barcodes are chosen and set automatically when a vertex or particle 00117 // comes under the ownership of an event (i.e. it is contained in an event). 00118 // - You can tell when a particle or vertex is owned, because its 00119 // parent_event() return value will return a pointer to the event which owns 00120 // it (or null if its an orphan). 00121 // - Please note that the barcodes are intended for internal use within HepMC 00122 // as a unique identifier for the particles and vertices. 00123 // Using the barcode to encode extra information is an abuse of 00124 // the barcode data member and causes confusion among users. 00125 // 00126 00127 #include "HepMC/GenVertex.h" 00128 #include "HepMC/GenParticle.h" 00129 #include "HepMC/WeightContainer.h" 00130 #include "HepMC/GenCrossSection.h" 00131 #include "HepMC/HeavyIon.h" 00132 #include "HepMC/PdfInfo.h" 00133 #include "HepMC/Units.h" 00134 #include "HepMC/HepMCDefs.h" 00135 #include <map> 00136 #include <string> 00137 #include <vector> 00138 #include <algorithm> 00139 #include <iostream> 00140 00141 namespace HepMC { 00142 00144 00150 class GenEvent { 00151 friend class GenParticle; 00152 friend class GenVertex; 00153 public: 00155 GenEvent( int signal_process_id = 0, int event_number = 0, 00156 GenVertex* signal_vertex = 0, 00157 const WeightContainer& weights = std::vector<double>(), 00158 const std::vector<long>& randomstates = std::vector<long>(), 00159 Units::MomentumUnit = Units::default_momentum_unit(), 00160 Units::LengthUnit = Units::default_length_unit() ); 00162 GenEvent( int signal_process_id, int event_number, 00163 GenVertex* signal_vertex, const WeightContainer& weights, 00164 const std::vector<long>& randomstates, 00165 const HeavyIon& ion, const PdfInfo& pdf, 00166 Units::MomentumUnit = Units::default_momentum_unit(), 00167 Units::LengthUnit = Units::default_length_unit() ); 00169 GenEvent( Units::MomentumUnit, Units::LengthUnit, 00170 int signal_process_id = 0, int event_number = 0, 00171 GenVertex* signal_vertex = 0, 00172 const WeightContainer& weights = std::vector<double>(), 00173 const std::vector<long>& randomstates = std::vector<long>() ); 00175 GenEvent( Units::MomentumUnit, Units::LengthUnit, 00176 int signal_process_id, int event_number, 00177 GenVertex* signal_vertex, const WeightContainer& weights, 00178 const std::vector<long>& randomstates, 00179 const HeavyIon& ion, const PdfInfo& pdf ); 00180 GenEvent( const GenEvent& inevent ); 00181 GenEvent& operator=( const GenEvent& inevent ); 00182 virtual ~GenEvent(); 00183 00184 void swap( GenEvent & other ); 00185 00186 void print( std::ostream& ostr = std::cout ) const; 00187 void print_version( std::ostream& ostr = std::cout ) const; 00188 00190 GenParticle* barcode_to_particle( int barCode ) const; 00192 GenVertex* barcode_to_vertex( int barCode ) const; 00193 00195 // access methods // 00197 00198 int signal_process_id() const; 00199 int event_number() const; 00200 int mpi() const; 00201 double event_scale() const; 00202 double alphaQCD() const; 00203 double alphaQED() const; 00204 00205 GenVertex* signal_process_vertex() const; 00207 bool valid_beam_particles() const; 00209 std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const; 00212 bool is_valid() const; 00213 00219 WeightContainer& weights(); 00220 const WeightContainer& weights() const; 00221 00223 GenCrossSection const * cross_section() const; 00224 GenCrossSection* cross_section(); 00226 HeavyIon const * heavy_ion() const; 00227 HeavyIon* heavy_ion(); 00229 PdfInfo const * pdf_info() const; 00230 PdfInfo* pdf_info(); 00231 00233 const std::vector<long>& random_states() const; 00234 00236 int particles_size() const; 00238 bool particles_empty() const; 00240 int vertices_size() const; 00242 bool vertices_empty() const; 00243 00246 void write_units( std::ostream & os = std::cout ) const; 00250 void write_cross_section( std::ostream& ostr = std::cout ) const; 00251 00253 Units::MomentumUnit momentum_unit() const; 00255 Units::LengthUnit length_unit() const; 00256 00257 std::ostream& write(std::ostream&); 00258 std::istream& read(std::istream&); 00259 00261 // mutator methods // 00263 00264 bool add_vertex( GenVertex* vtx ); 00265 bool remove_vertex( GenVertex* vtx ); 00266 void clear(); 00267 00268 void set_signal_process_id( int id ); 00269 void set_event_number( int eventno ); 00270 void set_mpi( int ); 00271 void set_event_scale( double scale ); 00272 void set_alphaQCD( double a ); 00273 void set_alphaQED( double a ); 00274 00276 void set_signal_process_vertex( GenVertex* ); 00278 bool set_beam_particles(GenParticle*, GenParticle*); 00280 bool set_beam_particles(std::pair<HepMC::GenParticle*,HepMC::GenParticle*> const &); 00282 void set_random_states( const std::vector<long>& randomstates ); 00283 00285 void set_cross_section( const GenCrossSection& ); 00287 void set_heavy_ion( const HeavyIon& ion ); 00289 void set_pdf_info( const PdfInfo& p ); 00290 00292 void use_units( Units::MomentumUnit, Units::LengthUnit ); 00295 void use_units( std::string&, std::string& ); 00296 00297 public: 00299 // vertex_iterators // 00301 // Note: the XXX_iterator is "resolvable" as XXX_const_iterator, but 00302 // not the reverse, which is consistent with STL, 00303 // see Musser, Derge, Saini 2ndEd. p. 69,70. 00304 00306 00310 class vertex_const_iterator : 00311 public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{ 00312 // Iterates over all vertices in this event 00313 public: 00315 vertex_const_iterator( 00316 const 00317 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator& i) 00318 : m_map_iterator(i) {} 00319 vertex_const_iterator() {} 00321 vertex_const_iterator( const vertex_const_iterator& i ) 00322 { *this = i; } 00323 virtual ~vertex_const_iterator() {} 00325 vertex_const_iterator& operator=( const vertex_const_iterator& i ) 00326 { m_map_iterator = i.m_map_iterator; return *this; } 00328 GenVertex* operator*(void) const { return m_map_iterator->second; } 00330 vertex_const_iterator& operator++(void) //Pre-fix increment 00331 { ++m_map_iterator; return *this; } 00333 vertex_const_iterator operator++(int) //Post-fix increment 00334 { vertex_const_iterator out(*this); ++(*this); return out; } 00336 bool operator==( const vertex_const_iterator& a ) const 00337 { return m_map_iterator == a.m_map_iterator; } 00339 bool operator!=( const vertex_const_iterator& a ) const 00340 { return !(m_map_iterator == a.m_map_iterator); } 00341 protected: 00343 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator 00344 m_map_iterator; 00345 private: 00347 vertex_const_iterator& operator--(void); 00349 vertex_const_iterator operator--(int); 00350 }; 00351 friend class vertex_const_iterator; 00353 vertex_const_iterator vertices_begin() const 00354 { return GenEvent::vertex_const_iterator( 00355 m_vertex_barcodes.begin() ); } 00357 vertex_const_iterator vertices_end() const 00358 { return GenEvent::vertex_const_iterator( 00359 m_vertex_barcodes.end() ); } 00360 00361 00363 00367 class vertex_iterator : 00368 public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{ 00369 // Iterates over all vertices in this event 00370 public: 00372 vertex_iterator( 00373 const 00374 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator& i ) 00375 : m_map_iterator( i ) {} 00376 vertex_iterator() {} 00378 vertex_iterator( const vertex_iterator& i ) { *this = i; } 00379 virtual ~vertex_iterator() {} 00381 vertex_iterator& operator=( const vertex_iterator& i ) { 00382 m_map_iterator = i.m_map_iterator; 00383 return *this; 00384 } 00386 operator vertex_const_iterator() const 00387 { return vertex_const_iterator(m_map_iterator); } 00389 GenVertex* operator*(void) const 00390 { return m_map_iterator->second; } 00392 vertex_iterator& operator++(void) //Pre-fix increment 00393 { ++m_map_iterator; return *this; } 00395 vertex_iterator operator++(int) //Post-fix increment 00396 { vertex_iterator out(*this); ++(*this); return out; } 00398 bool operator==( const vertex_iterator& a ) const 00399 { return m_map_iterator == a.m_map_iterator; } 00401 bool operator!=( const vertex_iterator& a ) const 00402 { return !(m_map_iterator == a.m_map_iterator); } 00403 protected: 00405 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator 00406 m_map_iterator; 00407 private: 00409 vertex_iterator& operator--(void); 00411 vertex_iterator operator--(int); 00412 00413 }; 00414 friend class vertex_iterator; 00416 vertex_iterator vertices_begin() 00417 { return GenEvent::vertex_iterator( 00418 m_vertex_barcodes.begin() ); } 00420 vertex_iterator vertices_end() 00421 { return GenEvent::vertex_iterator( 00422 m_vertex_barcodes.end() ); } 00423 00424 public: 00426 // particle_iterator // 00428 // Example of iterating over all particles in the event: 00429 // for ( GenEvent::particle_const_iterator p = particles_begin(); 00430 // p != particles_end(); ++p ) { 00431 // (*p)->print(); 00432 // } 00433 // 00434 00436 00440 class particle_const_iterator : 00441 public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{ 00442 // Iterates over all vertices in this event 00443 public: 00445 particle_const_iterator( 00446 const std::map<int,HepMC::GenParticle*>::const_iterator& i ) 00447 : m_map_iterator(i) {} 00448 particle_const_iterator() {} 00450 particle_const_iterator( const particle_const_iterator& i ) 00451 { *this = i; } 00452 virtual ~particle_const_iterator() {} 00454 particle_const_iterator& operator=( 00455 const particle_const_iterator& i ) 00456 { m_map_iterator = i.m_map_iterator; return *this; } 00458 GenParticle* operator*(void) const 00459 { return m_map_iterator->second; } 00461 particle_const_iterator& operator++(void) //Pre-fix increment 00462 { ++m_map_iterator; return *this; } 00464 particle_const_iterator operator++(int) //Post-fix increment 00465 { particle_const_iterator out(*this); ++(*this); return out; } 00467 bool operator==( const particle_const_iterator& a ) const 00468 { return m_map_iterator == a.m_map_iterator; } 00470 bool operator!=( const particle_const_iterator& a ) const 00471 { return !(m_map_iterator == a.m_map_iterator); } 00472 protected: 00474 std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator; 00475 private: 00477 particle_const_iterator& operator--(void); 00479 particle_const_iterator operator--(int); 00480 }; 00481 friend class particle_const_iterator; 00483 particle_const_iterator particles_begin() const 00484 { return GenEvent::particle_const_iterator( 00485 m_particle_barcodes.begin() ); } 00487 particle_const_iterator particles_end() const 00488 { return GenEvent::particle_const_iterator( 00489 m_particle_barcodes.end() ); } 00490 00492 00496 class particle_iterator : 00497 public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{ 00498 // Iterates over all vertices in this event 00499 public: 00501 particle_iterator( const std::map<int,HepMC::GenParticle*>::iterator& i ) 00502 : m_map_iterator( i ) {} 00503 particle_iterator() {} 00505 particle_iterator( const particle_iterator& i ) { *this = i; } 00506 virtual ~particle_iterator() {} 00508 particle_iterator& operator=( const particle_iterator& i ) { 00509 m_map_iterator = i.m_map_iterator; 00510 return *this; 00511 } 00513 operator particle_const_iterator() const 00514 { return particle_const_iterator(m_map_iterator); } 00516 GenParticle* operator*(void) const 00517 { return m_map_iterator->second; } 00519 particle_iterator& operator++(void) 00520 { ++m_map_iterator; return *this; } 00522 particle_iterator operator++(int) 00523 { particle_iterator out(*this); ++(*this); return out; } 00525 bool operator==( const particle_iterator& a ) const 00526 { return m_map_iterator == a.m_map_iterator; } 00528 bool operator!=( const particle_iterator& a ) const 00529 { return !(m_map_iterator == a.m_map_iterator); } 00530 protected: 00532 std::map<int,HepMC::GenParticle*>::iterator m_map_iterator; 00533 private: 00535 particle_iterator& operator--(void); 00537 particle_iterator operator--(int); 00538 }; 00539 friend class particle_iterator; 00541 particle_iterator particles_begin() 00542 { return GenEvent::particle_iterator( 00543 m_particle_barcodes.begin() ); } 00545 particle_iterator particles_end() 00546 { return GenEvent::particle_iterator( 00547 m_particle_barcodes.end() ); } 00548 00550 protected: 00551 // 00552 // Following methods intended for use by GenParticle/Vertex classes: 00553 // In general there is no reason they should be used elsewhere. 00555 bool set_barcode( GenParticle* p, int suggested_barcode =false ); 00557 bool set_barcode( GenVertex* v, int suggested_barcode =false ); 00559 void remove_barcode( GenParticle* p ); 00561 void remove_barcode( GenVertex* v ); 00562 00563 void delete_all_vertices(); 00564 00565 private: // methods 00567 bool use_momentum_unit( Units::MomentumUnit ); 00568 bool use_momentum_unit( std::string& ); 00570 bool use_length_unit( Units::LengthUnit ); 00571 bool use_length_unit( std::string& ); 00572 00573 // the following internal methods are used by read() and write() 00574 00576 std::ostream & write_beam_particles( std::ostream &, 00577 std::pair<HepMC::GenParticle *,HepMC::GenParticle *> ); 00579 std::ostream & write_vertex( std::ostream &, GenVertex const * ); 00581 std::ostream & write_particle( std::ostream&, GenParticle const * ); 00583 std::istream & find_file_type( std::istream & ); 00585 std::istream & find_end_key( std::istream &, int & ); 00587 std::istream & read_units( std::istream & ); 00588 00589 private: // data members 00590 int m_signal_process_id; 00591 int m_event_number; 00592 int m_mpi; // number of multi paricle interactions 00593 double m_event_scale;// energy scale, see hep-ph/0109068 00594 double m_alphaQCD; // QCD coupling, see hep-ph/0109068 00595 double m_alphaQED; // QED coupling, see hep-ph/0109068 00596 GenVertex* m_signal_process_vertex; 00597 GenParticle* m_beam_particle_1; 00598 GenParticle* m_beam_particle_2; 00599 WeightContainer m_weights; // weights for this event first weight 00600 // is used by default for hit and miss 00601 std::vector<long> m_random_states; // container of rndm num 00602 // generator states 00603 00604 std::map< int,HepMC::GenVertex*,std::greater<int> > m_vertex_barcodes; 00605 std::map< int,HepMC::GenParticle*,std::less<int> > m_particle_barcodes; 00606 GenCrossSection* m_cross_section; // undefined by default 00607 HeavyIon* m_heavy_ion; // undefined by default 00608 PdfInfo* m_pdf_info; // undefined by default 00609 Units::MomentumUnit m_momentum_unit; // default value set by configure switch 00610 Units::LengthUnit m_position_unit; // default value set by configure switch 00611 00612 }; 00613 00614 00616 // IO Free Functions // 00618 00620 std::ostream & operator << (std::ostream &, GenEvent &); 00622 std::istream & operator >> (std::istream &, GenEvent &); 00624 std::istream & set_input_units(std::istream &, 00625 Units::MomentumUnit, Units::LengthUnit); 00627 std::ostream & write_HepMC_IO_block_begin(std::ostream & ); 00629 std::ostream & write_HepMC_IO_block_end(std::ostream & ); 00630 00631 00633 // INLINE Free Functions // 00635 00636 // Implemented in terms of GenEvent::use_... 00637 inline GenEvent& convert_units(GenEvent & evt, Units::MomentumUnit m, Units::LengthUnit l) 00638 { 00639 evt.use_units(m, l); 00640 return evt; 00641 } 00642 00644 // INLINE Access Methods // 00646 00651 inline int GenEvent::signal_process_id() const 00652 { return m_signal_process_id; } 00653 00654 inline int GenEvent::event_number() const { return m_event_number; } 00655 00658 inline int GenEvent::mpi() const { return m_mpi; } 00659 00660 inline double GenEvent::event_scale() const { return m_event_scale; } 00661 00662 inline double GenEvent::alphaQCD() const { return m_alphaQCD; } 00663 00664 inline double GenEvent::alphaQED() const { return m_alphaQED; } 00665 00666 inline GenVertex* GenEvent::signal_process_vertex() const { 00668 return m_signal_process_vertex; 00669 } 00670 00671 inline WeightContainer& GenEvent::weights() { return m_weights; } 00672 00673 inline const WeightContainer& GenEvent::weights() const 00674 { return m_weights; } 00675 00676 inline GenCrossSection const * GenEvent::cross_section() const 00677 { return m_cross_section; } 00678 00679 inline GenCrossSection* GenEvent::cross_section() 00680 { return m_cross_section; } 00681 00682 inline HeavyIon const * GenEvent::heavy_ion() const 00683 { return m_heavy_ion; } 00684 00685 inline HeavyIon* GenEvent::heavy_ion() 00686 { return m_heavy_ion; } 00687 00688 inline PdfInfo const * GenEvent::pdf_info() const 00689 { return m_pdf_info; } 00690 00691 inline PdfInfo* GenEvent::pdf_info() 00692 { return m_pdf_info; } 00693 00699 inline const std::vector<long>& GenEvent::random_states() const 00700 { return m_random_states; } 00701 00702 inline void GenEvent::set_signal_process_id( int id ) 00703 { m_signal_process_id = id; } 00704 00705 inline void GenEvent::set_event_number( int eventno ) 00706 { m_event_number = eventno; } 00707 00709 inline void GenEvent::set_mpi( int nmpi ) 00710 { m_mpi = nmpi; } 00711 00712 00713 inline void GenEvent::set_event_scale( double sc ) { m_event_scale = sc; } 00714 00715 inline void GenEvent::set_alphaQCD( double a ) { m_alphaQCD = a; } 00716 00717 inline void GenEvent::set_alphaQED( double a ) { m_alphaQED = a; } 00718 00719 inline void GenEvent::set_signal_process_vertex( GenVertex* vtx ) { 00720 m_signal_process_vertex = vtx; 00721 if ( m_signal_process_vertex ) add_vertex( m_signal_process_vertex ); 00722 } 00723 00724 inline void GenEvent::set_cross_section( const GenCrossSection& xs ) 00725 { 00726 delete m_cross_section; 00727 m_cross_section = new GenCrossSection(xs); 00728 } 00729 00730 inline void GenEvent::set_heavy_ion( const HeavyIon& ion ) 00731 { 00732 delete m_heavy_ion; 00733 m_heavy_ion = new HeavyIon(ion); 00734 } 00735 00736 inline void GenEvent::set_pdf_info( const PdfInfo& p ) 00737 { 00738 delete m_pdf_info; 00739 m_pdf_info = new PdfInfo(p); 00740 } 00741 00742 inline void GenEvent::set_random_states( const std::vector<long>& 00743 randomstates ) 00744 { m_random_states = randomstates; } 00745 00746 inline void GenEvent::remove_barcode( GenParticle* p ) 00747 { m_particle_barcodes.erase( p->barcode() ); } 00748 00749 inline void GenEvent::remove_barcode( GenVertex* v ) 00750 { m_vertex_barcodes.erase( v->barcode() ); } 00751 00770 inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const 00771 { 00772 std::map<int,HepMC::GenParticle*>::const_iterator i 00773 = m_particle_barcodes.find(barCode); 00774 return ( i != m_particle_barcodes.end() ) ? (*i).second : 0; 00775 } 00776 00795 inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const 00796 { 00797 std::map<int,GenVertex*,std::greater<int> >::const_iterator i 00798 = m_vertex_barcodes.find(barCode); 00799 return ( i != m_vertex_barcodes.end() ) ? (*i).second : 0; 00800 } 00801 00802 inline int GenEvent::particles_size() const { 00803 return (int)m_particle_barcodes.size(); 00804 } 00805 inline bool GenEvent::particles_empty() const { 00806 return (bool)m_particle_barcodes.empty(); 00807 } 00808 inline int GenEvent::vertices_size() const { 00809 return (int)m_vertex_barcodes.size(); 00810 } 00811 inline bool GenEvent::vertices_empty() const { 00812 return (bool)m_vertex_barcodes.empty(); 00813 } 00814 00815 // beam particles 00816 inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const { 00817 return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2); 00818 } 00819 00820 // units 00821 inline Units::MomentumUnit GenEvent::momentum_unit() const { 00822 return m_momentum_unit; 00823 } 00824 inline Units::LengthUnit GenEvent::length_unit() const { 00825 return m_position_unit; 00826 } 00827 00828 inline void GenEvent::use_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) { 00829 use_momentum_unit( new_m ); 00830 use_length_unit( new_l ); 00831 } 00832 00833 inline void GenEvent::use_units( std::string& new_m, std::string& new_l ) { 00834 use_momentum_unit( new_m ); 00835 use_length_unit( new_l ); 00836 } 00837 00838 } // HepMC 00839 00840 #endif // HEPMC_GEN_EVENT_H 00841 00842 //-------------------------------------------------------------------------- 00843 00844