/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Static Public Member Functions | Static Protected Member Functions | Static Private Attributes
HepMC::HEPEVT_Wrapper Class Reference

Generic Wrapper for the fortran HEPEVT common block. More...

#include <HEPEVT_Wrapper.h>

List of all members.

Static Public Member Functions

static void print_hepevt (std::ostream &ostr=std::cout)
 write information from HEPEVT common block
static void print_hepevt_particle (int index, std::ostream &ostr=std::cout)
 write particle information to ostr
static bool is_double_precision ()
 True if common block uses double.
static bool check_hepevt_consistency (std::ostream &ostr=std::cout)
 check for problems with HEPEVT common block
static void zero_everything ()
 set all entries in HEPEVT to zero
static int event_number ()
 event number
static int number_entries ()
 num entries in current evt
static int status (int index)
 status code
static int id (int index)
 PDG particle id.
static int first_parent (int index)
 index of 1st mother
static int last_parent (int index)
 index of last mother
static int number_parents (int index)
 number of parents
static int first_child (int index)
 index of 1st daughter
static int last_child (int index)
 index of last daughter
static int number_children (int index)
 number of children
static double px (int index)
 X momentum.
static double py (int index)
 Y momentum.
static double pz (int index)
 Z momentum.
static double e (int index)
 Energy.
static double m (int index)
 generated mass
static double x (int index)
 X Production vertex.
static double y (int index)
 Y Production vertex.
static double z (int index)
 Z Production vertex.
static double t (int index)
 production time
static void set_event_number (int evtno)
 set event number
static void set_number_entries (int noentries)
 set number of entries in HEPEVT
static void set_status (int index, int status)
 set particle status
static void set_id (int index, int id)
 set particle ID
static void set_parents (int index, int firstparent, int lastparent)
 define parents of a particle
static void set_children (int index, int firstchild, int lastchild)
 define children of a particle
static void set_momentum (int index, double px, double py, double pz, double e)
 set particle momentum
static void set_mass (int index, double mass)
 set particle mass
static void set_position (int index, double x, double y, double z, double t)
 set particle production vertex
static unsigned int sizeof_int ()
 size of integer in bytes
static unsigned int sizeof_real ()
 size of real in bytes
static int max_number_entries ()
 size of common block
static void set_sizeof_int (unsigned int)
 define size of integer
static void set_sizeof_real (unsigned int)
 define size of real
static void set_max_number_entries (unsigned int)
 define size of common block

Static Protected Member Functions

static double byte_num_to_double (unsigned int)
 navigate a byte array
static int byte_num_to_int (unsigned int)
 navigate a byte array
static void write_byte_num (double, unsigned int)
 pretend common block is an array of bytes
static void write_byte_num (int, unsigned int)
 pretend common block is an array of bytes
static void print_legend (std::ostream &ostr=std::cout)
 print output legend

Static Private Attributes

static unsigned int s_sizeof_int
static unsigned int s_sizeof_real
static unsigned int s_max_number_entries

Detailed Description

Generic Wrapper for the fortran HEPEVT common block.

This class is intended for static use only - it makes no sense to instantiate it.

Definition at line 130 of file HEPEVT_Wrapper.h.


Member Function Documentation

static void HepMC::HEPEVT_Wrapper::print_hepevt ( std::ostream &  ostr = std::cout) [static]

write information from HEPEVT common block

static void HepMC::HEPEVT_Wrapper::print_hepevt_particle ( int  index,
std::ostream &  ostr = std::cout 
) [static]

write particle information to ostr

bool HepMC::HEPEVT_Wrapper::is_double_precision ( ) [inline, static]

True if common block uses double.

Definition at line 337 of file HEPEVT_Wrapper.h.

    { 
        // true if 8byte floating point numbers are used in the HepEVT common.
        return ( sizeof(double) == sizeof_real() );
    }
static bool HepMC::HEPEVT_Wrapper::check_hepevt_consistency ( std::ostream &  ostr = std::cout) [static]

check for problems with HEPEVT common block

static void HepMC::HEPEVT_Wrapper::zero_everything ( ) [static]

set all entries in HEPEVT to zero

int HepMC::HEPEVT_Wrapper::event_number ( ) [inline, static]

event number

Definition at line 343 of file HEPEVT_Wrapper.h.

    { return byte_num_to_int(0); }
int HepMC::HEPEVT_Wrapper::number_entries ( ) [inline, static]

num entries in current evt

Definition at line 346 of file HEPEVT_Wrapper.h.

    { 
        int nhep = byte_num_to_int( 1*sizeof_int() );
        return ( nhep <= max_number_entries() ?
                 nhep : max_number_entries() );
    }
int HepMC::HEPEVT_Wrapper::status ( int  index) [inline, static]

status code

Definition at line 353 of file HEPEVT_Wrapper.h.

    { return byte_num_to_int( (2+index-1) * sizeof_int() ); }
int HepMC::HEPEVT_Wrapper::id ( int  index) [inline, static]

PDG particle id.

Definition at line 356 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_int( (2+max_number_entries()+index-1) 
                                * sizeof_int() ); 
    }
int HepMC::HEPEVT_Wrapper::first_parent ( int  index) [inline, static]

index of 1st mother

Definition at line 362 of file HEPEVT_Wrapper.h.

    { 
        int parent = byte_num_to_int( (2+2*max_number_entries()+2*(index-1)) 
                                      * sizeof_int() ); 
        return ( parent > 0 && parent <= number_entries() ) ?
                                         parent : 0; 
    }
int HepMC::HEPEVT_Wrapper::last_parent ( int  index) [inline, static]

index of last mother

Definition at line 370 of file HEPEVT_Wrapper.h.

    { 
        // Returns the Index of the LAST parent in the HEPEVT record
        // for particle with Index index.
        // If there is only one parent, the last parent is forced to 
        // be the same as the first parent.
        // If there are no parents for this particle, both the first_parent
        // and the last_parent with return 0.
        // Error checking is done to ensure the parent is always
        // within range ( 0 <= parent <= nhep )
        //
        int firstparent = first_parent(index);
        int parent = byte_num_to_int( (2+2*max_number_entries()+2*(index-1)+1) 
                                      * sizeof_int() ); 
        return ( parent > firstparent && parent <= number_entries() ) 
                                                   ? parent : firstparent; 
    }
int HepMC::HEPEVT_Wrapper::number_parents ( int  index) [inline, static]

number of parents

Definition at line 388 of file HEPEVT_Wrapper.h.

                                                         {
        int firstparent = first_parent(index);
        return ( firstparent>0 ) ? 
            ( 1+last_parent(index)-firstparent ) : 0;
    }
int HepMC::HEPEVT_Wrapper::first_child ( int  index) [inline, static]

index of 1st daughter

Definition at line 394 of file HEPEVT_Wrapper.h.

    { 
        int child = byte_num_to_int( (2+4*max_number_entries()+2*(index-1)) 
                                     * sizeof_int() ); 
        return ( child > 0 && child <= number_entries() ) ?
                                       child : 0; 
    }
int HepMC::HEPEVT_Wrapper::last_child ( int  index) [inline, static]

index of last daughter

Definition at line 402 of file HEPEVT_Wrapper.h.

    { 
        // Returns the Index of the LAST child in the HEPEVT record
        // for particle with Index index.
        // If there is only one child, the last child is forced to 
        // be the same as the first child.
        // If there are no children for this particle, both the first_child
        // and the last_child with return 0.
        // Error checking is done to ensure the child is always
        // within range ( 0 <= parent <= nhep )
        //
        int firstchild = first_child(index);
        int child = byte_num_to_int( (2+4*max_number_entries()+2*(index-1)+1) 
                                     * sizeof_int() ); 
        return ( child > firstchild && child <= number_entries() ) 
                                                ? child : firstchild;
    }
int HepMC::HEPEVT_Wrapper::number_children ( int  index) [inline, static]

number of children

Definition at line 420 of file HEPEVT_Wrapper.h.

    {
        int firstchild = first_child(index);
        return ( firstchild>0 ) ? 
            ( 1+last_child(index)-firstchild ) : 0;
    }
double HepMC::HEPEVT_Wrapper::px ( int  index) [inline, static]

X momentum.

Definition at line 427 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                 + (5*(index-1)+0) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::py ( int  index) [inline, static]

Y momentum.

Definition at line 433 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                 + (5*(index-1)+1) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::pz ( int  index) [inline, static]

Z momentum.

Definition at line 440 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                 + (5*(index-1)+2) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::e ( int  index) [inline, static]

Energy.

Definition at line 446 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                 + (5*(index-1)+3) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::m ( int  index) [inline, static]

generated mass

Definition at line 452 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                 + (5*(index-1)+4) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::x ( int  index) [inline, static]

X Production vertex.

Definition at line 458 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                   + ( 5*max_number_entries()
                                       + (4*(index-1)+0) ) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::y ( int  index) [inline, static]

Y Production vertex.

Definition at line 465 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                   + ( 5*max_number_entries()
                                       + (4*(index-1)+1) ) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::z ( int  index) [inline, static]

Z Production vertex.

Definition at line 472 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                   + ( 5*max_number_entries()
                                       + (4*(index-1)+2) ) *sizeof_real() );
    }
double HepMC::HEPEVT_Wrapper::t ( int  index) [inline, static]

production time

Definition at line 479 of file HEPEVT_Wrapper.h.

    { 
        return byte_num_to_double( (2+6*max_number_entries())*sizeof_int()
                                   + ( 5*max_number_entries()
                                       + (4*(index-1)+3) ) *sizeof_real() );
    }
void HepMC::HEPEVT_Wrapper::set_event_number ( int  evtno) [inline, static]

set event number

Definition at line 486 of file HEPEVT_Wrapper.h.

    { write_byte_num( evtno, 0 ); }
void HepMC::HEPEVT_Wrapper::set_number_entries ( int  noentries) [inline, static]

set number of entries in HEPEVT

Definition at line 489 of file HEPEVT_Wrapper.h.

    { write_byte_num( noentries, 1*sizeof_int() ); }
void HepMC::HEPEVT_Wrapper::set_status ( int  index,
int  status 
) [inline, static]

set particle status

Definition at line 492 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( status, (2+index-1) * sizeof_int() );
    }
void HepMC::HEPEVT_Wrapper::set_id ( int  index,
int  id 
) [inline, static]

set particle ID

Definition at line 498 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( id, (2+max_number_entries()+index-1) *sizeof_int() );
    }
void HepMC::HEPEVT_Wrapper::set_parents ( int  index,
int  firstparent,
int  lastparent 
) [inline, static]

define parents of a particle

Definition at line 504 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( firstparent, (2+2*max_number_entries()+2*(index-1)) 
                                     *sizeof_int() );
        write_byte_num( lastparent, (2+2*max_number_entries()+2*(index-1)+1) 
                                    * sizeof_int() );
    }
void HepMC::HEPEVT_Wrapper::set_children ( int  index,
int  firstchild,
int  lastchild 
) [inline, static]

define children of a particle

Definition at line 514 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( firstchild, (2+4*max_number_entries()+2*(index-1)) 
                                     *sizeof_int() );
        write_byte_num( lastchild, (2+4*max_number_entries()+2*(index-1)+1) 
                                    *sizeof_int() );
    }
void HepMC::HEPEVT_Wrapper::set_momentum ( int  index,
double  px,
double  py,
double  pz,
double  e 
) [inline, static]

set particle momentum

Definition at line 524 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( px, (2+6*max_number_entries()) *sizeof_int()
                            + (5*(index-1)+0) *sizeof_real() );
        write_byte_num( py, (2+6*max_number_entries())*sizeof_int()
                            + (5*(index-1)+1) *sizeof_real() );
        write_byte_num( pz, (2+6*max_number_entries())*sizeof_int()
                            + (5*(index-1)+2) *sizeof_real() );
        write_byte_num( e,  (2+6*max_number_entries())*sizeof_int()
                            + (5*(index-1)+3) *sizeof_real() );
    }
void HepMC::HEPEVT_Wrapper::set_mass ( int  index,
double  mass 
) [inline, static]

set particle mass

Definition at line 538 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( mass, (2+6*max_number_entries())*sizeof_int()
                              + (5*(index-1)+4) *sizeof_real() );
    }
void HepMC::HEPEVT_Wrapper::set_position ( int  index,
double  x,
double  y,
double  z,
double  t 
) [inline, static]

set particle production vertex

Definition at line 545 of file HEPEVT_Wrapper.h.

    {
        if ( index <= 0 || index > max_number_entries() ) return;
        write_byte_num( x, (2+6*max_number_entries())*sizeof_int()
                           + ( 5*max_number_entries()
                               + (4*(index-1)+0) ) *sizeof_real() );
        write_byte_num( y, (2+6*max_number_entries())*sizeof_int()
                           + ( 5*max_number_entries()
                               + (4*(index-1)+1) ) *sizeof_real() );
        write_byte_num( z, (2+6*max_number_entries())*sizeof_int()
                           + ( 5*max_number_entries()
                               + (4*(index-1)+2) ) *sizeof_real() );
        write_byte_num( t, (2+6*max_number_entries())*sizeof_int()
                           + ( 5*max_number_entries()
                               + (4*(index-1)+3) ) *sizeof_real() );
    }
unsigned int HepMC::HEPEVT_Wrapper::sizeof_int ( ) [inline, static]

size of integer in bytes

Definition at line 225 of file HEPEVT_Wrapper.h.

{ return s_sizeof_int; }
unsigned int HepMC::HEPEVT_Wrapper::sizeof_real ( ) [inline, static]

size of real in bytes

Definition at line 227 of file HEPEVT_Wrapper.h.

{ return s_sizeof_real; }
int HepMC::HEPEVT_Wrapper::max_number_entries ( ) [inline, static]

size of common block

Definition at line 229 of file HEPEVT_Wrapper.h.

    { return (int)s_max_number_entries; }
void HepMC::HEPEVT_Wrapper::set_sizeof_int ( unsigned int  size) [inline, static]

define size of integer

Definition at line 232 of file HEPEVT_Wrapper.h.

    {
        if ( size != sizeof(short int) && size != sizeof(long int) && size != sizeof(int) ) {
            std::cerr << "HepMC is not able to handle integers "
                      << " of size other than 2 or 4."
                      << " You requested: " << size << std::endl;
        }
        s_sizeof_int = size;
    }
void HepMC::HEPEVT_Wrapper::set_sizeof_real ( unsigned int  size) [inline, static]

define size of real

Definition at line 242 of file HEPEVT_Wrapper.h.

                                                                   {
        if ( size != sizeof(float) && size != sizeof(double) ) {
            std::cerr << "HepMC is not able to handle floating point numbers"
                      << " of size other than 4 or 8."
                      << " You requested: " << size << std::endl;
        }
        s_sizeof_real = size;
    }
void HepMC::HEPEVT_Wrapper::set_max_number_entries ( unsigned int  size) [inline, static]

define size of common block

Definition at line 251 of file HEPEVT_Wrapper.h.

                                                                          {
        s_max_number_entries = size;
    }
double HepMC::HEPEVT_Wrapper::byte_num_to_double ( unsigned int  b) [inline, static, protected]

navigate a byte array

Definition at line 255 of file HEPEVT_Wrapper.h.

                                                                     {
        if ( b >= hepevt_bytes_allocation ) std::cerr 
                  << "HEPEVT_Wrapper: requested hepevt data exceeds allocation"
                  << std::endl;
        if ( s_sizeof_real == sizeof(float) ) {
            float* myfloat = (float*)&hepevt.data[b];
            return (double)(*myfloat);
        } else if ( s_sizeof_real == sizeof(double) ) {
            double* mydouble = (double*)&hepevt.data[b];
            return (*mydouble);
        } else {
            std::cerr 
                << "HEPEVT_Wrapper: illegal floating point number length." 
                << s_sizeof_real << std::endl;
        }
        return 0;
    }
int HepMC::HEPEVT_Wrapper::byte_num_to_int ( unsigned int  b) [inline, static, protected]

navigate a byte array

Definition at line 273 of file HEPEVT_Wrapper.h.

                                                               {
        if ( b >= hepevt_bytes_allocation ) std::cerr 
                  << "HEPEVT_Wrapper: requested hepevt data exceeds allocation"
                  << std::endl;
        if ( s_sizeof_int == sizeof(short int) ) {
            short int* myshortint = (short int*)&hepevt.data[b];
            return (int)(*myshortint);
        } else if ( s_sizeof_int == sizeof(long int) ) {
            long int* mylongint = (long int*)&hepevt.data[b];
            return (*mylongint);
       // on some 64 bit machines, int, short, and long are all different
        } else if ( s_sizeof_int == sizeof(int) ) {
            int* myint = (int*)&hepevt.data[b];
            return (*myint);
        } else {
            std::cerr 
                << "HEPEVT_Wrapper: illegal integer number length." 
                << s_sizeof_int << std::endl;
        }
        return 0;
    }
void HepMC::HEPEVT_Wrapper::write_byte_num ( double  in,
unsigned int  b 
) [inline, static, protected]

pretend common block is an array of bytes

Definition at line 295 of file HEPEVT_Wrapper.h.

                                                                          {
        if ( b >= hepevt_bytes_allocation ) std::cerr 
                  << "HEPEVT_Wrapper: requested hepevt data exceeds allocation"
                  << std::endl;
        if ( s_sizeof_real == sizeof(float) ) {
            float* myfloat = (float*)&hepevt.data[b];
            (*myfloat) = (float)in;
        } else if ( s_sizeof_real == sizeof(double) ) {
            double* mydouble = (double*)&hepevt.data[b];
            (*mydouble) = (double)in;
        } else {
            std::cerr 
                << "HEPEVT_Wrapper: illegal floating point number length." 
                << s_sizeof_real << std::endl;
        }
    }
void HepMC::HEPEVT_Wrapper::write_byte_num ( int  in,
unsigned int  b 
) [inline, static, protected]

pretend common block is an array of bytes

Definition at line 312 of file HEPEVT_Wrapper.h.

                                                                       {
        if ( b >= hepevt_bytes_allocation ) std::cerr 
                  << "HEPEVT_Wrapper: requested hepevt data exceeds allocation"
                  << std::endl;
        if ( s_sizeof_int == sizeof(short int) ) {
            short int* myshortint = (short int*)&hepevt.data[b];
            (*myshortint) = (short int)in;
        } else if ( s_sizeof_int == sizeof(long int) ) {
            long int* mylongint = (long int*)&hepevt.data[b];
            (*mylongint) = (int)in;
       // on some 64 bit machines, int, short, and long are all different
        } else if ( s_sizeof_int == sizeof(int) ) {
            int* myint = (int*)&hepevt.data[b];
            (*myint) = (int)in;
        } else {
            std::cerr 
                << "HEPEVT_Wrapper: illegal integer number length." 
                << s_sizeof_int << std::endl;
        }
    }
static void HepMC::HEPEVT_Wrapper::print_legend ( std::ostream &  ostr = std::cout) [static, protected]

print output legend


Member Data Documentation

unsigned int HepMC::HEPEVT_Wrapper::s_sizeof_int [static, private]

Definition at line 216 of file HEPEVT_Wrapper.h.

unsigned int HepMC::HEPEVT_Wrapper::s_sizeof_real [static, private]

Definition at line 217 of file HEPEVT_Wrapper.h.

unsigned int HepMC::HEPEVT_Wrapper::s_max_number_entries [static, private]

Definition at line 218 of file HEPEVT_Wrapper.h.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:49:37 for HepMC by doxygen 1.7.4