54 if (mat1 ==
nullptr && mat2 ==
nullptr)
return false;
55 if (mat1 ==
nullptr)
return true;
56 if (mat2 ==
nullptr)
return false;
61 if ((baseMat1 ==
nullptr) && (baseMat2 ==
nullptr)){
65 if ((baseMat1 !=
nullptr) && (baseMat2 !=
nullptr)){
67 return baseMat1 < baseMat2;
70 if ((baseMat1 !=
nullptr) && (baseMat2 ==
nullptr)){
72 return baseMat1 < mat2;
75 return mat1 < baseMat2;
118 std::map<const G4Material*, std::vector<G4double>*,
CompareMaterial>::iterator it;
121 if (it->second !=
nullptr){
123 it->second =
nullptr;
128 if (it->second !=
nullptr){
130 it->second =
nullptr;
184 mat = materialTable->at(i);
210 parentMat = materialTable->at(i);
211 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
216 for (
const auto& it : massFractionComp){
218 massFraction = it.second;
219 densityComp[compMat] = massFraction * parentDensity;
227 exceptionDescription <<
"The pointer fpCompFractionTable is not initialized"
229 G4Exception(
"G4DNAMolecularMaterial::InitializeDensity",
231 exceptionDescription);
245 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
247 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
249 for (
auto& it : massFractionComp){
251 numMolPerVol[compMat] = densityComp[compMat]
259 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized"
261 G4Exception(
"G4DNAMolecularMaterial::InitializeNumMolPerVol",
263 exceptionDescription);
275 (*fpCompFractionTable)[parentMaterial->
GetIndex()];
277 if (matComponent.empty()){
278 matComponent[molecularMaterial] = fraction;
282 auto it = matComponent.find(molecularMaterial);
284 if (it == matComponent.cend()){
285 matComponent[molecularMaterial] = fraction;
288 matComponent[molecularMaterial] = it->second + fraction;
306 std::map<G4Material*, G4double> matComponent = material->
GetMatComponents();
307 auto it = matComponent.cbegin();
309 for (; it != matComponent.cend(); ++it){
311 fraction = it->second;
314 currentFraction * fraction);
318 currentFraction * fraction);
325const std::vector<G4double>*
333 <<
"The pointer fpCompDensityTable is not initialized will the "
334 "singleton of G4DNAMolecularMaterial "
335 <<
"has already been initialized." <<
G4endl;
336 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
338 exceptionDescription);
347 <<
"The geant4 application is at the wrong state. State must be: "
350 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
351 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
359 return it_askedDensityTable->second;
364 auto output =
new std::vector<G4double>(materialTable->size());
366 ComponentMap::const_iterator it;
368 G4bool materialWasNotFound =
true;
373 it = densityTable.find(lookForMaterial);
375 if (it == densityTable.cend()){
379 materialWasNotFound =
false;
380 (*output)[i] = it->second;
384 if (materialWasNotFound){
399 if(lookForMaterial==
nullptr)
return nullptr;
405 <<
"The pointer fpCompNumMolPerVolTable is not initialized whereas "
406 "the singleton of G4DNAMolecularMaterial "
407 <<
"has already been initialized." <<
G4endl;
408 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
410 exceptionDescription);
419 <<
"The geant4 application is at the wrong state. State must be : "
422 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
423 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
430 return it_askedNumMolPerVolTable->second;
435 auto output =
new std::vector<G4double>(materialTable->size());
437 ComponentMap::const_iterator it;
439 G4bool materialWasNotFound =
true;
442 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
444 it = densityTable.find(lookForMaterial);
446 if (it == densityTable.cend()){
450 materialWasNotFound =
false;
451 (*output)[i] = it->second;
455 if (materialWasNotFound){
457 "G4DNAMolecularMaterial::GetNumMolPerVolTableFor", lookForMaterial);
475 exceptionDescription <<
"The material " << lookForMaterial->
GetName()
476 <<
" is not defined as a molecular material."
478 <<
"Meaning: The elements should be added to the "
479 "material using atom count rather than mass fraction "
482 <<
"If you want to use DNA processes on liquid water, you should better use "
483 "the NistManager to create the water material."
485 <<
"Since this message is displayed, it means that the DNA models will not "
487 <<
"Please note that this message will only appear once even if you are "
488 "using other methods of G4DNAMolecularMaterial."
492 exceptionDescription);
516 assert(material !=
nullptr);
527 assert(material !=
nullptr);
541 if(material ==
nullptr){
542 G4cout<<
"Material " << materialName
543 <<
" was not found and therefore won't be linked to "
556 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolForComponentInComposite",
559 " at the run initialization to retrieve a read-only table used"
560 " during stepping. The method is thread-safe.");
572 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolForComponentInComposite",
575 " at the run initialization to retrieve a read-only table used"
576 " during stepping. The method is thread-safe.");
std::map< const G4Material *, G4double, CompareMaterial > ComponentMap
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
std::vector< G4Material * > G4MaterialTable
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
G4DNAMolecularMaterial builds tables of molecular densities for chosen molecular materials....
void SetMolecularConfiguration(const G4Material *, G4MolecularConfiguration *)
Associate a molecular configuration to a G4material.
std::map< const G4Material *, std::vector< G4double > *, CompareMaterial > fAskedDensityTable
void RecordMolecularMaterial(G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
G4MolecularConfiguration * GetMolecularConfiguration(const G4Material *) const
std::map< const G4Material *, G4bool, CompareMaterial > fWarningPrinted
void PrintNotAMolecularMaterial(const char *methodName, const G4Material *lookForMaterial) const
void InitializeNumMolPerVol()
std::map< G4int, G4MolecularConfiguration * > fMaterialToMolecularConf
const std::vector< G4double > * GetNumMolPerVolTableFor(const G4Material *) const
Retrieve a table of molecular densities (number of molecules per unit volume) in the G4 unit system f...
G4double GetNumMoleculePerVolumeUnitForMaterial(const G4Material *mat)
Deprecated.
std::vector< ComponentMap > * fpCompFractionTable
std::vector< ComponentMap > * fpCompNumMolPerVolTable
static G4DNAMolecularMaterial * Instance()
G4bool Notify(G4ApplicationState requestedState) override
G4double GetNumMolPerVolForComponentInComposite(const G4Material *composite, const G4Material *component, G4double massFraction)
Deprecated.
const std::vector< G4double > * GetDensityTableFor(const G4Material *) const
Retrieve a table of volumetric mass densities (mass per unit volume) in the G4 unit system for chosen...
static G4DNAMolecularMaterial * fInstance
~G4DNAMolecularMaterial() override
void SearchMolecularMaterial(G4Material *parentMaterial, G4Material *material, G4double currentFraction)
std::map< const G4Material *, std::vector< G4double > *, CompareMaterial > fAskedNumPerVolTable
std::vector< ComponentMap > * fpCompDensityTable
G4double GetDensity() const
const std::map< G4Material *, G4double > & GetMatComponents() const
const G4Material * GetBaseMaterial() const
G4double GetMassOfMolecule() const
std::size_t GetIndex() const
static G4MaterialTable * GetMaterialTable()
const G4String & GetName() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)
static G4MoleculeTable * Instance()
static G4StateManager * GetStateManager()
Materials can be described as a derivation of existing "parent" materials in order to alter few of th...
bool operator()(const G4Material *mat1, const G4Material *mat2) const