Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
+44 -1
View File
@@ -1,4 +1,4 @@
$Id: History 104459 2017-05-31 15:54:52Z gcosmo $
$Id: History 106997 2017-10-31 10:22:36Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,49 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
20-10-17 S.Y.Jun (materials-V10-03-13)
- G4MaterialPropertiesTable - rename SetGROUPVEL to CalculateGROUPVEL
and move it from GetProperty to AddProperty to resolve a MT scaling
problem. Remove SetGROUPVEL from the next release (version 11),
courtesy of Tao Lin, IHEP (the JUNO experiment)
25-09-17 V.Ivanchenko (materials-V10-03-12)
- G4Material - set lock when defining Material Property Table
- G4IonisParamMat - set lock when user defines density effect parameters
15-09-17 S.Y.Jun (materials-V10-03-11)
- G4MaterialPropertiesTable - keep old property and constant property
maps and public methods, GetPropertiesMap and GetPropertiesCMap.
These method should be obsolete from the next release and GetPropertyMap
and GetConstPropertyMap should be used instead
13-09-17 S.Y.Jun (materials-V10-03-10)
- G4MaterialPropertiesIndex - add missing MIEHG index and name
12-09-17 S.Y.Jun (materials-V10-03-09)
- G4MaterialPropertiesTable - fix the warning from a wrong comparison
between different enum types
11-09-17 S.Y.Jun (materials-V10-03-08)
- add a header file (G4MaterialPropertiesIndex.hh) to define indices
and names for G4MaterialProperties
- G4MaterialPropertiesIndex - use the enum type instead of G4String
for keys in the material (constant) property table maps and provide
necessary accessors and interfaces
01-09-17 V.Ivanchenko (materials-V10-03-07)
- G4IonisParMat - added possibility of defining custom density effect
parameters and another possibility to request parameters of a base
material, which may have not exactly the same atomic composition
25-08-17 V.Ivanchenko (materials-V10-03-06)
- G4Material, G4IonisParMat - fixed definition of State of material,
when a material is constructed via based material (problem #1997)
21-08-17 V.Ivanchenko (materials-V10-03-05)
- G4NistManager, G4NistElementBuilder, G4NistMaterialBuilder - thread
safe element and material build
29-05-17 P.Gumplinger (materials-V10-03-04)
- This version of Mariele Stockhoff's DAVIS model includes not only
reflection but also the capability of transmitting photons based on LUTs
+12 -1
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4IonisParamMat.hh 97248 2016-05-30 15:00:11Z gcosmo $
// $Id: G4IonisParamMat.hh 106243 2017-09-26 01:56:43Z gcosmo $
//
// class description
@@ -49,6 +49,7 @@
#include "globals.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
#include "G4Threading.hh"
class G4Material; // forward declaration
class G4DensityEffectData;
@@ -93,6 +94,13 @@ public:
G4double GetX1density() const {return fX1density;};
inline
G4double GetD0density() const {return fD0density;};
// user defined density correction parameterisation
void SetDensityEffectParameters(G4double cd, G4double md, G4double ad,
G4double x0, G4double x1, G4double d0);
// defined density correction parameterisation via base material
void SetDensityEffectParameters(const G4Material* bmat);
// compute density correction as a function of the kinematic variable
// x = log10(beta*gamma)
@@ -211,6 +219,9 @@ private:
// static data created only once
static G4DensityEffectData* fDensityData;
G4double twoln10;
#ifdef G4MULTITHREADED
static G4Mutex ionisMutex;
#endif
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
+6 -4
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4Material.hh 100406 2016-10-21 08:18:05Z gcosmo $
// $Id: G4Material.hh 106243 2017-09-26 01:56:43Z gcosmo $
//
//---------------------------------------------------------------------------
@@ -110,6 +110,7 @@
#include "G4SandiaTable.hh"
#include "G4ElementVector.hh"
#include "G4MaterialTable.hh"
#include "G4Threading.hh"
enum G4State { kStateUndefined = 0, kStateSolid, kStateLiquid, kStateGas };
@@ -246,8 +247,7 @@ public: // with description
G4double GetA() const;
//the MaterialPropertiesTable (if any) attached to this material:
inline void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT)
{fMaterialPropertiesTable = anMPT;}
void SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT);
inline G4MaterialPropertiesTable* GetMaterialPropertiesTable() const
{return fMaterialPropertiesTable;}
@@ -278,7 +278,6 @@ public: // with description
inline void SetName (const G4String& name) {fName=name;}
public:
virtual G4bool IsExtended() const;
private:
@@ -352,6 +351,9 @@ private:
G4double fMassOfMolecule; // for materials built by atoms count
std::map<G4Material*,G4double> fMatComponents; // for composites built via
// AddMaterial()
#ifdef G4MULTITHREADED
static G4Mutex materialMutex;
#endif
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -0,0 +1,173 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4MaterialPropertiesIndex.hh 103256 2017-03-23 08:53:38Z gcosmo $
//
// File: G4MaterialPropertiesIndex.hh
// Description: Indices and Names for G4MaterialProperties
// Created: 29-06-2017
// Author: Soon Yung Jun
////////////////////////////////////////////////////////////////////////
#ifndef G4MaterialPropertiesIndex_h
#define G4MaterialPropertiesIndex_h 1
#include <vector>
#include "G4String.hh"
enum G4MaterialPropertyIndex {
kNullPropertyIndex = -1, // the number of G4MaterialPropertyIndex
kRINDEX, // index of refraction
kREFLECTIVITY, // reflectivity
kREALRINDEX, // real part of the refractive index
kIMAGINARYRINDEX, // imaginary part of the refractive index
kEFFICIENCY, // efficiency
kTRANSMITTANCE, // transmittance of a dielectric surface
kSPECULARLOBECONSTANT, // reflection probability about the normal of a micro facet.
kSPECULARSPIKECONSTANT, // reflection probability about the average surface normal
kBACKSCATTERCONSTANT, // for the case of several reflections within a deep groove
kGROUPVEL, // group velocity
kMIEHG, // Mie scattering length
kRAYLEIGH, // Rayleigh scattering attenuation length
kWLSCOMPONENT, // the relative emission spectrum of the material as a function of the photon's momentum
kWLSABSLENGTH, // the absorption length of the material as a function of the photon's momentum
kABSLENGTH, // the absorption length
kFASTCOMPONENT, // fast component of scintillation
kSLOWCOMPONENT, // slow component of scintillation
kPROTONSCINTILLATIONYIELD, // scintillation light yield by protons
kDEUTERONSCINTILLATIONYIELD, // scintillation light yield by deuterons
kTRITONSCINTILLATIONYIELD, // scintillation light yield by tritons
kALPHASCINTILLATIONYIELD, // scintillation light yield by alphas
kIONSCINTILLATIONYIELD, // scintillation light yield by ions
kELECTRONSCINTILLATIONYIELD, // scintillation light yield by electrons
kNumberOfPropertyIndex // the number of G4MaterialPropertyIndex
} ;
typedef G4MaterialPropertyIndex G4MPindex;
const std::vector<G4String> G4MaterialPropertyName = {
"RINDEX",
"REFLECTIVITY",
"REALRINDEX",
"IMAGINARYRINDEX",
"EFFICIENCY",
"TRANSMITTANCE",
"SPECULARLOBECONSTANT",
"SPECULARSPIKECONSTANT",
"BACKSCATTERCONSTANT",
"GROUPVEL",
"MIEHG",
"RAYLEIGH",
"WLSCOMPONENT",
"WLSABSLENGTH",
"ABSLENGTH",
"FASTCOMPONENT",
"SLOWCOMPONENT",
"PROTONSCINTILLATIONYIELD",
"DEUTERONSCINTILLATIONYIELD",
"TRITONSCINTILLATIONYIELD",
"ALPHASCINTILLATIONYIELD",
"IONSCINTILLATIONYIELD",
"ELECTRONSCINTILLATIONYIELD"
};
enum G4MaterialConstPropertyIndex
{
kNullConstPropertyIndex = -1, // the number of G4MaterialPropertyIndex
kSURFACEROUGHNESS, // surface microroughness
kISOTHERMAL_COMPRESSIBILITY, // isothermal compressibility
kRS_SCALE_FACTOR, // Rayleigh scattering scale factor
kWLSMEANNUMBERPHOTONS, // WLS mean number of photons
kWLSTIMECONSTANT, // any time delay which may occur between absorption and re-emission of the photon
kMIEHG_FORWARD, // forward angle of Mie scattering based on Henyey-Greenstein phase function
kMIEHG_BACKWARD, // backward angle of Mie scattering based on Henyey-Greenstein phase function
kMIEHG_FORWARD_RATIO, // ratio of the MIEHG forward scattering
kSCINTILLATIONYIELD, // scintillation light yield
kRESOLUTIONSCALE, // resolution scale
kFASTTIMECONSTANT, // fast scintillation time constant
kFASTSCINTILLATIONRISETIME, // rise time of fast scintillation
kSLOWTIMECONSTANT, // slow scintillation time constant
kSLOWSCINTILLATIONRISETIME, // rise time of slow scintillation
kYIELDRATIO, // yield ratio
kFERMIPOT, // the Fermi potential (in neV)
kDIFFUSION, // diffusion
kSPINFLIP, // spin flip
kLOSS, // loss
kLOSSCS, // loss cross-section
kABSCS, // 1/v energy dependent absorption cross section
kSCATCS, // incoherent elastic scattering cross-section
kMR_NBTHETA, // number of theta bins of microroughness (MR)
kMR_NBE, // number of energy bins
kMR_RRMS, // RMS of roughness
kMR_CORRLEN, // correlation length
kMR_THETAMIN, // minimum value of theta
kMR_THETAMAX, // maximum value of theta
kMR_EMIN, // mininum value of energy
kMR_EMAX, // maximum value of energy
kMR_ANGNOTHETA, // number of theta angles in the look-up table
kMR_ANGNOPHI, // number of phi angles in the look-up table
kMR_ANGCUT, // angular cut
kNumberOfConstPropertyIndex // the number of G4MaterialConstPropertyIndex
};
typedef G4MaterialConstPropertyIndex G4MCPindex;
const std::vector<G4String> G4MaterialConstPropertyName = {
"SURFACEROUGHNESS",
"ISOTHERMAL_COMPRESSIBILITY",
"RS_SCALE_FACTOR",
"WLSMEANNUMBERPHOTONS",
"WLSTIMECONSTANT",
"MIEHG_FORWARD",
"MIEHG_BACKWARD",
"MIEHG_FORWARD_RATIO",
"SCINTILLATIONYIELD",
"RESOLUTIONSCALE",
"FASTTIMECONSTANT",
"FASTSCINTILLATIONRISETIME",
"SLOWTIMECONSTANT",
"SLOWSCINTILLATIONRISETIME",
"YIELDRATIO",
"FERMIPOT",
"DIFFUSION",
"SPINFLIP",
"LOSS",
"LOSSCS",
"ABSCS",
"SCATCS",
"MR_NBTHETA",
"MR_NBE",
"MR_RRMS",
"MR_CORRLEN",
"MR_THETAMIN",
"MR_THETAMAX",
"MR_EMIN",
"MR_EMAX",
"MR_ANGNOTHETA",
"MR_ANGNOPHI",
"MR_ANGCUT"
};
#endif /* G4MaterialPropertiesIndex_h */
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MaterialPropertiesTable.hh 99765 2016-10-05 08:49:47Z gcosmo $
// $Id: G4MaterialPropertiesTable.hh 106997 2017-10-31 10:22:36Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
//
@@ -61,6 +61,7 @@
#include <cmath>
#include <map>
#include "globals.hh"
#include "G4MaterialPropertiesIndex.hh"
#include "G4MaterialPropertyVector.hh"
/////////////////////
@@ -80,14 +81,14 @@ class G4MaterialPropertiesTable
G4double PropertyValue);
// Add a new property to the table by giving a key-name and value
inline G4MaterialPropertyVector* AddProperty(const char *key,
G4double *PhotonEnergies,
G4double *PropertyValues,
G4int NumEntries);
G4MaterialPropertyVector* AddProperty(const char *key,
G4double *PhotonEnergies,
G4double *PropertyValues,
G4int NumEntries);
// Add a new property to the table by giving a key-name and the
// arrays x and y of size NumEntries.
inline void AddProperty(const char *key, G4MaterialPropertyVector *opv);
void AddProperty(const char *key, G4MaterialPropertyVector *opv);
// Add a new property to the table by giving a key-name and an
// already constructed G4MaterialPropertyVector.
@@ -100,29 +101,50 @@ class G4MaterialPropertiesTable
G4double GetConstProperty(const char *key) const;
// Get the constant property from the table corresponding to the key-name
G4double GetConstProperty(const G4MCPindex index) const;
// Get the constant property from the table corresponding to the key-index
G4bool ConstPropertyExists(const char *key) const;
// Return true if a const property 'key' exists.
G4MaterialPropertyVector* GetProperty(const char *key);
// Get the property from the table corresponding to the key-name.
G4MaterialPropertyVector* GetProperty(const G4MPindex index);
// Get the property from the table corresponding to the key-index.
void AddEntry(const char *key, G4double aPhotonEnergy,
G4double aPropertyValue);
G4double aPropertyValue);
// Add a new entry (pair of numbers) to the table for a given key.
G4MCPindex GetConstPropertyIndex(const G4String& key) const;
// Get the constant property index from the key-name
G4MPindex GetPropertyIndex(const G4String& key) const;
// Get the property index by the key-name.
void DumpTable();
public: // without description
const std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >*
GetPropertiesMap() const { return &MPT; }
const std::map< G4String, G4double, std::less<G4String> >*
GetPropertiesCMap() const { return &MPTC; }
std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >*
GetPropertiesMap();
std::map< G4String, G4double, std::less<G4String> >*
GetPropertiesCMap();
const std::map<G4MPindex, G4MaterialPropertyVector*, std::less<G4MPindex> >*
GetPropertyMap() const { return &MP; }
const std::map<G4MCPindex, G4double, std::less<G4MCPindex> >*
GetConstPropertyMap() const { return &MCP; }
// Accessors required for persistency purposes
private:
G4MaterialPropertyVector* CalculateGROUPVEL();
// Calculate the group velocity based on RINDEX
G4MaterialPropertyVector* SetGROUPVEL();
// Dummy method: will be obsolete from the next (version 11) release
private:
@@ -133,6 +155,17 @@ class G4MaterialPropertiesTable
std::map< G4String, G4double, std::less<G4String> > MPTC;
typedef std::map< G4String, G4double,
std::less<G4String> >::const_iterator MPTCiterator;
// MPT and MPTC will be obsolete when associate public interfaces,
// GetPropertiesMap and GetPropertiesCMap are removed from the version 11.
std::map<G4MPindex, G4MaterialPropertyVector*, std::less<G4MPindex> > MP;
typedef std::map< G4MPindex, G4MaterialPropertyVector*,
std::less<G4MPindex> >::const_iterator MPiterator;
std::map< G4MCPindex, G4double, std::less<G4MCPindex> > MCP;
typedef std::map< G4MCPindex, G4double,
std::less<G4MCPindex> >::const_iterator MCPiterator;
//material property map and constant property map by index types
};
/////////////////////
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MaterialPropertiesTable.icc 99765 2016-10-05 08:49:47Z gcosmo $
// $Id: G4MaterialPropertiesTable.icc 106997 2017-10-31 10:22:36Z gcosmo $
//
////////////////////////////////////////////////////////////////////////
//
@@ -45,45 +45,21 @@ void G4MaterialPropertiesTable::AddConstProperty(const char *key,
{
// Provides a way of adding a constant property to the Material Properties
// Table given a key
MPTC [G4String(key)] = PropertyValue;
G4MCPindex index = GetConstPropertyIndex(G4String(key));
MCP[index] = PropertyValue;
}
inline
G4MaterialPropertyVector* G4MaterialPropertiesTable::AddProperty(
const char *key,
G4double *PhotonEnergies,
G4double *PropertyValues,
G4int NumEntries)
{
// Provides a way of adding a property to the Material Properties
// Table given a pair of numbers and a key
G4MaterialPropertyVector *mpv = new G4MaterialPropertyVector(PhotonEnergies,
PropertyValues, NumEntries);
MPT [G4String(key)] = mpv;
return mpv;
}
inline
void G4MaterialPropertiesTable::
AddProperty(const char *key, G4MaterialPropertyVector *mpv)
{
// Provides a way of adding a property to the Material Properties
// Table given an G4MaterialPropertyVector Reference and a key
MPT [G4String(key)] = mpv;
}
inline
void G4MaterialPropertiesTable::RemoveConstProperty(const char *key)
{
MPTC.erase(G4String(key));
G4MCPindex index = GetConstPropertyIndex(G4String(key));
MCP.erase(index);
}
inline
void G4MaterialPropertiesTable::RemoveProperty(const char *key)
{
MPT.erase(G4String(key));
G4MPindex index = GetPropertyIndex(G4String(key));
MP.erase(index);
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NistElementBuilder.hh 96794 2016-05-09 10:09:30Z gcosmo $
// $Id: G4NistElementBuilder.hh 105820 2017-08-22 08:03:26Z gcosmo $
#ifndef G4NistElementBuilder_h
#define G4NistElementBuilder_h 1
@@ -59,6 +59,7 @@
#include "globals.hh"
#include "G4Element.hh"
#include "G4Threading.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -152,6 +153,9 @@ private:
G4int verbose;
std::vector<G4String> elmNames;
#ifdef G4MULTITHREADED
static G4Mutex nistElementMutex;
#endif
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+6 -2
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NistManager.hh 97248 2016-05-30 15:00:11Z gcosmo $
// $Id: G4NistManager.hh 105820 2017-08-22 08:03:26Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -73,6 +73,7 @@
#include "G4NistElementBuilder.hh"
#include "G4NistMaterialBuilder.hh"
#include "G4Pow.hh"
#include "G4Threading.hh"
class G4NistMessenger;
@@ -278,7 +279,7 @@ public:
private:
G4NistManager();
explicit G4NistManager();
static G4NistManager* instance;
G4Pow* g4pow;
@@ -297,6 +298,9 @@ private:
G4NistMaterialBuilder* matBuilder;
G4NistMessenger* messenger;
#ifdef G4MULTITHREADED
static G4Mutex nistManagerMutex;
#endif
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+2 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 101157 2016-11-08 08:27:49Z gcosmo $
# $Id: sources.cmake 106115 2017-09-13 10:16:51Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -56,6 +56,7 @@ GEANT4_DEFINE_MODULE(NAME G4materials
G4LatticeLogical.hh
G4LatticePhysical.hh
G4Material.hh
G4MaterialPropertiesIndex.hh
G4MaterialPropertiesTable.hh
G4MaterialPropertiesTable.icc
G4MaterialPropertyVector.hh
+56 -9
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4IonisParamMat.cc 97248 2016-05-30 15:00:11Z gcosmo $
// $Id: G4IonisParamMat.cc 106243 2017-09-26 01:56:43Z gcosmo $
//
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
@@ -51,6 +51,10 @@
G4DensityEffectData* G4IonisParamMat::fDensityData = nullptr;
#ifdef G4MULTITHREADED
G4Mutex G4IonisParamMat::ionisMutex = G4MUTEX_INITIALIZER;
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
G4IonisParamMat::G4IonisParamMat(const G4Material* material)
@@ -115,8 +119,8 @@ G4IonisParamMat::G4IonisParamMat(__void__&)
G4IonisParamMat::~G4IonisParamMat()
{
if (fShellCorrectionVector) { delete [] fShellCorrectionVector; }
if (fDensityData) { delete fDensityData; }
delete [] fShellCorrectionVector;
delete fDensityData;
fDensityData = nullptr;
fShellCorrectionVector = nullptr;
}
@@ -269,12 +273,10 @@ void G4IonisParamMat::ComputeDensityEffect()
if (1 == nelm && 1 == Z0) {
fX0density = 0.425; fX1density = 2.0; fMdensity = 5.949;
}
}
//
// gases
//
if (State == kStateGas) {
} else {
//
// gases
//
fMdensity = 3.;
fX1density = 4.0;
//static const G4double ClimiG[] = {10.,10.5,11.,11.5,12.25,13.804};
@@ -443,6 +445,51 @@ void G4IonisParamMat::SetMeanExcitationEnergy(G4double value)
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
void G4IonisParamMat::SetDensityEffectParameters(G4double cd, G4double md,
G4double ad, G4double x0,
G4double x1, G4double d0)
{
// no check on consistence of user parameters
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&ionisMutex);
#endif
fCdensity = cd;
fMdensity = md;
fAdensity = ad;
fX0density = x0;
fX1density = x1;
fD0density = d0;
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&ionisMutex);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
void G4IonisParamMat::SetDensityEffectParameters(const G4Material* bmat)
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&ionisMutex);
#endif
const G4IonisParamMat* ipm = bmat->GetIonisation();
fCdensity = ipm->GetCdensity();
fMdensity = ipm->GetMdensity();
fAdensity = ipm->GetAdensity();
fX0density = ipm->GetX0density();
fX1density = ipm->GetX1density();
fD0density = ipm->GetD0density();
G4double corr = G4Log(bmat->GetDensity()/fMaterial->GetDensity());
fCdensity += corr;
fX0density += corr/twoln10;
fX1density += corr/twoln10;
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&ionisMutex);
#endif
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... ....oooOO0OOooo....
G4double G4IonisParamMat::FindMeanExcitationEnergy(const G4Material* mat) const
{
G4double res = 0.0;
+26 -4
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4Material.cc 102843 2017-02-27 13:02:28Z gcosmo $
// $Id: G4Material.cc 106243 2017-09-26 01:56:43Z gcosmo $
//
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
//
@@ -83,6 +83,10 @@
G4MaterialTable G4Material::theMaterialTable;
#ifdef G4MULTITHREADED
G4Mutex G4Material::materialMutex = G4MUTEX_INITIALIZER;
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// Constructor to create a material from scratch
@@ -238,11 +242,11 @@ G4Material::~G4Material()
delete theElementVector;
delete fSandiaTable;
//delete fMaterialPropertiesTable;
if(fMassFractionVector) { delete [] fMassFractionVector; }
if(fAtomsVector) { delete [] fAtomsVector; }
delete [] fMassFractionVector;
delete [] fAtomsVector;
}
delete fIonisation;
if(VecNbOfAtomsPerVolume) { delete [] VecNbOfAtomsPerVolume; }
delete [] VecNbOfAtomsPerVolume;
// Remove this material from theMaterialTable.
//
@@ -331,6 +335,8 @@ void G4Material::CopyPointersOfBaseMaterial()
TotNbOfAtomsPerVolume = factor*fBaseMaterial->GetTotNbOfAtomsPerVolume();
TotNbOfElectPerVolume = factor*fBaseMaterial->GetTotNbOfElectPerVolume();
if(fState == kStateUndefined) { fState = fBaseMaterial->GetState(); }
theElementVector =
const_cast<G4ElementVector*>(fBaseMaterial->GetElementVector());
fMassFractionVector =
@@ -720,3 +726,19 @@ G4bool G4Material::IsExtended() const
{ return false; }
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4Material::SetMaterialPropertiesTable(G4MaterialPropertiesTable* anMPT)
{
if(anMPT && fMaterialPropertiesTable != anMPT) {
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&materialMutex);
#endif
delete fMaterialPropertiesTable;
fMaterialPropertiesTable = anMPT;
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&materialMutex);
#endif
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+170 -52
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4MaterialPropertiesTable.cc 102805 2017-02-22 16:34:13Z gcosmo $
// $Id: G4MaterialPropertiesTable.cc 106997 2017-10-31 10:22:36Z gcosmo $
//
//
////////////////////////////////////////////////////////////////////////
@@ -51,6 +51,8 @@
#include "G4PhysicalConstants.hh"
#include "G4Log.hh"
#include <algorithm>
/////////////////
// Constructors
/////////////////
@@ -72,32 +74,76 @@ G4MaterialPropertiesTable::~G4MaterialPropertiesTable()
}
MPT.clear();
MPTC.clear();
MPiterator it;
for (it = MP.begin(); it != MP.end(); ++it)
{
delete (*it).second;
}
MP.clear();
MCP.clear();
}
////////////
// Methods
////////////
G4MCPindex G4MaterialPropertiesTable::GetConstPropertyIndex(const G4String& key) const
{
// Returns the constant material property index corresponding to a key
size_t index = std::distance(G4MaterialConstPropertyName.begin(),
std::find(G4MaterialConstPropertyName.begin(),
G4MaterialConstPropertyName.end(), key));
if((G4MCPindex)index != kNumberOfConstPropertyIndex) return (G4MCPindex)index;
G4cout << "key: " << key << G4endl;
G4Exception("G4MaterialPropertiesTable::GetConstPropertyIndex()","mat206",
FatalException, "Constant Material Property Index not found.");
return kNullConstPropertyIndex;
}
G4MPindex G4MaterialPropertiesTable::GetPropertyIndex(const G4String& key) const
{
// Returns the material property index corresponding to a key
size_t index = std::distance(G4MaterialPropertyName.begin(),
std::find(G4MaterialPropertyName.begin(),
G4MaterialPropertyName.end(), key));
if((G4MPindex)index != kNumberOfPropertyIndex) return (G4MPindex)index;
G4cout << "key: " << key << G4endl;
G4Exception("G4MaterialPropertiesTable::GetPropertyIndex()","mat207",
FatalException, "Material Property Index not found.");
return kNullPropertyIndex;
}
G4double G4MaterialPropertiesTable::GetConstProperty(const G4MCPindex index) const
{
// Returns the constant material property corresponding to an index
MCPiterator j;
j = MCP.find(index);
if ( j != MCP.end() ) return j->second;
G4cout << "index: " << index << G4endl;
G4Exception("G4MaterialPropertiesTable::GetConstProperty()","mat202",
FatalException, "Constant Material Property Index not found.");
return 0.;
}
G4double G4MaterialPropertiesTable::GetConstProperty(const char *key) const
{
// Returns the constant material property corresponding to a key
MPTCiterator j;
j = MPTC.find(G4String(key));
if ( j != MPTC.end() ) return j->second;
G4cout << "key: " << G4String(key) << G4endl;
G4Exception("G4MaterialPropertiesTable::GetConstProperty()","mat202",
FatalException, "Constant Material Property not found.");
return 0.;
const G4MCPindex index = GetConstPropertyIndex(G4String(key));
return GetConstProperty(index);
}
G4bool G4MaterialPropertiesTable::ConstPropertyExists(const char *key) const
{
// Returns true if a const property 'key' exists
const G4MCPindex index = GetConstPropertyIndex(G4String(key));
MPTCiterator j;
j = MPTC.find(G4String(key));
if ( j != MPTC.end() ) return true;
MCPiterator j;
j = MCP.find(index);
if ( j != MCP.end() ) return true;
return false;
}
@@ -105,45 +151,67 @@ G4MaterialPropertyVector*
G4MaterialPropertiesTable::GetProperty(const char *key)
{
// Returns a Material Property Vector corresponding to a key
const G4MPindex index = GetPropertyIndex(G4String(key));
return GetProperty(index);
}
//Important Note for MT. adotti 17 Feb 2016
//In previous implementation the following line was at the bottom of the
//function causing a rare race-condition.
//Moving this line here from the bottom solves the problem because:
//1- Map is accessed only via operator[] (to insert) and find() (to search),
// and these are thread safe if done on separate elements.
// See notes on data-races at:
// http://www.cplusplus.com/reference/map/map/operator%5B%5D/
// http://www.cplusplus.com/reference/map/map/find/
//2- So we have a data race if two threads access the same element (GROUPVEL)
// one in read and one in write mode. This was happening with the line
// at the bottom of the code, one thread in SetGROUPVEL(),
// and the other here
//3- SetGROUPVEL() is protected by a mutex that ensures that only
// one thread at the time will execute its code
//4- The if() statement guarantees that only if two threads are searching
// the same problematic key (GROUPVEL) the mutex will be used.
// Different keys do not lock (good for performances)
//5- As soon as a thread acquires the mutex in SetGROUPVEL it checks again
// if the map has GROUPVEL key, if so returns immediately.
// This "double check" allows to execute the heavy code to calculate
// group velocity only once even if two threads enter SetGROUPVEL together
if (G4String(key) == "GROUPVEL") return SetGROUPVEL();
MPTiterator i;
i = MPT.find(G4String(key));
if ( i != MPT.end() ) return i->second;
G4MaterialPropertyVector*
G4MaterialPropertiesTable::GetProperty(const G4MPindex index)
{
// Returns a Material Property Vector corresponding to an index
MPiterator i;
i = MP.find(index);
if ( i != MP.end() ) return i->second;
return nullptr;
}
G4MaterialPropertyVector* G4MaterialPropertiesTable::AddProperty(
const char *key,
G4double *PhotonEnergies,
G4double *PropertyValues,
G4int NumEntries)
{
// Provides a way of adding a property to the Material Properties
// Table given a pair of numbers and a key
G4MPindex index = GetPropertyIndex(G4String(key));
G4MaterialPropertyVector *mpv = new G4MaterialPropertyVector(PhotonEnergies,
PropertyValues, NumEntries);
MP[index] = mpv;
// if key is RINDEX, we calculate GROUPVEL -
// contribution from Tao Lin (IHEP, the JUNO experiment)
if (G4String(key)=="RINDEX") {
CalculateGROUPVEL();
}
return mpv;
}
void G4MaterialPropertiesTable::
AddProperty(const char *key, G4MaterialPropertyVector *mpv)
{
// Provides a way of adding a property to the Material Properties
// Table given an G4MaterialPropertyVector Reference and a key
G4MPindex index = GetPropertyIndex(G4String(key));
MP[ index ] = mpv;
// if key is RINDEX, we calculate GROUPVEL -
// contribution from Tao Lin (IHEP, the JUNO experiment)
if (G4String(key)=="RINDEX") {
CalculateGROUPVEL();
}
}
void G4MaterialPropertiesTable::AddEntry(const char *key,
G4double aPhotonEnergy,
G4double aPropertyValue)
{
// Allows to add an entry pair directly to the Material Property Vector
// given a key
const G4MPindex index = GetPropertyIndex(G4String(key));
G4MaterialPropertyVector *targetVector=MPT [G4String(key)];
G4MaterialPropertyVector *targetVector=MP[index];
if (targetVector != nullptr)
{
targetVector->InsertValues(aPhotonEnergy, aPropertyValue);
@@ -157,8 +225,8 @@ void G4MaterialPropertiesTable::AddEntry(const char *key,
void G4MaterialPropertiesTable::DumpTable()
{
MPTiterator i;
for (i = MPT.begin(); i != MPT.end(); ++i)
MPiterator i;
for (i = MP.begin(); i != MP.end(); ++i)
{
G4cout << (*i).first << G4endl;
if ( (*i).second != 0 )
@@ -171,8 +239,8 @@ void G4MaterialPropertiesTable::DumpTable()
JustWarning, "NULL Material Property Vector Pointer.");
}
}
MPTCiterator j;
for (j = MPTC.begin(); j != MPTC.end(); ++j)
MCPiterator j;
for (j = MCP.begin(); j != MCP.end(); ++j)
{
G4cout << j->first << G4endl;
if ( j->second != 0 )
@@ -194,20 +262,23 @@ namespace {
}
#endif
G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
G4MaterialPropertyVector* G4MaterialPropertiesTable::CalculateGROUPVEL()
{
#ifdef G4MULTITHREADED
G4AutoLock mptm(&materialPropertyTableMutex);
#endif
// reconsider (i.e, remove) above mutex as this method is likely called only
// when RINDEX is added during the detector construction phase (i.e., adding
// meterials properties into geometry) on the master thread (Oct. 2017, SYJ)
// check if "GROUPVEL" already exists
MPTiterator itr;
itr = MPT.find("GROUPVEL");
if(itr != MPT.end()) return itr->second;
MPiterator itr;
itr = MP.find(kGROUPVEL);
if(itr != MP.end()) return itr->second;
// fetch RINDEX data, give up if unavailable
//
G4MaterialPropertyVector *rindex = this->GetProperty("RINDEX");
G4MaterialPropertyVector *rindex = this->GetProperty(kRINDEX);
if (rindex==0) { return 0; }
// RINDEX exists but has no entries, give up
@@ -226,7 +297,7 @@ G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
if (E0 <= 0.)
{
G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
FatalException, "Optical Photon Energy <= 0");
}
@@ -240,7 +311,7 @@ G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
if (E1 <= 0.)
{
G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
FatalException, "Optical Photon Energy <= 0");
}
@@ -277,7 +348,7 @@ G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
if (E1 <= 0.)
{
G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "mat205",
G4Exception("G4MaterialPropertiesTable::CalculateGROUPVEL()", "mat205",
FatalException, "Optical Photon Energy <= 0");
}
}
@@ -300,3 +371,50 @@ G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
return groupvel;
}
G4MaterialPropertyVector* G4MaterialPropertiesTable::SetGROUPVEL()
{
G4String message("SetGROUPVEL will be obsolete from the next release ");
message += "Use G4MaterialPropertiesTable::CalculateGROUPVEL() instead";
G4Exception("G4MaterialPropertiesTable::SetGROUPVEL()", "Obsolete",
JustWarning, message);
return CalculateGROUPVEL();
}
std::map< G4String, G4MaterialPropertyVector*, std::less<G4String> >*
G4MaterialPropertiesTable::GetPropertiesMap()
{
// warning message
G4String message("GetPropertiesMap will be obsolete from the next release ");
message += "Use G4MaterialPropertiesTable::GetPropertyMap() instead";
G4Exception("G4MaterialPropertiesTable::GetPropertiesMap()", "Obsolete",
JustWarning, message);
for (MPiterator miter = MP.begin(); miter != MP.end(); miter++)
{
if(miter->second) {
MPT [ G4MaterialPropertyName[miter->first] ] = miter->second;
}
else {
G4Exception("G4MaterialPropertiesTable::GetPropertiesMap()","NullPointer",
JustWarning, "Null Pointer for Material Property");
continue;
}
}
return &MPT;
}
std::map< G4String, G4double, std::less<G4String> >* G4MaterialPropertiesTable::GetPropertiesCMap()
{
// warning message
G4String message("GetPropertiesCMap will be obsolete from the next release ");
message += "Use G4MaterialPropertiesTable::GetConstPropertyMap() instead";
G4Exception("G4MaterialPropertiesTable::GetPropertiesCMap()", "Obsolete",
JustWarning, message);
for (MCPiterator miter = MCP.begin(); miter != MCP.end(); miter++) {
MPTC[ G4MaterialConstPropertyName[miter->first] ] = miter->second;
}
return &MPTC;
}
+20 -3
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NistElementBuilder.cc 97248 2016-05-30 15:00:11Z gcosmo $
// $Id: G4NistElementBuilder.cc 105820 2017-08-22 08:03:26Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -60,6 +60,10 @@
#include "G4PhysicalConstants.hh"
#include "G4SystemOfUnits.hh"
#ifdef G4MULTITHREADED
G4Mutex G4NistElementBuilder::nistElementMutex = G4MUTEX_INITIALIZER;
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4NistElementBuilder::G4NistElementBuilder(G4int vb):
@@ -103,8 +107,14 @@ G4Element* G4NistElementBuilder::FindOrBuildElement(G4int Z, G4bool)
{
G4Element* anElement = FindElement(Z);
if(anElement == nullptr && Z > 0 && Z < maxNumElements) {
anElement = BuildElement(Z);
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&nistElementMutex);
#endif
if(elmIndex[Z] < 0) { anElement = BuildElement(Z); }
if(anElement) { elmIndex[Z] = anElement->GetIndex(); }
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&nistElementMutex);
#endif
}
return anElement;
}
@@ -127,7 +137,14 @@ G4NistElementBuilder::FindOrBuildElement(const G4String& symb, G4bool)
if(nullptr == elm) {
for(G4int Z = 1; Z<maxNumElements; ++Z) {
if(symb == elmSymbol[Z]) {
elm = BuildElement(Z);
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&nistElementMutex);
#endif
if(elmIndex[Z] < 0) { elm = BuildElement(Z); }
if(elm) { elmIndex[Z] = elm->GetIndex(); }
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&nistElementMutex);
#endif
break;
}
}
+14 -3
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NistManager.cc 96794 2016-05-09 10:09:30Z gcosmo $
// $Id: G4NistManager.cc 105820 2017-08-22 08:03:26Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -62,14 +62,25 @@
#include "G4Isotope.hh"
G4NistManager* G4NistManager::instance = nullptr;
#ifdef G4MULTITHREADED
G4Mutex G4NistManager::nistManagerMutex = G4MUTEX_INITIALIZER;
#endif
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
G4NistManager* G4NistManager::Instance()
{
if (instance == nullptr) {
static G4NistManager manager;
instance = &manager;
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&nistManagerMutex);
if (instance == nullptr) {
#endif
static G4NistManager manager;
instance = &manager;
#ifdef G4MULTITHREADED
}
G4MUTEXUNLOCK(&nistManagerMutex);
#endif
}
return instance;
}
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4NistMaterialBuilder.cc 99413 2016-09-21 09:02:30Z gcosmo $
// $Id: G4NistMaterialBuilder.cc 105820 2017-08-22 08:03:26Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -129,7 +129,7 @@ G4Material* G4NistMaterialBuilder::BuildNistMaterial(const G4String& name,
if (name == names[i]) {
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&G4NistMaterialBuilder::nistMaterialMutex);
G4MUTEXLOCK(&nistMaterialMutex);
#endif
if(matIndex[i] == -1) {
// Build new Nist material
@@ -141,7 +141,7 @@ G4Material* G4NistMaterialBuilder::BuildNistMaterial(const G4String& name,
mat = (*theMaterialTable)[matIndex[i]];
}
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&G4NistMaterialBuilder::nistMaterialMutex);
G4MUTEXUNLOCK(&nistMaterialMutex);
#endif
return mat;
}