HepMC3 event record library
HEPEVT_Wrapper_Runtime.h
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// This file is part of HepMC
4// Copyright (C) 2014-2021 The HepMC collaboration (see AUTHORS for details)
5//
6#ifndef HEPMC3_HEPEVT_WRAPPER_RUNTIME_H
7#define HEPMC3_HEPEVT_WRAPPER_RUNTIME_H
8#include <iostream>
9#include <cstdio>
10#include <set>
11#include <map>
12#include <cstring> // memset
13#include <algorithm> //min max for VS2017
14#include "HepMC3/GenEvent.h"
15#include "HepMC3/GenParticle.h"
16#include "HepMC3/GenVertex.h"
18
19/**
20 * @file HEPEVT_Wrapper_Runtime.h
21 * @brief Definition of \b class HEPEVT_Wrapper_Runtime
22 *
23 * @class HepMC3::HEPEVT_Wrapper_Runtime
24 * @brief An interface to HEPEVT common block implemented to deal with varying block size in runtime
25 */
26namespace HepMC3
27{
28
30{
31//
32// Functions
33//
34public:
35 /** @brief Default constructor */
37 /** @brief Default destructor */
39 /** @brief Print information from HEPEVT common block */
40 void print_hepevt( std::ostream& ostr = std::cout ) const;
41 /** @brief Print particle information */
42 void print_hepevt_particle( int index, std::ostream& ostr = std::cout ) const;
43 /** @brief Set all entries in HEPEVT to zero */
44 void zero_everything();
45 /** @brief Convert GenEvent to HEPEVT*/
46 bool GenEvent_to_HEPEVT( const GenEvent* evt ) { return GenEvent_to_HEPEVT_nonstatic(evt, this);};
47 /** @brief Convert HEPEVT to GenEvent*/
48 bool HEPEVT_to_GenEvent( GenEvent* evt ) const { return HEPEVT_to_GenEvent_nonstatic(evt, this);};
49 /** @brief Tries to fix list of daughters */
50 bool fix_daughters();
51private:
52 /** @brief Fortran common block HEPEVT */
53 std::shared_ptr<struct HEPEVT_Pointers<double> > m_hepevtptr;
54 /** @brief Block size */
56 /** @brief Internalstorage storage. Optional.*/
57 std::vector<char> m_internal_storage;
58//
59// Accessors
60//
61public:
62 void allocate_internal_storage(); //!< Allocates m_internal_storage storage in smart pointer to hold HEPEVT of fixed size
63 void copy_to_internal_storage( char *c, int N ); //!< Copies the content of foreight common block into the internal storage
64 void set_max_number_entries( unsigned int size ) { m_max_particles = size; }//!< Set block size
65 void set_hepevt_address(char *c); //!< Set Fortran block address
66 int max_number_entries() const { return m_max_particles; } //!< Block size
67 int event_number() const { return *(m_hepevtptr->nevhep); } //!< Get event number
68 int number_entries() const { return *(m_hepevtptr->nhep); } //!< Get number of entries
69 int status(const int index ) const { return m_hepevtptr->isthep[index-1]; } //!< Get status code
70 int id(const int index ) const { return m_hepevtptr->idhep[index-1]; } //!< Get PDG particle id
71 int first_parent(const int index ) const { return m_hepevtptr->jmohep[2*(index-1)]; } //!< Get index of 1st mother
72 int last_parent(const int index ) const { return m_hepevtptr->jmohep[2*(index-1)+1]; } //!< Get index of last mother
73 int first_child(const int index ) const { return m_hepevtptr->jdahep[2*(index-1)]; } //!< Get index of 1st daughter
74 int last_child(const int index ) const { return m_hepevtptr->jdahep[2*(index-1)+1]; } //!< Get index of last daughter
75 double px(const int index ) const { return m_hepevtptr->phep[5*(index-1)]; } //!< Get X momentum
76 double py(const int index ) const { return m_hepevtptr->phep[5*(index-1)+1]; } //!< Get Y momentum
77 double pz(const int index ) const { return m_hepevtptr->phep[5*(index-1)+2]; } //!< Get Z momentum
78 double e(const int index ) const { return m_hepevtptr->phep[5*(index-1)+3]; } //!< Get Energy
79 double m(const int index ) const { return m_hepevtptr->phep[5*(index-1)+4]; } //!< Get generated mass
80 double x(const int index ) const { return m_hepevtptr->vhep[4*(index-1)]; } //!< Get X Production vertex
81 double y(const int index ) const { return m_hepevtptr->vhep[4*(index-1)+1]; } //!< Get Y Production vertex
82 double z(const int index ) const { return m_hepevtptr->vhep[4*(index-1)+2]; } //!< Get Z Production vertex
83 double t(const int index ) const { return m_hepevtptr->vhep[4*(index-1)+3]; } //!< Get production time
84 int number_parents(const int index ) const; //!< Get number of parents
85 int number_children(const int index ) const; //!< Get number of children from the range of daughters
86 int number_children_exact(const int index ) const; //!< Get number of children by counting
87 void set_event_number( const int evtno ) { *(m_hepevtptr->nevhep) = evtno; } //!< Set event number
88 void set_number_entries( const int noentries ) { *(m_hepevtptr->nhep) = noentries; } //!< Set number of entries
89 void set_status( const int index, const int status ) { m_hepevtptr->isthep[index-1] = status; } //!< Set status code
90 void set_id(const int index, const int id ) { m_hepevtptr->idhep[index-1] = id; } //!< Set PDG particle id
91 void set_parents( const int index, const int firstparent, const int lastparent ); //!< Set parents
92 void set_children( const int index, const int firstchild, const int lastchild ); //!< Set children
93 void set_momentum( const int index, const double px, const double py, const double pz, const double e ); //!< Set 4-momentum
94 void set_mass( const int index, double mass ); //!< Set mass
95 void set_position( const int index, const double x, const double y, const double z, const double t ); //!< Set position in time-space
96};
97
98
99} // namespace HepMC3
100#endif
Definition of class GenEvent.
Definition of class GenParticle.
Definition of class GenVertex.
Helper functions used to manipulate with HEPEVT block.
Stores event-related information.
Definition: GenEvent.h:41
An interface to HEPEVT common block implemented to deal with varying block size in runtime.
int first_child(const int index) const
Get index of 1st daughter.
int last_parent(const int index) const
Get index of last mother.
void set_id(const int index, const int id)
Set PDG particle id.
int event_number() const
Get event number.
bool HEPEVT_to_GenEvent(GenEvent *evt) const
Convert HEPEVT to GenEvent.
bool GenEvent_to_HEPEVT(const GenEvent *evt)
Convert GenEvent to HEPEVT.
int last_child(const int index) const
Get index of last daughter.
void allocate_internal_storage()
Allocates m_internal_storage storage in smart pointer to hold HEPEVT of fixed size.
int first_parent(const int index) const
Get index of 1st mother.
double pz(const int index) const
Get Z momentum.
void zero_everything()
Set all entries in HEPEVT to zero.
double py(const int index) const
Get Y momentum.
HEPEVT_Wrapper_Runtime()
Default constructor.
void set_parents(const int index, const int firstparent, const int lastparent)
Set parents.
int number_children_exact(const int index) const
Get number of children by counting.
void print_hepevt_particle(int index, std::ostream &ostr=std::cout) const
Print particle information.
int id(const int index) const
Get PDG particle id.
double t(const int index) const
Get production time.
void set_momentum(const int index, const double px, const double py, const double pz, const double e)
Set 4-momentum.
void set_children(const int index, const int firstchild, const int lastchild)
Set children.
int number_parents(const int index) const
Get number of parents.
void set_position(const int index, const double x, const double y, const double z, const double t)
Set position in time-space.
double y(const int index) const
Get Y Production vertex.
bool fix_daughters()
Tries to fix list of daughters.
void set_max_number_entries(unsigned int size)
Set block size.
int number_entries() const
Get number of entries.
void set_hepevt_address(char *c)
Set Fortran block address.
double m(const int index) const
Get generated mass.
int status(const int index) const
Get status code.
double px(const int index) const
Get X momentum.
std::vector< char > m_internal_storage
Internalstorage storage. Optional.
int number_children(const int index) const
Get number of children from the range of daughters.
double z(const int index) const
Get Z Production vertex.
void print_hepevt(std::ostream &ostr=std::cout) const
Print information from HEPEVT common block.
void set_mass(const int index, double mass)
Set mass.
int max_number_entries() const
Block size.
double x(const int index) const
Get X Production vertex.
void set_event_number(const int evtno)
Set event number.
~HEPEVT_Wrapper_Runtime()
Default destructor.
void copy_to_internal_storage(char *c, int N)
Copies the content of foreight common block into the internal storage.
void set_status(const int index, const int status)
Set status code.
void set_number_entries(const int noentries)
Set number of entries.
std::shared_ptr< struct HEPEVT_Pointers< double > > m_hepevtptr
Fortran common block HEPEVT.
double e(const int index) const
Get Energy.
HepMC3 main namespace.
bool HEPEVT_to_GenEvent_nonstatic(GenEvent *evt, T *A)
Converts HEPEVT into GenEvent.
bool GenEvent_to_HEPEVT_nonstatic(const GenEvent *evt, T *A)
Converts GenEvent into HEPEVT.