44 if(mat1==0 && mat2==0)
return false;
45 if(mat1==0)
return true;
46 if(mat2==0)
return false;
51 if((baseMat1 || baseMat2) == 0)
55 else if(baseMat1 && baseMat2)
57 return baseMat1 < baseMat2;
60 else if(baseMat1 && (baseMat2 == 0))
62 return baseMat1 < mat2;
65 return mat1 < baseMat2;
82 fpCompFractionTable = 0;
83 fpCompDensityTable = 0;
84 fpCompNumMolPerVolTable = 0;
85 fIsInitialized =
false;
108 if(
this == &rhs)
return *
this;
134 std::map<const G4Material*,std::vector<double>*,
CompareMaterial>::iterator it;
159 if(matComponent.empty())
161 matComponent[molecularMaterial] = fraction;
165 ComponentMap::iterator it = matComponent.find(molecularMaterial);
167 if(it == matComponent.end())
169 matComponent[molecularMaterial] = fraction;
173 matComponent[molecularMaterial] = it->second + fraction;
188 std::map<G4Material*,G4double>::iterator it = matComponent.begin();
190 for( ; it!=matComponent.end() ; it++)
193 fraction = it->second;
217 double massFraction = -1;
218 double parentDensity = -1;
220 for(
int i = 0 ; i <
int(materialTable->size()) ; i++)
222 parentMat = materialTable->at(i);
223 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
226 parentDensity = parentMat->GetDensity();
228 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
231 massFraction = it->second;
232 densityComp[compMat] = massFraction*parentDensity;
241 exceptionDescription <<
"The pointer fpCompFractionTable is not initialized" <<
G4endl;
242 G4Exception(
"G4DNAMolecularMaterial::InitializeDensity",
"G4DNAMolecularMaterial001",
256 for(
int i = 0 ; i <
int(materialTable->size()) ; i++)
258 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
260 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
262 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
265 numMolPerVol[compMat] = densityComp[compMat]/ compMat->GetMassOfMolecule();
273 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized" <<
G4endl;
274 G4Exception(
"G4DNAMolecularMaterial::InitializeNumMolPerVol",
"G4DNAMolecularMaterial002",
296 for(
int i = 0 ; i <
int(materialTable->size()) ; i++)
298 mat = materialTable->at(i);
317 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized will the singleton of G4DNAMolecularMaterial "
318 <<
"has already been initialized."<<
G4endl;
319 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
"G4DNAMolecularMaterial003",
328 exceptionDescription <<
"The geant4 application is at the wrong state. State must be: G4State_Idle."<<
G4endl;
329 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
330 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException,exceptionDescription);
337 return it_askedDensityTable->second;
342 std::vector<double>* output =
new std::vector<double>(materialTable->size());
344 ComponentMap::const_iterator it;
346 G4bool materialWasNotFound =
true;
348 for(
int i = 0 ; i <
int(materialTable->size()) ; i++)
352 it = densityTable.find(lookForMaterial);
354 if(it==densityTable.end())
360 materialWasNotFound =
false;
361 (*output)[i] = it->second;
365 if(materialWasNotFound)
382 exceptionDescription <<
"The pointer fpCompNumMolPerVolTable is not initialized whereas the singleton of G4DNAMolecularMaterial "
383 <<
"has already been initialized."<<
G4endl;
384 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
"G4DNAMolecularMaterial005",
395 exceptionDescription <<
"The geant4 application is at the wrong state. State must be : G4State_Idle."<<
G4endl;
396 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
397 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException,exceptionDescription);
404 return it_askedNumMolPerVolTable->second;
409 std::vector<double>* output =
new std::vector<double>(materialTable->size());
411 ComponentMap::const_iterator it;
413 G4bool materialWasNotFound =
true;
415 for(
int i = 0 ; i <
int(materialTable->size()) ; i++)
417 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
419 it = densityTable.find(lookForMaterial);
421 if(it==densityTable.end())
427 materialWasNotFound =
false;
428 (*output)[i] = it->second;
432 if(materialWasNotFound)
444 std::map<const G4Material*,bool,CompareMaterial>::iterator it =
fWarningPrinted.find(lookForMaterial);
450 <<
"The material " << lookForMaterial->
GetName()
451 <<
" is not defined as a molecular material."<<
G4endl
452 <<
"Meaning: The elements should be added to the material using atom count rather than mass fraction (cf. G4Material)"
454 <<
"If you want to use DNA processes on liquid water, you should better use the NistManager to create the water material."
456 <<
"Since this message is displayed, it means that the DNA models will not be called."
457 <<
"Please note that this message will only appear once even if you are using other methods of G4DNAMolecularMaterial."
const std::vector< double > * GetDensityTableFor(const G4Material *) const
void SearchMolecularMaterial(G4Material *parentMaterial, G4Material *material, double currentFraction)
std::ostringstream G4ExceptionDescription
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
virtual G4bool Notify(G4ApplicationState requestedState)
const G4String & GetName() const
void RecordMolecularMaterial(G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
static G4MaterialTable * GetMaterialTable()
std::vector< G4Material * > G4MaterialTable
std::map< const G4Material *, double, CompareMaterial > ComponentMap
bool operator()(const G4Material *mat1, const G4Material *mat2) const
void InitializeNumMolPerVol()
void PrintNotAMolecularMaterial(const char *methodName, const G4Material *lookForMaterial) const
#define G4MUTEX_INITIALIZER
std::vector< ComponentMap > * fpCompNumMolPerVolTable
static G4DNAMolecularMaterial * fInstance
static G4StateManager * GetStateManager()
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedNumPerVolTable
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedDensityTable
G4DNAMolecularMaterial & operator=(const G4DNAMolecularMaterial &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::map< const G4Material *, bool, CompareMaterial > fWarningPrinted
static G4DNAMolecularMaterial * Instance()
std::vector< ComponentMap > * fpCompFractionTable
G4double GetMassOfMolecule() const
const G4Material * GetBaseMaterial() const
virtual ~G4DNAMolecularMaterial()
std::vector< ComponentMap > * fpCompDensityTable
std::map< G4Material *, G4double > GetMatComponents() const