hepmc - Blame information for rev 92

Subversion Repositories:
Rev:
Rev Author Line No. Line
2 garren 1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_GEN_EVENT_H
3 #define HEPMC_GEN_EVENT_H
4  
5 //////////////////////////////////////////////////////////////////////////
6 // Matt.Dobbs@Cern.CH, September 1999, refer to:
7 // M. Dobbs and J.B. Hansen, "The HepMC C++ Monte Carlo Event Record for
8 // High Energy Physics", Computer Physics Communications (to be published).
9 //
10 // Event record for MC generators (for use at any stage of generation)
11 //////////////////////////////////////////////////////////////////////////
12 //
13 // This class is intended as both a "container class" ( to store a MC
14 //  event for interface between MC generators and detector simulation )
15 //  and also as a "work in progress class" ( that could be used inside
16 //  a generator and modified as the event is built ).
17 //
18 // Iterators are provided which allow the user to easily obtain a
19 //  list of particles or vertices in an event --- this list can be filled
20 //  subject to some sort of selection criteria. Examples are given below
21 //  ( see HepMC::copy_if and std::copy )
22  
65 garren 23 ///
24 /// \namespace HepMC
25 /// All classes in the HepMC packages are in the HepMC namespace
26 ///
2 garren 27 namespace HepMC {
65 garren 28  
2 garren 29     // To create a list from an iterator, use: (i.e. for a list of particles);
30     // #include <algorithm>
31     //     list<GenParticle*> thelist;
32     //     copy( evt->particles_begin(), evt->particles_end(),
33     //           back_inserter(thelist) );
34     // to create a list subject to a condition (predicate) use:
35     //     list<GenParticle*> thelist;
36     //     HepMC::copy_if( evt->particles_begin(), evt->particles_end(),
37     //                     back_inserter(thelist), is_photon() );
38     // where is_photon() is a predicate like:
39     //     class is_photon {
40     //       public:
41     //         bool operator() ( const GenParticle* p ) {
42     //             if ( p && p->pdg_id() == 22 ) return 1;
43     //             return 0;
44     //         }
45     //     };
46     // which the user defines herself.
65 garren 47  
48     /// define the type of iterator to use
2 garren 49     template <class InputIterator, class OutputIterator, class Predicate>
50     void copy_if( InputIterator first, InputIterator last, OutputIterator out,
51                   Predicate pred ) {
52         for ( ; first != last; ++first ) { if ( pred(*first) ) out = *first; }
53     }
54 } // HepMC
55  
56 // Since a container of all vertices in the event is maintained, the time
57 //  required to loop over all vertices (or particles) is very fast -- and
58 //  the user does not gain much by first making his own list.
59 //  (this is not true for the GenVertex:: versions of these iterators, which
60 //   allow you to specify the vertex starting point and range)
61  
62 // Data Members:
63 // signal_process_id()   The integer ID that uniquely specifies this signal
64 //                       process, i.e. MSUB in Pythia. It is necessary to
65 //                       package this with each event rather than with the run
66 //                       because many processes may be generated within one
67 //                       run.
68 // event_number()        Strictly speaking we cannot think of any reason that
69 //                       an event would need to know its own event number, it
70 //                       is more likely something that would be assigned by
71 //                       a database. It is included anyway (tradition?) since
72 //                       we expect it may be useful for debugging. It can
73 //                       be reset later by a database.
74 // signal_process_vertex() pointer to the vertex containing the signal process
75 // weights()             Vector of doubles which specify th weight of the evnt,
76 //                       the first entry will be the "event weight" used for
77 //                       hit and miss etc., but a general vector is used to
78 //                       allow for reweighting etc. We envision a list of
79 //                       WeightTags to be included with a run class which
80 //                       would specify the meaning of the Weights .
81 // random_states()       Vector of integers which specify the random number
82 //                       generator's state for this event. It is left to the
83 //                       generator to make use of this. We envision a vector of
84 //                       RndmStatesTags to be included with a run class which
85 //                       would specify the meaning of the random_states.
86 //
87 ///////////////////////
88 // Memory allocation //
89 ///////////////////////
90 // -When a vertex (particle) is added to a event (vertex), it is "adopted"
91 //  and becomes the responsibility of the event (vertex) to delete that
92 //  particle.
93 // -objects responsible for deleting memory:
94 //    -events delete included vertices
95 //    -each vertex deletes its outgoing particles which do not have decay
96 //     vertices
97 //    -each vertex deletes its incoming particles which do not
98 //     have creation vertices
99 //
100 ////////////////////////
101 // About the Barcodes //
102 ////////////////////////
103 // - each vertex or particle has a barcode, which is just an integer which
104 //   uniquely identifies it inside the event (i.e. there is a one to one
105 //   mapping between particle memory addresses and particle barcodes... and
106 //   the same applied for vertices)
107 // - The value of a barcode has NO MEANING and NO ORDER!
108 //   For the user's convenience, when an event is read in via an IO_method
109 //   from an indexed list (like the HEPEVT common block), then the index will
110 //   become the barcode for that particle.
111 // - particle barcodes are always positive integers
112 //   vertex barcodes are always negative integers
113 //   The barcodes are chosen and set automatically when a vertex or particle
114 //   comes under the ownership of an event (i.e. it is contained in an event).
115 // - You can tell when a particle or vertex is owned, because its
116 //   parent_event() return value will return a pointer to the event which owns
117 //   it (or null if its an orphan).
118 //
119  
120 #include "HepMC/GenVertex.h"
121 #include "HepMC/GenParticle.h"
122 #include "HepMC/WeightContainer.h"
14 garren 123 #include "HepMC/HeavyIon.h"
36 garren 124 #include "HepMC/PdfInfo.h"
2 garren 125 #include <map>
126 #include <vector>
127 #include <algorithm>
128 #include <iostream>
129  
130 namespace HepMC {
131  
65 garren 132     //! The GenEvent class is the core of HepMC
133  
134     ///
135     /// \class GenEvent
136     /// HepMC::GenEvent contains information about generated particles.
137     /// GenEvent is structured as a set of vertices which contain the particles.
138     ///
2 garren 139     class GenEvent {
140         friend class GenParticle;
141         friend class GenVertex;  
142     public:
92 garren 143         /// default constructor creates null pointers to HeavyIon and PdfInfo
2 garren 144         GenEvent( int signal_process_id = 0, int event_number = 0,
145                   GenVertex* signal_vertex = 0,
146                   const WeightContainer& weights = std::vector<double>(),
92 garren 147                   const std::vector<long int>& randomstates = std::vector<long int>() );
148         /// explicit constructor that takes HeavyIon and PdfInfo
149         GenEvent( int signal_process_id, int event_number,
150                   GenVertex* signal_vertex, const WeightContainer& weights,
151                   const std::vector<long int>& randomstates,
152                   const HeavyIon& ion, const PdfInfo& pdf );
65 garren 153         GenEvent( const GenEvent& inevent );          //!< deep copy
154         GenEvent& operator=( const GenEvent& inevent ); //!< make a deep copy
155         virtual ~GenEvent(); //!<deletes all vertices/particles in this evt
2 garren 156  
65 garren 157         void print( std::ostream& ostr = std::cout ) const; //!< dumps to ostr
2 garren 158  
65 garren 159         /// assign a barcode to a particle
2 garren 160         GenParticle* barcode_to_particle( int barCode ) const;
65 garren 161         /// assign a barcode to a vertex
2 garren 162         GenVertex*   barcode_to_vertex(   int barCode ) const;
163  
164         ////////////////////
165         // access methods //
166         ////////////////////
167  
65 garren 168         int signal_process_id() const; //!<  unique signal process id
169         int event_number() const; //!<  event number
170         double event_scale() const; //!< energy scale, see hep-ph/0109068
171         double alphaQCD() const; //!<  QCD coupling, see hep-ph/0109068
172         double alphaQED() const; //!<  QED coupling, see hep-ph/0109068
173         /// pointer to the vertex containing the signal process
2 garren 174         GenVertex* signal_process_vertex() const;
175  
65 garren 176         /// direct access to the weights container is allowed.
177         /// Thus you can use myevt.weights()[2];
178         /// to access element 2 of the weights.
179         /// or use myevt.weights().push_back( mywgt ); to add an element.
180         /// and you can set the weights with myevt.weights() = myvector;
181         WeightContainer&        weights(); //!< direct access to WeightContainer
182         const WeightContainer&  weights() const; //!< direct access to WeightContainer
2 garren 183  
65 garren 184         /// access the HeavyIon container if it exists
92 garren 185         HeavyIon* const          heavy_ion() const;
186         HeavyIon*                heavy_ion();
65 garren 187         /// access the PdfInfo container if it exists
92 garren 188         PdfInfo* const           pdf_info() const;
189         PdfInfo*                 pdf_info();
14 garren 190  
65 garren 191         /// vector of integers containing information about the random state
2 garren 192         std::vector<long int> random_states() const;
193  
65 garren 194         void set_signal_process_id( int id ); //!< set unique signal process id
195         void set_event_number( int eventno ); //!< set event number
196         void set_event_scale( double scale ); //!< set energy scale
197         void set_alphaQCD( double a ); //!< set QCD coupling
198         void set_alphaQED( double a ); //!< set QED coupling
199  
200         /// set pointer to the vertex containing the signal process
2 garren 201         void set_signal_process_vertex( GenVertex* );
65 garren 202         /// provide random state information
2 garren 203         void set_random_states( const std::vector<long int>& randomstates );
204  
65 garren 205         /// provide a pointer to the HeavyIon container
92 garren 206         void set_heavy_ion( const HeavyIon& ion );
65 garren 207         /// provide a pointer to the PdfInfo container
92 garren 208         void set_pdf_info( const PdfInfo& p );
14 garren 209  
65 garren 210         /// how many particle barcodes exist?
2 garren 211         int     particles_size() const;
65 garren 212         /// return true if there are no particle barcodes
2 garren 213         bool    particles_empty() const;
65 garren 214         /// how many vertex barcodes exist?
2 garren 215         int     vertices_size() const;
65 garren 216         /// return true if there are no vertex barcodes
2 garren 217         bool    vertices_empty() const;
218  
65 garren 219         bool    add_vertex( GenVertex* vtx );    //!< adds to evt and adopts
220         bool    remove_vertex( GenVertex* vtx ); //!< erases vtx from evt,
2 garren 221  
222     public:
223         ///////////////////////////////
224         // vertex_iterators          //
225         ///////////////////////////////
226         // Note:  the XXX_iterator is "resolvable" as XXX_const_iterator, but
227         //  not the reverse, which is consistent with STL,
228         //  see Musser, Derge, Saini 2ndEd. p. 69,70.
65 garren 229  
230         //!  const vertex iterator
231  
232         /// \class  vertex_const_iterator
233         /// HepMC::GenEvent::vertex_const_iterator
234         /// is used to iterate over all vertices in the event.
2 garren 235         class vertex_const_iterator :
236           public std::iterator<std::forward_iterator_tag,GenVertex*,ptrdiff_t>{
237             // Iterates over all vertices in this event
238         public:
65 garren 239             /// constructor requiring vertex information
2 garren 240             vertex_const_iterator(
241                 const
242                 std::map<int,GenVertex*,std::greater<int> >::const_iterator& i)
243                 : m_map_iterator(i) {}
244             vertex_const_iterator() {}
65 garren 245             /// copy constructor
2 garren 246             vertex_const_iterator( const vertex_const_iterator& i )
247                 { *this = i; }
248             virtual ~vertex_const_iterator() {}
65 garren 249             /// make a copy
2 garren 250             vertex_const_iterator&  operator=( const vertex_const_iterator& i )
251                 { m_map_iterator = i.m_map_iterator; return *this; }
65 garren 252             /// return a pointer to a GenVertex
2 garren 253             GenVertex* operator*(void) const { return m_map_iterator->second; }
65 garren 254             /// Pre-fix increment
2 garren 255             vertex_const_iterator&  operator++(void)  //Pre-fix increment
256                 { ++m_map_iterator; return *this; }
65 garren 257             /// Post-fix increment
2 garren 258             vertex_const_iterator   operator++(int)   //Post-fix increment
259                 { vertex_const_iterator out(*this); ++(*this); return out; }
65 garren 260             /// equality
2 garren 261             bool  operator==( const vertex_const_iterator& a ) const
262                 { return m_map_iterator == a.m_map_iterator; }
65 garren 263             /// inequality
2 garren 264             bool  operator!=( const vertex_const_iterator& a ) const
265                 { return !(m_map_iterator == a.m_map_iterator); }
266         protected:
65 garren 267             /// const iterator to a vertex map
2 garren 268             std::map<int,GenVertex*,std::greater<int> >::const_iterator
269                                                                 m_map_iterator;
270         };
271         friend class vertex_const_iterator;
65 garren 272         /// begin vertex iteration
2 garren 273         vertex_const_iterator      vertices_begin() const
274             { return GenEvent::vertex_const_iterator(
275                 m_vertex_barcodes.begin() ); }
65 garren 276         /// end vertex iteration
2 garren 277         vertex_const_iterator      vertices_end() const
278             { return GenEvent::vertex_const_iterator(
279                 m_vertex_barcodes.end() ); }
280  
65 garren 281  
282         //!  non-const vertex iterator
283  
284         /// \class  vertex_iterator
285         /// HepMC::GenEvent::vertex_iterator
286         /// is used to iterate over all vertices in the event.
2 garren 287         class vertex_iterator :
288           public std::iterator<std::forward_iterator_tag,GenVertex*,ptrdiff_t>{
289             // Iterates over all vertices in this event
290         public:
65 garren 291             /// constructor requiring vertex information
2 garren 292             vertex_iterator(
293                 const
294                 std::map<int,GenVertex*,std::greater<int> >::iterator& i )
295                 : m_map_iterator( i ) {}
296             vertex_iterator() {}
65 garren 297             /// copy constructor
2 garren 298             vertex_iterator( const vertex_iterator& i ) { *this = i; }
299             virtual ~vertex_iterator() {}
65 garren 300             /// make a copy
2 garren 301             vertex_iterator&  operator=( const vertex_iterator& i ) {
302                 m_map_iterator = i.m_map_iterator;
303                 return *this;
304             }
65 garren 305             /// const vertex iterator
2 garren 306             operator vertex_const_iterator() const
307                 { return vertex_const_iterator(m_map_iterator); }
65 garren 308             /// return a pointer to a GenVertex
2 garren 309             GenVertex*        operator*(void) const
310                 { return m_map_iterator->second; }
65 garren 311             /// Pre-fix increment
2 garren 312             vertex_iterator&  operator++(void)  //Pre-fix increment
313                 { ++m_map_iterator;     return *this; }
65 garren 314             /// Post-fix increment
2 garren 315             vertex_iterator   operator++(int)   //Post-fix increment
316                 { vertex_iterator out(*this); ++(*this); return out; }
65 garren 317             /// equality
2 garren 318             bool              operator==( const vertex_iterator& a ) const
319                 { return m_map_iterator == a.m_map_iterator; }
65 garren 320             /// inequality
2 garren 321             bool              operator!=( const vertex_iterator& a ) const
322                 { return !(m_map_iterator == a.m_map_iterator); }
323         protected:
65 garren 324             /// iterator to the vertex map
2 garren 325             std::map<int,GenVertex*,std::greater<int> >::iterator
326                                                                m_map_iterator;
327         };
328         friend class vertex_iterator;
65 garren 329         /// begin vertex iteration
2 garren 330         vertex_iterator            vertices_begin()
331             { return GenEvent::vertex_iterator(
332                 m_vertex_barcodes.begin() ); }
65 garren 333         /// end vertex iteration
2 garren 334         vertex_iterator            vertices_end()
335             { return GenEvent::vertex_iterator(
336                 m_vertex_barcodes.end() ); }
337  
338     public:
339         ///////////////////////////////
340         // particle_iterator         //
341         ///////////////////////////////
342         // Example of iterating over all particles in the event:
343         //      for ( GenEvent::particle_const_iterator p = particles_begin();
344         //            p != particles_end(); ++p ) {
345         //         (*p)->print();
346         //      }
347         //
65 garren 348  
349         //!  const particle iterator
350  
351         /// \class  particle_const_iterator
352         /// HepMC::GenEvent::particle_const_iterator
353         /// is used to iterate over all particles in the event.
2 garren 354         class particle_const_iterator :
355           public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
356             // Iterates over all vertices in this event
357         public:
65 garren 358             /// iterate over particles
2 garren 359             particle_const_iterator(
360                 const std::map<int,GenParticle*>::const_iterator& i )
361                 : m_map_iterator(i) {}
362             particle_const_iterator() {}
65 garren 363             /// copy constructor
2 garren 364             particle_const_iterator( const particle_const_iterator& i )
365                 { *this = i; }
366             virtual ~particle_const_iterator() {}
65 garren 367             /// make a copy
2 garren 368             particle_const_iterator& operator=(
369                 const particle_const_iterator& i )
370                 { m_map_iterator = i.m_map_iterator; return *this; }
65 garren 371             /// return a pointer to GenParticle
2 garren 372             GenParticle*        operator*(void) const
373                 { return m_map_iterator->second; }
65 garren 374             /// Pre-fix increment
2 garren 375             particle_const_iterator&  operator++(void)  //Pre-fix increment
376                 { ++m_map_iterator; return *this; }
65 garren 377             /// Post-fix increment
2 garren 378             particle_const_iterator   operator++(int)   //Post-fix increment
379                 { particle_const_iterator out(*this); ++(*this); return out; }
65 garren 380             /// equality
2 garren 381             bool  operator==( const particle_const_iterator& a ) const
382                 { return m_map_iterator == a.m_map_iterator; }
65 garren 383             /// inequality
2 garren 384             bool  operator!=( const particle_const_iterator& a ) const
385                 { return !(m_map_iterator == a.m_map_iterator); }
386         protected:
65 garren 387             /// const iterator to the GenParticle map
2 garren 388             std::map<int,GenParticle*>::const_iterator m_map_iterator;
389         };     
390         friend class particle_const_iterator;
65 garren 391         /// begin particle iteration
2 garren 392         particle_const_iterator      particles_begin() const
393             { return GenEvent::particle_const_iterator(
394                 m_particle_barcodes.begin() ); }
65 garren 395         /// end particle iteration
2 garren 396         particle_const_iterator      particles_end() const
397             { return GenEvent::particle_const_iterator(
398                 m_particle_barcodes.end() ); }
399  
65 garren 400         //!  non-const particle iterator
401  
402         /// \class  particle_iterator
403         /// HepMC::GenEvent::particle_iterator
404         /// is used to iterate over all particles in the event.
405         class particle_iterator :
2 garren 406           public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
407             // Iterates over all vertices in this event
408         public:
65 garren 409             /// iterate over particles
2 garren 410             particle_iterator( const std::map<int,GenParticle*>::iterator& i )
411                 : m_map_iterator( i ) {}
412             particle_iterator() {}
65 garren 413             /// copy constructor
2 garren 414             particle_iterator( const particle_iterator& i ) { *this = i; }
415             virtual ~particle_iterator() {}
65 garren 416             /// make a copy
2 garren 417             particle_iterator&  operator=( const particle_iterator& i ) {
418                 m_map_iterator = i.m_map_iterator;
419                 return *this;
420             }
65 garren 421             /// const particle iterator
2 garren 422             operator particle_const_iterator() const
423                 { return particle_const_iterator(m_map_iterator); }
65 garren 424             /// return pointer to GenParticle
2 garren 425             GenParticle*        operator*(void) const
426                 { return m_map_iterator->second; }
65 garren 427             /// Pre-fix increment
428             particle_iterator&  operator++(void)
2 garren 429                 { ++m_map_iterator;     return *this; }
65 garren 430             /// Post-fix increment
431             particle_iterator   operator++(int)  
2 garren 432                 { particle_iterator out(*this); ++(*this); return out; }
65 garren 433             /// equality
2 garren 434             bool              operator==( const particle_iterator& a ) const
435                 { return m_map_iterator == a.m_map_iterator; }
65 garren 436             /// inequality
2 garren 437             bool              operator!=( const particle_iterator& a ) const
438                 { return !(m_map_iterator == a.m_map_iterator); }
439         protected:
65 garren 440             /// iterator for GenParticle map
2 garren 441             std::map<int,GenParticle*>::iterator m_map_iterator;
442         };
443         friend class particle_iterator;
65 garren 444         /// begin particle iteration
2 garren 445         particle_iterator particles_begin()
446             { return GenEvent::particle_iterator(
447                 m_particle_barcodes.begin() ); }
65 garren 448         /// end particle iteration
2 garren 449         particle_iterator particles_end()
450             { return GenEvent::particle_iterator(
451                 m_particle_barcodes.end() ); }
452  
453         ////////////////////////////////////////////////
454     protected:
455         //
456         // Following methods intended for use by GenParticle/Vertex classes:
457         // In general there is no reason they should be used elsewhere.
65 garren 458         /// set the barcode - intended for use by GenParticle
2 garren 459         bool         set_barcode( GenParticle* p, int suggested_barcode =0 );
65 garren 460         /// set the barcode - intended for use by GenVertex
2 garren 461         bool         set_barcode( GenVertex*   v, int suggested_barcode =0 );
65 garren 462         ///  intended for use by GenParticle
2 garren 463         void         remove_barcode( GenParticle* p );
65 garren 464         ///  intended for use by GenVertex
2 garren 465         void         remove_barcode( GenVertex*   v );
466  
65 garren 467         static unsigned int counter(); //!<num GenEvent objects in memory
468         void delete_all_vertices(); //!<delete all vertices owned by this event
2 garren 469  
470     private: // data members
471         int                   m_signal_process_id;
472         int                   m_event_number;  
473         double                m_event_scale;// energy scale, see hep-ph/0109068
474         double                m_alphaQCD;   // QCD coupling, see hep-ph/0109068
475         double                m_alphaQED;   // QED coupling, see hep-ph/0109068
476         GenVertex*            m_signal_process_vertex;
477         WeightContainer       m_weights; // weights for this event first weight
478                                          // is used by default for hit and miss
479         std::vector<long int> m_random_states; // container of rndm num
480                                                // generator states
481  
482         std::map< int,GenVertex*,std::greater<int> >   m_vertex_barcodes;
483         std::map< int,GenParticle*,std::less<int> >    m_particle_barcodes;
14 garren 484         HeavyIon*        m_heavy_ion;         // undefined by default
36 garren 485         PdfInfo*         m_pdf_info;          // undefined by default
2 garren 486  
487         static unsigned int   s_counter;
488     };
489  
490     ///////////////////////////
491     // INLINE Access Methods //
492     ///////////////////////////
493  
65 garren 494     ///  The integer ID that uniquely specifies this signal
495     ///  process, i.e. MSUB in Pythia. It is necessary to
496     ///  package this with each event rather than with the run
497     ///  because many processes may be generated within one run.
2 garren 498     inline int GenEvent::signal_process_id() const
499     { return m_signal_process_id; }
500  
501     inline int GenEvent::event_number() const { return m_event_number; }
502  
503     inline double GenEvent::event_scale() const { return m_event_scale; }
504  
505     inline double GenEvent::alphaQCD() const { return m_alphaQCD; }
506  
507     inline double GenEvent::alphaQED() const { return m_alphaQED; }
508  
509     inline GenVertex* GenEvent::signal_process_vertex() const {
65 garren 510         /// returns a (mutable) pointer to the signal process vertex
2 garren 511         return m_signal_process_vertex;
512     }  
513  
514     inline WeightContainer& GenEvent::weights() { return m_weights; }
515  
516     inline const WeightContainer& GenEvent::weights() const
517     { return m_weights; }
518  
92 garren 519     inline HeavyIon* const GenEvent::heavy_ion() const
14 garren 520     { return m_heavy_ion; }
521  
92 garren 522     inline HeavyIon*  GenEvent::heavy_ion()  
523     { return m_heavy_ion; }
524  
525     inline PdfInfo* const GenEvent::pdf_info() const
36 garren 526     { return m_pdf_info; }
527  
92 garren 528     inline PdfInfo*  GenEvent::pdf_info()  
529     { return m_pdf_info; }
530  
65 garren 531     ///  Vector of integers which specify the random number
532     ///  generator's state for this event. It is left to the
533     ///  generator to make use of this. We envision a vector of
534     ///  RndmStatesTags to be included with a run class which
535     ///  would specify the meaning of the random_states.
2 garren 536     inline std::vector<long int> GenEvent::random_states() const
537     { return m_random_states; }
538  
539     inline void GenEvent::set_signal_process_id( int id )
540     { m_signal_process_id = id; }
541  
542     inline void GenEvent::set_event_number( int eventno )
543     { m_event_number = eventno; }
544  
545  
546     inline void GenEvent::set_event_scale( double sc ) { m_event_scale = sc; }
547  
548     inline void GenEvent::set_alphaQCD( double a ) { m_alphaQCD = a; }
549  
550     inline void GenEvent::set_alphaQED( double a ) { m_alphaQED = a; }
551  
552     inline void GenEvent::set_signal_process_vertex( GenVertex* vtx ) {
553         m_signal_process_vertex = vtx;
554         if ( m_signal_process_vertex ) add_vertex( m_signal_process_vertex );
555     }
556  
92 garren 557     inline void GenEvent::set_heavy_ion( const HeavyIon& ion )
558     { m_heavy_ion = new HeavyIon(ion); }
14 garren 559  
92 garren 560     inline void GenEvent::set_pdf_info( const PdfInfo& p )
561     { m_pdf_info = new PdfInfo(p); }
36 garren 562  
2 garren 563     inline void GenEvent::set_random_states( const std::vector<long int>&
564                                              randomstates )
565     { m_random_states = randomstates; }
566  
567     inline void GenEvent::remove_barcode( GenParticle* p )
568     { m_particle_barcodes.erase( p->barcode() ); }
569  
570     inline void GenEvent::remove_barcode( GenVertex* v )
571     { m_vertex_barcodes.erase( v->barcode() ); }
572  
65 garren 573     /// Each vertex or particle has a barcode, which is just an integer which
574     /// uniquely identifies it inside the event (i.e. there is a one to one
575     /// mapping between particle memory addresses and particle barcodes... and
576     /// the same applied for vertices).
577     ///
578     /// The value of a barcode has NO MEANING and NO ORDER!
579     /// For the user's convenience, when an event is read in via an IO_method
580     /// from an indexed list (like the HEPEVT common block), then the index will
581     /// become the barcode for that particle.
582     ///
583     /// Particle barcodes are always positive integers.
584     /// The barcodes are chosen and set automatically when a vertex or particle
585     /// comes under the ownership of an event (i.e. it is contained in an event).
2 garren 586     inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
587     {
588         std::map<int,GenParticle*>::const_iterator i
589             = m_particle_barcodes.find(barCode);
590         return ( i != m_particle_barcodes.end() ) ? (*i).second : 0;
591     }
592  
65 garren 593     /// Each vertex or particle has a barcode, which is just an integer which
594     /// uniquely identifies it inside the event (i.e. there is a one to one
595     /// mapping between particle memory addresses and particle barcodes... and
596     /// the same applied for vertices).
597     ///
598     /// The value of a barcode has NO MEANING and NO ORDER!
599     /// For the user's convenience, when an event is read in via an IO_method
600     /// from an indexed list (like the HEPEVT common block), then the index will
601     /// become the barcode for that particle.
602     ///
603     /// Vertex barcodes are always negative integers.
604     /// The barcodes are chosen and set automatically when a vertex or particle
605     /// comes under the ownership of an event (i.e. it is contained in an event).
2 garren 606     inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const
607     {
608         std::map<int,GenVertex*,std::greater<int> >::const_iterator i
609             = m_vertex_barcodes.find(barCode);
610         return ( i != m_vertex_barcodes.end() ) ? (*i).second : 0;
611     }
612  
613     inline int GenEvent::particles_size() const {
614         return (int)m_particle_barcodes.size();
615     }
616     inline bool GenEvent::particles_empty() const {
617         return (bool)m_particle_barcodes.empty();
618     }
619     inline int GenEvent::vertices_size() const {
620         return (int)m_vertex_barcodes.size();
621     }
622     inline bool GenEvent::vertices_empty() const {
623         return (bool)m_vertex_barcodes.empty();
624     }
625  
626 } // HepMC
627  
628 #endif  // HEPMC_GEN_EVENT_H
629  
630 //--------------------------------------------------------------------------
631  
632