|
|
|||
File indexing completed on 2026-07-13 08:21:05
0001 #ifndef G4HepEmMatrialData_HH 0002 #define G4HepEmMatrialData_HH 0003 0004 /** 0005 * @file G4HepEmMaterialData.hh 0006 * @struct G4HepEmMaterialData 0007 * @author M. Novak 0008 * @date 2020 0009 * 0010 * @brief All material related data used by ``G4HepEm``. 0011 * 0012 * All material related data, used by ``G4HepEm``, is stored in this simple data 0013 * structure. The G4HepEmMaterialData structure contains a collection of G4HepEmMatData 0014 * for each G4Material object that is used in the geometry. Such a G4HepEmMatData 0015 * stores a single material realted data required during the simulation. 0016 * 0017 * A single instance of this structure is created and stored in the `master` 0018 * G4HepEmRunManager when its InitializeGlobal() method is invoked by calling 0019 * the InitMaterialAndCoupleData() function declared in the G4HepEmMaterialInit 0020 * header file. This method extracts information form the already initialised 0021 * part of the Geant4 application (i.e. G4MaterialCutsCoupleTable) by reading all 0022 * G4MaterialCutsCouple objects used in the current geometry, translating their 0023 * G4Material objects into G4HepEmMatData strcutrues and store in this single 0024 * G4HepEmMaterialData sturcture. 0025 * 0026 * In case of ``CUDA`` build, the data can be easily copied to the device by either 0027 * using the CopyMaterialDataToGPU() function or the more general CopyG4HepEmDataToGPU() 0028 * function: the first will copy only the specified G4HepEmMaterialData structure 0029 * while the second will (deep copy) all the members (including the G4HepEmMaterialData 0030 * one) of the G4HepEmData, top level data structure member of the (master) 0031 * G4HepEmRunManager. 0032 * 0033 * @note only the data members that are needed on the device side are copied to 0034 * the device memory. This means, that only the G4HepEmMaterialData::fMaterialData 0035 * collection of the G4HepEmMatData structures is copied to the device memory 0036 * together with the G4HepEmMaterialData::fNumMaterialData length of this collection. 0037 * 0038 */ 0039 0040 /** Data that describes a single matrial in ``G4HepEm``. */ 0041 struct G4HepEmMatData { 0042 /** The corresponding G4Material object index.*/ 0043 int fG4MatIndex = -1; 0044 /** Number of elements this matrial is composed of (size of the arrays below). */ 0045 int fNumOfElement = 0; 0046 /** The list of element indices in G4HepEmElemData (their atomic number Z), this material is composed of.*/ 0047 int* fElementVect = nullptr; // [fNumOfElement] 0048 /** The list of number-of-atoms-per-unit-volume for each element this material is composed of.*/ 0049 double* fNumOfAtomsPerVolumeVect = nullptr; // [fNumOfElement] 0050 /** The mass density (\f$\rho\f$) of the material in Geant4 internal units. */ 0051 double fDensity = 0.0; 0052 /** Density correction factor (\f$C_{Mg}\rho_{e^-}\f$) used in the `dielectric suppression` 0053 * of bremsstrahlung photon emission (\f$C_{Mg}=4\pi r_0 \hbar c/(mc^2)\f$ is the `Migdal constant` 0054 * and \f$\rho_{e^-}\f$ is the electron density of the material). */ 0055 double fDensityCorFactor = 0.0; 0056 /** Electron density (\f$\rho_{e^-}\f$) of the material in Geant4 internal units.*/ 0057 double fElectronDensity = 0.0; 0058 /** Radiation length. */ 0059 double fRadiationLength = 0.0; 0060 /** Mean excition energy */ 0061 double fMeanExEnergy = 0.0; 0062 // 0063 /** Number of intervals in the Sandia table */ 0064 int fNumOfSandiaIntervals = 0; 0065 /** Starting energy of the intervals */ 0066 double* fSandiaEnergies = nullptr; // [fNumOfSandiaIntervals] 0067 /** Coefficients for the interval (four per energy range) */ 0068 double* fSandiaCoefficients = nullptr; // [4 x fNumOfSandiaIntervals] 0069 // 0070 double fZeff; 0071 double fZeff23; 0072 double fZeffSqrt; 0073 // 0074 double fUMSCPar; 0075 double fUMSCStepMinPars[2]; 0076 double fUMSCTailCoeff[4]; 0077 double fUMSCThetaCoeff[2]; 0078 }; 0079 0080 // Data for all materials used in the current geometry. 0081 struct G4HepEmMaterialData { 0082 /** Number of Geant4 material objects (irrespectively if used or not).*/ 0083 int fNumG4Material = 0; 0084 /** Number of G4HepEmMatData structures in ``G4HepEm`` (only the used G4Material objects are translated).*/ 0085 int fNumMaterialData = 0; 0086 /** Array that translates a Geant4 G4Material object index to the correspondig G4HepEmMatData index in the collection below.*/ 0087 int* fG4MatIndexToHepEmMatIndex = nullptr; // [fNumG4Material] 0088 /** Collection of G4HepEmMatData structures for all materials used in the current geometry.*/ 0089 struct G4HepEmMatData* fMaterialData = nullptr; // [fNumMaterialData] 0090 }; 0091 0092 0093 /** 0094 * Allocates and pre-initialises the G4HepEmMaterialData structure. 0095 * 0096 * This method is invoked from the InitMaterialAndCoupleData() function declared 0097 * in the G4HepEmMaterialInit header file. The input argument address of the 0098 * G4HepEmMaterialData structure pointer is the one stored in the G4HepEmData 0099 * member of the `master` G4HepEmRunManager and the initialisation should be 0100 * done by the master G4HepEmRunManager. 0101 * 0102 * @param theMatData address of a G4HepEmMaterialData structure pointer. At termination, 0103 * the correspondig pointer will be set to a memory location with a freshly allocated 0104 * G4HepEmMaterialData structure. If the pointer was not null at input, the pointed 0105 * memory is freed before the new allocation. 0106 * @param numG4Mat number of Geant4 material objects (irrespectively if used or not). 0107 * It determines the maximum value of the G4Material object index. 0108 * @param numUsedG4Mat number of Geant4 material objects used in the current geometry. 0109 * It determines the number of the G4HepEmMatData structures. 0110 */ 0111 void AllocateMaterialData(struct G4HepEmMaterialData** theMatData, int numG4Mat, int numUsedG4Mat); 0112 0113 /** 0114 * Initializes a new @ref G4HepEmMaterialData structure 0115 * 0116 * This function constructs and returns an instance of G4HepEmMaterialData to hold a given number of indices 0117 * to Geant4 materials objects and their corresponding G4HepEmMaterialData instance. 0118 * It is the callees responsibility to free the instance using @ref FreeMaterialData. 0119 * 0120 * @param[in] numG4Mat number of Geant4 material objects 0121 * @param[in] numUsedG4Mat number of Geant4 materials objects used in the current geometry. 0122 * @return Pointer to instance of @ref G4HepEmMaterialData 0123 */ 0124 G4HepEmMaterialData* MakeMaterialData(int numG4Mat, int numUsedG4Mat); 0125 0126 /** 0127 * Frees a G4HepEmMaterialData structure. 0128 * 0129 * This function deallocates all dynamically allocated memory stored in the 0130 * input argument related G4HepEmMaterialData structure, deallocates the structure 0131 * itself and sets the input address to store a pointer to null. This makes the 0132 * corresponding input stucture cleared, freed and ready to be re-initialised. 0133 * The input argument is supposed to be the address of the corresponding pointer 0134 * member of the G4HepEmData member of the `master` G4HepEmRunManager. 0135 * 0136 * @param theMatData memory address that stores pointer to a G4HepEmMaterialData 0137 * structure. The memory is freed and the input address will store a null pointer 0138 * at termination. 0139 */ 0140 void FreeMaterialData (struct G4HepEmMaterialData** theMatData); 0141 0142 0143 #ifdef G4HepEm_CUDA_BUILD 0144 /** 0145 * Allocates memory for and copies the G4HepEmMaterialData structure from the 0146 * host to the device. 0147 * 0148 * Only the G4HepEmMaterialData::fMaterialData collection of the G4HepEmMatData 0149 * structures is copied to the device together with the G4HepEmMaterialData::fNumMaterialData 0150 * length of this collection. 0151 * 0152 * The input arguments are supposed to be the corresponding members of the 0153 * G4HepEmData, top level data structure, stored in the `master` G4HepEmRunManager. 0154 * 0155 * @param onHost pointer to the host side, already initialised G4HepEmMaterialData structure. 0156 * @param onDevice host side address of a G4HepEmMaterialData structure memory pointer. The pointed 0157 * memory is cleaned (if not null at input) and points to the device side memory at termination 0158 * that stores the copied G4HepEmMaterialData structure. 0159 */ 0160 void CopyMaterialDataToGPU(struct G4HepEmMaterialData* onHost, struct G4HepEmMaterialData** onDevice); 0161 0162 /** 0163 * Frees all memory related to the device side G4HepEmMaterialData structure referred 0164 * by the pointer stored on the host side input argument address. 0165 * 0166 * @param onDevice host side address of a G4HepEmMaterialData structure located on the device side memory. 0167 * The correspondig device memory will be freed and the input argument address will be set to null. 0168 */ 0169 void FreeMaterialDataOnGPU(struct G4HepEmMaterialData** onDevice); 0170 #endif // DG4HepEm_CUDA_BUILD 0171 0172 0173 #endif // G4HepEmMatrialData_HH
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|