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"
17 #include "HepMC3/HEPEVT_Helpers.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  */
26 namespace HepMC3
27 {
28 
30 {
31 //
32 // Functions
33 //
34 public:
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();
51 private:
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 //
61 public:
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
int max_number_entries() const
Block size.
double x(const int index) const
Get X Production vertex.
HepMC3 main namespace.
double m(const int index) const
Get generated mass.
int first_parent(const int index) const
Get index of 1st mother.
double py(const int index) const
Get Y momentum.
int number_entries() const
Get number of entries.
Definition of class GenParticle.
bool HEPEVT_to_GenEvent_nonstatic(GenEvent *evt, T *A)
Converts HEPEVT into GenEvent.
bool HEPEVT_to_GenEvent(GenEvent *evt) const
Convert HEPEVT to GenEvent.
double pz(const int index) const
Get Z momentum.
Definition of class GenVertex.
int number_parents(const int index) const
Get number of parents.
void set_number_entries(const int noentries)
Set number of entries.
int status(const int index) const
Get status code.
std::shared_ptr< struct HEPEVT_Pointers< double > > m_hepevtptr
Fortran common block HEPEVT.
An interface to HEPEVT common block implemented to deal with varying block size in runtime...
double z(const int index) const
Get Z Production vertex.
void set_children(const int index, const int firstchild, const int lastchild)
Set children.
Helper functions used to manipulate with HEPEVT block.
int event_number() const
Get event number.
void set_momentum(const int index, const double px, const double py, const double pz, const double e)
Set 4-momentum.
void set_mass(const int index, double mass)
Set mass.
void set_parents(const int index, const int firstparent, const int lastparent)
Set parents.
void set_position(const int index, const double x, const double y, const double z, const double t)
Set position in time-space.
bool fix_daughters()
Tries to fix list of daughters.
~HEPEVT_Wrapper_Runtime()
Default destructor.
void print_hepevt(std::ostream &ostr=std::cout) const
Print information from HEPEVT common block.
void zero_everything()
Set all entries in HEPEVT to zero.
int last_child(const int index) const
Get index of last daughter.
Stores event-related information.
Definition: GenEvent.h:41
double t(const int index) const
Get production time.
std::vector< char > m_internal_storage
Internalstorage storage. Optional.
int last_parent(const int index) const
Get index of last mother.
double e(const int index) const
Get Energy.
int number_children_exact(const int index) const
Get number of children by counting.
void set_id(const int index, const int id)
Set PDG particle id.
double y(const int index) const
Get Y Production vertex.
bool GenEvent_to_HEPEVT(const GenEvent *evt)
Convert GenEvent to HEPEVT.
void print_hepevt_particle(int index, std::ostream &ostr=std::cout) const
Print particle information.
double px(const int index) const
Get X momentum.
int first_child(const int index) const
Get index of 1st daughter.
void set_status(const int index, const int status)
Set status code.
bool GenEvent_to_HEPEVT_nonstatic(const GenEvent *evt, T *A)
Converts GenEvent into HEPEVT.
Definition of class GenEvent.
void set_hepevt_address(char *c)
Set Fortran block address.
void set_max_number_entries(unsigned int size)
!< Copies the content of foreight common block into the internal storage
int id(const int index) const
Get PDG particle id.
void copy_to_internal_storage(char *c, int N)
!< Allocates m_internal_storage storage in smart pointer to hold HEPEVT of fixed size ...
HEPEVT_Wrapper_Runtime()
Default constructor.
void set_event_number(const int evtno)
Set event number.
int number_children(const int index) const
Get number of children from the range of daughters.