HepMC Reference Documentation

HepMC

GenEvent.h

Go to the documentation of this file.
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 // 
00122 
00123 #include "HepMC/GenVertex.h"
00124 #include "HepMC/GenParticle.h"
00125 #include "HepMC/WeightContainer.h"
00126 #include "HepMC/GenCrossSection.h"
00127 #include "HepMC/HeavyIon.h"
00128 #include "HepMC/PdfInfo.h"
00129 #include "HepMC/Units.h"
00130 #include "HepMC/HepMCDefs.h"
00131 #include <map>
00132 #include <string>
00133 #include <vector>
00134 #include <algorithm>
00135 #include <iostream>
00136 
00137 namespace HepMC {
00138 
00140 
00146     class GenEvent {
00147         friend class GenParticle;
00148         friend class GenVertex;  
00149     public:
00151         GenEvent( int signal_process_id = 0, int event_number = 0,
00152                   GenVertex* signal_vertex = 0,
00153                   const WeightContainer& weights = std::vector<double>(),
00154                   const std::vector<long>& randomstates = std::vector<long>(),
00155                   Units::MomentumUnit = Units::default_momentum_unit(), 
00156                   Units::LengthUnit = Units::default_length_unit() );
00158         GenEvent( int signal_process_id, int event_number,
00159                   GenVertex* signal_vertex, const WeightContainer& weights,
00160                   const std::vector<long>& randomstates,
00161                   const HeavyIon& ion, const PdfInfo& pdf,
00162                   Units::MomentumUnit = Units::default_momentum_unit(), 
00163                   Units::LengthUnit = Units::default_length_unit() );
00165         GenEvent( Units::MomentumUnit, Units::LengthUnit,
00166                   int signal_process_id = 0, int event_number = 0,
00167                   GenVertex* signal_vertex = 0,
00168                   const WeightContainer& weights = std::vector<double>(),
00169                   const std::vector<long>& randomstates = std::vector<long>() );
00171         GenEvent( Units::MomentumUnit, Units::LengthUnit,
00172                   int signal_process_id, int event_number,
00173                   GenVertex* signal_vertex, const WeightContainer& weights,
00174                   const std::vector<long>& randomstates,
00175                   const HeavyIon& ion, const PdfInfo& pdf );
00176         GenEvent( const GenEvent& inevent );          
00177         GenEvent& operator=( const GenEvent& inevent ); 
00178         virtual ~GenEvent(); 
00179 
00180         void swap( GenEvent & other );  
00181     
00182         void print( std::ostream& ostr = std::cout ) const; 
00183         void print_version( std::ostream& ostr = std::cout ) const; 
00184 
00186         GenParticle* barcode_to_particle( int barCode ) const;
00188         GenVertex*   barcode_to_vertex(   int barCode ) const;
00189 
00191         // access methods //
00193 
00194         int signal_process_id() const; 
00195         int event_number() const; 
00196         int mpi() const;          
00197         double event_scale() const; 
00198         double alphaQCD() const; 
00199         double alphaQED() const; 
00200 
00201         GenVertex* signal_process_vertex() const;
00203         bool valid_beam_particles() const;
00205         std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const;
00208         bool is_valid() const;
00209 
00215         WeightContainer&        weights(); 
00216         const WeightContainer&  weights() const; 
00217 
00219         GenCrossSection const *     cross_section() const;
00220         GenCrossSection*            cross_section();
00222         HeavyIon const *         heavy_ion() const;
00223         HeavyIon*                heavy_ion();
00225         PdfInfo const *          pdf_info() const;
00226         PdfInfo*                 pdf_info();
00227 
00229         const std::vector<long>& random_states() const;
00230 
00232         int     particles_size() const;
00234         bool    particles_empty() const;
00236         int     vertices_size() const;
00238         bool    vertices_empty() const;
00239 
00240         void write_units( std::ostream & os = std::cout ) const; 
00241 
00243         Units::MomentumUnit momentum_unit() const;
00245         Units::LengthUnit   length_unit()   const;
00246         
00247         std::ostream& write(std::ostream&);
00248         std::istream& read(std::istream&);
00249 
00251         // mutator methods //
00253 
00254         bool    add_vertex( GenVertex* vtx );    
00255         bool    remove_vertex( GenVertex* vtx ); 
00256         void    clear();                         
00257         
00258         void set_signal_process_id( int id ); 
00259         void set_event_number( int eventno ); 
00260         void set_mpi( int  ); 
00261         void set_event_scale( double scale ); 
00262         void set_alphaQCD( double a ); 
00263         void set_alphaQED( double a ); 
00264 
00266         void set_signal_process_vertex( GenVertex* );
00268         bool set_beam_particles(GenParticle*, GenParticle*);
00270         bool set_beam_particles(std::pair<HepMC::GenParticle*,HepMC::GenParticle*> const &);
00272         void set_random_states( const std::vector<long>& randomstates );
00273 
00275         void set_cross_section( const GenCrossSection& );
00277         void set_heavy_ion( const HeavyIon& ion );
00279         void set_pdf_info( const PdfInfo& p );
00280         
00282         void use_units( Units::MomentumUnit, Units::LengthUnit );
00285         void use_units( std::string&, std::string& );
00286 
00287     public:
00289         // vertex_iterators          //
00291         // Note:  the XXX_iterator is "resolvable" as XXX_const_iterator, but 
00292         //  not the reverse, which is consistent with STL, 
00293         //  see Musser, Derge, Saini 2ndEd. p. 69,70.
00294 
00296 
00300         class vertex_const_iterator :
00301           public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
00302             // Iterates over all vertices in this event
00303         public:
00305             vertex_const_iterator(
00306                 const 
00307                 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator& i)
00308                 : m_map_iterator(i) {}
00309             vertex_const_iterator() {}
00311             vertex_const_iterator( const vertex_const_iterator& i )
00312                 { *this = i; }
00313             virtual ~vertex_const_iterator() {}
00315             vertex_const_iterator&  operator=( const vertex_const_iterator& i )
00316                 { m_map_iterator = i.m_map_iterator; return *this; }
00318             GenVertex* operator*(void) const { return m_map_iterator->second; }
00320             vertex_const_iterator&  operator++(void)  //Pre-fix increment 
00321                 { ++m_map_iterator; return *this; }
00323             vertex_const_iterator   operator++(int)   //Post-fix increment
00324                 { vertex_const_iterator out(*this); ++(*this); return out; }
00326             bool  operator==( const vertex_const_iterator& a ) const
00327                 { return m_map_iterator == a.m_map_iterator; }
00329             bool  operator!=( const vertex_const_iterator& a ) const
00330                 { return !(m_map_iterator == a.m_map_iterator); }
00331         protected:
00333             std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator 
00334                                                                 m_map_iterator;
00335         private:
00337             vertex_const_iterator&  operator--(void);
00339             vertex_const_iterator   operator--(int);
00340         };
00341         friend class vertex_const_iterator;
00343         vertex_const_iterator      vertices_begin() const
00344             { return GenEvent::vertex_const_iterator( 
00345                 m_vertex_barcodes.begin() ); }
00347         vertex_const_iterator      vertices_end() const
00348             { return GenEvent::vertex_const_iterator(
00349                 m_vertex_barcodes.end() ); }
00350 
00351 
00353 
00357         class vertex_iterator :
00358           public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
00359             // Iterates over all vertices in this event
00360         public:
00362             vertex_iterator( 
00363                 const 
00364                 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator& i )
00365                 : m_map_iterator( i ) {}
00366             vertex_iterator() {}
00368             vertex_iterator( const vertex_iterator& i ) { *this = i; }
00369             virtual ~vertex_iterator() {}
00371             vertex_iterator&  operator=( const vertex_iterator& i ) {
00372                 m_map_iterator = i.m_map_iterator;
00373                 return *this;
00374             }
00376             operator vertex_const_iterator() const
00377                 { return vertex_const_iterator(m_map_iterator); }
00379             GenVertex*        operator*(void) const
00380                 { return m_map_iterator->second; }
00382             vertex_iterator&  operator++(void)  //Pre-fix increment 
00383                 { ++m_map_iterator;     return *this; }
00385             vertex_iterator   operator++(int)   //Post-fix increment
00386                 { vertex_iterator out(*this); ++(*this); return out; }
00388             bool              operator==( const vertex_iterator& a ) const
00389                 { return m_map_iterator == a.m_map_iterator; }
00391             bool              operator!=( const vertex_iterator& a ) const
00392                 { return !(m_map_iterator == a.m_map_iterator); }
00393         protected:
00395             std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator 
00396                                                                m_map_iterator;
00397         private:
00399             vertex_iterator&  operator--(void);
00401             vertex_iterator   operator--(int);
00402 
00403         };
00404         friend class vertex_iterator;
00406         vertex_iterator            vertices_begin() 
00407             { return GenEvent::vertex_iterator( 
00408                 m_vertex_barcodes.begin() ); }
00410         vertex_iterator            vertices_end()
00411             { return GenEvent::vertex_iterator(
00412                 m_vertex_barcodes.end() ); }
00413 
00414     public:
00416         // particle_iterator         //
00418         // Example of iterating over all particles in the event:
00419         //      for ( GenEvent::particle_const_iterator p = particles_begin();
00420         //            p != particles_end(); ++p ) {
00421         //         (*p)->print();
00422         //      }
00423         //
00424 
00426 
00430         class particle_const_iterator :
00431           public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
00432             // Iterates over all vertices in this event
00433         public:
00435             particle_const_iterator(
00436                 const std::map<int,HepMC::GenParticle*>::const_iterator& i )
00437                 : m_map_iterator(i) {}
00438             particle_const_iterator() {}
00440             particle_const_iterator( const particle_const_iterator& i )
00441                 { *this = i; }
00442             virtual ~particle_const_iterator() {}
00444             particle_const_iterator& operator=(
00445                 const particle_const_iterator& i )
00446                 { m_map_iterator = i.m_map_iterator; return *this; }
00448             GenParticle*        operator*(void) const
00449                 { return m_map_iterator->second; }
00451             particle_const_iterator&  operator++(void)  //Pre-fix increment 
00452                 { ++m_map_iterator; return *this; }
00454             particle_const_iterator   operator++(int)   //Post-fix increment
00455                 { particle_const_iterator out(*this); ++(*this); return out; }
00457             bool  operator==( const particle_const_iterator& a ) const
00458                 { return m_map_iterator == a.m_map_iterator; }
00460             bool  operator!=( const particle_const_iterator& a ) const
00461                 { return !(m_map_iterator == a.m_map_iterator); }
00462         protected:
00464             std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator;
00465         private:
00467             particle_const_iterator&  operator--(void);
00469             particle_const_iterator   operator--(int);
00470         };      
00471         friend class particle_const_iterator;
00473         particle_const_iterator      particles_begin() const
00474             { return GenEvent::particle_const_iterator( 
00475                 m_particle_barcodes.begin() ); }
00477         particle_const_iterator      particles_end() const
00478             { return GenEvent::particle_const_iterator(
00479                 m_particle_barcodes.end() ); }
00480 
00482 
00486         class particle_iterator :
00487           public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
00488             // Iterates over all vertices in this event
00489         public:
00491             particle_iterator( const std::map<int,HepMC::GenParticle*>::iterator& i )
00492                 : m_map_iterator( i ) {}
00493             particle_iterator() {}
00495             particle_iterator( const particle_iterator& i ) { *this = i; }
00496             virtual ~particle_iterator() {}
00498             particle_iterator&  operator=( const particle_iterator& i ) {
00499                 m_map_iterator = i.m_map_iterator;
00500                 return *this;
00501             }
00503             operator particle_const_iterator() const
00504                 { return particle_const_iterator(m_map_iterator); }
00506             GenParticle*        operator*(void) const
00507                 { return m_map_iterator->second; }
00509             particle_iterator&  operator++(void) 
00510                 { ++m_map_iterator;     return *this; }
00512             particle_iterator   operator++(int)   
00513                 { particle_iterator out(*this); ++(*this); return out; }
00515             bool              operator==( const particle_iterator& a ) const
00516                 { return m_map_iterator == a.m_map_iterator; }
00518             bool              operator!=( const particle_iterator& a ) const
00519                 { return !(m_map_iterator == a.m_map_iterator); }
00520         protected:
00522             std::map<int,HepMC::GenParticle*>::iterator m_map_iterator;
00523         private:
00525             particle_iterator&  operator--(void);
00527             particle_iterator   operator--(int);
00528         };
00529         friend class particle_iterator;
00531         particle_iterator particles_begin() 
00532             { return GenEvent::particle_iterator(
00533                 m_particle_barcodes.begin() ); }
00535         particle_iterator particles_end()
00536             { return GenEvent::particle_iterator(
00537                 m_particle_barcodes.end() ); }
00538 
00540     protected:
00541         //
00542         // Following methods intended for use by GenParticle/Vertex classes:
00543         // In general there is no reason they should be used elsewhere.
00545         bool         set_barcode( GenParticle* p, int suggested_barcode =false );
00547         bool         set_barcode( GenVertex*   v, int suggested_barcode =false );
00549         void         remove_barcode( GenParticle* p );
00551         void         remove_barcode( GenVertex*   v );
00552 
00553         void delete_all_vertices(); 
00554 
00555      private: // methods
00557         bool use_momentum_unit( Units::MomentumUnit );
00558         bool use_momentum_unit( std::string& );
00560         bool use_length_unit( Units::LengthUnit );
00561         bool use_length_unit( std::string& );
00562         
00563         // the following internal methods are used by read() and write()
00564 
00566         std::ostream & write_beam_particles( std::ostream &, 
00567                              std::pair<HepMC::GenParticle *,HepMC::GenParticle *> );
00569         std::ostream & write_vertex( std::ostream &, GenVertex const * );
00571         std::ostream & write_particle( std::ostream&, GenParticle const * );
00573         std::istream & find_file_type( std::istream & );
00575         std::istream & find_end_key( std::istream &, int & );
00577         std::istream & read_units( std::istream & );
00578 
00579     private: // data members
00580         int                   m_signal_process_id;
00581         int                   m_event_number;  
00582         int                   m_mpi;        // number of multi paricle interactions
00583         double                m_event_scale;// energy scale, see hep-ph/0109068
00584         double                m_alphaQCD;   // QCD coupling, see hep-ph/0109068
00585         double                m_alphaQED;   // QED coupling, see hep-ph/0109068
00586         GenVertex*            m_signal_process_vertex;
00587         GenParticle*          m_beam_particle_1;
00588         GenParticle*          m_beam_particle_2;
00589         WeightContainer       m_weights; // weights for this event first weight
00590                                          // is used by default for hit and miss
00591         std::vector<long> m_random_states; // container of rndm num 
00592                                                // generator states
00593 
00594         std::map< int,HepMC::GenVertex*,std::greater<int> >   m_vertex_barcodes;
00595         std::map< int,HepMC::GenParticle*,std::less<int> >    m_particle_barcodes;
00596         GenCrossSection*         m_cross_section;             // undefined by default
00597         HeavyIon*             m_heavy_ion;            // undefined by default
00598         PdfInfo*              m_pdf_info;             // undefined by default
00599         Units::MomentumUnit   m_momentum_unit;    // default value set by configure switch
00600         Units::LengthUnit     m_position_unit;    // default value set by configure switch
00601 
00602     };
00603 
00604 
00606     // IO Free Functions     //
00608   
00610     std::ostream & operator << (std::ostream &, GenEvent &);
00612     std::istream & operator >> (std::istream &, GenEvent &);
00614     std::istream & set_input_units(std::istream &, 
00615                                    Units::MomentumUnit, Units::LengthUnit);
00617     std::ostream & write_HepMC_IO_block_begin(std::ostream & );
00619     std::ostream & write_HepMC_IO_block_end(std::ostream & );
00620 
00621 
00623     // INLINE Free Functions //
00625 
00626     // Implemented in terms of GenEvent::use_...
00627     inline GenEvent& convert_units(GenEvent & evt, Units::MomentumUnit m, Units::LengthUnit l)
00628     {
00629       evt.use_units(m, l);
00630       return evt;
00631     }
00632 
00634     // INLINE Access Methods //
00636 
00641     inline int GenEvent::signal_process_id() const 
00642     { return m_signal_process_id; }
00643 
00644     inline int GenEvent::event_number() const { return m_event_number; }
00645 
00648     inline int GenEvent::mpi() const { return m_mpi; }
00649 
00650     inline double GenEvent::event_scale() const { return m_event_scale; }
00651 
00652     inline double GenEvent::alphaQCD() const { return m_alphaQCD; }
00653 
00654     inline double GenEvent::alphaQED() const { return m_alphaQED; }
00655  
00656     inline GenVertex* GenEvent::signal_process_vertex() const {
00658         return m_signal_process_vertex;
00659     }  
00660 
00661     inline WeightContainer& GenEvent::weights() { return m_weights; }
00662 
00663     inline const WeightContainer& GenEvent::weights() const 
00664     { return m_weights; }
00665 
00666     inline GenCrossSection const * GenEvent::cross_section() const 
00667     { return m_cross_section; }
00668 
00669     inline GenCrossSection*  GenEvent::cross_section()  
00670     { return m_cross_section; }
00671 
00672     inline HeavyIon const * GenEvent::heavy_ion() const 
00673     { return m_heavy_ion; }
00674 
00675     inline HeavyIon*  GenEvent::heavy_ion()  
00676     { return m_heavy_ion; }
00677 
00678     inline PdfInfo const * GenEvent::pdf_info() const 
00679     { return m_pdf_info; }
00680 
00681     inline PdfInfo*  GenEvent::pdf_info()  
00682     { return m_pdf_info; }
00683 
00689     inline const std::vector<long>& GenEvent::random_states() const 
00690     { return m_random_states; }
00691 
00692     inline void GenEvent::set_signal_process_id( int id )
00693     { m_signal_process_id = id; }
00694 
00695     inline void GenEvent::set_event_number( int eventno )
00696     { m_event_number = eventno; }
00697 
00699     inline void GenEvent::set_mpi( int nmpi )
00700     { m_mpi = nmpi; }
00701 
00702 
00703     inline void GenEvent::set_event_scale( double sc ) { m_event_scale = sc; }
00704 
00705     inline void GenEvent::set_alphaQCD( double a ) { m_alphaQCD = a; }
00706 
00707     inline void GenEvent::set_alphaQED( double a ) { m_alphaQED = a; }
00708 
00709     inline void GenEvent::set_signal_process_vertex( GenVertex* vtx ) {
00710         m_signal_process_vertex = vtx;
00711         if ( m_signal_process_vertex ) add_vertex( m_signal_process_vertex );
00712     }
00713 
00714     inline void GenEvent::set_cross_section( const GenCrossSection& xs )
00715     { 
00716         delete m_cross_section;
00717         m_cross_section = new GenCrossSection(xs); 
00718     }
00719 
00720     inline void GenEvent::set_heavy_ion( const HeavyIon& ion )
00721     { 
00722         delete m_heavy_ion;
00723         m_heavy_ion = new HeavyIon(ion); 
00724     }
00725 
00726     inline void GenEvent::set_pdf_info( const PdfInfo& p )
00727     { 
00728         delete m_pdf_info;
00729         m_pdf_info = new PdfInfo(p); 
00730     }
00731 
00732     inline void GenEvent::set_random_states( const std::vector<long>&
00733                                              randomstates )
00734     { m_random_states = randomstates; }
00735 
00736     inline void GenEvent::remove_barcode( GenParticle* p )
00737     { m_particle_barcodes.erase( p->barcode() ); }
00738 
00739     inline void GenEvent::remove_barcode( GenVertex* v )
00740     { m_vertex_barcodes.erase( v->barcode() ); }
00741 
00755     inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
00756     { 
00757         std::map<int,HepMC::GenParticle*>::const_iterator i 
00758             = m_particle_barcodes.find(barCode);
00759         return ( i != m_particle_barcodes.end() ) ? (*i).second : 0;
00760     }
00761 
00775     inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const
00776     {
00777         std::map<int,GenVertex*,std::greater<int> >::const_iterator i 
00778             = m_vertex_barcodes.find(barCode);
00779         return ( i != m_vertex_barcodes.end() ) ? (*i).second : 0;
00780     }
00781 
00782     inline int GenEvent::particles_size() const {
00783         return (int)m_particle_barcodes.size();
00784     }
00785     inline bool GenEvent::particles_empty() const {
00786         return (bool)m_particle_barcodes.empty();
00787     }
00788     inline int GenEvent::vertices_size() const {
00789         return (int)m_vertex_barcodes.size();
00790     }
00791     inline bool GenEvent::vertices_empty() const {
00792         return (bool)m_vertex_barcodes.empty();
00793     }
00794     
00795     // beam particles
00796     inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const {
00797         return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2);
00798     }
00799 
00800     // units
00801     inline Units::MomentumUnit GenEvent::momentum_unit() const {
00802         return m_momentum_unit; 
00803     }
00804     inline Units::LengthUnit   GenEvent::length_unit()   const {
00805         return m_position_unit; 
00806     }
00807     
00808     inline void GenEvent::use_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) { 
00809        use_momentum_unit( new_m );
00810        use_length_unit( new_l );
00811     }
00812     
00813     inline void GenEvent::use_units( std::string& new_m, std::string& new_l ) { 
00814        use_momentum_unit( new_m );
00815        use_length_unit( new_l );
00816     }
00817 
00818 } // HepMC
00819 
00820 #endif  // HEPMC_GEN_EVENT_H
00821 
00822 //--------------------------------------------------------------------------
00823 
00824 

Generated on Tue Jun 2 20:28:25 2009 for HepMC by  doxygen 1.5.1-3