50 if (mat1 == 0 && mat2 == 0)
return false;
51 if (mat1 == 0)
return true;
52 if (mat2 == 0)
return false;
57 if ((baseMat1 || baseMat2) == 0){
61 else if (baseMat1 && baseMat2){
63 return baseMat1 < baseMat2;
66 else if (baseMat1 && (baseMat2 == 0)){
68 return baseMat1 < mat2;
71 return mat1 < baseMat2;
96 fpCompFractionTable = 0;
97 fpCompDensityTable = 0;
98 fpCompNumMolPerVolTable = 0;
99 fIsInitialized =
false;
108 if (fpCompFractionTable){
109 fpCompFractionTable->clear();
110 delete fpCompFractionTable;
111 fpCompFractionTable = 0;
113 if (fpCompDensityTable){
114 fpCompDensityTable->clear();
115 delete fpCompDensityTable;
116 fpCompDensityTable = 0;
118 if (fpCompNumMolPerVolTable){
119 fpCompNumMolPerVolTable->clear();
120 delete fpCompNumMolPerVolTable;
121 fpCompNumMolPerVolTable = 0;
124 map<const G4Material*, std::vector<double>*,
CompareMaterial>::iterator it;
126 for (it = fAskedDensityTable.begin(); it != fAskedDensityTable.end(); it++){
133 for (it = fAskedNumPerVolTable.begin(); it != fAskedNumPerVolTable.end();
182 if (
this == &rhs)
return *
this;
219 mat = materialTable->at(i);
242 double massFraction = -1;
243 double parentDensity = -1;
246 parentMat = materialTable->at(i);
247 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
250 parentDensity = parentMat->GetDensity();
252 for (ComponentMap::iterator it = massFractionComp.begin();
253 it != massFractionComp.end(); it++){
255 massFraction = it->second;
256 densityComp[compMat] = massFraction * parentDensity;
264 exceptionDescription <<
"The pointer fpCompFractionTable is not initialized"
266 G4Exception(
"G4DNAMolecularMaterial::InitializeDensity",
268 exceptionDescription);
282 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
284 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
286 for (ComponentMap::iterator it = massFractionComp.begin();
287 it != massFractionComp.end(); it++){
289 numMolPerVol[compMat] = densityComp[compMat]
290 / compMat->GetMassOfMolecule();
297 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized"
299 G4Exception(
"G4DNAMolecularMaterial::InitializeNumMolPerVol",
301 exceptionDescription);
313 (*fpCompFractionTable)[parentMaterial->
GetIndex()];
315 if (matComponent.empty()){
316 matComponent[molecularMaterial] = fraction;
320 ComponentMap::iterator it = matComponent.find(molecularMaterial);
322 if (it == matComponent.end()){
323 matComponent[molecularMaterial] = fraction;
326 matComponent[molecularMaterial] = it->second + fraction;
335 double currentFraction)
344 std::map<G4Material*, G4double> matComponent = material->
GetMatComponents();
345 std::map<G4Material*, G4double>::iterator it = matComponent.begin();
347 for (; it != matComponent.end(); it++){
349 fraction = it->second;
352 currentFraction * fraction);
356 currentFraction * fraction);
363 const std::vector<double>*
371 <<
"The pointer fpCompDensityTable is not initialized will the "
372 "singleton of G4DNAMolecularMaterial "
373 <<
"has already been initialized." <<
G4endl;
374 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
376 exceptionDescription);
385 <<
"The geant4 application is at the wrong state. State must be: "
388 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
389 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
395 const_iterator it_askedDensityTable =
399 return it_askedDensityTable->second;
404 std::vector<double>* output =
new std::vector<double>(materialTable->size());
406 ComponentMap::const_iterator it;
408 G4bool materialWasNotFound =
true;
413 it = densityTable.find(lookForMaterial);
415 if (it == densityTable.end()){
419 materialWasNotFound =
false;
420 (*output)[i] = it->second;
424 if (materialWasNotFound){
439 if(lookForMaterial==0)
return nullptr;
445 <<
"The pointer fpCompNumMolPerVolTable is not initialized whereas "
446 "the singleton of G4DNAMolecularMaterial "
447 <<
"has already been initialized." <<
G4endl;
448 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
450 exceptionDescription);
459 <<
"The geant4 application is at the wrong state. State must be : "
462 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
463 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
469 const_iterator it_askedNumMolPerVolTable =
472 return it_askedNumMolPerVolTable->second;
477 std::vector<double>* output =
new std::vector<double>(materialTable->size());
479 ComponentMap::const_iterator it;
481 G4bool materialWasNotFound =
true;
484 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
486 it = densityTable.find(lookForMaterial);
488 if (it == densityTable.end()){
492 materialWasNotFound =
false;
493 (*output)[i] = it->second;
497 if (materialWasNotFound){
499 "G4DNAMolecularMaterial::GetNumMolPerVolTableFor", lookForMaterial);
513 std::map<const G4Material*, bool, CompareMaterial>::iterator it =
518 exceptionDescription <<
"The material " << lookForMaterial->
GetName()
519 <<
" is not defined as a molecular material."
521 <<
"Meaning: The elements should be added to the "
522 "material using atom count rather than mass fraction "
525 <<
"If you want to use DNA processes on liquid water, you should better use "
526 "the NistManager to create the water material."
528 <<
"Since this message is displayed, it means that the DNA models will not "
530 <<
"Please note that this message will only appear once even if you are "
531 "using other methods of G4DNAMolecularMaterial."
535 exceptionDescription);
546 int material_id = material->
GetIndex();
559 assert(material != 0);
560 int material_id = material->
GetIndex();
570 assert(material != 0);
571 int material_id = material->
GetIndex();
585 G4cout<<
"Material " << materialName
586 <<
" was not found and therefore won't be linked to "
599 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolForComponentInComposite",
602 " at the run initialization to retrieve a read-only table used"
603 " during stepping. The method is thread-safe.");
615 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolForComponentInComposite",
618 " at the run initialization to retrieve a read-only table used"
619 " during stepping. The method is thread-safe.");
std::vector< ComponentMap > * fpCompDensityTable
static G4MoleculeTable * Instance()
void SearchMolecularMaterial(G4Material *parentMaterial, G4Material *material, double currentFraction)
std::ostringstream G4ExceptionDescription
void SetMolecularConfiguration(const G4Material *, G4MolecularConfiguration *)
Associate a molecular configuration to a G4material.
static G4MaterialTable * GetMaterialTable()
G4DNAMolecularMaterial builds tables of molecular densities for chosen molecular materials. The class handles homogeneous, composite and derived materials. A material of interest is labeled as molecular if built using the number of atoms rather than the mass fractions.
Materials can be described as a derivation of existing "parent" materials in order to alter few of th...
std::map< int, G4MolecularConfiguration * > fMaterialToMolecularConf
static G4DNAMolecularMaterial * fInstance
G4double GetNumMoleculePerVolumeUnitForMaterial(const G4Material *mat)
Deprecated.
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedDensityTable
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
void InitializeNumMolPerVol()
std::vector< ComponentMap > * fpCompFractionTable
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
Retrieve a table of molecular densities (number of molecules per unit volume) in the G4 unit system f...
std::map< const G4Material *, double, CompareMaterial > ComponentMap
const G4String & GetName() const
bool operator()(const G4Material *mat1, const G4Material *mat2) const
#define G4MUTEX_INITIALIZER
virtual ~G4DNAMolecularMaterial()
static void DeleteInstance()
void RecordMolecularMaterial(G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
const std::vector< double > * GetDensityTableFor(const G4Material *) const
Retrieve a table of volumetric mass densities (mass per unit volume) in the G4 unit system for chosen...
static G4DNAMolecularMaterial * Instance()
G4DNAMolecularMaterial & operator=(const G4DNAMolecularMaterial &)
std::vector< ComponentMap > * fpCompNumMolPerVolTable
std::vector< G4Material * > G4MaterialTable
std::map< const G4Material *, bool, CompareMaterial > fWarningPrinted
G4double GetNumMolPerVolForComponentInComposite(const G4Material *composite, const G4Material *component, G4double massFraction)
Deprecated.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
void PrintNotAMolecularMaterial(const char *methodName, const G4Material *lookForMaterial) const
G4GLOB_DLL std::ostream G4cout
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)
G4MolecularConfiguration * GetMolecularConfiguration(const G4Material *) const
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedNumPerVolTable
const std::map< G4Material *, G4double > & GetMatComponents() const
const G4Material * GetBaseMaterial() const
G4double GetMassOfMolecule() const
virtual G4bool Notify(G4ApplicationState requestedState)
static G4StateManager * GetStateManager()