StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GenEvent.h
1 //--------------------------------------------------------------------------
2 #ifndef HEPMC_GEN_EVENT_H
3 #define HEPMC_GEN_EVENT_H
4 
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)
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 
27 namespace HepMC {
28 
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() ( GenParticle const * p ) {
42  // if ( p && p->pdg_id() == 22 ) return true;
43  // return false;
44  // }
45  // };
46  // which the user defines herself.
47 
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 // mpi() The number of multi parton interactions in the event.
75 // This is NOT beam pileup. Set to -1 by default.
76 // beam_particles() A pair of pointers to the incoming beam particles.
77 // signal_process_vertex() pointer to the vertex containing the signal process
78 // weights() Vector of doubles which specify th weight of the evnt,
79 // the first entry will be the "event weight" used for
80 // hit and miss etc., but a general vector is used to
81 // allow for reweighting etc. We envision a list of
82 // WeightTags to be included with a run class which
83 // would specify the meaning of the Weights .
84 // random_states() Vector of integers which specify the random number
85 // generator's state for this event. It is left to the
86 // generator to make use of this. We envision a vector of
87 // RndmStatesTags to be included with a run class which
88 // would specify the meaning of the random_states.
89 //
91 // Memory allocation //
93 // -When a vertex (particle) is added to a event (vertex), it is "adopted"
94 // and becomes the responsibility of the event (vertex) to delete that
95 // particle.
96 // -objects responsible for deleting memory:
97 // -events delete included vertices
98 // -each vertex deletes its outgoing particles which do not have decay
99 // vertices
100 // -each vertex deletes its incoming particles which do not
101 // have creation vertices
102 //
104 // About the Barcodes //
106 // - each vertex or particle has a barcode, which is just an integer which
107 // uniquely identifies it inside the event (i.e. there is a one to one
108 // mapping between particle memory addresses and particle barcodes... and
109 // the same applied for vertices)
110 // - The value of a barcode has NO MEANING and NO ORDER!
111 // For the user's convenience, when an event is read in via an IO_method
112 // from an indexed list (like the HEPEVT common block), then the index will
113 // become the barcode for that particle.
114 // - particle barcodes are always positive integers
115 // vertex barcodes are always negative integers
116 // The barcodes are chosen and set automatically when a vertex or particle
117 // comes under the ownership of an event (i.e. it is contained in an event).
118 // - You can tell when a particle or vertex is owned, because its
119 // parent_event() return value will return a pointer to the event which owns
120 // it (or null if its an orphan).
121 // - Please note that the barcodes are intended for internal use within HepMC
122 // as a unique identifier for the particles and vertices.
123 // Using the barcode to encode extra information is an abuse of
124 // the barcode data member and causes confusion among users.
125 //
126 
127 #include "HepMC/GenVertex.h"
128 #include "HepMC/GenParticle.h"
129 #include "HepMC/WeightContainer.h"
130 #include "HepMC/GenCrossSection.h"
131 #include "HepMC/HeavyIon.h"
132 #include "HepMC/PdfInfo.h"
133 #include "HepMC/Units.h"
134 #include "HepMC/HepMCDefs.h"
135 #include <map>
136 #include <string>
137 #include <vector>
138 #include <algorithm>
139 #include <iostream>
140 
141 namespace HepMC {
142 
143  class GenEventVertexRange;
144  class ConstGenEventVertexRange;
145  class GenEventParticleRange;
146  class ConstGenEventParticleRange;
147 
149 
155  class GenEvent {
156  friend class GenParticle;
157  friend class GenVertex;
158  public:
160  GenEvent( int signal_process_id = 0, int event_number = 0,
161  GenVertex* signal_vertex = 0,
162  const WeightContainer& weights = std::vector<double>(),
163  const std::vector<long>& randomstates = std::vector<long>(),
164  Units::MomentumUnit = Units::default_momentum_unit(),
165  Units::LengthUnit = Units::default_length_unit() );
168  GenVertex* signal_vertex, const WeightContainer& weights,
169  const std::vector<long>& randomstates,
170  const HeavyIon& ion, const PdfInfo& pdf,
171  Units::MomentumUnit = Units::default_momentum_unit(),
172  Units::LengthUnit = Units::default_length_unit() );
174  GenEvent( Units::MomentumUnit, Units::LengthUnit,
175  int signal_process_id = 0, int event_number = 0,
176  GenVertex* signal_vertex = 0,
177  const WeightContainer& weights = std::vector<double>(),
178  const std::vector<long>& randomstates = std::vector<long>() );
180  GenEvent( Units::MomentumUnit, Units::LengthUnit,
181  int signal_process_id, int event_number,
182  GenVertex* signal_vertex, const WeightContainer& weights,
183  const std::vector<long>& randomstates,
184  const HeavyIon& ion, const PdfInfo& pdf );
185  GenEvent( const GenEvent& inevent );
186  GenEvent& operator=( const GenEvent& inevent );
187  virtual ~GenEvent();
188 
189  void swap( GenEvent & other );
190 
191  void print( std::ostream& ostr = std::cout ) const;
192  void print_version( std::ostream& ostr = std::cout ) const;
193 
195  GenParticle* barcode_to_particle( int barCode ) const;
197  GenVertex* barcode_to_vertex( int barCode ) const;
198 
200  // access methods //
202 
203  int signal_process_id() const;
204  int event_number() const;
205  int mpi() const;
206  double event_scale() const;
207  double alphaQCD() const;
208  double alphaQED() const;
212  bool valid_beam_particles() const;
214  std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const;
217  bool is_valid() const;
218 
225  const WeightContainer& weights() const;
226 
228  GenCrossSection const * cross_section() const;
231  HeavyIon const * heavy_ion() const;
232  HeavyIon* heavy_ion();
234  PdfInfo const * pdf_info() const;
235  PdfInfo* pdf_info();
236 
238  const std::vector<long>& random_states() const;
239 
241  int particles_size() const;
243  bool particles_empty() const;
245  int vertices_size() const;
247  bool vertices_empty() const;
248 
251  void write_units( std::ostream & os = std::cout ) const;
255  void write_cross_section( std::ostream& ostr = std::cout ) const;
256 
258  Units::MomentumUnit momentum_unit() const;
260  Units::LengthUnit length_unit() const;
261 
262  std::ostream& write(std::ostream&);
263  std::istream& read(std::istream&);
264 
266  // mutator methods //
268 
269  bool add_vertex( GenVertex* vtx );
270  bool remove_vertex( GenVertex* vtx );
271  void clear();
272 
273  void set_signal_process_id( int id );
274  void set_event_number( int eventno );
275  void set_mpi( int );
276  void set_event_scale( double scale );
277  void set_alphaQCD( double a );
278  void set_alphaQED( double a );
279 
285  bool set_beam_particles(std::pair<HepMC::GenParticle*,HepMC::GenParticle*> const &);
287  void set_random_states( const std::vector<long>& randomstates );
288 
290  void set_cross_section( const GenCrossSection& );
292  void set_heavy_ion( const HeavyIon& ion );
294  void set_pdf_info( const PdfInfo& p );
295 
298  void use_units( Units::MomentumUnit, Units::LengthUnit );
302  void use_units( std::string&, std::string& );
303 
306  void define_units( Units::MomentumUnit, Units::LengthUnit );
310  void define_units( std::string&, std::string& );
311 
320 
321  public:
323  // vertex_iterators //
325  // Note: the XXX_iterator is "resolvable" as XXX_const_iterator, but
326  // not the reverse, which is consistent with STL,
327  // see Musser, Derge, Saini 2ndEd. p. 69,70.
328 
330 
335  public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
336  // Iterates over all vertices in this event
337  public:
340  const
341  std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator& i)
342  : m_map_iterator(i) {}
346  { *this = i; }
347  virtual ~vertex_const_iterator() {}
350  { m_map_iterator = i.m_map_iterator; return *this; }
352  GenVertex* operator*(void) const { return m_map_iterator->second; }
354  vertex_const_iterator& operator++(void) //Pre-fix increment
355  { ++m_map_iterator; return *this; }
357  vertex_const_iterator operator++(int) //Post-fix increment
358  { vertex_const_iterator out(*this); ++(*this); return out; }
360  bool operator==( const vertex_const_iterator& a ) const
361  { return m_map_iterator == a.m_map_iterator; }
363  bool operator!=( const vertex_const_iterator& a ) const
364  { return !(m_map_iterator == a.m_map_iterator); }
365  protected:
367  std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator
369  private:
371  vertex_const_iterator& operator--(void);
373  vertex_const_iterator operator--(int);
374  };
375  friend class vertex_const_iterator;
379  m_vertex_barcodes.begin() ); }
383  m_vertex_barcodes.end() ); }
384 
385 
387 
392  public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
393  // Iterates over all vertices in this event
394  public:
397  const
398  std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator& i )
399  : m_map_iterator( i ) {}
400  vertex_iterator() {}
402  vertex_iterator( const vertex_iterator& i ) { *this = i; }
403  virtual ~vertex_iterator() {}
407  return *this;
408  }
410  operator vertex_const_iterator() const
413  GenVertex* operator*(void) const
414  { return m_map_iterator->second; }
416  vertex_iterator& operator++(void) //Pre-fix increment
417  { ++m_map_iterator; return *this; }
419  vertex_iterator operator++(int) //Post-fix increment
420  { vertex_iterator out(*this); ++(*this); return out; }
422  bool operator==( const vertex_iterator& a ) const
423  { return m_map_iterator == a.m_map_iterator; }
425  bool operator!=( const vertex_iterator& a ) const
426  { return !(m_map_iterator == a.m_map_iterator); }
427  protected:
429  std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator
431  private:
433  vertex_iterator& operator--(void);
435  vertex_iterator operator--(int);
436 
437  };
438  friend class vertex_iterator;
441  { return GenEvent::vertex_iterator(
442  m_vertex_barcodes.begin() ); }
445  { return GenEvent::vertex_iterator(
446  m_vertex_barcodes.end() ); }
447 
448  public:
450  // particle_iterator //
452  // Example of iterating over all particles in the event:
453  // for ( GenEvent::particle_const_iterator p = particles_begin();
454  // p != particles_end(); ++p ) {
455  // (*p)->print();
456  // }
457  //
458 
460 
465  public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
466  // Iterates over all vertices in this event
467  public:
470  const std::map<int,HepMC::GenParticle*>::const_iterator& i )
471  : m_map_iterator(i) {}
475  { *this = i; }
476  virtual ~particle_const_iterator() {}
479  const particle_const_iterator& i )
480  { m_map_iterator = i.m_map_iterator; return *this; }
482  GenParticle* operator*(void) const
483  { return m_map_iterator->second; }
485  particle_const_iterator& operator++(void) //Pre-fix increment
486  { ++m_map_iterator; return *this; }
488  particle_const_iterator operator++(int) //Post-fix increment
489  { particle_const_iterator out(*this); ++(*this); return out; }
491  bool operator==( const particle_const_iterator& a ) const
492  { return m_map_iterator == a.m_map_iterator; }
494  bool operator!=( const particle_const_iterator& a ) const
495  { return !(m_map_iterator == a.m_map_iterator); }
496  protected:
498  std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator;
499  private:
501  particle_const_iterator& operator--(void);
503  particle_const_iterator operator--(int);
504  };
505  friend class particle_const_iterator;
509  m_particle_barcodes.begin() ); }
513  m_particle_barcodes.end() ); }
514 
516 
521  public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
522  // Iterates over all vertices in this event
523  public:
525  particle_iterator( const std::map<int,HepMC::GenParticle*>::iterator& i )
526  : m_map_iterator( i ) {}
527  particle_iterator() {}
529  particle_iterator( const particle_iterator& i ) { *this = i; }
530  virtual ~particle_iterator() {}
534  return *this;
535  }
537  operator particle_const_iterator() const
540  GenParticle* operator*(void) const
541  { return m_map_iterator->second; }
544  { ++m_map_iterator; return *this; }
547  { particle_iterator out(*this); ++(*this); return out; }
549  bool operator==( const particle_iterator& a ) const
550  { return m_map_iterator == a.m_map_iterator; }
552  bool operator!=( const particle_iterator& a ) const
553  { return !(m_map_iterator == a.m_map_iterator); }
554  protected:
556  std::map<int,HepMC::GenParticle*>::iterator m_map_iterator;
557  private:
559  particle_iterator& operator--(void);
561  particle_iterator operator--(int);
562  };
563  friend class particle_iterator;
567  m_particle_barcodes.begin() ); }
571  m_particle_barcodes.end() ); }
572 
574  protected:
575  //
576  // Following methods intended for use by GenParticle/Vertex classes:
577  // In general there is no reason they should be used elsewhere.
579  bool set_barcode( GenParticle* p, int suggested_barcode =false );
581  bool set_barcode( GenVertex* v, int suggested_barcode =false );
583  void remove_barcode( GenParticle* p );
585  void remove_barcode( GenVertex* v );
586 
587  void delete_all_vertices();
588 
589  private: // methods
591  bool use_momentum_unit( Units::MomentumUnit );
592  bool use_momentum_unit( std::string& );
594  bool use_length_unit( Units::LengthUnit );
595  bool use_length_unit( std::string& );
596 
597  // the following internal methods are used by read() and write()
598 
600  std::ostream & write_beam_particles( std::ostream &,
601  std::pair<HepMC::GenParticle *,HepMC::GenParticle *> );
603  std::ostream & write_vertex( std::ostream &, GenVertex const * );
605  std::ostream & write_particle( std::ostream&, GenParticle const * );
607  std::istream & find_file_type( std::istream & );
609  std::istream & find_end_key( std::istream &, int & );
611  std::istream & read_units( std::istream & );
613  std::istream & read_weight_names( std::istream & );
615  std::istream & process_event_line( std::istream &, int &, int &, int &, int & );
616 
617  private: // data members
618  int m_signal_process_id;
619  int m_event_number;
620  int m_mpi; // number of multi paricle interactions
621  double m_event_scale;// energy scale, see hep-ph/0109068
622  double m_alphaQCD; // QCD coupling, see hep-ph/0109068
623  double m_alphaQED; // QED coupling, see hep-ph/0109068
624  GenVertex* m_signal_process_vertex;
625  GenParticle* m_beam_particle_1;
626  GenParticle* m_beam_particle_2;
627  WeightContainer m_weights; // weights for this event first weight
628  // is used by default for hit and miss
629  std::vector<long> m_random_states; // container of rndm num
630  // generator states
631 
632  std::map< int,HepMC::GenVertex*,std::greater<int> > m_vertex_barcodes;
633  std::map< int,HepMC::GenParticle*,std::less<int> > m_particle_barcodes;
634  GenCrossSection* m_cross_section; // undefined by default
635  HeavyIon* m_heavy_ion; // undefined by default
636  PdfInfo* m_pdf_info; // undefined by default
637  Units::MomentumUnit m_momentum_unit; // default value set by configure switch
638  Units::LengthUnit m_position_unit; // default value set by configure switch
639 
640  };
641 
642 
644  // IO Free Functions //
646 
648  std::ostream & operator << (std::ostream &, GenEvent &);
650  std::istream & operator >> (std::istream &, GenEvent &);
652  std::istream & set_input_units(std::istream &,
653  Units::MomentumUnit, Units::LengthUnit);
655  std::ostream & write_HepMC_IO_block_begin(std::ostream & );
657  std::ostream & write_HepMC_IO_block_end(std::ostream & );
658 
659 
661  // INLINE Free Functions //
663 
664  // Implemented in terms of GenEvent::use_...
665  inline GenEvent& convert_units(GenEvent & evt, Units::MomentumUnit m, Units::LengthUnit l)
666  {
667  evt.use_units(m, l);
668  return evt;
669  }
670 
672  // INLINE Access Methods //
674 
679  inline int GenEvent::signal_process_id() const
680  { return m_signal_process_id; }
681 
682  inline int GenEvent::event_number() const { return m_event_number; }
683 
686  inline int GenEvent::mpi() const { return m_mpi; }
687 
688  inline double GenEvent::event_scale() const { return m_event_scale; }
689 
690  inline double GenEvent::alphaQCD() const { return m_alphaQCD; }
691 
692  inline double GenEvent::alphaQED() const { return m_alphaQED; }
693 
696  return m_signal_process_vertex;
697  }
698 
699  inline WeightContainer& GenEvent::weights() { return m_weights; }
700 
701  inline const WeightContainer& GenEvent::weights() const
702  { return m_weights; }
703 
704  inline GenCrossSection const * GenEvent::cross_section() const
705  { return m_cross_section; }
706 
708  { return m_cross_section; }
709 
710  inline HeavyIon const * GenEvent::heavy_ion() const
711  { return m_heavy_ion; }
712 
713  inline HeavyIon* GenEvent::heavy_ion()
714  { return m_heavy_ion; }
715 
716  inline PdfInfo const * GenEvent::pdf_info() const
717  { return m_pdf_info; }
718 
719  inline PdfInfo* GenEvent::pdf_info()
720  { return m_pdf_info; }
721 
727  inline const std::vector<long>& GenEvent::random_states() const
728  { return m_random_states; }
729 
730  inline void GenEvent::set_signal_process_id( int id )
731  { m_signal_process_id = id; }
732 
733  inline void GenEvent::set_event_number( int eventno )
734  { m_event_number = eventno; }
735 
737  inline void GenEvent::set_mpi( int nmpi )
738  { m_mpi = nmpi; }
739 
740 
741  inline void GenEvent::set_event_scale( double sc ) { m_event_scale = sc; }
742 
743  inline void GenEvent::set_alphaQCD( double a ) { m_alphaQCD = a; }
744 
745  inline void GenEvent::set_alphaQED( double a ) { m_alphaQED = a; }
746 
748  m_signal_process_vertex = vtx;
749  if ( m_signal_process_vertex ) add_vertex( m_signal_process_vertex );
750  }
751 
753  {
754  delete m_cross_section;
755  m_cross_section = new GenCrossSection(xs);
756  }
757 
758  inline void GenEvent::set_heavy_ion( const HeavyIon& ion )
759  {
760  delete m_heavy_ion;
761  m_heavy_ion = new HeavyIon(ion);
762  }
763 
764  inline void GenEvent::set_pdf_info( const PdfInfo& p )
765  {
766  delete m_pdf_info;
767  m_pdf_info = new PdfInfo(p);
768  }
769 
770  inline void GenEvent::set_random_states( const std::vector<long>&
771  randomstates )
772  { m_random_states = randomstates; }
773 
775  { m_particle_barcodes.erase( p->barcode() ); }
776 
778  { m_vertex_barcodes.erase( v->barcode() ); }
779 
798  inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
799  {
800  std::map<int,HepMC::GenParticle*>::const_iterator i
801  = m_particle_barcodes.find(barCode);
802  return ( i != m_particle_barcodes.end() ) ? (*i).second : 0;
803  }
804 
823  inline GenVertex* GenEvent::barcode_to_vertex( int barCode ) const
824  {
825  std::map<int,GenVertex*,std::greater<int> >::const_iterator i
826  = m_vertex_barcodes.find(barCode);
827  return ( i != m_vertex_barcodes.end() ) ? (*i).second : 0;
828  }
829 
830  inline int GenEvent::particles_size() const {
831  return (int)m_particle_barcodes.size();
832  }
833  inline bool GenEvent::particles_empty() const {
834  return (bool)m_particle_barcodes.empty();
835  }
836  inline int GenEvent::vertices_size() const {
837  return (int)m_vertex_barcodes.size();
838  }
839  inline bool GenEvent::vertices_empty() const {
840  return (bool)m_vertex_barcodes.empty();
841  }
842 
843  // beam particles
844  inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const {
845  return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2);
846  }
847 
848  // units
849  inline Units::MomentumUnit GenEvent::momentum_unit() const {
850  return m_momentum_unit;
851  }
852  inline Units::LengthUnit GenEvent::length_unit() const {
853  return m_position_unit;
854  }
855 
856  inline void GenEvent::use_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) {
857  use_momentum_unit( new_m );
858  use_length_unit( new_l );
859  }
860 
861  inline void GenEvent::use_units( std::string& new_m, std::string& new_l ) {
862  use_momentum_unit( new_m );
863  use_length_unit( new_l );
864  }
865 
866  inline void GenEvent::define_units( Units::MomentumUnit new_m, Units::LengthUnit new_l ) {
867  m_momentum_unit = new_m;
868  m_position_unit = new_l;
869  }
870 
871 } // HepMC
872 
873 #endif // HEPMC_GEN_EVENT_H
874 
875 //--------------------------------------------------------------------------
876 
877 
bool remove_vertex(GenVertex *vtx)
erases vtx from evt
Definition: GenEvent.cc:357
particle_const_iterator(const std::map< int, HepMC::GenParticle * >::const_iterator &i)
iterate over particles
Definition: GenEvent.h:469
vertex_iterator vertices_begin()
begin vertex iteration
Definition: GenEvent.h:440
vertex_const_iterator operator++(int)
Post-fix increment.
Definition: GenEvent.h:357
void set_pdf_info(const PdfInfo &p)
provide a pointer to the PdfInfo container
Definition: GenEvent.h:764
GenVertex * barcode_to_vertex(int barCode) const
assign a barcode to a vertex
Definition: GenEvent.h:823
bool particles_empty() const
return true if there are no particle barcodes
Definition: GenEvent.h:833
std::map< int, HepMC::GenVertex *, std::greater< int > >::const_iterator m_map_iterator
const iterator to a vertex map
Definition: GenEvent.h:368
bool vertices_empty() const
return true if there are no vertex barcodes
Definition: GenEvent.h:839
int barcode() const
unique identifier
Definition: GenVertex.h:416
GenParticle * operator*(void) const
return a pointer to GenParticle
Definition: GenEvent.h:482
std::istream & read(std::istream &)
particle_iterator particles_end()
end particle iteration
Definition: GenEvent.h:569
HeavyIon const * heavy_ion() const
access the HeavyIon container if it exists
Definition: GenEvent.h:710
The GenCrossSection class stores the generated cross section.
bool is_valid() const
Definition: GenEvent.cc:677
bool set_barcode(GenParticle *p, int suggested_barcode=false)
set the barcode - intended for use by GenParticle
Definition: GenEvent.cc:430
bool operator==(const particle_iterator &a) const
equality
Definition: GenEvent.h:549
vertex_iterator & operator++(void)
Pre-fix increment.
Definition: GenEvent.h:416
void set_signal_process_vertex(GenVertex *)
set pointer to the vertex containing the signal process
Definition: GenEvent.h:747
const particle iterator
Definition: GenEvent.h:464
ConstGenEventParticleRange acts like a collection of particles.
Definition: GenRanges.h:112
int particles_size() const
how many particle barcodes exist?
Definition: GenEvent.h:830
particle_const_iterator(const particle_const_iterator &i)
copy constructor
Definition: GenEvent.h:474
particle_const_iterator operator++(int)
Post-fix increment.
Definition: GenEvent.h:488
int barcode() const
particle barcode
Definition: GenParticle.h:252
particle_const_iterator particles_begin() const
begin particle iteration
Definition: GenEvent.h:507
vertex_const_iterator(const vertex_const_iterator &i)
copy constructor
Definition: GenEvent.h:345
vertex_iterator operator++(int)
Post-fix increment.
Definition: GenEvent.h:419
particle_iterator & operator++(void)
Pre-fix increment.
Definition: GenEvent.h:543
particle_iterator(const particle_iterator &i)
copy constructor
Definition: GenEvent.h:529
particle_iterator(const std::map< int, HepMC::GenParticle * >::iterator &i)
iterate over particles
Definition: GenEvent.h:525
GenEventParticleRange particle_range()
particle range
Definition: GenRanges.cc:26
void set_event_scale(double scale)
set energy scale
Definition: GenEvent.h:741
std::istream & set_input_units(std::istream &, Units::MomentumUnit, Units::LengthUnit)
set the units for this input stream
void remove_barcode(GenParticle *p)
intended for use by GenParticle
Definition: GenEvent.h:774
void set_cross_section(const GenCrossSection &)
provide a pointer to the GenCrossSection container
Definition: GenEvent.h:752
void copy_if(InputIterator first, InputIterator last, OutputIterator out, Predicate pred)
define the type of iterator to use
Definition: GenEvent.h:50
particle_iterator & operator=(const particle_iterator &i)
make a copy
Definition: GenEvent.h:532
non-const particle iterator
Definition: GenEvent.h:520
std::pair< HepMC::GenParticle *, HepMC::GenParticle * > beam_particles() const
pair of pointers to the two incoming beam particles
Definition: GenEvent.h:844
void delete_all_vertices()
delete all vertices owned by this event
Definition: GenEvent.cc:403
GenCrossSection const * cross_section() const
access the GenCrossSection container if it exists
Definition: GenEvent.h:704
void set_event_number(int eventno)
set event number
Definition: GenEvent.h:733
GenVertex contains information about decay vertices.
Definition: GenVertex.h:52
void write_units(std::ostream &os=std::cout) const
Definition: GenEvent.cc:599
double alphaQED() const
Definition: GenEvent.h:692
particle_const_iterator & operator=(const particle_const_iterator &i)
make a copy
Definition: GenEvent.h:478
GenEventParticleRange acts like a collection of particles.
Definition: GenRanges.h:83
The GenEvent class is the core of HepMC.
Definition: GenEvent.h:155
bool operator==(const vertex_const_iterator &a) const
equality
Definition: GenEvent.h:360
GenVertex * signal_process_vertex() const
pointer to the vertex containing the signal process
Definition: GenEvent.h:694
Units::MomentumUnit momentum_unit() const
Units used by the GenParticle momentum FourVector.
Definition: GenEvent.h:849
void swap(GenEvent &other)
swap
Definition: GenEvent.cc:226
void set_random_states(const std::vector< long > &randomstates)
provide random state information
Definition: GenEvent.h:770
GenEvent(int signal_process_id=0, int event_number=0, GenVertex *signal_vertex=0, const WeightContainer &weights=std::vector< double >(), const std::vector< long > &randomstates=std::vector< long >(), Units::MomentumUnit=Units::default_momentum_unit(), Units::LengthUnit=Units::default_length_unit())
default constructor creates null pointers to HeavyIon, PdfInfo, and GenCrossSection ...
Definition: GenEvent.cc:22
vertex_const_iterator & operator=(const vertex_const_iterator &i)
make a copy
Definition: GenEvent.h:349
void set_heavy_ion(const HeavyIon &ion)
provide a pointer to the HeavyIon container
Definition: GenEvent.h:758
bool add_vertex(GenVertex *vtx)
adds to evt and adopts
Definition: GenEvent.cc:334
void print_version(std::ostream &ostr=std::cout) const
dumps release version to ostr
Definition: GenEvent.cc:328
vertex_const_iterator vertices_end() const
end vertex iteration
Definition: GenEvent.h:381
void set_mpi(int)
set number of multi parton interactions
Definition: GenEvent.h:737
bool operator!=(const vertex_const_iterator &a) const
inequality
Definition: GenEvent.h:363
WeightContainer & weights()
direct access to WeightContainer
Definition: GenEvent.h:699
void write_cross_section(std::ostream &ostr=std::cout) const
Definition: GenEvent.cc:605
vertex_iterator & operator=(const vertex_iterator &i)
make a copy
Definition: GenEvent.h:405
int vertices_size() const
how many vertex barcodes exist?
Definition: GenEvent.h:836
void set_alphaQCD(double a)
set QCD coupling
Definition: GenEvent.h:743
bool valid_beam_particles() const
test to see if we have two valid beam particles
Definition: GenEvent.cc:568
void set_alphaQED(double a)
set QED coupling
Definition: GenEvent.h:745
std::map< int, HepMC::GenParticle * >::iterator m_map_iterator
iterator for GenParticle map
Definition: GenEvent.h:556
bool set_beam_particles(GenParticle *, GenParticle *)
set incoming beam particles
Definition: GenEvent.cc:586
std::ostream & write(std::ostream &)
GenEventVertexRange vertex_range()
vertex range
Definition: GenRanges.cc:16
vertex_iterator vertices_end()
end vertex iteration
Definition: GenEvent.h:444
void print(std::ostream &ostr=std::cout) const
dumps to ostr
Definition: GenEvent.cc:277
void clear()
empties the entire event
Definition: GenEvent.cc:365
particle_const_iterator particles_end() const
end particle iteration
Definition: GenEvent.h:511
GenParticle * barcode_to_particle(int barCode) const
assign a barcode to a particle
Definition: GenEvent.h:798
std::ostream & write_HepMC_IO_block_begin(std::ostream &)
Explicitly write the begin block lines that IO_GenEvent uses.
bool operator==(const particle_const_iterator &a) const
equality
Definition: GenEvent.h:491
ConstGenEventVertexRange acts like a collection of vertices.
Definition: GenRanges.h:55
particle_const_iterator & operator++(void)
Pre-fix increment.
Definition: GenEvent.h:485
void define_units(Units::MomentumUnit, Units::LengthUnit)
Definition: GenEvent.h:866
GenVertex * operator*(void) const
return a pointer to a GenVertex
Definition: GenEvent.h:352
GenEvent & operator=(const GenEvent &inevent)
make a deep copy
Definition: GenEvent.cc:269
vertex_const_iterator vertices_begin() const
begin vertex iteration
Definition: GenEvent.h:377
vertex_iterator(const vertex_iterator &i)
copy constructor
Definition: GenEvent.h:402
GenEventVertexRange acts like a collection of vertices.
Definition: GenRanges.h:26
vertex_const_iterator(const std::map< int, HepMC::GenVertex *, std::greater< int > >::const_iterator &i)
constructor requiring vertex information
Definition: GenEvent.h:339
particle_iterator operator++(int)
Post-fix increment.
Definition: GenEvent.h:546
GenParticle * operator*(void) const
return pointer to GenParticle
Definition: GenEvent.h:540
bool operator!=(const particle_iterator &a) const
inequality
Definition: GenEvent.h:552
int mpi() const
number of multi parton interactions
Definition: GenEvent.h:686
non-const vertex iterator
Definition: GenEvent.h:391
int event_number() const
event number
Definition: GenEvent.h:682
GenVertex * operator*(void) const
return a pointer to a GenVertex
Definition: GenEvent.h:413
bool operator==(const vertex_iterator &a) const
equality
Definition: GenEvent.h:422
vertex_const_iterator & operator++(void)
Pre-fix increment.
Definition: GenEvent.h:354
int signal_process_id() const
unique signal process id
Definition: GenEvent.h:679
The HeavyIon class stores information about heavy ions.
Definition: HeavyIon.h:45
Container for the Weights associated with an event or vertex.
void use_units(Units::MomentumUnit, Units::LengthUnit)
Definition: GenEvent.h:856
std::map< int, HepMC::GenVertex *, std::greater< int > >::iterator m_map_iterator
iterator to the vertex map
Definition: GenEvent.h:430
std::map< int, HepMC::GenParticle * >::const_iterator m_map_iterator
const iterator to the GenParticle map
Definition: GenEvent.h:498
void set_signal_process_id(int id)
set unique signal process id
Definition: GenEvent.h:730
PdfInfo const * pdf_info() const
access the PdfInfo container if it exists
Definition: GenEvent.h:716
vertex_iterator(const std::map< int, HepMC::GenVertex *, std::greater< int > >::iterator &i)
constructor requiring vertex information
Definition: GenEvent.h:396
std::ostream & write_HepMC_IO_block_end(std::ostream &)
Explicitly write the end block line that IO_GenEvent uses.
const std::vector< long > & random_states() const
vector of integers containing information about the random state
Definition: GenEvent.h:727
virtual ~GenEvent()
deletes all vertices/particles in this evt
Definition: GenEvent.cc:258
bool operator!=(const particle_const_iterator &a) const
inequality
Definition: GenEvent.h:494
double event_scale() const
energy scale, see hep-ph/0109068
Definition: GenEvent.h:688
bool operator!=(const vertex_iterator &a) const
inequality
Definition: GenEvent.h:425
The GenParticle class contains information about generated particles.
Definition: GenParticle.h:60
double alphaQCD() const
QCD coupling, see hep-ph/0109068.
Definition: GenEvent.h:690
The PdfInfo class stores PDF information.
Definition: PdfInfo.h:37
Units::LengthUnit length_unit() const
Units used by the GenVertex position FourVector.
Definition: GenEvent.h:852
particle_iterator particles_begin()
begin particle iteration
Definition: GenEvent.h:565