2 #ifndef HEPMC_GEN_EVENT_H
3 #define HEPMC_GEN_EVENT_H
49 template <
class InputIterator,
class OutputIterator,
class Predicate>
50 void copy_if( InputIterator first, InputIterator last, OutputIterator out,
52 for ( ; first != last; ++first ) {
if ( pred(*first) ) out = *first; }
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"
143 class GenEventVertexRange;
144 class ConstGenEventVertexRange;
145 class GenEventParticleRange;
146 class ConstGenEventParticleRange;
163 const std::vector<long>& randomstates = std::vector<long>(),
164 Units::MomentumUnit = Units::default_momentum_unit(),
165 Units::LengthUnit = Units::default_length_unit() );
169 const std::vector<long>& randomstates,
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,
178 const std::vector<long>& randomstates = std::vector<long>() );
180 GenEvent( Units::MomentumUnit, Units::LengthUnit,
181 int signal_process_id,
int event_number,
183 const std::vector<long>& randomstates,
191 void print( std::ostream& ostr = std::cout )
const;
214 std::pair<HepMC::GenParticle*,HepMC::GenParticle*>
beam_particles()
const;
251 void write_units( std::ostream & os = std::cout )
const;
262 std::ostream&
write(std::ostream&);
263 std::istream&
read(std::istream&);
298 void use_units( Units::MomentumUnit, Units::LengthUnit );
302 void use_units( std::string&, std::string& );
306 void define_units( Units::MomentumUnit, Units::LengthUnit );
335 public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
367 std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator
379 m_vertex_barcodes.begin() ); }
383 m_vertex_barcodes.end() ); }
392 public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
429 std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator
442 m_vertex_barcodes.begin() ); }
446 m_vertex_barcodes.end() ); }
465 public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
470 const std::map<int,HepMC::GenParticle*>::const_iterator& i )
509 m_particle_barcodes.begin() ); }
513 m_particle_barcodes.end() ); }
521 public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
567 m_particle_barcodes.begin() ); }
571 m_particle_barcodes.end() ); }
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& );
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 & );
618 int m_signal_process_id;
621 double m_event_scale;
629 std::vector<long> m_random_states;
632 std::map< int,HepMC::GenVertex*,std::greater<int> > m_vertex_barcodes;
633 std::map< int,HepMC::GenParticle*,std::less<int> > m_particle_barcodes;
637 Units::MomentumUnit m_momentum_unit;
638 Units::LengthUnit m_position_unit;
648 std::ostream & operator << (std::ostream &, GenEvent &);
650 std::istream & operator >> (std::istream &, GenEvent &);
653 Units::MomentumUnit, Units::LengthUnit);
665 inline GenEvent& convert_units(GenEvent & evt, Units::MomentumUnit m, Units::LengthUnit l)
680 {
return m_signal_process_id; }
696 return m_signal_process_vertex;
702 {
return m_weights; }
705 {
return m_cross_section; }
708 {
return m_cross_section; }
711 {
return m_heavy_ion; }
714 {
return m_heavy_ion; }
717 {
return m_pdf_info; }
720 {
return m_pdf_info; }
728 {
return m_random_states; }
731 { m_signal_process_id = id; }
734 { m_event_number = eventno; }
748 m_signal_process_vertex = vtx;
749 if ( m_signal_process_vertex )
add_vertex( m_signal_process_vertex );
754 delete m_cross_section;
772 { m_random_states = randomstates; }
775 { m_particle_barcodes.erase( p->
barcode() ); }
778 { m_vertex_barcodes.erase( v->
barcode() ); }
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;
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;
831 return (
int)m_particle_barcodes.size();
834 return (
bool)m_particle_barcodes.empty();
837 return (
int)m_vertex_barcodes.size();
840 return (
bool)m_vertex_barcodes.empty();
845 return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2);
850 return m_momentum_unit;
853 return m_position_unit;
857 use_momentum_unit( new_m );
858 use_length_unit( new_l );
862 use_momentum_unit( new_m );
863 use_length_unit( new_l );
867 m_momentum_unit = new_m;
868 m_position_unit = new_l;
873 #endif // HEPMC_GEN_EVENT_H
bool remove_vertex(GenVertex *vtx)
erases vtx from evt
particle_const_iterator(const std::map< int, HepMC::GenParticle * >::const_iterator &i)
iterate over particles
vertex_iterator vertices_begin()
begin vertex iteration
vertex_const_iterator operator++(int)
Post-fix increment.
void set_pdf_info(const PdfInfo &p)
provide a pointer to the PdfInfo container
GenVertex * barcode_to_vertex(int barCode) const
assign a barcode to a vertex
bool particles_empty() const
return true if there are no particle barcodes
std::map< int, HepMC::GenVertex *, std::greater< int > >::const_iterator m_map_iterator
const iterator to a vertex map
bool vertices_empty() const
return true if there are no vertex barcodes
int barcode() const
unique identifier
GenParticle * operator*(void) const
return a pointer to GenParticle
std::istream & read(std::istream &)
particle_iterator particles_end()
end particle iteration
HeavyIon const * heavy_ion() const
access the HeavyIon container if it exists
The GenCrossSection class stores the generated cross section.
bool set_barcode(GenParticle *p, int suggested_barcode=false)
set the barcode - intended for use by GenParticle
bool operator==(const particle_iterator &a) const
equality
vertex_iterator & operator++(void)
Pre-fix increment.
void set_signal_process_vertex(GenVertex *)
set pointer to the vertex containing the signal process
ConstGenEventParticleRange acts like a collection of particles.
int particles_size() const
how many particle barcodes exist?
particle_const_iterator(const particle_const_iterator &i)
copy constructor
particle_const_iterator operator++(int)
Post-fix increment.
int barcode() const
particle barcode
particle_const_iterator particles_begin() const
begin particle iteration
vertex_const_iterator(const vertex_const_iterator &i)
copy constructor
vertex_iterator operator++(int)
Post-fix increment.
particle_iterator & operator++(void)
Pre-fix increment.
particle_iterator(const particle_iterator &i)
copy constructor
particle_iterator(const std::map< int, HepMC::GenParticle * >::iterator &i)
iterate over particles
GenEventParticleRange particle_range()
particle range
void set_event_scale(double scale)
set energy scale
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
void set_cross_section(const GenCrossSection &)
provide a pointer to the GenCrossSection container
void copy_if(InputIterator first, InputIterator last, OutputIterator out, Predicate pred)
define the type of iterator to use
particle_iterator & operator=(const particle_iterator &i)
make a copy
non-const particle iterator
std::pair< HepMC::GenParticle *, HepMC::GenParticle * > beam_particles() const
pair of pointers to the two incoming beam particles
void delete_all_vertices()
delete all vertices owned by this event
GenCrossSection const * cross_section() const
access the GenCrossSection container if it exists
void set_event_number(int eventno)
set event number
GenVertex contains information about decay vertices.
void write_units(std::ostream &os=std::cout) const
particle_const_iterator & operator=(const particle_const_iterator &i)
make a copy
GenEventParticleRange acts like a collection of particles.
The GenEvent class is the core of HepMC.
bool operator==(const vertex_const_iterator &a) const
equality
GenVertex * signal_process_vertex() const
pointer to the vertex containing the signal process
Units::MomentumUnit momentum_unit() const
Units used by the GenParticle momentum FourVector.
void swap(GenEvent &other)
swap
void set_random_states(const std::vector< long > &randomstates)
provide random state information
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 ...
vertex_const_iterator & operator=(const vertex_const_iterator &i)
make a copy
void set_heavy_ion(const HeavyIon &ion)
provide a pointer to the HeavyIon container
bool add_vertex(GenVertex *vtx)
adds to evt and adopts
void print_version(std::ostream &ostr=std::cout) const
dumps release version to ostr
vertex_const_iterator vertices_end() const
end vertex iteration
void set_mpi(int)
set number of multi parton interactions
bool operator!=(const vertex_const_iterator &a) const
inequality
WeightContainer & weights()
direct access to WeightContainer
void write_cross_section(std::ostream &ostr=std::cout) const
vertex_iterator & operator=(const vertex_iterator &i)
make a copy
int vertices_size() const
how many vertex barcodes exist?
void set_alphaQCD(double a)
set QCD coupling
bool valid_beam_particles() const
test to see if we have two valid beam particles
void set_alphaQED(double a)
set QED coupling
std::map< int, HepMC::GenParticle * >::iterator m_map_iterator
iterator for GenParticle map
bool set_beam_particles(GenParticle *, GenParticle *)
set incoming beam particles
std::ostream & write(std::ostream &)
GenEventVertexRange vertex_range()
vertex range
vertex_iterator vertices_end()
end vertex iteration
void print(std::ostream &ostr=std::cout) const
dumps to ostr
void clear()
empties the entire event
particle_const_iterator particles_end() const
end particle iteration
GenParticle * barcode_to_particle(int barCode) const
assign a barcode to a particle
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
ConstGenEventVertexRange acts like a collection of vertices.
particle_const_iterator & operator++(void)
Pre-fix increment.
void define_units(Units::MomentumUnit, Units::LengthUnit)
GenVertex * operator*(void) const
return a pointer to a GenVertex
GenEvent & operator=(const GenEvent &inevent)
make a deep copy
vertex_const_iterator vertices_begin() const
begin vertex iteration
vertex_iterator(const vertex_iterator &i)
copy constructor
GenEventVertexRange acts like a collection of vertices.
vertex_const_iterator(const std::map< int, HepMC::GenVertex *, std::greater< int > >::const_iterator &i)
constructor requiring vertex information
particle_iterator operator++(int)
Post-fix increment.
GenParticle * operator*(void) const
return pointer to GenParticle
bool operator!=(const particle_iterator &a) const
inequality
int mpi() const
number of multi parton interactions
non-const vertex iterator
int event_number() const
event number
GenVertex * operator*(void) const
return a pointer to a GenVertex
bool operator==(const vertex_iterator &a) const
equality
vertex_const_iterator & operator++(void)
Pre-fix increment.
int signal_process_id() const
unique signal process id
The HeavyIon class stores information about heavy ions.
Container for the Weights associated with an event or vertex.
void use_units(Units::MomentumUnit, Units::LengthUnit)
std::map< int, HepMC::GenVertex *, std::greater< int > >::iterator m_map_iterator
iterator to the vertex map
std::map< int, HepMC::GenParticle * >::const_iterator m_map_iterator
const iterator to the GenParticle map
void set_signal_process_id(int id)
set unique signal process id
PdfInfo const * pdf_info() const
access the PdfInfo container if it exists
vertex_iterator(const std::map< int, HepMC::GenVertex *, std::greater< int > >::iterator &i)
constructor requiring vertex information
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
virtual ~GenEvent()
deletes all vertices/particles in this evt
bool operator!=(const particle_const_iterator &a) const
inequality
double event_scale() const
energy scale, see hep-ph/0109068
bool operator!=(const vertex_iterator &a) const
inequality
The GenParticle class contains information about generated particles.
double alphaQCD() const
QCD coupling, see hep-ph/0109068.
The PdfInfo class stores PDF information.
Units::LengthUnit length_unit() const
Units used by the GenVertex position FourVector.
particle_iterator particles_begin()
begin particle iteration