HepMC3 event record library: HEPEVT_Wrapper_Runtime.h Source File

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-2023 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 */
26namespace HepMC3
27{
28
29 class HEPEVT_Wrapper_Runtime
30{
31//
32// Functions
33//
34public:
35 /** @brief Default constructor */
36 HEPEVT_Wrapper_Runtime() {m_max_particles=0; m_hepevtptr=nullptr;};
37 /** @brief Default destructor */
38 ~HEPEVT_Wrapper_Runtime() {};
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 */
55 int m_max_particles;
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 foreign 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
GenEvent.h
Definition of class GenEvent.
GenParticle.h
Definition of class GenParticle.
GenVertex.h
Definition of class GenVertex.
HEPEVT_Helpers.h
Helper functions used to manipulate with HEPEVT block.
HepMC3::GenEvent
Stores event-related information.
Definition GenEvent.h:47
HepMC3::HEPEVT_Wrapper_Runtime::first_child
int first_child(const int index) const
Get index of 1st daughter.
Definition HEPEVT_Wrapper_Runtime.h:73
HepMC3::HEPEVT_Wrapper_Runtime::last_parent
int last_parent(const int index) const
Get index of last mother.
Definition HEPEVT_Wrapper_Runtime.h:72
HepMC3::HEPEVT_Wrapper_Runtime::set_id
void set_id(const int index, const int id)
Set PDG particle id.
Definition HEPEVT_Wrapper_Runtime.h:90
HepMC3::HEPEVT_Wrapper_Runtime::event_number
int event_number() const
Get event number.
Definition HEPEVT_Wrapper_Runtime.h:67
HepMC3::HEPEVT_Wrapper_Runtime::HEPEVT_to_GenEvent
bool HEPEVT_to_GenEvent(GenEvent *evt) const
Convert HEPEVT to GenEvent.
Definition HEPEVT_Wrapper_Runtime.h:48
HepMC3::HEPEVT_Wrapper_Runtime::GenEvent_to_HEPEVT
bool GenEvent_to_HEPEVT(const GenEvent *evt)
Convert GenEvent to HEPEVT.
Definition HEPEVT_Wrapper_Runtime.h:46
HepMC3::HEPEVT_Wrapper_Runtime::last_child
int last_child(const int index) const
Get index of last daughter.
Definition HEPEVT_Wrapper_Runtime.h:74
HepMC3::HEPEVT_Wrapper_Runtime::allocate_internal_storage
void allocate_internal_storage()
Allocates m_internal_storage storage in smart pointer to hold HEPEVT of fixed size.
Definition HEPEVT_Wrapper.cc:242
HepMC3::HEPEVT_Wrapper_Runtime::first_parent
int first_parent(const int index) const
Get index of 1st mother.
Definition HEPEVT_Wrapper_Runtime.h:71
HepMC3::HEPEVT_Wrapper_Runtime::pz
double pz(const int index) const
Get Z momentum.
Definition HEPEVT_Wrapper_Runtime.h:77
HepMC3::HEPEVT_Wrapper_Runtime::zero_everything
void zero_everything()
Set all entries in HEPEVT to zero.
Definition HEPEVT_Wrapper.cc:146
HepMC3::HEPEVT_Wrapper_Runtime::py
double py(const int index) const
Get Y momentum.
Definition HEPEVT_Wrapper_Runtime.h:76
HepMC3::HEPEVT_Wrapper_Runtime::HEPEVT_Wrapper_Runtime
HEPEVT_Wrapper_Runtime()
Default constructor.
Definition HEPEVT_Wrapper_Runtime.h:36
HepMC3::HEPEVT_Wrapper_Runtime::set_parents
void set_parents(const int index, const int firstparent, const int lastparent)
Set parents.
Definition HEPEVT_Wrapper.cc:181
HepMC3::HEPEVT_Wrapper_Runtime::number_children_exact
int number_children_exact(const int index) const
Get number of children by counting.
Definition HEPEVT_Wrapper.cc:171
HepMC3::HEPEVT_Wrapper_Runtime::print_hepevt_particle
void print_hepevt_particle(int index, std::ostream &ostr=std::cout) const
Print particle information.
Definition HEPEVT_Wrapper.cc:133
HepMC3::HEPEVT_Wrapper_Runtime::id
int id(const int index) const
Get PDG particle id.
Definition HEPEVT_Wrapper_Runtime.h:70
HepMC3::HEPEVT_Wrapper_Runtime::t
double t(const int index) const
Get production time.
Definition HEPEVT_Wrapper_Runtime.h:83
HepMC3::HEPEVT_Wrapper_Runtime::set_momentum
void set_momentum(const int index, const double px, const double py, const double pz, const double e)
Set 4-momentum.
Definition HEPEVT_Wrapper.cc:194
HepMC3::HEPEVT_Wrapper_Runtime::set_children
void set_children(const int index, const int firstchild, const int lastchild)
Set children.
Definition HEPEVT_Wrapper.cc:187
HepMC3::HEPEVT_Wrapper_Runtime::number_parents
int number_parents(const int index) const
Get number of parents.
Definition HEPEVT_Wrapper.cc:159
HepMC3::HEPEVT_Wrapper_Runtime::set_position
void set_position(const int index, const double x, const double y, const double z, const double t)
Set position in time-space.
Definition HEPEVT_Wrapper.cc:209
HepMC3::HEPEVT_Wrapper_Runtime::y
double y(const int index) const
Get Y Production vertex.
Definition HEPEVT_Wrapper_Runtime.h:81
HepMC3::HEPEVT_Wrapper_Runtime::fix_daughters
bool fix_daughters()
Tries to fix list of daughters.
Definition HEPEVT_Wrapper.cc:218
HepMC3::HEPEVT_Wrapper_Runtime::set_max_number_entries
void set_max_number_entries(unsigned int size)
Set block size.
Definition HEPEVT_Wrapper_Runtime.h:64
HepMC3::HEPEVT_Wrapper_Runtime::number_entries
int number_entries() const
Get number of entries.
Definition HEPEVT_Wrapper_Runtime.h:68
HepMC3::HEPEVT_Wrapper_Runtime::set_hepevt_address
void set_hepevt_address(char *c)
Set Fortran block address.
Definition HEPEVT_Wrapper.cc:101
HepMC3::HEPEVT_Wrapper_Runtime::m
double m(const int index) const
Get generated mass.
Definition HEPEVT_Wrapper_Runtime.h:79
HepMC3::HEPEVT_Wrapper_Runtime::status
int status(const int index) const
Get status code.
Definition HEPEVT_Wrapper_Runtime.h:69
HepMC3::HEPEVT_Wrapper_Runtime::m_max_particles
int m_max_particles
Block size.
Definition HEPEVT_Wrapper_Runtime.h:55
HepMC3::HEPEVT_Wrapper_Runtime::px
double px(const int index) const
Get X momentum.
Definition HEPEVT_Wrapper_Runtime.h:75
HepMC3::HEPEVT_Wrapper_Runtime::m_internal_storage
std::vector< char > m_internal_storage
Internalstorage storage. Optional.
Definition HEPEVT_Wrapper_Runtime.h:57
HepMC3::HEPEVT_Wrapper_Runtime::number_children
int number_children(const int index) const
Get number of children from the range of daughters.
Definition HEPEVT_Wrapper.cc:166
HepMC3::HEPEVT_Wrapper_Runtime::z
double z(const int index) const
Get Z Production vertex.
Definition HEPEVT_Wrapper_Runtime.h:82
HepMC3::HEPEVT_Wrapper_Runtime::print_hepevt
void print_hepevt(std::ostream &ostr=std::cout) const
Print information from HEPEVT common block.
Definition HEPEVT_Wrapper.cc:122
HepMC3::HEPEVT_Wrapper_Runtime::set_mass
void set_mass(const int index, double mass)
Set mass.
Definition HEPEVT_Wrapper.cc:203
HepMC3::HEPEVT_Wrapper_Runtime::max_number_entries
int max_number_entries() const
Block size.
Definition HEPEVT_Wrapper_Runtime.h:66
HepMC3::HEPEVT_Wrapper_Runtime::x
double x(const int index) const
Get X Production vertex.
Definition HEPEVT_Wrapper_Runtime.h:80
HepMC3::HEPEVT_Wrapper_Runtime::set_event_number
void set_event_number(const int evtno)
Set event number.
Definition HEPEVT_Wrapper_Runtime.h:87
HepMC3::HEPEVT_Wrapper_Runtime::~HEPEVT_Wrapper_Runtime
~HEPEVT_Wrapper_Runtime()
Default destructor.
Definition HEPEVT_Wrapper_Runtime.h:38
HepMC3::HEPEVT_Wrapper_Runtime::copy_to_internal_storage
void copy_to_internal_storage(char *c, int N)
Copies the content of foreign common block into the internal storage.
Definition HEPEVT_Wrapper.cc:248
HepMC3::HEPEVT_Wrapper_Runtime::set_status
void set_status(const int index, const int status)
Set status code.
Definition HEPEVT_Wrapper_Runtime.h:89
HepMC3::HEPEVT_Wrapper_Runtime::set_number_entries
void set_number_entries(const int noentries)
Set number of entries.
Definition HEPEVT_Wrapper_Runtime.h:88
HepMC3::HEPEVT_Wrapper_Runtime::m_hepevtptr
std::shared_ptr< struct HEPEVT_Pointers< double > > m_hepevtptr
Fortran common block HEPEVT.
Definition HEPEVT_Wrapper_Runtime.h:53
HepMC3::HEPEVT_Wrapper_Runtime::e
double e(const int index) const
Get Energy.
Definition HEPEVT_Wrapper_Runtime.h:78
HepMC3
HepMC3 main namespace.
Definition AnalysisExample.h:24
HepMC3::HEPEVT_to_GenEvent_nonstatic
bool HEPEVT_to_GenEvent_nonstatic(GenEvent *evt, T *A)
Converts HEPEVT into GenEvent.
Definition HEPEVT_Helpers.h:110
HepMC3::GenEvent_to_HEPEVT_nonstatic
bool GenEvent_to_HEPEVT_nonstatic(const GenEvent *evt, T *A)
Converts GenEvent into HEPEVT.
Definition HEPEVT_Helpers.h:181