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 // - 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 
00143     class GenEventVertexRange;
00144     class ConstGenEventVertexRange;
00145     class GenEventParticleRange;
00146     class ConstGenEventParticleRange;
00147 
00149 
00155     class GenEvent {
00156         friend class GenParticle;
00157         friend class GenVertex;  
00158     public:
00160         GenEvent( int signal_process_id = 0, int event_number = 0,
00161                   GenVertex* signal_vertex = 0,
00162                   const WeightContainer& weights = std::vector<double>(),
00163                   const std::vector<long>& randomstates = std::vector<long>(),
00164                   Units::MomentumUnit = Units::default_momentum_unit(), 
00165                   Units::LengthUnit = Units::default_length_unit() );
00167         GenEvent( int signal_process_id, int event_number,
00168                   GenVertex* signal_vertex, const WeightContainer& weights,
00169                   const std::vector<long>& randomstates,
00170                   const HeavyIon& ion, const PdfInfo& pdf,
00171                   Units::MomentumUnit = Units::default_momentum_unit(), 
00172                   Units::LengthUnit = Units::default_length_unit() );
00174         GenEvent( Units::MomentumUnit, Units::LengthUnit,
00175                   int signal_process_id = 0, int event_number = 0,
00176                   GenVertex* signal_vertex = 0,
00177                   const WeightContainer& weights = std::vector<double>(),
00178                   const std::vector<long>& randomstates = std::vector<long>() );
00180         GenEvent( Units::MomentumUnit, Units::LengthUnit,
00181                   int signal_process_id, int event_number,
00182                   GenVertex* signal_vertex, const WeightContainer& weights,
00183                   const std::vector<long>& randomstates,
00184                   const HeavyIon& ion, const PdfInfo& pdf );
00185         GenEvent( const GenEvent& inevent );          
00186         GenEvent& operator=( const GenEvent& inevent ); 
00187         virtual ~GenEvent(); 
00188 
00189         void swap( GenEvent & other );  
00190     
00191         void print( std::ostream& ostr = std::cout ) const; 
00192         void print_version( std::ostream& ostr = std::cout ) const; 
00193 
00195         GenParticle* barcode_to_particle( int barCode ) const;
00197         GenVertex*   barcode_to_vertex(   int barCode ) const;
00198 
00200         // access methods //
00202 
00203         int signal_process_id() const; 
00204         int event_number() const; 
00205         int mpi() const;          
00206         double event_scale() const; 
00207         double alphaQCD() const; 
00208         double alphaQED() const; 
00209 
00210         GenVertex* signal_process_vertex() const;
00212         bool valid_beam_particles() const;
00214         std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const;
00217         bool is_valid() const;
00218 
00224         WeightContainer&        weights(); 
00225         const WeightContainer&  weights() const; 
00226 
00228         GenCrossSection const *     cross_section() const;
00229         GenCrossSection*            cross_section();
00231         HeavyIon const *         heavy_ion() const;
00232         HeavyIon*                heavy_ion();
00234         PdfInfo const *          pdf_info() const;
00235         PdfInfo*                 pdf_info();
00236 
00238         const std::vector<long>& random_states() const;
00239 
00241         int     particles_size() const;
00243         bool    particles_empty() const;
00245         int     vertices_size() const;
00247         bool    vertices_empty() const;
00248 
00251         void write_units( std::ostream & os = std::cout ) const; 
00255         void write_cross_section( std::ostream& ostr = std::cout ) const;
00256 
00258         Units::MomentumUnit momentum_unit() const;
00260         Units::LengthUnit   length_unit()   const;
00261         
00262         std::ostream& write(std::ostream&);
00263         std::istream& read(std::istream&);
00264 
00266         // mutator methods //
00268 
00269         bool    add_vertex( GenVertex* vtx );    
00270         bool    remove_vertex( GenVertex* vtx ); 
00271         void    clear();                         
00272         
00273         void set_signal_process_id( int id ); 
00274         void set_event_number( int eventno ); 
00275         void set_mpi( int  ); 
00276         void set_event_scale( double scale ); 
00277         void set_alphaQCD( double a ); 
00278         void set_alphaQED( double a ); 
00279 
00281         void set_signal_process_vertex( GenVertex* );
00283         bool set_beam_particles(GenParticle*, GenParticle*);
00285         bool set_beam_particles(std::pair<HepMC::GenParticle*,HepMC::GenParticle*> const &);
00287         void set_random_states( const std::vector<long>& randomstates );
00288 
00290         void set_cross_section( const GenCrossSection& );
00292         void set_heavy_ion( const HeavyIon& ion );
00294         void set_pdf_info( const PdfInfo& p );
00295         
00298         void use_units( Units::MomentumUnit, Units::LengthUnit );
00302         void use_units( std::string&, std::string& );
00303         
00306         void define_units( Units::MomentumUnit, Units::LengthUnit );
00310         void define_units( std::string&, std::string& );
00311         
00313         GenEventVertexRange vertex_range();
00315         ConstGenEventVertexRange vertex_range() const;
00317         GenEventParticleRange particle_range();
00319         ConstGenEventParticleRange particle_range() const;
00320 
00321     public:
00323         // vertex_iterators          //
00325         // Note:  the XXX_iterator is "resolvable" as XXX_const_iterator, but 
00326         //  not the reverse, which is consistent with STL, 
00327         //  see Musser, Derge, Saini 2ndEd. p. 69,70.
00328 
00330 
00334         class vertex_const_iterator :
00335           public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
00336             // Iterates over all vertices in this event
00337         public:
00339             vertex_const_iterator(
00340                 const 
00341                 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator& i)
00342                 : m_map_iterator(i) {}
00343             vertex_const_iterator() {}
00345             vertex_const_iterator( const vertex_const_iterator& i )
00346                 { *this = i; }
00347             virtual ~vertex_const_iterator() {}
00349             vertex_const_iterator&  operator=( const vertex_const_iterator& i )
00350                 { m_map_iterator = i.m_map_iterator; return *this; }
00352             GenVertex* operator*(void) const { return m_map_iterator->second; }
00354             vertex_const_iterator&  operator++(void)  //Pre-fix increment 
00355                 { ++m_map_iterator; return *this; }
00357             vertex_const_iterator   operator++(int)   //Post-fix increment
00358                 { vertex_const_iterator out(*this); ++(*this); return out; }
00360             bool  operator==( const vertex_const_iterator& a ) const
00361                 { return m_map_iterator == a.m_map_iterator; }
00363             bool  operator!=( const vertex_const_iterator& a ) const
00364                 { return !(m_map_iterator == a.m_map_iterator); }
00365         protected:
00367             std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator 
00368                                                                 m_map_iterator;
00369         private:
00371             vertex_const_iterator&  operator--(void);
00373             vertex_const_iterator   operator--(int);
00374         };
00375         friend class vertex_const_iterator;
00377         vertex_const_iterator      vertices_begin() const
00378             { return GenEvent::vertex_const_iterator( 
00379                 m_vertex_barcodes.begin() ); }
00381         vertex_const_iterator      vertices_end() const
00382             { return GenEvent::vertex_const_iterator(
00383                 m_vertex_barcodes.end() ); }
00384 
00385 
00387 
00391         class vertex_iterator :
00392           public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
00393             // Iterates over all vertices in this event
00394         public:
00396             vertex_iterator( 
00397                 const 
00398                 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator& i )
00399                 : m_map_iterator( i ) {}
00400             vertex_iterator() {}
00402             vertex_iterator( const vertex_iterator& i ) { *this = i; }
00403             virtual ~vertex_iterator() {}
00405             vertex_iterator&  operator=( const vertex_iterator& i ) {
00406                 m_map_iterator = i.m_map_iterator;
00407                 return *this;
00408             }
00410             operator vertex_const_iterator() const
00411                 { return vertex_const_iterator(m_map_iterator); }
00413             GenVertex*        operator*(void) const
00414                 { return m_map_iterator->second; }
00416             vertex_iterator&  operator++(void)  //Pre-fix increment 
00417                 { ++m_map_iterator;     return *this; }
00419             vertex_iterator   operator++(int)   //Post-fix increment
00420                 { vertex_iterator out(*this); ++(*this); return out; }
00422             bool              operator==( const vertex_iterator& a ) const
00423                 { return m_map_iterator == a.m_map_iterator; }
00425             bool              operator!=( const vertex_iterator& a ) const
00426                 { return !(m_map_iterator == a.m_map_iterator); }
00427         protected:
00429             std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator 
00430                                                                m_map_iterator;
00431         private:
00433             vertex_iterator&  operator--(void);
00435             vertex_iterator   operator--(int);
00436 
00437         };
00438         friend class vertex_iterator;
00440         vertex_iterator            vertices_begin() 
00441             { return GenEvent::vertex_iterator( 
00442                 m_vertex_barcodes.begin() ); }
00444         vertex_iterator            vertices_end()
00445             { return GenEvent::vertex_iterator(
00446                 m_vertex_barcodes.end() ); }
00447 
00448     public:
00450         // particle_iterator         //
00452         // Example of iterating over all particles in the event:
00453         //      for ( GenEvent::particle_const_iterator p = particles_begin();
00454         //            p != particles_end(); ++p ) {
00455         //         (*p)->print();
00456         //      }
00457         //
00458 
00460 
00464         class particle_const_iterator :
00465           public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
00466             // Iterates over all vertices in this event
00467         public:
00469             particle_const_iterator(
00470                 const std::map<int,HepMC::GenParticle*>::const_iterator& i )
00471                 : m_map_iterator(i) {}
00472             particle_const_iterator() {}
00474             particle_const_iterator( const particle_const_iterator& i )
00475                 { *this = i; }
00476             virtual ~particle_const_iterator() {}
00478             particle_const_iterator& operator=(
00479                 const particle_const_iterator& i )
00480                 { m_map_iterator = i.m_map_iterator; return *this; }
00482             GenParticle*        operator*(void) const
00483                 { return m_map_iterator->second; }
00485             particle_const_iterator&  operator++(void)  //Pre-fix increment 
00486                 { ++m_map_iterator; return *this; }
00488             particle_const_iterator   operator++(int)   //Post-fix increment
00489                 { particle_const_iterator out(*this); ++(*this); return out; }
00491             bool  operator==( const particle_const_iterator& a ) const
00492                 { return m_map_iterator == a.m_map_iterator; }
00494             bool  operator!=( const particle_const_iterator& a ) const
00495                 { return !(m_map_iterator == a.m_map_iterator); }
00496         protected:
00498             std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator;
00499         private:
00501             particle_const_iterator&  operator--(void);
00503             particle_const_iterator   operator--(int);
00504         };      
00505         friend class particle_const_iterator;
00507         particle_const_iterator      particles_begin() const
00508             { return GenEvent::particle_const_iterator( 
00509                 m_particle_barcodes.begin() ); }
00511         particle_const_iterator      particles_end() const
00512             { return GenEvent::particle_const_iterator(
00513                 m_particle_barcodes.end() ); }
00514 
00516 
00520         class particle_iterator :
00521           public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
00522             // Iterates over all vertices in this event
00523         public:
00525             particle_iterator( const std::map<int,HepMC::GenParticle*>::iterator& i )
00526                 : m_map_iterator( i ) {}
00527             particle_iterator() {}
00529             particle_iterator( const particle_iterator& i ) { *this = i; }
00530             virtual ~particle_iterator() {}
00532             particle_iterator&  operator=( const particle_iterator& i ) {
00533                 m_map_iterator = i.m_map_iterator;
00534                 return *this;
00535             }
00537             operator particle_const_iterator() const
00538                 { return particle_const_iterator(m_map_iterator); }
00540             GenParticle*        operator*(void) const
00541                 { return m_map_iterator->second; }
00543             particle_iterator&  operator++(void) 
00544                 { ++m_map_iterator;     return *this; }
00546             particle_iterator   operator++(int)   
00547                 { particle_iterator out(*this); ++(*this); return out; }
00549             bool              operator==( const particle_iterator& a ) const
00550                 { return m_map_iterator == a.m_map_iterator; }
00552             bool              operator!=( const particle_iterator& a ) const
00553                 { return !(m_map_iterator == a.m_map_iterator); }
00554         protected:
00556             std::map<int,HepMC::GenParticle*>::iterator m_map_iterator;
00557         private:
00559             particle_iterator&  operator--(void);
00561             particle_iterator   operator--(int);
00562         };
00563         friend class particle_iterator;
00565         particle_iterator particles_begin() 
00566             { return GenEvent::particle_iterator(
00567                 m_particle_barcodes.begin() ); }
00569         particle_iterator particles_end()
00570             { return GenEvent::particle_iterator(
00571                 m_particle_barcodes.end() ); }
00572 
00574     protected:
00575         //
00576         // Following methods intended for use by GenParticle/Vertex classes:
00577         // In general there is no reason they should be used elsewhere.
00579         bool         set_barcode( GenParticle* p, int suggested_barcode =false );
00581         bool         set_barcode( GenVertex*   v, int suggested_barcode =false );
00583         void         remove_barcode( GenParticle* p );
00585         void         remove_barcode( GenVertex*   v );
00586 
00587         void delete_all_vertices(); 
00588 
00589      private: // methods
00591         bool use_momentum_unit( Units::MomentumUnit );
00592         bool use_momentum_unit( std::string& );
00594         bool use_length_unit( Units::LengthUnit );
00595         bool use_length_unit( std::string& );
00596         
00597         // the following internal methods are used by read() and write()
00598 
00600         std::ostream & write_beam_particles( std::ostream &, 
00601                              std::pair<HepMC::GenParticle *,HepMC::GenParticle *> );
00603         std::ostream & write_vertex( std::ostream &, GenVertex const * );
00605         std::ostream & write_particle( std::ostream&, GenParticle const * );
00607         std::istream & find_file_type( std::istream & );
00609         std::istream & find_end_key( std::istream &, int & );
00611         std::istream & read_units( std::istream & );
00613         std::istream & read_weight_names( std::istream & );
00615         std::istream & process_event_line( std::istream &, int &, int &, int &, int & );
00616 
00617     private: // data members
00618         int                   m_signal_process_id;
00619         int                   m_event_number;  
00620         int                   m_mpi;        // number of multi paricle interactions
00621         double                m_event_scale;// energy scale, see hep-ph/0109068
00622         double                m_alphaQCD;   // QCD coupling, see hep-ph/0109068
00623         double                m_alphaQED;   // QED coupling, see hep-ph/0109068
00624         GenVertex*            m_signal_process_vertex;
00625         GenParticle*          m_beam_particle_1;
00626         GenParticle*          m_beam_particle_2;
00627         WeightContainer       m_weights; // weights for this event first weight
00628                                          // is used by default for hit and miss
00629         std::vector<long> m_random_states; // container of rndm num 
00630                                                // generator states
00631 
00632         std::map< int,HepMC::GenVertex*,std::greater<int> >   m_vertex_barcodes;
00633         std::map< int,HepMC::GenParticle*,std::less<int> >    m_particle_barcodes;
00634         GenCrossSection*         m_cross_section;             // undefined by default
00635         HeavyIon*             m_heavy_ion;            // undefined by default
00636         PdfInfo*              m_pdf_info;             // undefined by default
00637         Units::MomentumUnit   m_momentum_unit;    // default value set by configure switch
00638         Units::LengthUnit     m_position_unit;    // default value set by configure switch
00639 
00640     };
00641 
00642 
00644     // IO Free Functions     //
00646   
00648     std::ostream & operator << (std::ostream &, GenEvent &);
00650     std::istream & operator >> (std::istream &, GenEvent &);
00652     std::istream & set_input_units(std::istream &, 
00653                                    Units::MomentumUnit, Units::LengthUnit);
00655     std::ostream & write_HepMC_IO_block_begin(std::ostream & );
00657     std::ostream & write_HepMC_IO_block_end(std::ostream & );
00658 
00659 
00661     // INLINE Free Functions //
00663 
00664     // Implemented in terms of GenEvent::use_...
00665     inline GenEvent& convert_units(GenEvent & evt, Units::MomentumUnit m, Units::LengthUnit l)
00666     {
00667       evt.use_units(m, l);
00668       return evt;
00669     }
00670 
00672     // INLINE Access Methods //
00674 
00679     inline int GenEvent::signal_process_id() const 
00680     { return m_signal_process_id; }
00681 
00682     inline int GenEvent::event_number() const { return m_event_number; }
00683 
00686     inline int GenEvent::mpi() const { return m_mpi; }
00687 
00688     inline double GenEvent::event_scale() const { return m_event_scale; }
00689 
00690     inline double GenEvent::alphaQCD() const { return m_alphaQCD; }
00691 
00692     inline double GenEvent::alphaQED() const { return m_alphaQED; }
00693  
00694     inline GenVertex* GenEvent::signal_process_vertex() const {
00696         return m_signal_process_vertex;
00697     }  
00698 
00699     inline WeightContainer& GenEvent::weights() { return m_weights; }
00700 
00701     inline const WeightContainer& GenEvent::weights() const 
00702     { return m_weights; }
00703 
00704     inline GenCrossSection const * GenEvent::cross_section() const 
00705     { return m_cross_section; }
00706 
00707     inline GenCrossSection*  GenEvent::cross_section()  
00708     { return m_cross_section; }
00709 
00710     inline HeavyIon const * GenEvent::heavy_ion() const 
00711     { return m_heavy_ion; }
00712 
00713     inline HeavyIon*  GenEvent::heavy_ion()  
00714     { return m_heavy_ion; }
00715 
00716     inline PdfInfo const * GenEvent::pdf_info() const 
00717     { return m_pdf_info; }
00718 
00719     inline PdfInfo*  GenEvent::pdf_info()  
00720     { return m_pdf_info; }
00721 
00727     inline const std::vector<long>& GenEvent::random_states() const 
00728     { return m_random_states; }
00729 
00730     inline void GenEvent::set_signal_process_id( int id )
00731     { m_signal_process_id = id; }
00732 
00733     inline void GenEvent::set_event_number( int eventno )
00734     { m_event_number = eventno; }
00735 
00737     inline void GenEvent::set_mpi( int nmpi )
00738     { m_mpi = nmpi; }
00739 
00740 
00741     inline void GenEvent::set_event_scale( double sc ) { m_event_scale = sc; }
00742 
00743     inline void GenEvent::set_alphaQCD( double a ) { m_alphaQCD = a; }
00744 
00745     inline void GenEvent::set_alphaQED( double a ) { m_alphaQED = a; }
00746 
00747     inline void GenEvent::set_signal_process_vertex( GenVertex* vtx ) {
00748         m_signal_process_vertex = vtx;
00749         if ( m_signal_process_vertex ) add_vertex( m_signal_process_vertex );
00750     }
00751 
00752     inline void GenEvent::set_cross_section( const GenCrossSection& xs )
00753     { 
00754         delete m_cross_section;
00755         m_cross_section = new GenCrossSection(xs); 
00756     }
00757 
00758     inline void GenEvent::set_heavy_ion( const HeavyIon& ion )
00759     { 
00760         delete m_heavy_ion;
00761         m_heavy_ion = new HeavyIon(ion); 
00762     }
00763 
00764     inline void GenEvent::set_pdf_info( const PdfInfo& p )
00765     { 
00766         delete m_pdf_info;
00767         m_pdf_info = new PdfInfo(p); 
00768     }
00769 
00770     inline void GenEvent::set_random_states( const std::vector<long>&
00771                                              randomstates )
00772     { m_random_states = randomstates; }
00773 
00774     inline void GenEvent::remove_barcode( GenParticle* p )
00775     { m_particle_barcodes.erase( p->barcode() ); }
00776 
00777     inline void GenEvent::remove_barcode( GenVertex* v )
00778     { m_vertex_barcodes.erase( v->barcode() ); }
00779 
00798     inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
00799     { 
00800         std::map<int,HepMC::GenParticle*>::const_iterator i 
00801             = m_particle_barcodes.find(barCode);
00802         return ( i != m_particle_barcodes.end() ) ? (*i).second : 0;
00803     }
00804 
00823     inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const
00824     {
00825         std::map<int,GenVertex*,std::greater<int> >::const_iterator i 
00826             = m_vertex_barcodes.find(barCode);
00827         return ( i != m_vertex_barcodes.end() ) ? (*i).second : 0;
00828     }
00829 
00830     inline int GenEvent::particles_size() const {
00831         return (int)m_particle_barcodes.size();
00832     }
00833     inline bool GenEvent::particles_empty() const {
00834         return (bool)m_particle_barcodes.empty();
00835     }
00836     inline int GenEvent::vertices_size() const {
00837         return (int)m_vertex_barcodes.size();
00838     }
00839     inline bool GenEvent::vertices_empty() const {
00840         return (bool)m_vertex_barcodes.empty();
00841     }
00842     
00843     // beam particles
00844     inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const {
00845         return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2);
00846     }
00847 
00848     // units
00849     inline Units::MomentumUnit GenEvent::momentum_unit() const {
00850         return m_momentum_unit; 
00851     }
00852     inline Units::LengthUnit   GenEvent::length_unit()   const {
00853         return m_position_unit; 
00854     }
00855     
00856     inline void GenEvent::use_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) { 
00857        use_momentum_unit( new_m );
00858        use_length_unit( new_l );
00859     }
00860     
00861     inline void GenEvent::use_units( std::string& new_m, std::string& new_l ) { 
00862        use_momentum_unit( new_m );
00863        use_length_unit( new_l );
00864     }
00865     
00866     inline void GenEvent::define_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) { 
00867         m_momentum_unit = new_m; 
00868         m_position_unit = new_l; 
00869     }
00870 
00871 } // HepMC
00872 
00873 #endif  // HEPMC_GEN_EVENT_H
00874 
00875 //--------------------------------------------------------------------------
00876 
00877 

Generated on Fri Feb 17 00:31:25 2012 for HepMC by  doxygen 1.4.7