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;
109 if(
this == &rhs)
return *
this;
135 std::map<const G4Material*,std::vector<double>*,
CompareMaterial>::iterator it;
180 mat = materialTable->at(i);
201 double massFraction = -1;
202 double parentDensity = -1;
206 parentMat = materialTable->at(i);
207 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
210 parentDensity = parentMat->GetDensity();
212 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
215 massFraction = it->second;
216 densityComp[compMat] = massFraction*parentDensity;
225 exceptionDescription <<
"The pointer fpCompFractionTable is not initialized" <<
G4endl;
226 G4Exception(
"G4DNAMolecularMaterial::InitializeDensity",
"G4DNAMolecularMaterial001",
241 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
243 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
245 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
248 numMolPerVol[compMat] = densityComp[compMat]/ compMat->GetMassOfMolecule();
256 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized" <<
G4endl;
257 G4Exception(
"G4DNAMolecularMaterial::InitializeNumMolPerVol",
"G4DNAMolecularMaterial002",
266 if(matComponent.empty())
268 matComponent[molecularMaterial] = fraction;
272 ComponentMap::iterator it = matComponent.find(molecularMaterial);
274 if(it == matComponent.end())
276 matComponent[molecularMaterial] = fraction;
280 matComponent[molecularMaterial] = it->second + fraction;
295 std::map<G4Material*,G4double>::iterator it = matComponent.begin();
297 for( ; it!=matComponent.end() ; it++)
300 fraction = it->second;
323 exceptionDescription <<
"The pointer fpCompDensityTable is not initialized will the singleton of G4DNAMolecularMaterial "
324 <<
"has already been initialized."<<
G4endl;
325 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
"G4DNAMolecularMaterial003",
334 exceptionDescription <<
"The geant4 application is at the wrong state. State must be: G4State_Idle."<<
G4endl;
335 G4Exception(
"G4DNAMolecularMaterial::GetDensityTableFor",
336 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException,exceptionDescription);
343 return it_askedDensityTable->second;
348 std::vector<double>* output =
new std::vector<double>(materialTable->size());
350 ComponentMap::const_iterator it;
352 G4bool materialWasNotFound =
true;
358 it = densityTable.find(lookForMaterial);
360 if(it==densityTable.end())
366 materialWasNotFound =
false;
367 (*output)[i] = it->second;
371 if(materialWasNotFound)
388 exceptionDescription <<
"The pointer fpCompNumMolPerVolTable is not initialized whereas the singleton of G4DNAMolecularMaterial "
389 <<
"has already been initialized."<<
G4endl;
390 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
"G4DNAMolecularMaterial005",
401 exceptionDescription <<
"The geant4 application is at the wrong state. State must be : G4State_Idle."<<
G4endl;
402 G4Exception(
"G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
403 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",
FatalException,exceptionDescription);
410 return it_askedNumMolPerVolTable->second;
415 std::vector<double>* output =
new std::vector<double>(materialTable->size());
417 ComponentMap::const_iterator it;
419 G4bool materialWasNotFound =
true;
423 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
425 it = densityTable.find(lookForMaterial);
427 if(it==densityTable.end())
433 materialWasNotFound =
false;
434 (*output)[i] = it->second;
438 if(materialWasNotFound)
450 std::map<const G4Material*,bool,CompareMaterial>::iterator it =
fWarningPrinted.find(lookForMaterial);
456 <<
"The material " << lookForMaterial->
GetName()
457 <<
" is not defined as a molecular material."<<
G4endl
458 <<
"Meaning: The elements should be added to the material using atom count rather than mass fraction (cf. G4Material)"
460 <<
"If you want to use DNA processes on liquid water, you should better use the NistManager to create the water material."
462 <<
"Since this message is displayed, it means that the DNA models will not be called."
463 <<
"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
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