hepmc

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/trunk @ 159  →  /trunk @ 173
/trunk/src/GenEvent.cc
@@ -11,6 +11,7 @@
//////////////////////////////////////////////////////////////////////////
 
#include "HepMC/GenEvent.h"
#include "HepMC/Version.h"
 
namespace HepMC {
 
@@ -240,6 +241,12 @@
<< "________________________________________" << std::endl;
}
 
void GenEvent::print_version( std::ostream& ostr ) const {
ostr << "---------------------------------------------" << std::endl;
writeVersion( ostr );
ostr << "---------------------------------------------" << std::endl;
}
 
bool GenEvent::add_vertex( GenVertex* vtx ) {
/// returns true if successful - generally will only return false
/// if the inserted vertex is already included in the event.
/trunk/src/GenParticle.cc
@@ -14,8 +14,7 @@
GenParticle::GenParticle( void ) :
m_momentum(0), m_pdg_id(0), m_status(0), m_flow(this),
m_polarization(0), m_production_vertex(0), m_end_vertex(0),
m_barcode(0), m_generated_mass(0.),
m_serialnumber(++s_serialize)
m_barcode(0), m_generated_mass(0.)
{
s_counter++;
}
@@ -26,8 +25,7 @@
const Polarization& polar ) :
m_momentum(momentum), m_pdg_id(pdg_id), m_status(status), m_flow(this),
m_polarization(polar), m_production_vertex(0), m_end_vertex(0),
m_barcode(0), m_generated_mass(momentum.m()),
m_serialnumber(++s_serialize)
m_barcode(0), m_generated_mass(momentum.m())
{
// Establishing *this as the owner of m_flow is done above,
// then we set it equal to the other flow pattern (subtle)
@@ -44,8 +42,7 @@
m_production_vertex(0),
m_end_vertex(0),
m_barcode(0),
m_generated_mass( inparticle.generated_mass() ),
m_serialnumber( inparticle.serialnumber() )
m_generated_mass( inparticle.generated_mass() )
{
/// Shallow copy: does not copy the vertex pointers
/// (note - impossible to copy vertex pointers which having the vertex
@@ -74,7 +71,6 @@
std::swap( m_end_vertex, other.m_end_vertex );
std::swap( m_barcode, other.m_barcode );
std::swap( m_generated_mass, other.m_generated_mass );
std::swap( m_serialnumber, other.m_serialnumber );
}
 
GenParticle& GenParticle::operator=( const GenParticle& inparticle ) {
@@ -184,9 +180,6 @@
unsigned int GenParticle::counter() { return s_counter; }
unsigned int GenParticle::s_counter = 0U;
 
hepmc_uint64_t GenParticle::serialnumber() const { return m_serialnumber; }
hepmc_uint64_t GenParticle::s_serialize = 0U;
 
/////////////
// Friends //
/////////////
/trunk/src/IO_Ascii.cc
@@ -175,7 +175,7 @@
//
// the end vertices of the particles are not connected until
// after the event is read --- we store the values in a map until then
std::map<GenParticle*,int> particle_to_end_vertex;
TempParticleMap particle_to_end_vertex;
//
// read in the vertices
for ( int iii = 1; iii <= num_vertices; ++iii ) {
@@ -189,11 +189,13 @@
}
//
// last connect particles to their end vertices
for ( std::map<GenParticle*,int>::iterator pmap
= particle_to_end_vertex.begin();
pmap != particle_to_end_vertex.end(); ++pmap ) {
GenVertex* itsDecayVtx = evt->barcode_to_vertex(pmap->second);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( pmap->first );
for ( std::map<int,GenParticle*>::iterator pmap
= particle_to_end_vertex.order_begin();
pmap != particle_to_end_vertex.order_end(); ++pmap ) {
GenParticle* p = pmap->second;
int vtx = particle_to_end_vertex.end_vertex( p );
GenVertex* itsDecayVtx = evt->barcode_to_vertex(vtx);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( p );
else {
std::cerr << "IO_Ascii::fill_next_event ERROR particle points"
<< "\n to null end vertex. " <<std::endl;
@@ -374,7 +376,7 @@
}
 
GenVertex* IO_Ascii::read_vertex
( std::map<GenParticle*,int>& particle_to_end_vertex )
( TempParticleMap& particle_to_end_vertex )
{
// assumes mode has already been checked
//
@@ -411,7 +413,7 @@
}
 
GenParticle* IO_Ascii::read_particle(
std::map<GenParticle*,int>& particle_to_end_vertex ){
TempParticleMap& particle_to_end_vertex ){
// assumes mode has already been checked
//
// test to be sure the next entry is of type "P" then ignore it
@@ -445,7 +447,9 @@
// all particles are connected to their end vertex separately
// after all particles and vertices have been created - so we keep
// a map of all particles that have end vertices
if ( end_vtx_code != 0 ) particle_to_end_vertex[p] = end_vtx_code;
if ( end_vtx_code != 0 ) {
particle_to_end_vertex.addEndParticle(p,end_vtx_code);
}
return p;
}
 
/trunk/src/IO_ExtendedAscii.cc
@@ -189,7 +189,7 @@
//
// the end vertices of the particles are not connected until
// after the event is read --- we store the values in a map until then
std::map<GenParticle*,int> particle_to_end_vertex;
TempParticleMap particle_to_end_vertex;
//
// read in the vertices
for ( int iii = 1; iii <= num_vertices; ++iii ) {
@@ -205,17 +205,18 @@
// last connect particles to their end vertices
GenParticle* beam1(0);
GenParticle* beam2(0);
for ( std::map<GenParticle*,int>::iterator pmap
= particle_to_end_vertex.begin();
pmap != particle_to_end_vertex.end(); ++pmap ) {
GenVertex* itsDecayVtx = evt->barcode_to_vertex(pmap->second);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( pmap->first );
for ( std::map<int,GenParticle*>::iterator pmap
= particle_to_end_vertex.order_begin();
pmap != particle_to_end_vertex.order_end(); ++pmap ) {
GenParticle* p = pmap->second;
int vtx = particle_to_end_vertex.end_vertex( p );
GenVertex* itsDecayVtx = evt->barcode_to_vertex(vtx);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( p );
else {
std::cerr << "IO_ExtendedAscii::fill_next_event ERROR particle points"
<< "\n to null end vertex. " <<std::endl;
}
// also look for the beam particles
GenParticle* p = pmap->first;
if( p->barcode() == bp1 ) beam1 = p;
if( p->barcode() == bp2 ) beam2 = p;
}
@@ -489,7 +490,7 @@
}
 
GenVertex* IO_ExtendedAscii::read_vertex
( std::map<GenParticle*,int>& particle_to_end_vertex )
( TempParticleMap& particle_to_end_vertex )
{
// assumes mode has already been checked
//
@@ -574,7 +575,7 @@
}
 
GenParticle* IO_ExtendedAscii::read_particle(
std::map<GenParticle*,int>& particle_to_end_vertex ){
TempParticleMap& particle_to_end_vertex ){
// assumes mode has already been checked
//
// test to be sure the next entry is of type "P" then ignore it
@@ -609,7 +610,9 @@
// all particles are connected to their end vertex separately
// after all particles and vertices have been created - so we keep
// a map of all particles that have end vertices
if ( end_vtx_code != 0 ) particle_to_end_vertex[p] = end_vtx_code;
if ( end_vtx_code != 0 ) {
particle_to_end_vertex.addEndParticle(p,end_vtx_code);
}
return p;
}
 
/trunk/src/IO_GenEvent.cc
@@ -226,7 +226,7 @@
//
// the end vertices of the particles are not connected until
// after the event is read --- we store the values in a map until then
std::map<GenParticle*,int> particle_to_end_vertex;
TempParticleMap particle_to_end_vertex;
//
// read in the vertices
for ( int iii = 1; iii <= num_vertices; ++iii ) {
@@ -242,17 +242,18 @@
// last connect particles to their end vertices
GenParticle* beam1(0);
GenParticle* beam2(0);
for ( std::map<GenParticle*,int>::iterator pmap
= particle_to_end_vertex.begin();
pmap != particle_to_end_vertex.end(); ++pmap ) {
GenVertex* itsDecayVtx = evt->barcode_to_vertex(pmap->second);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( pmap->first );
for ( std::map<int,GenParticle*>::iterator pmap
= particle_to_end_vertex.order_begin();
pmap != particle_to_end_vertex.order_end(); ++pmap ) {
GenParticle* p = pmap->second;
int vtx = particle_to_end_vertex.end_vertex( p );
GenVertex* itsDecayVtx = evt->barcode_to_vertex(vtx);
if ( itsDecayVtx ) itsDecayVtx->add_particle_in( p );
else {
std::cerr << "IO_GenEvent::fill_next_event ERROR particle points"
<< "\n to null end vertex. " <<std::endl;
}
// also look for the beam particles
GenParticle* p = pmap->first;
if( p->barcode() == bp1 ) beam1 = p;
if( p->barcode() == bp2 ) beam2 = p;
}
@@ -526,7 +527,7 @@
}
 
GenVertex* IO_GenEvent::read_vertex
( std::map<GenParticle*,int>& particle_to_end_vertex )
( TempParticleMap& particle_to_end_vertex )
{
// assumes mode has already been checked
//
@@ -611,7 +612,7 @@
}
 
GenParticle* IO_GenEvent::read_particle(
std::map<GenParticle*,int>& particle_to_end_vertex ){
TempParticleMap& particle_to_end_vertex ){
// assumes mode has already been checked
//
// test to be sure the next entry is of type "P" then ignore it
@@ -646,7 +647,9 @@
// all particles are connected to their end vertex separately
// after all particles and vertices have been created - so we keep
// a map of all particles that have end vertices
if ( end_vtx_code != 0 ) particle_to_end_vertex[p] = end_vtx_code;
if ( end_vtx_code != 0 ) {
particle_to_end_vertex.addEndParticle(p,end_vtx_code);
}
return p;
}
 
/trunk/src/Makefile.am
@@ -17,7 +17,8 @@
IO_PDG_ParticleDataTable.cc \
IO_GenEvent.cc \
ParticleData.cc \
Polarization.cc
Polarization.cc \
SearchVector.cc
 
libHepMC_so_OBJECTS = $(patsubst %.cc,$(shareddir)/%.$(OBJEXT),$(libHepMC_a_SOURCES))
 
/trunk/src/Flow.cc
@@ -5,8 +5,8 @@
 
#include "HepMC/Flow.h"
#include "HepMC/GenParticle.h"
#include "HepMC/GenParticleComparison.h"
#include "HepMC/GenVertex.h"
#include "HepMC/SearchVector.h"
 
namespace HepMC {
 
@@ -35,7 +35,7 @@
ostr << "Flow(" << m_particle_owner << "): " << *this << std::endl;
}
std::set<GenParticle*,GenParticleComparison> Flow::connected_partners( int code, int code_index,
std::vector<GenParticle*> Flow::connected_partners( int code, int code_index,
int num_indices ) const {
/// Returns all flow partners which have "code" in any of the
/// num_indices beginning with index code_index.
@@ -46,10 +46,10 @@
/// set<GenParticle*> result =
/// p->flow().connected_partners(p->flow().icode(2),2,3);
//
std::set<GenParticle*,GenParticleComparison> output;
std::vector<GenParticle*> output;
for ( int i = code_index; i!=code_index+num_indices; ++i ) {
if ( icode(i)==code ) {
output.insert(m_particle_owner);
output.push_back(m_particle_owner);
connected_partners( &output, code, code_index, num_indices );
break;
}
@@ -57,7 +57,7 @@
return output;
}
 
void Flow::connected_partners( std::set<GenParticle*,GenParticleComparison>* output, int code,
void Flow::connected_partners( std::vector<GenParticle*>* output, int code,
int code_index, int num_indices ) const
{
/// protected: for recursive use by Flow::connected_partners()
@@ -74,8 +74,8 @@
// the set, then we recursively call connected_partners
for ( int index = code_index; index!=code_index+num_indices;
++index ){
if ( (*p)->flow(index)==code &&
output->insert(*p).second ) {
if ( (*p)->flow(index)==code && not_in_vector(output,(*p)) ) {
output->push_back(*p);
(*p)->flow().connected_partners( output, code,
code_index,
num_indices );
@@ -94,8 +94,8 @@
// the set, then we recursively call connected_partners
for ( int index = code_index; index!=code_index+num_indices;
++index ){
if ( (*p)->flow(index)==code &&
output->insert(*p).second ) {
if ( (*p)->flow(index)==code && not_in_vector(output,(*p)) ) {
output->push_back(*p);
(*p)->flow().connected_partners( output, code,
code_index,
num_indices );
@@ -105,13 +105,13 @@
}
}
 
std::set<GenParticle*,GenParticleComparison> Flow::dangling_connected_partners( int code,
std::vector<GenParticle*> Flow::dangling_connected_partners( int code,
int code_index, int num_indices ) const {
std::set<GenParticle*,GenParticleComparison> output;
std::set<GenParticle*,GenParticleComparison> visited_particles;
std::vector<GenParticle*> output;
std::vector<GenParticle*> visited_particles;
for ( int i = code_index; i!=code_index+num_indices; ++i ) {
if ( icode(i)==code ) {
visited_particles.insert(m_particle_owner);
visited_particles.push_back(m_particle_owner);
dangling_connected_partners( &output, &visited_particles, code,
code_index, num_indices );
break;
@@ -120,8 +120,8 @@
return output;
}
 
void Flow::dangling_connected_partners( std::set<GenParticle*,GenParticleComparison>* output,
std::set<GenParticle*,GenParticleComparison>*
void Flow::dangling_connected_partners( std::vector<GenParticle*>* output,
std::vector<GenParticle*>*
visited_particles,
int code, int code_index,
int num_indices ) const
@@ -143,7 +143,8 @@
++index ){
if ( (*p)->flow(index)==code ) {
if ( *p!=m_particle_owner ) ++count_partners;
if ( visited_particles->insert(*p).second ) {
if ( not_in_vector(visited_particles,(*p)) ) {
visited_particles->push_back(*p);
(*p)->flow().dangling_connected_partners( output,
visited_particles, code,
code_index, num_indices );
@@ -167,7 +168,8 @@
++index ){
if ( (*p)->flow(index)==code ) {
if ( *p!=m_particle_owner ) ++count_partners;
if ( visited_particles->insert(*p).second ) {
if ( not_in_vector(visited_particles,(*p)) ) {
visited_particles->push_back(*p);
(*p)->flow().dangling_connected_partners( output,
visited_particles, code,
code_index, num_indices );
@@ -177,7 +179,7 @@
}
}
}
if ( count_partners <= 1 ) output->insert( m_particle_owner );
if ( count_partners <= 1 ) output->push_back( m_particle_owner );
}
/////////////
/trunk/src/GenVertex.cc
@@ -6,6 +6,7 @@
#include "HepMC/GenParticle.h"
#include "HepMC/GenVertex.h"
#include "HepMC/GenEvent.h"
#include "HepMC/SearchVector.h"
#include <iomanip> // needed for formatted output
 
namespace HepMC {
@@ -273,9 +274,9 @@
// if inparticle previously had a decay vertex, remove it from that
// vertex's list
if ( inparticle->end_vertex() ) {
inparticle->end_vertex()->m_particles_in.erase( inparticle );
inparticle->end_vertex()->remove_particle_in( inparticle );
}
m_particles_in.insert( inparticle );
m_particles_in.push_back( inparticle );
inparticle->set_end_vertex_( this );
}
 
@@ -284,10 +285,9 @@
// if outparticle previously had a production vertex,
// remove it from that vertex's list
if ( outparticle->production_vertex() ) {
outparticle->production_vertex()->m_particles_out.erase(
outparticle );
outparticle->production_vertex()->remove_particle_out( outparticle );
}
m_particles_out.insert( outparticle );
m_particles_out.push_back( outparticle );
outparticle->set_production_vertex_( this );
}
 
@@ -304,15 +304,27 @@
if ( !particle ) return 0;
if ( particle->end_vertex() == this ) {
particle->set_end_vertex_( 0 );
m_particles_in.erase(particle);
remove_particle_in(particle);
}
if ( particle->production_vertex() == this ) {
particle->set_production_vertex_(0);
m_particles_out.erase(particle);
remove_particle_out(particle);
}
return particle;
}
 
void GenVertex::remove_particle_in( GenParticle* particle ) {
/// this finds *particle in m_particles_in and removes it from that list
if ( !particle ) return;
m_particles_in.erase( already_in_vector( &m_particles_in, particle ) );
}
 
void GenVertex::remove_particle_out( GenParticle* particle ) {
/// this finds *particle in m_particles_out and removes it from that list
if ( !particle ) return;
m_particles_out.erase( already_in_vector( &m_particles_out, particle ) );
}
 
void GenVertex::delete_adopted_particles() {
/// deletes all particles which this vertex owns
/// to be used by the vertex destructor and operator=
@@ -321,7 +333,7 @@
// 1. delete all outgoing particles which don't have decay vertices.
// those that do become the responsibility of the decay vertex
// and have their productionvertex pointer set to NULL
for ( std::set<GenParticle*,GenParticleComparison>::iterator part1 = m_particles_out.begin();
for ( std::vector<GenParticle*>::iterator part1 = m_particles_out.begin();
part1 != m_particles_out.end(); ) {
if ( !(*part1)->end_vertex() ) {
delete *(part1++);
@@ -335,7 +347,7 @@
// 2. delete all incoming particles which don't have production
// vertices. those that do become the responsibility of the
// production vertex and have their decayvertex pointer set to NULL
for ( std::set<GenParticle*,GenParticleComparison>::iterator part2 = m_particles_in.begin();
for ( std::vector<GenParticle*>::iterator part2 = m_particles_in.begin();
part2 != m_particles_in.end(); ) {
if ( !(*part2)->production_vertex() ) {
delete *(part2++);
New file
/trunk/src/SearchVector.cc
@@ -0,0 +1,29 @@
//////////////////////////////////////////////////////////////////////////
// Author: Lynn Garren
// search vectors for a GenParicle* instance
//////////////////////////////////////////////////////////////////////////
 
#include "HepMC/SearchVector.h"
 
namespace HepMC {
 
bool not_in_vector( std::vector<GenParticle*>* v, GenParticle* p )
{
if( already_in_vector(v,p) == v->end() ) return true;
return false;
}
 
/// returns true if GenParticle is in the vector
std::vector<HepMC::GenParticle*>::iterator already_in_vector( std::vector<GenParticle*>* v, GenParticle* p )
{
// if the vectors are mostly large, the search should be coded differently
std::vector<GenParticle*>::iterator it;
for( it = v->begin(); it != v->end(); ++it ) {
// bail as soon as we find a match
if( (*it) == p ) return it;
}
return v->end();
}
 
} // HepMC
/trunk/HepMC/IO_ExtendedAscii.h
@@ -43,6 +43,7 @@
#include <map>
#include <vector>
#include "HepMC/IO_BaseClass.h"
#include "HepMC/TempParticleMap.h"
 
namespace HepMC {
 
@@ -88,7 +89,7 @@
/// write vertex information
void write_vertex( GenVertex* );
/// write beam particle information
void write_beam_particles( std::pair<GenParticle *,GenParticle *> );
void write_beam_particles( std::pair<HepMC::GenParticle *,HepMC::GenParticle *> );
/// write heavy ion information
void write_heavy_ion( HeavyIon* );
/// write PDF information
@@ -98,11 +99,9 @@
/// write particle data information
void write_particle_data( const ParticleData* d );
/// read vertex information
GenVertex* read_vertex( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenVertex* read_vertex( TempParticleMap& particle_to_end_vertex );
/// read GenParticle information
GenParticle* read_particle( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenParticle* read_particle( TempParticleMap& particle_to_end_vertex );
/// read particle data table information
ParticleData* read_particle_data( ParticleDataTable* );
/// read heavy ion information
@@ -120,7 +119,7 @@
/// string manipulation accounting
bool eat_key( std::iostream& in, const char* key );
/// find this vertex in the map of vertices
int find_in_map( const std::map<GenVertex*,int>& m,
int find_in_map( const std::map<HepMC::GenVertex*,int>& m,
GenVertex* v) const;
 
void output( const double& ); //!< write double
/trunk/HepMC/Flow.h
@@ -41,20 +41,19 @@
// later on if we wish to know the color partner of q1 we can ask for a list
// of all particles connected via this code to q1 which do have less than
// 2 color partners using:
// set<GenParticle*> result=q1->dangling_connected_partners(q1->icode(1),1,2);
// vector<GenParticle*> result=q1->dangling_connected_partners(q1->icode(1),1,2);
// this will return a list containing q1 and q4.
// set<GenParticle*> result=q1->connected_partners(q1->icode(1),1,2);
// vector<GenParticle*> result=q1->connected_partners(q1->icode(1),1,2);
// would return a list containing q1, g, and q4.
//
 
#include <iostream>
#include <map>
#include <set>
#include <vector>
 
namespace HepMC {
 
class GenParticle;
class GenParticleComparison;
 
//! The flow object
 
@@ -89,12 +88,12 @@
 
/// returns all connected particles which have "code" in any of the
/// num_indices beginning with index code_index.
std::set<GenParticle*,GenParticleComparison> connected_partners( int code, int code_index =1,
std::vector<HepMC::GenParticle*> connected_partners( int code, int code_index =1,
int num_indices = 2 ) const;
/// same as connected_partners, but returns only those particles which
/// are connected to <=1 other particles (i.e. the flow line "dangles"
/// at these particles)
std::set<GenParticle*,GenParticleComparison> dangling_connected_partners( int code,
std::vector<HepMC::GenParticle*> dangling_connected_partners( int code,
int code_index = 1, int num_indices = 2 ) const;
 
////////////////////
@@ -138,14 +137,14 @@
 
protected: // intended for internal use only
/// for internal use only
void connected_partners( std::set<GenParticle*,GenParticleComparison>* output,
void connected_partners( std::vector<HepMC::GenParticle*>* output,
int code,
int code_index,
int num_indices ) const;
/// for internal use only
void dangling_connected_partners( std::set<GenParticle*,GenParticleComparison>*
void dangling_connected_partners( std::vector<HepMC::GenParticle*>*
output,
std::set<GenParticle*,GenParticleComparison>*
std::vector<HepMC::GenParticle*>*
visited_particles,
int code, int code_index,
int num_indices ) const;
/trunk/HepMC/GenEvent.h
@@ -147,11 +147,11 @@
GenEvent( int signal_process_id = 0, int event_number = 0,
GenVertex* signal_vertex = 0,
const WeightContainer& weights = std::vector<double>(),
const std::vector<long int>& randomstates = std::vector<long int>() );
const std::vector<long>& randomstates = std::vector<long>() );
/// explicit constructor that takes HeavyIon and PdfInfo
GenEvent( int signal_process_id, int event_number,
GenVertex* signal_vertex, const WeightContainer& weights,
const std::vector<long int>& randomstates,
const std::vector<long>& randomstates,
const HeavyIon& ion, const PdfInfo& pdf );
GenEvent( const GenEvent& inevent ); //!< deep copy
GenEvent& operator=( const GenEvent& inevent ); //!< make a deep copy
@@ -160,6 +160,7 @@
void swap( GenEvent & other ); //!< swap
void print( std::ostream& ostr = std::cout ) const; //!< dumps to ostr
void print_version( std::ostream& ostr = std::cout ) const; //!< dumps release version to ostr
 
/// assign a barcode to a particle
GenParticle* barcode_to_particle( int barCode ) const;
@@ -181,7 +182,7 @@
/// test to see if we have two valid beam particles
bool valid_beam_particles() const;
/// pair of pointers to the two incoming beam particles
std::pair<GenParticle*,GenParticle*> beam_particles() const;
std::pair<HepMC::GenParticle*,HepMC::GenParticle*> beam_particles() const;
 
/// direct access to the weights container is allowed.
/// Thus you can use myevt.weights()[2];
@@ -199,7 +200,7 @@
PdfInfo* pdf_info();
 
/// vector of integers containing information about the random state
std::vector<long int> random_states() const;
std::vector<long> random_states() const;
 
void set_signal_process_id( int id ); //!< set unique signal process id
void set_event_number( int eventno ); //!< set event number
@@ -213,9 +214,9 @@
/// set incoming beam particles
bool set_beam_particles(GenParticle*, GenParticle*);
/// use a pair of GenParticle*'s to set incoming beam particles
bool set_beam_particles(std::pair<GenParticle*,GenParticle*> const &);
bool set_beam_particles(std::pair<HepMC::GenParticle*,HepMC::GenParticle*> const &);
/// provide random state information
void set_random_states( const std::vector<long int>& randomstates );
void set_random_states( const std::vector<long>& randomstates );
 
/// provide a pointer to the HeavyIon container
void set_heavy_ion( const HeavyIon& ion );
@@ -253,13 +254,13 @@
/// HepMC::GenEvent::vertex_const_iterator
/// is used to iterate over all vertices in the event.
class vertex_const_iterator :
public std::iterator<std::forward_iterator_tag,GenVertex*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
// Iterates over all vertices in this event
public:
/// constructor requiring vertex information
vertex_const_iterator(
const
std::map<int,GenVertex*,std::greater<int> >::const_iterator& i)
std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator& i)
: m_map_iterator(i) {}
vertex_const_iterator() {}
/// copy constructor
@@ -285,7 +286,7 @@
{ return !(m_map_iterator == a.m_map_iterator); }
protected:
/// const iterator to a vertex map
std::map<int,GenVertex*,std::greater<int> >::const_iterator
std::map<int,HepMC::GenVertex*,std::greater<int> >::const_iterator
m_map_iterator;
};
friend class vertex_const_iterator;
@@ -305,13 +306,13 @@
/// HepMC::GenEvent::vertex_iterator
/// is used to iterate over all vertices in the event.
class vertex_iterator :
public std::iterator<std::forward_iterator_tag,GenVertex*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
// Iterates over all vertices in this event
public:
/// constructor requiring vertex information
vertex_iterator(
const
std::map<int,GenVertex*,std::greater<int> >::iterator& i )
std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator& i )
: m_map_iterator( i ) {}
vertex_iterator() {}
/// copy constructor
@@ -342,7 +343,7 @@
{ return !(m_map_iterator == a.m_map_iterator); }
protected:
/// iterator to the vertex map
std::map<int,GenVertex*,std::greater<int> >::iterator
std::map<int,HepMC::GenVertex*,std::greater<int> >::iterator
m_map_iterator;
};
friend class vertex_iterator;
@@ -372,12 +373,12 @@
/// HepMC::GenEvent::particle_const_iterator
/// is used to iterate over all particles in the event.
class particle_const_iterator :
public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
// Iterates over all vertices in this event
public:
/// iterate over particles
particle_const_iterator(
const std::map<int,GenParticle*>::const_iterator& i )
const std::map<int,HepMC::GenParticle*>::const_iterator& i )
: m_map_iterator(i) {}
particle_const_iterator() {}
/// copy constructor
@@ -405,7 +406,7 @@
{ return !(m_map_iterator == a.m_map_iterator); }
protected:
/// const iterator to the GenParticle map
std::map<int,GenParticle*>::const_iterator m_map_iterator;
std::map<int,HepMC::GenParticle*>::const_iterator m_map_iterator;
};
friend class particle_const_iterator;
/// begin particle iteration
@@ -423,11 +424,11 @@
/// HepMC::GenEvent::particle_iterator
/// is used to iterate over all particles in the event.
class particle_iterator :
public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
// Iterates over all vertices in this event
public:
/// iterate over particles
particle_iterator( const std::map<int,GenParticle*>::iterator& i )
particle_iterator( const std::map<int,HepMC::GenParticle*>::iterator& i )
: m_map_iterator( i ) {}
particle_iterator() {}
/// copy constructor
@@ -458,7 +459,7 @@
{ return !(m_map_iterator == a.m_map_iterator); }
protected:
/// iterator for GenParticle map
std::map<int,GenParticle*>::iterator m_map_iterator;
std::map<int,HepMC::GenParticle*>::iterator m_map_iterator;
};
friend class particle_iterator;
/// begin particle iteration
@@ -499,11 +500,11 @@
GenParticle* m_beam_particle_2;
WeightContainer m_weights; // weights for this event first weight
// is used by default for hit and miss
std::vector<long int> m_random_states; // container of rndm num
std::vector<long> m_random_states; // container of rndm num
// generator states
 
std::map< int,GenVertex*,std::greater<int> > m_vertex_barcodes;
std::map< int,GenParticle*,std::less<int> > m_particle_barcodes;
std::map< int,HepMC::GenVertex*,std::greater<int> > m_vertex_barcodes;
std::map< int,HepMC::GenParticle*,std::less<int> > m_particle_barcodes;
HeavyIon* m_heavy_ion; // undefined by default
PdfInfo* m_pdf_info; // undefined by default
 
@@ -560,7 +561,7 @@
/// generator to make use of this. We envision a vector of
/// RndmStatesTags to be included with a run class which
/// would specify the meaning of the random_states.
inline std::vector<long int> GenEvent::random_states() const
inline std::vector<long> GenEvent::random_states() const
{ return m_random_states; }
 
inline void GenEvent::set_signal_process_id( int id )
@@ -591,7 +592,7 @@
inline void GenEvent::set_pdf_info( const PdfInfo& p )
{ m_pdf_info = new PdfInfo(p); }
 
inline void GenEvent::set_random_states( const std::vector<long int>&
inline void GenEvent::set_random_states( const std::vector<long>&
randomstates )
{ m_random_states = randomstates; }
 
@@ -616,7 +617,7 @@
/// comes under the ownership of an event (i.e. it is contained in an event).
inline GenParticle* GenEvent::barcode_to_particle( int barCode ) const
{
std::map<int,GenParticle*>::const_iterator i
std::map<int,HepMC::GenParticle*>::const_iterator i
= m_particle_barcodes.find(barCode);
return ( i != m_particle_barcodes.end() ) ? (*i).second : 0;
}
@@ -655,7 +656,7 @@
}
// beam particles
inline std::pair<GenParticle *,GenParticle *> GenEvent::beam_particles() const {
inline std::pair<HepMC::GenParticle *,HepMC::GenParticle *> GenEvent::beam_particles() const {
return std::pair<GenParticle *,GenParticle *> (m_beam_particle_1, m_beam_particle_2);
}
 
New file
/trunk/HepMC/TempParticleMap.h
@@ -0,0 +1,69 @@
//--------------------------------------------------------------------------
#ifndef HEPMC_TempParticleMap_H
#define HEPMC_TempParticleMap_H
 
//////////////////////////////////////////////////////////////////////////
// garren@fnal.gov, October 2007
//
// Used by IO classes
//////////////////////////////////////////////////////////////////////////
 
#include <map>
 
namespace HepMC {
 
class GenParticle;
 
//! TempParticleMap is a temporary GenParticle* container used during input.
 
///
/// \class TempParticleMap
/// Used by IO classes for recoverable particle ordering.
/// Map GenParticle* against both outgoing vertex and particle order.
///
class TempParticleMap {
public:
typedef std::map<HepMC::GenParticle*,int> TempMap;
typedef std::map<int,HepMC::GenParticle*> TempOrderMap;
typedef TempMap::iterator TempMapIterator;
typedef TempOrderMap::iterator orderIterator;
TempParticleMap()
: m_particle_to_end_vertex(), m_particle_order(), m_counter(0) {}
~TempParticleMap() {}
TempMapIterator begin() { return m_particle_to_end_vertex.begin(); }
TempMapIterator end() { return m_particle_to_end_vertex.end(); }
orderIterator order_begin() { return m_particle_order.begin(); }
orderIterator order_end() { return m_particle_order.end(); }
int end_vertex( GenParticle* );
void addEndParticle( GenParticle*, int& );
private:
TempMap m_particle_to_end_vertex;
TempOrderMap m_particle_order;
int m_counter;
};
inline int TempParticleMap::end_vertex( GenParticle* p )
{
//return m_particle_to_end_vertex[p]->second;
TempMapIterator it = m_particle_to_end_vertex.find(p);
if( it == end() ) return 0;
return m_particle_to_end_vertex[p];
}
 
inline void TempParticleMap::addEndParticle( GenParticle* p, int& end_vtx_code )
{
++m_counter;
m_particle_order[m_counter] = p;
m_particle_to_end_vertex[p] = end_vtx_code;
}
 
} // HepMC
 
#endif // HEPMC_TempParticleMap_H
//--------------------------------------------------------------------------
/trunk/HepMC/GenParticle.h
@@ -79,7 +79,7 @@
/// dump this particle's full info to ostr
void print( std::ostream& ostr = std::cout ) const;
 
operator FourVector() const; //!< conversion operator
operator HepMC::FourVector() const; //!< conversion operator
 
////////////////////
// access methods //
@@ -122,8 +122,6 @@
/// vertex barcodes are negative numbers.
int barcode() const; //!< particle barcode
 
hepmc_uint64_t serialnumber() const; //!< used by GenParticleComparison
 
/// In general there is no reason to "suggest_barcode"
bool suggest_barcode( int the_bar_code );
 
@@ -162,17 +160,15 @@
GenVertex* m_end_vertex; // null if not-decayed
int m_barcode; // unique identifier in the event
double m_generated_mass; // mass of this particle when it was generated
hepmc_uint64_t m_serialnumber; // unique ID for set comparator
 
static unsigned int s_counter;
static hepmc_uint64_t s_serialize;
};
 
//////////////
// INLINES //
//////////////
 
inline GenParticle::operator FourVector() const
inline GenParticle::operator HepMC::FourVector() const
{ return m_momentum; }
 
inline FourVector GenParticle::momentum() const
/trunk/HepMC/IO_GenEvent.h
@@ -15,6 +15,7 @@
#include <map>
#include <vector>
#include "HepMC/IO_BaseClass.h"
#include "HepMC/TempParticleMap.h"
 
namespace HepMC {
 
@@ -92,7 +93,7 @@
/// write vertex information
void write_vertex( GenVertex* );
/// write beam particle information
void write_beam_particles( std::pair<GenParticle *,GenParticle *> );
void write_beam_particles( std::pair<HepMC::GenParticle *,HepMC::GenParticle *> );
/// write heavy ion information
void write_heavy_ion( HeavyIon* );
/// write PDF information
@@ -102,11 +103,9 @@
/// write particle data information
void write_particle_data( const ParticleData* d );
/// read vertex information
GenVertex* read_vertex( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenVertex* read_vertex( TempParticleMap& particle_to_end_vertex );
/// read GenParticle information
GenParticle* read_particle( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenParticle* read_particle( TempParticleMap& particle_to_end_vertex );
/// read particle data table information
ParticleData* read_particle_data( ParticleDataTable* );
/// read heavy ion information
@@ -124,7 +123,7 @@
/// string manipulation accounting
bool eat_key( std::istream& in, const char* key );
/// find this vertex in the map of vertices
int find_in_map( const std::map<GenVertex*,int>& m,
int find_in_map( const std::map<HepMC::GenVertex*,int>& m,
GenVertex* v) const;
 
void output( const double& ); //!< write double
/trunk/HepMC/ParticleDataTable.h
@@ -72,9 +72,9 @@
/// removes from table - does not delete
bool erase( int id );
/// iterator for ParticleData map
typedef std::map<int,ParticleData*>::iterator iterator;
typedef std::map<int,HepMC::ParticleData*>::iterator iterator;
/// const iterator for ParticleData map
typedef std::map<int,ParticleData*>::const_iterator const_iterator;
typedef std::map<int,HepMC::ParticleData*>::const_iterator const_iterator;
/// begin iteration
iterator begin();
/// end iteration
@@ -96,8 +96,8 @@
void set_description( const char );
 
private:
std::string m_description;
std::map<int,ParticleData*> m_data_table;
std::string m_description;
std::map<int,HepMC::ParticleData*> m_data_table;
};
 
///////////////////////////
/trunk/HepMC/GenVertex.h
@@ -23,7 +23,6 @@
 
#include "HepMC/WeightContainer.h"
#include "HepMC/SimpleVector.h"
#include "HepMC/GenParticleComparison.h"
#include <iostream>
#include <iterator>
#include <vector>
@@ -88,8 +87,8 @@
/// delete vtx->remove_particle( particle );
GenParticle* remove_particle( GenParticle* particle ); //!< remove a particle
 
operator FourVector() const; //!< conversion operator
operator ThreeVector() const; //!< conversion operator
operator HepMC::FourVector() const; //!< conversion operator
operator HepMC::ThreeVector() const; //!< conversion operator
 
////////////////////
// access methods //
@@ -127,10 +126,10 @@
////////////////////
 
/// const iterator for incoming particles
typedef std::set<GenParticle*,GenParticleComparison>::const_iterator
typedef std::vector<HepMC::GenParticle*>::const_iterator
particles_in_const_iterator;
/// const iterator for outgoing particles
typedef std::set<GenParticle*,GenParticleComparison>::const_iterator
typedef std::vector<HepMC::GenParticle*>::const_iterator
particles_out_const_iterator;
/// begin iteration of incoming particles
particles_in_const_iterator particles_in_const_begin() const;
@@ -170,7 +169,7 @@
/// for the public iterators and is intended for internal use only.
/// The acceptable Iterator Ranges are: family, parents, children
class edge_iterator :
public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
public:
edge_iterator();
/// used to set limits on the iteration
@@ -199,7 +198,7 @@
private:
const GenVertex* m_vertex;
IteratorRange m_range;
std::set<GenParticle*,GenParticleComparison>::const_iterator m_set_iter;
std::vector<HepMC::GenParticle*>::const_iterator m_set_iter;
bool m_is_inparticle_iter;
bool m_is_past_end;
};
@@ -234,14 +233,14 @@
/// vertex) and returning the vertices in POST ORDER traversal.
///
class vertex_iterator :
public std::iterator<std::forward_iterator_tag,GenVertex*,ptrdiff_t>{
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
public:
vertex_iterator();
/// used to set limits on the iteration
vertex_iterator( GenVertex& vtx_root, IteratorRange range );
/// next constructor is intended for internal use only
vertex_iterator( GenVertex& vtx_root, IteratorRange range,
std::set<const GenVertex*>& visited_vertices );
std::set<const HepMC::GenVertex*>& visited_vertices );
/// copy
vertex_iterator( const vertex_iterator& v_iter );
virtual ~vertex_iterator();
@@ -264,7 +263,7 @@
/// intended for internal use only.
void copy_with_own_set( const vertex_iterator&
v_iter,
std::set<const GenVertex*>&
std::set<const HepMC::GenVertex*>&
visited_vertices );
 
protected: // intended for internal use only
@@ -276,7 +275,7 @@
private:
GenVertex* m_vertex; // the vertex associated to this iter
IteratorRange m_range;
std::set<const GenVertex*>* m_visited_vertices;
std::set<const HepMC::GenVertex*>* m_visited_vertices;
bool m_it_owns_set; // true if it is responsible for
// deleting the visited vertex set
edge_iterator m_edge; // particle edge pointing to return vtx
@@ -342,11 +341,15 @@
protected:
/// for internal use only
void delete_adopted_particles();
/// for internal use only - remove particle from incoming list
void remove_particle_in( GenParticle* );
/// for internal use only - remove particle from outgoing list
void remove_particle_out( GenParticle* );
private: // GenVertex data members
FourVector m_position; //4-vec of vertex [mm]
std::set<GenParticle*,GenParticleComparison> m_particles_in; //all incoming particles
std::set<GenParticle*,GenParticleComparison> m_particles_out; //all outgoing particles
std::vector<HepMC::GenParticle*> m_particles_in; //all incoming particles
std::vector<HepMC::GenParticle*> m_particles_out; //all outgoing particles
int m_id;
WeightContainer m_weights; // weights for this vtx
GenEvent* m_event;
@@ -359,9 +362,9 @@
// INLINES access methods //
////////////////////////////
 
inline GenVertex::operator FourVector() const { return position(); }
inline GenVertex::operator HepMC::FourVector() const { return position(); }
 
inline GenVertex::operator ThreeVector() const { return point3d(); }
inline GenVertex::operator HepMC::ThreeVector() const { return point3d(); }
 
inline FourVector GenVertex::position() const { return m_position; }
 
/trunk/HepMC/IO_Ascii.h
@@ -43,6 +43,7 @@
#include <map>
#include <vector>
#include "HepMC/IO_BaseClass.h"
#include "HepMC/TempParticleMap.h"
 
namespace HepMC {
 
@@ -91,11 +92,9 @@
/// write ParticleDataTable information
void write_particle_data( const ParticleData* d );
/// read vertex information
GenVertex* read_vertex( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenVertex* read_vertex( TempParticleMap& particle_to_end_vertex );
/// read GenParticle information
GenParticle* read_particle( std::map<GenParticle*,int>&
particle_to_end_vertex );
GenParticle* read_particle( TempParticleMap& particle_to_end_vertex );
/// read ParticleDataTable information
ParticleData* read_particle_data( ParticleDataTable* );
/// write end tag
/trunk/HepMC/IO_HEPEVT.h
@@ -19,7 +19,7 @@
//
//
 
#include <set>
#include <map>
#include <vector>
#include "HepMC/IO_BaseClass.h"
#include "HepMC/HEPEVT_Wrapper.h"
@@ -86,13 +86,13 @@
GenParticle* build_particle( int index );
/// create a production vertex
void build_production_vertex(
int i,std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
int i,std::vector<HepMC::GenParticle*>& hepevt_particle, GenEvent* evt );
/// create an end vertex
void build_end_vertex(
int i, std::vector<GenParticle*>& hepevt_particle, GenEvent* evt );
int i, std::vector<HepMC::GenParticle*>& hepevt_particle, GenEvent* evt );
/// find this particle in the particle map
int find_in_map(
const std::map<GenParticle*,int>& m, GenParticle* p) const;
const std::map<HepMC::GenParticle*,int>& m, GenParticle* p) const;
 
private: // following are not implemented for HEPEVT
virtual void write_particle_data_table( const ParticleDataTable* ){}
/trunk/HepMC/Makefile.am
@@ -11,7 +11,6 @@
Flow.h \
GenEvent.h \
GenParticle.h \
GenParticleComparison.h \
GenVertex.h \
HeavyIon.h \
HEPEVT_Wrapper.h \
@@ -36,11 +35,13 @@
PythiaWrapper6_2_WIN32.h \
PythiaWrapper.h \
WeightContainer.h \
SearchVector.h \
SimpleVector.h \
SimpleVector.icc \
enable_if.h \
is_arithmetic.h \
HepMC_CLHEP20.h \
TempParticleMap.h \
Version.h \
defs.h
 
New file
/trunk/HepMC/SearchVector.h
@@ -0,0 +1,25 @@
#ifndef SearchVector_h
#define SearchVector_h
// ----------------------------------------------------------------------
//
// SearchVector.h
// Author: Lynn Garren
//
// Utilities to search std::vector<GenParticle*> a GenParticle instance
// ----------------------------------------------------------------------
 
#include "HepMC/GenVertex.h"
#include "HepMC/GenParticle.h"
 
namespace HepMC {
/// returns true if it cannot find GenParticle* in the vector
bool not_in_vector( std::vector<HepMC::GenParticle*>*, GenParticle* );
 
/// Returns the index of a GenParticle* within a vector.
/// Returns -1 if GenParticle* is not in the vector.
std::vector<HepMC::GenParticle*>::iterator already_in_vector( std::vector<HepMC::GenParticle*>*, GenParticle* );
 
} // HepMC
 
#endif // SearchVector_h