Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:12

0001 // -*- C++ -*-
0002 //
0003 // This file is part of HepMC
0004 // Copyright (C) 2014-2023 The HepMC collaboration (see AUTHORS for details)
0005 //
0006 #ifndef HEPMC3_HEPEVT_WRAPPER_RUNTIME_H
0007 #define HEPMC3_HEPEVT_WRAPPER_RUNTIME_H
0008 #include <iostream>
0009 #include <cstdio>
0010 #include <set>
0011 #include <map>
0012 #include <cstring> // memset
0013 #include <algorithm> //min max for VS2017
0014 #include "HepMC3/GenEvent.h"
0015 #include "HepMC3/GenParticle.h"
0016 #include "HepMC3/GenVertex.h"
0017 #include "HepMC3/HEPEVT_Helpers.h"
0018 
0019 /**
0020  *  @file HEPEVT_Wrapper_Runtime.h
0021  *  @brief Definition of \b class HEPEVT_Wrapper_Runtime
0022  *
0023  *  @class HepMC3::HEPEVT_Wrapper_Runtime
0024  *  @brief An interface to HEPEVT common block implemented to deal with varying block size in runtime
0025  */
0026 namespace HepMC3
0027 {
0028 
0029 class HEPEVT_Wrapper_Runtime
0030 {
0031 //
0032 // Functions
0033 //
0034 public:
0035     /** @brief Default constructor */
0036     HEPEVT_Wrapper_Runtime() {m_max_particles=0; m_hepevtptr=nullptr;};
0037     /** @brief Default destructor */
0038     ~HEPEVT_Wrapper_Runtime() {};
0039     /** @brief Print information from HEPEVT common block */
0040     void print_hepevt( std::ostream& ostr = std::cout ) const;
0041     /** @brief Print particle information */
0042     void print_hepevt_particle( int index, std::ostream& ostr = std::cout ) const;
0043     /** @brief Set all entries in HEPEVT to zero */
0044     void zero_everything();
0045     /** @brief Convert GenEvent to HEPEVT*/
0046     bool GenEvent_to_HEPEVT( const GenEvent* evt ) { return GenEvent_to_HEPEVT_nonstatic(evt, this);};
0047     /** @brief Convert HEPEVT to GenEvent*/
0048     bool HEPEVT_to_GenEvent( GenEvent* evt ) const { return HEPEVT_to_GenEvent_nonstatic(evt, this);};
0049     /** @brief Tries to fix list of daughters */
0050     bool fix_daughters();
0051 private:
0052     /** @brief  Fortran common block HEPEVT */
0053     std::shared_ptr<struct HEPEVT_Pointers<double> >  m_hepevtptr;
0054     /** @brief Block size */
0055     int m_max_particles;
0056     /** @brief  Internalstorage storage. Optional.*/
0057     std::vector<char> m_internal_storage;
0058 //
0059 // Accessors
0060 //
0061 public:
0062     void   allocate_internal_storage(); //!< Allocates m_internal_storage storage in smart pointer to hold HEPEVT of fixed size
0063     void   copy_to_internal_storage( char *c, int N ); //!< Copies the content of foreign common block into the internal storage
0064     void   set_max_number_entries( unsigned int size ) { m_max_particles = size; }//!< Set block size
0065     void   set_hepevt_address(char *c); //!< Set Fortran block address
0066     int    max_number_entries()  const     { return m_max_particles;                              } //!< Block size
0067     int    event_number()     const        { return *(m_hepevtptr->nevhep);             } //!< Get event number
0068     int    number_entries()  const         { return *(m_hepevtptr->nhep);               } //!< Get number of entries
0069     int    status(const int index )   const     { return m_hepevtptr->isthep[index-1];    } //!< Get status code
0070     int    id(const int index )     const       { return m_hepevtptr->idhep[index-1];     } //!< Get PDG particle id
0071     int    first_parent(const int index ) const { return m_hepevtptr->jmohep[2*(index-1)]; } //!< Get index of 1st mother
0072     int    last_parent(const int index )  const { return m_hepevtptr->jmohep[2*(index-1)+1]; } //!< Get index of last mother
0073     int    first_child(const int index )  const { return m_hepevtptr->jdahep[2*(index-1)]; } //!< Get index of 1st daughter
0074     int    last_child(const int index )  const  { return m_hepevtptr->jdahep[2*(index-1)+1]; } //!< Get index of last daughter
0075     double px(const int index ) const           { return m_hepevtptr->phep[5*(index-1)];   } //!< Get X momentum
0076     double py(const int index )  const          { return m_hepevtptr->phep[5*(index-1)+1];   } //!< Get Y momentum
0077     double pz(const int index ) const           { return m_hepevtptr->phep[5*(index-1)+2];   } //!< Get Z momentum
0078     double e(const int index )  const           { return m_hepevtptr->phep[5*(index-1)+3];   } //!< Get Energy
0079     double m(const int index )  const           { return m_hepevtptr->phep[5*(index-1)+4];   } //!< Get generated mass
0080     double x(const int index )  const           { return m_hepevtptr->vhep[4*(index-1)];   } //!< Get X Production vertex
0081     double y(const int index )  const           { return m_hepevtptr->vhep[4*(index-1)+1];   } //!< Get Y Production vertex
0082     double z(const int index )   const          { return m_hepevtptr->vhep[4*(index-1)+2];   } //!< Get Z Production vertex
0083     double t(const int index )   const          { return m_hepevtptr->vhep[4*(index-1)+3];   } //!< Get production time
0084     int    number_parents(const int index ) const;                                   //!< Get number of parents
0085     int    number_children(const int index ) const;                                  //!< Get number of children from the range of daughters
0086     int    number_children_exact(const int index ) const;                            //!< Get number of children by counting
0087     void set_event_number( const int evtno )       { *(m_hepevtptr->nevhep) = evtno;         } //!< Set event number
0088     void set_number_entries( const int noentries ) { *(m_hepevtptr->nhep) = noentries;       } //!< Set number of entries
0089     void set_status( const int index, const int status ) { m_hepevtptr->isthep[index-1] = status; } //!< Set status code
0090     void set_id(const int index, const int id )         { m_hepevtptr->idhep[index-1] = id;      } //!< Set PDG particle id
0091     void set_parents( const int index, const int firstparent, const int lastparent );              //!< Set parents
0092     void set_children( const int index, const int firstchild, const int lastchild );               //!< Set children
0093     void set_momentum( const int index, const double px, const double py, const double pz, const double e );   //!< Set 4-momentum
0094     void set_mass( const int index, double mass );                                     //!< Set mass
0095     void set_position( const int index, const double x, const double y, const double z, const double t );      //!< Set position in time-space
0096 };
0097 
0098 
0099 } // namespace HepMC3
0100 #endif