49 if (mat1 == 0 && mat2 == 0)
return false;
50 if (mat1 == 0)
return true;
51 if (mat2 == 0)
return false;
56 if ((baseMat1 || baseMat2) == 0){
60 else if (baseMat1 && baseMat2){
62 return baseMat1 < baseMat2;
65 else if (baseMat1 && (baseMat2 == 0)){
67 return baseMat1 < mat2;
70 return mat1 < baseMat2;
95 fpCompFractionTable = 0;
96 fpCompDensityTable = 0;
97 fpCompNumMolPerVolTable = 0;
98 fIsInitialized =
false;
107 if (fpCompFractionTable){
108 fpCompFractionTable->clear();
109 delete fpCompFractionTable;
110 fpCompFractionTable = 0;
112 if (fpCompDensityTable){
113 fpCompDensityTable->clear();
114 delete fpCompDensityTable;
115 fpCompDensityTable = 0;
117 if (fpCompNumMolPerVolTable){
118 fpCompNumMolPerVolTable->clear();
119 delete fpCompNumMolPerVolTable;
120 fpCompNumMolPerVolTable = 0;
123 map<const G4Material*, std::vector<double>*,
CompareMaterial>::iterator it;
125 for (it = fAskedDensityTable.begin(); it != fAskedDensityTable.end(); it++){
132 for (it = fAskedNumPerVolTable.begin(); it != fAskedNumPerVolTable.end();
181 if (
this == &rhs)
return *
this;
218 mat = materialTable->at(i);
241 double massFraction = -1;
242 double parentDensity = -1;
245 parentMat = materialTable->at(i);
246 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
249 parentDensity = parentMat->GetDensity();
251 for (ComponentMap::iterator it = massFractionComp.begin();
252 it != massFractionComp.end(); it++){
254 massFraction = it->second;
255 densityComp[compMat] = massFraction * parentDensity;
263 exceptionDescription <<
"The pointer fpCompFractionTable is not initialized"
265 G4Exception(
"G4DNAMolecularMaterial::InitializeDensity",
267 exceptionDescription);
281 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
283 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
285 for (ComponentMap::iterator it = massFractionComp.begin();
286 it != massFractionComp.end(); it++){
288 numMolPerVol[compMat] = densityComp[compMat]
289 / compMat->GetMassOfMolecule();
296 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized"
298 G4Exception(
"G4DNAMolecularMaterial::InitializeNumMolPerVol",
300 exceptionDescription);
312 (*fpCompFractionTable)[parentMaterial->
GetIndex()];
314 if (matComponent.empty()){
315 matComponent[molecularMaterial] = fraction;
319 ComponentMap::iterator it = matComponent.find(molecularMaterial);
321 if (it == matComponent.end()){
322 matComponent[molecularMaterial] = fraction;
325 matComponent[molecularMaterial] = it->second + fraction;
333 double currentFraction)
342 std::map<G4Material*, G4double> matComponent = material->
GetMatComponents();
343 std::map<G4Material*, G4double>::iterator it = matComponent.begin();
345 for (; it != matComponent.end(); it++){
347 fraction = it->second;
350 currentFraction * fraction);
354 currentFraction * fraction);
364 const std::vector<double>*
372 <<
"The pointer fpCompDensityTable is not initialized will the "
373 "singleton of G4DNAMolecularMaterial "
374 <<
"has already been initialized." <<
G4endl;
375 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
377 exceptionDescription);
386 <<
"The geant4 application is at the wrong state. State must be: "
389 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
390 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
396 const_iterator it_askedDensityTable =
400 return it_askedDensityTable->second;
405 std::vector<double>* output =
new std::vector<double>(materialTable->size());
407 ComponentMap::const_iterator it;
409 G4bool materialWasNotFound =
true;
414 it = densityTable.find(lookForMaterial);
416 if (it == densityTable.end()){
420 materialWasNotFound =
false;
421 (*output)[i] = it->second;
425 if (materialWasNotFound){
440 if(lookForMaterial==0)
return nullptr;
446 <<
"The pointer fpCompNumMolPerVolTable is not initialized whereas "
447 "the singleton of G4DNAMolecularMaterial "
448 <<
"has already been initialized." <<
G4endl;
449 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
451 exceptionDescription);
460 <<
"The geant4 application is at the wrong state. State must be : "
463 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
464 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
470 const_iterator it_askedNumMolPerVolTable =
473 return it_askedNumMolPerVolTable->second;
478 std::vector<double>* output =
new std::vector<double>(materialTable->size());
480 ComponentMap::const_iterator it;
482 G4bool materialWasNotFound =
true;
485 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
487 it = densityTable.find(lookForMaterial);
489 if (it == densityTable.end()){
493 materialWasNotFound =
false;
494 (*output)[i] = it->second;
498 if (materialWasNotFound){
500 "G4DNAMolecularMaterial::GetNumMolPerVolTableFor", lookForMaterial);
514 std::map<const G4Material*, bool, CompareMaterial>::iterator it =
519 exceptionDescription <<
"The material " << lookForMaterial->
GetName()
520 <<
" is not defined as a molecular material."
522 <<
"Meaning: The elements should be added to the "
523 "material using atom count rather than mass fraction "
526 <<
"If you want to use DNA processes on liquid water, you should better use "
527 "the NistManager to create the water material."
529 <<
"Since this message is displayed, it means that the DNA models will not "
531 <<
"Please note that this message will only appear once even if you are "
532 "using other methods of G4DNAMolecularMaterial."
536 exceptionDescription);
547 int material_id = material->
GetIndex();
560 assert(material != 0);
561 int material_id = material->
GetIndex();
571 assert(material != 0);
572 int material_id = material->
GetIndex();
586 G4cout<<
"Material " << materialName
587 <<
" was not found and therefore won't be linked to "
const std::vector< double > * GetDensityTableFor(const G4Material *) const
const std::map< G4Material *, G4double > & GetMatComponents() const
std::map< const G4Material *, double, CompareMaterial > ComponentMap
void SearchMolecularMaterial(G4Material *parentMaterial, G4Material *material, double currentFraction)
std::ostringstream G4ExceptionDescription
void SetMolecularConfiguration(const G4Material *, G4MolecularConfiguration *)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
virtual G4bool Notify(G4ApplicationState requestedState)
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedNumPerVolTable
const G4String & GetName() const
void RecordMolecularMaterial(G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
bool operator()(const G4Material *mat1, const G4Material *mat2) const
void InitializeNumMolPerVol()
void PrintNotAMolecularMaterial(const char *methodName, const G4Material *lookForMaterial) const
std::map< int, G4MolecularConfiguration * > fMaterialToMolecularConf
#define G4MUTEX_INITIALIZER
std::vector< ComponentMap > * fpCompNumMolPerVolTable
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedDensityTable
static G4DNAMolecularMaterial * fInstance
static G4StateManager * GetStateManager()
G4GLOB_DLL std::ostream G4cout
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
G4DNAMolecularMaterial & operator=(const G4DNAMolecularMaterial &)
static G4MoleculeTable * Instance()
std::map< const G4Material *, bool, CompareMaterial > fWarningPrinted
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
static G4DNAMolecularMaterial * Instance()
std::vector< ComponentMap > * fpCompFractionTable
G4double GetMassOfMolecule() const
const G4Material * GetBaseMaterial() const
virtual ~G4DNAMolecularMaterial()
std::vector< ComponentMap > * fpCompDensityTable
static void DeleteInstance()
G4MolecularConfiguration * GetMolecularConfiguration(const G4Material *) const
G4MolecularConfiguration * GetConfiguration(const G4String &, bool mustExist=true)