Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-13 08:21:04

0001 #ifndef G4HepEmGammaData_HH
0002 #define G4HepEmGammaData_HH
0003 
0004 /**
0005  * @file    G4HepEmGammaData.hh
0006  * @struct  G4HepEmGammaData
0007  * @author  M. Novak
0008  * @date    2021
0009  *
0010  * @brief All energy loss process related data used for \f$e^-/e+\f$ simulations by `G4HepEm`.
0011  *
0012  * Covers Gamma conversion itno e-/e+ pairs and Compton scattering at the moment.
0013  */
0014 
0015 struct G4HepEmGammaData {
0016   /** Number of G4HepEm materials: number of G4HepEmMatData structures stored in the G4HepEmMaterialData::fMaterialData array. */
0017   int           fNumMaterials = 0;
0018 
0019 //// === Macroscopic cross section related data:
0020   // The 100 eV 100 TeV kinetic energy range is divided up to 3 kinetic energy window. At a discrete kinetic
0021   // energy point, the following macroscopic cross section data are stored:
0022   // - window 0: 100 eV - 150 keV; only 1 data stored at each E_i
0023   //   1. the Compton scattering mac. xsec. (as PE is not smooth in this region)
0024   //   note: the total mac. xsec. is the sum of 1. above plus the PE mac. xsec. as Conversion and Gamma-Nuclear
0025   //         are zero in this energy window
0026   // - window 1: 150 keV - 2mc^2; 2 data are stored at at each E_i
0027   //    1. the sum of the Compton and PE mac. xsec
0028   //    2. and the PE mac. xsec alone
0029   //    note: conversion is still zero in this energy window and gamma-nuclear is assumed to be zero (very small)
0030   //          so 1. above is the total mac. xsec.
0031   // - window 2: 2mc^2 - 100 TeV; 4 data are stored at each E_i
0032   //    1. the sum of Conversion, Compton, PE, Gamma-Nuclear (GN) mac. xsec.
0033   //    2. the Conversion mac. xsec.
0034   //    3. the Compton mac. xsec.
0035   //    4. the PE mac. xsec.
0036   //    note: 1. above is the total mac. xsec.
0037   // NOTE: the total mac. xsec. can be used to determine how far the gamma goes till the next interaction while
0038   //       the additional mac. xsec. data are sufficient (togeter with the total) to determine the interaction
0039   //       at that point (if any)
0040   //
0041   // these grid densities provide a relativ error less than 0.5 %
0042   const int     fEGridSize0 =   32;
0043   const int     fEGridSize1 =   32;
0044   const int     fEGridSize2 =  256;
0045 
0046   int           fDataPerMat =   0;    // #data for one material in the fMacXsecData array
0047   int           fNumData0   =   0;    // #data for one material related to the first  (0th) ekin window
0048   int           fNumData1   =   0;    // #data for one material related to the second (1th) ekinwindow
0049 
0050   double        fEMin0      = 0.0;     // minimum kinetic energy of the first window (100.0*CLHEP::eV)
0051   double        fEMax0      = 0.0;     // minimum kinetic energy of the second window (150.0*CLHEP::eV)
0052   double        fLogEMin0   = 0.0;     // =  0.021759358706830;  // log(fEMin0)
0053   double        fEILDelta0  = 0.0;     // =  13.85950970842557;  // 1./[log(fEMax0/fEMin0)/(fEGridSize0-1)]
0054 
0055   // double        fEMin1  --> fEMax0
0056   double        fEMax1      = 0.0;
0057   double        fLogEMin1   = 0.0;
0058   double        fEILDelta1  = 0.0;
0059 
0060   // double        fEMin2  --> fEMax1
0061   double        fEMax2      = 0.0;
0062   double        fLogEMin2   = 0.0;
0063   double        fEILDelta2  = 0.0;
0064 
0065   double*       fMacXsecData = nullptr; // [#materials x fDataPerMat]
0066 
0067 
0068 
0069 //// === element selector for conversion (note: KN compton interaction do not know anything about Z)
0070   int           fElemSelectorConvEgridSize = 0;
0071   int           fElemSelectorConvNumData = 0;          // total number of data i.e. lenght of fElemSelectorConvData
0072   double        fElemSelectorConvLogMinEkin = 0.0;
0073   double        fElemSelectorConvEILDelta = 0.0;         //
0074   int*          fElemSelectorConvStartIndexPerMat = nullptr; // [fNumMaterials]
0075   double*       fElemSelectorConvEgrid = nullptr;            // [fElemSelectorConvEgridSize]
0076 
0077   /** Element selector data for all materials */
0078   double*       fElemSelectorConvData = nullptr;             // [fElemSelectorConvNumData]
0079 };
0080 
0081 /**
0082   * Allocates and pre-initialises the G4HepEmGammaData structure.
0083   *
0084   * This method is invoked from the InitGammaData() function declared
0085   * in the G4HepEmGammaInit header file. The input argument address of the
0086   * G4HepEmGammaData structure pointer is the one stored in the G4HepEmData
0087   * member of the `master` G4HepEmRunManager and the initialisation should be
0088   * done by the master G4HepEmRunManager by invoking the InitGammaData() function
0089   * for \f$\gamma\f$ particles.
0090   *
0091   * @param theGammaData address of a G4HepEmGammaData structure pointer. At termination,
0092   *   the correspondig pointer will be set to a memory location with a freshly allocated
0093   *   G4HepEmGammaData structure with all its pointer members set to nullprt.
0094   *   If the input pointer was not null at input, the pointed memory, including all
0095   *   dynamic memory members, is freed before the new allocation.
0096   */
0097 void AllocateGammaData (struct G4HepEmGammaData** theGammaData);
0098 
0099 /**
0100  * Initializes a new @ref G4HepEmGammaData structure
0101  *
0102  * This function default constructs an instance of G4HepEmGammaData and returns
0103  * a pointer to the freshly constructed instance. It is the callees responsibility
0104  * to free the instance using @ref FreeGammaData.
0105  *
0106  * @return Pointer to instance of @ref G4HepEmGammaData
0107  */
0108 G4HepEmGammaData* MakeGammaData();
0109 
0110 /**
0111   * Frees a G4HepEmGammaData structure.
0112   *
0113   * This function deallocates all dynamically allocated memory stored in the
0114   * input argument related G4HepEmGammaData structure, deallocates the structure
0115   * itself and sets the input address to store a pointer to null. This makes the
0116   * corresponding input stucture cleared, freed and ready to be re-initialised.
0117   * The input argument is supposed to be the address of the corresponding pointer
0118   * member of the G4HepEmData member of the `master` G4HepEmRunManager.
0119   *
0120   * @param theGammaData memory address that stores pointer to a G4HepEmGammaData
0121   *  structure. The memory is freed and the input address will store a null pointer
0122   *  at termination.
0123   */
0124 void FreeGammaData (struct G4HepEmGammaData** theGammaData);
0125 
0126 
0127 
0128 #ifdef G4HepEm_CUDA_BUILD
0129   /**
0130     * Allocates memory for and copies the G4HepEmGammaData structure from the
0131     * host to the device.
0132     *
0133     * The input arguments are supposed to be the corresponding members of the
0134     * G4HepEmData, top level data structure, stored in the `master` G4HepEmRunManager.
0135     *
0136     * @param onHOST    pointer to the host side, already initialised G4HepEmGammaData structure.
0137     * @param onDEVICE  host side address of a pointer to a device side G4HepEmGammaData
0138     *   structure. The pointed device side memory is cleaned (if not null at input) and
0139     *   points to the device side memory at termination containing all the copied
0140     *   G4HepEmGammaData structure members.
0141     */
0142   void CopyGammaDataToDevice(struct G4HepEmGammaData* onHOST, struct G4HepEmGammaData** onDEVICE);
0143 
0144   /**
0145     * Frees all memory related to the device side G4HepEmGammaData structure referred
0146     * by the pointer stored on the host side input argument address.
0147     *
0148     * @param onDEVICE host side address of a G4HepEmGammaDataOnDevice structure located on the device side memory.
0149     *   The correspondig device memory will be freed and the input argument address will be set to null.
0150     */
0151   void FreeGammaDataOnDevice(struct G4HepEmGammaData** onDEVICE);
0152 #endif // DG4HepEm_CUDA_BUILD
0153 
0154 #endif // G4HepEmGammaData_HH