Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAMolecularMaterial Class Reference

#include <G4DNAMolecularMaterial.hh>

+ Inheritance diagram for G4DNAMolecularMaterial:

Public Member Functions

void DeleteInstance ()
 
void Initialize ()
 
virtual G4bool Notify (G4ApplicationState requestedState)
 
const std::vector< ComponentMap > * GetMassFractionTable () const
 
const std::vector< ComponentMap > * GetDensityTable () const
 
const std::vector< double > * GetDensityTableFor (const G4Material *) const
 
const std::vector< double > * GetNumMolPerVolTableFor (const G4Material *) const
 
- Public Member Functions inherited from G4VStateDependent
 G4VStateDependent (G4bool bottom=false)
 
virtual ~G4VStateDependent ()
 
G4int operator== (const G4VStateDependent &right) const
 
G4int operator!= (const G4VStateDependent &right) const
 
virtual G4bool Notify (G4ApplicationState requestedState)=0
 

Static Public Member Functions

static G4DNAMolecularMaterialInstance ()
 

Protected Member Functions

 G4DNAMolecularMaterial ()
 
 G4DNAMolecularMaterial (const G4DNAMolecularMaterial &right)
 
G4DNAMolecularMaterialoperator= (const G4DNAMolecularMaterial &)
 
virtual ~G4DNAMolecularMaterial ()
 
void Create ()
 
void InitializeNumMolPerVol ()
 
void InitializeDensity ()
 
void RecordMolecularMaterial (G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
 
void SearchMolecularMaterial (G4Material *parentMaterial, G4Material *material, double currentFraction)
 
void AddMaterial (const G4Material *, double fraction)
 
void PrintNotAMolecularMaterial (const char *methodName, const G4Material *lookForMaterial) const
 

Protected Attributes

std::vector< ComponentMap > * fpCompFractionTable
 
std::vector< ComponentMap > * fpCompDensityTable
 
std::vector< ComponentMap > * fpCompNumMolPerVolTable
 
std::map< const G4Material *, std::vector< double > *, CompareMaterialfAskedDensityTable
 
std::map< const G4Material *, std::vector< double > *, CompareMaterialfAskedNumPerVolTable
 
std::map< const G4Material *, bool, CompareMaterialfWarningPrinted
 
G4bool fIsInitialized
 

Static Protected Attributes

static G4DNAMolecularMaterialfInstance
 

Detailed Description

Definition at line 50 of file G4DNAMolecularMaterial.hh.

Constructor & Destructor Documentation

◆ G4DNAMolecularMaterial() [1/2]

G4DNAMolecularMaterial::G4DNAMolecularMaterial ( )
protected

Definition at line 85 of file G4DNAMolecularMaterial.cc.

86{
87 Create();
88 fInstance = this;
89}
static G4DNAMolecularMaterial * fInstance

Referenced by Instance().

◆ G4DNAMolecularMaterial() [2/2]

G4DNAMolecularMaterial::G4DNAMolecularMaterial ( const G4DNAMolecularMaterial right)
protected

Definition at line 97 of file G4DNAMolecularMaterial.cc.

98{
99 Create();
100}

◆ ~G4DNAMolecularMaterial()

G4DNAMolecularMaterial::~G4DNAMolecularMaterial ( )
protectedvirtual

Definition at line 109 of file G4DNAMolecularMaterial.cc.

110{
112 {
113 fpCompFractionTable->clear();
114 delete fpCompFractionTable;
116 }
118 {
119 fpCompDensityTable->clear();
120 delete fpCompDensityTable;
122 }
124 {
128 }
129
130 std::map<const G4Material*,std::vector<double>*,CompareMaterial>::iterator it;
131
132 for(it= fAskedDensityTable.begin() ; it != fAskedDensityTable.end() ;it++)
133 {
134 if(it->second)
135 {
136 delete it->second;
137 it->second = 0;
138 }
139 }
140
141 for(it= fAskedNumPerVolTable.begin() ; it != fAskedNumPerVolTable.end() ;it++)
142 {
143 if(it->second)
144 {
145 delete it->second;
146 it->second = 0;
147 }
148 }
149}
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedNumPerVolTable
std::vector< ComponentMap > * fpCompFractionTable
std::vector< ComponentMap > * fpCompNumMolPerVolTable
std::vector< ComponentMap > * fpCompDensityTable
std::map< const G4Material *, std::vector< double > *, CompareMaterial > fAskedDensityTable

Member Function Documentation

◆ AddMaterial()

void G4DNAMolecularMaterial::AddMaterial ( const G4Material ,
double  fraction 
)
protected

◆ Create()

void G4DNAMolecularMaterial::Create ( )
protected

Definition at line 76 of file G4DNAMolecularMaterial.cc.

Referenced by G4DNAMolecularMaterial(), and operator=().

◆ DeleteInstance()

void G4DNAMolecularMaterial::DeleteInstance ( )

Definition at line 70 of file G4DNAMolecularMaterial.cc.

71{
72 delete fInstance;
73 fInstance = 0;
74}

◆ GetDensityTable()

const std::vector< ComponentMap > * G4DNAMolecularMaterial::GetDensityTable ( ) const
inline

Definition at line 97 of file G4DNAMolecularMaterial.hh.

98{
99 return fpCompDensityTable;
100}

◆ GetDensityTableFor()

const std::vector< double > * G4DNAMolecularMaterial::GetDensityTableFor ( const G4Material lookForMaterial) const

Definition at line 302 of file G4DNAMolecularMaterial.cc.

303{
305 {
307 {
308 G4ExceptionDescription exceptionDescription;
309 exceptionDescription << "The pointer fpCompDensityTable is not initialized will the singleton of G4DNAMolecularMaterial "
310 << "has already been initialized."<< G4endl;
311 G4Exception("G4DNAMolecularMaterial::GetDensityTableFor","G4DNAMolecularMaterial003",
312 FatalException,exceptionDescription);
313 }
314
315 if(G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
316 const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
317 else
318 {
319 G4ExceptionDescription exceptionDescription;
320 exceptionDescription << "The geant4 application is at the wrong state. State must be: G4State_Idle."<< G4endl;
321 G4Exception("G4DNAMolecularMaterial::GetDensityTableFor",
322 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",FatalException,exceptionDescription);
323 }
324 }
325
326 std::map<const G4Material*,std::vector<double>*,CompareMaterial>::const_iterator it_askedDensityTable = fAskedDensityTable.find(lookForMaterial);
327 if(it_askedDensityTable != fAskedDensityTable.end())
328 {
329 return it_askedDensityTable->second;
330 }
331
332 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
333
334 std::vector<double>* output = new std::vector<double>(materialTable->size());
335
336 ComponentMap::const_iterator it;
337
338 G4bool materialWasNotFound = true;
339
340 for(int i = 0 ; i < int(materialTable->size()) ; i++)
341 {
342 ComponentMap& densityTable = (*fpCompDensityTable)[i];
343
344 it = densityTable.find(lookForMaterial);
345
346 if(it==densityTable.end())
347 {
348 (*output)[i] = 0.0;
349 }
350 else
351 {
352 materialWasNotFound = false;
353 (*output)[i] = it->second;
354 }
355 }
356
357 if(materialWasNotFound)
358 {
359 PrintNotAMolecularMaterial("G4DNAMolecularMaterial::GetDensityTableFor",lookForMaterial);
360 }
361
362 fAskedDensityTable.insert(make_pair(lookForMaterial, output));
363
364 return output;
365}
@ G4State_Idle
std::map< const G4Material *, double, CompareMaterial > ComponentMap
@ FatalException
std::vector< G4Material * > G4MaterialTable
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
void PrintNotAMolecularMaterial(const char *methodName, const G4Material *lookForMaterial) const
static const G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:562
static G4StateManager * GetStateManager()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

Referenced by G4DNABrownianTransportation::BuildPhysicsTable().

◆ GetMassFractionTable()

const std::vector< ComponentMap > * G4DNAMolecularMaterial::GetMassFractionTable ( ) const
inline

Definition at line 92 of file G4DNAMolecularMaterial.hh.

93{
95}

◆ GetNumMolPerVolTableFor()

const std::vector< double > * G4DNAMolecularMaterial::GetNumMolPerVolTableFor ( const G4Material lookForMaterial) const

Definition at line 367 of file G4DNAMolecularMaterial.cc.

368{
370 {
372 {
373 G4ExceptionDescription exceptionDescription;
374 exceptionDescription << "The pointer fpCompNumMolPerVolTable is not initialized will the singleton of G4DNAMolecularMaterial "
375 << "has already been initialized."<< G4endl;
376 G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor","G4DNAMolecularMaterial005",
377 FatalException,exceptionDescription);
378 }
379
380 if(G4StateManager::GetStateManager()->GetCurrentState() == G4State_Idle)
381 {
382 const_cast<G4DNAMolecularMaterial*>(this)->Initialize();
383 }
384 else
385 {
386 G4ExceptionDescription exceptionDescription;
387 exceptionDescription << "The geant4 application is at the wrong state. State must be : G4State_Idle."<< G4endl;
388 G4Exception("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",
389 "G4DNAMolecularMaterial_WRONG_STATE_APPLICATION",FatalException,exceptionDescription);
390 }
391 }
392
393 std::map<const G4Material*,std::vector<double>*,CompareMaterial>::const_iterator it_askedNumMolPerVolTable = fAskedNumPerVolTable.find(lookForMaterial);
394 if(it_askedNumMolPerVolTable != fAskedNumPerVolTable.end())
395 {
396 return it_askedNumMolPerVolTable->second;
397 }
398
399 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
400
401 std::vector<double>* output = new std::vector<double>(materialTable->size());
402
403 ComponentMap::const_iterator it;
404
405 G4bool materialWasNotFound = true;
406
407 for(int i = 0 ; i < int(materialTable->size()) ; i++)
408 {
409 ComponentMap& densityTable = (*fpCompNumMolPerVolTable)[i];
410
411 it = densityTable.find(lookForMaterial);
412
413 if(it==densityTable.end())
414 {
415 (*output)[i] = 0.0;
416 }
417 else
418 {
419 materialWasNotFound = false;
420 (*output)[i] = it->second;
421 }
422 }
423
424 if(materialWasNotFound)
425 {
426 PrintNotAMolecularMaterial("G4DNAMolecularMaterial::GetNumMolPerVolTableFor",lookForMaterial);
427 }
428
429 fAskedNumPerVolTable.insert(make_pair(lookForMaterial, output));
430
431 return output;
432}

Referenced by G4DNASecondOrderReaction::BuildPhysicsTable(), G4DNAChampionElasticModel::Initialise(), G4DNADingfelderChargeDecreaseModel::Initialise(), G4DNADingfelderChargeIncreaseModel::Initialise(), G4DNAMeltonAttachmentModel::Initialise(), G4DNAMillerGreenExcitationModel::Initialise(), G4DNARuddIonisationExtendedModel::Initialise(), G4DNARuddIonisationModel::Initialise(), G4DNASancheExcitationModel::Initialise(), G4DNASancheSolvatationModel::Initialise(), G4DNAScreenedRutherfordElasticModel::Initialise(), G4DNATransformElectronModel::Initialise(), G4DNABornExcitationModel::Initialise(), G4DNABornIonisationModel::Initialise(), and G4DNAEmfietzoglouExcitationModel::Initialise().

◆ Initialize()

void G4DNAMolecularMaterial::Initialize ( )

Definition at line 275 of file G4DNAMolecularMaterial.cc.

276{
277 if(fIsInitialized) return;
278
279 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
280
282 {
283 fpCompFractionTable = new vector<ComponentMap>(materialTable->size());
284 }
285
286 G4Material* mat(0);
287
288 for(int i = 0 ; i < int(materialTable->size()) ; i++)
289 {
290 mat = materialTable->at(i);
291 SearchMolecularMaterial(mat,mat,1);
292
293 mat = 0;
294 }
295
298
299 fIsInitialized = true;
300}
void SearchMolecularMaterial(G4Material *parentMaterial, G4Material *material, double currentFraction)

Referenced by GetDensityTableFor(), GetNumMolPerVolTableFor(), and Notify().

◆ InitializeDensity()

void G4DNAMolecularMaterial::InitializeDensity ( )
protected

Definition at line 204 of file G4DNAMolecularMaterial.cc.

205{
207 {
208 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
209 fpCompDensityTable = new vector<ComponentMap>(G4Material::GetMaterialTable()->size());
210
211 G4Material* parentMat;
212 const G4Material* compMat(0);
213 double massFraction = -1;
214 double parentDensity = -1;
215
216 for(int i = 0 ; i < int(materialTable->size()) ; i++)
217 {
218 parentMat = materialTable->at(i);
219 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
220 ComponentMap& densityComp = (*fpCompDensityTable)[i];
221
222 parentDensity = parentMat->GetDensity();
223
224 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
225 {
226 compMat = it->first;
227 massFraction = it->second;
228 densityComp[compMat] = massFraction*parentDensity;
229 compMat = 0;
230 massFraction = -1;
231 }
232 }
233 }
234 else
235 {
236 G4ExceptionDescription exceptionDescription;
237 exceptionDescription << "The pointer fpCompFractionTable is not initialized" << G4endl;
238 G4Exception("G4DNAMolecularMaterial::InitializeDensity","G4DNAMolecularMaterial001",
239 FatalException,exceptionDescription);
240 }
241}
G4double GetDensity() const
Definition: G4Material.hh:179

Referenced by Initialize().

◆ InitializeNumMolPerVol()

void G4DNAMolecularMaterial::InitializeNumMolPerVol ( )
protected

Definition at line 243 of file G4DNAMolecularMaterial.cc.

244{
246 {
247 const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
248 fpCompNumMolPerVolTable = new vector<ComponentMap>(G4Material::GetMaterialTable()->size());
249
250 const G4Material* compMat(0);
251
252 for(int i = 0 ; i < int(materialTable->size()) ; i++)
253 {
254 ComponentMap& massFractionComp = (*fpCompFractionTable)[i];
255 ComponentMap& densityComp = (*fpCompDensityTable)[i];
256 ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
257
258 for(ComponentMap::iterator it = massFractionComp.begin() ; it!=massFractionComp.end() ; it++)
259 {
260 compMat = it->first;
261 numMolPerVol[compMat] = densityComp[compMat]/ compMat->GetMassOfMolecule();
262 compMat = 0;
263 }
264 }
265 }
266 else
267 {
268 G4ExceptionDescription exceptionDescription;
269 exceptionDescription << "The pointer fpCompDensityTable is not initialized" << G4endl;
270 G4Exception("G4DNAMolecularMaterial::InitializeNumMolPerVol","G4DNAMolecularMaterial002",
271 FatalException,exceptionDescription);
272 }
273}

Referenced by Initialize().

◆ Instance()

◆ Notify()

G4bool G4DNAMolecularMaterial::Notify ( G4ApplicationState  requestedState)
virtual

Implements G4VStateDependent.

Definition at line 91 of file G4DNAMolecularMaterial.cc.

92{
93 if(requestedState == G4State_Idle) Initialize();
94 return true;
95}

◆ operator=()

G4DNAMolecularMaterial & G4DNAMolecularMaterial::operator= ( const G4DNAMolecularMaterial rhs)
protected

Definition at line 102 of file G4DNAMolecularMaterial.cc.

103{
104 if(this == &rhs) return *this;
105 Create();
106 return *this;
107}

◆ PrintNotAMolecularMaterial()

void G4DNAMolecularMaterial::PrintNotAMolecularMaterial ( const char *  methodName,
const G4Material lookForMaterial 
) const
protected

Definition at line 434 of file G4DNAMolecularMaterial.cc.

435{
436 std::map<const G4Material*,bool,CompareMaterial>::iterator it = fWarningPrinted.find(lookForMaterial);
437
438 if(it == fWarningPrinted.end())
439 {
440 G4ExceptionDescription exceptionDescription;
441 exceptionDescription
442 << "The material " << lookForMaterial->GetName()
443 << " is not defined as a molecular material."<< G4endl
444 << "Meaning: The elements should be added to the material using atom count rather than mass fraction (cf. G4Material)"
445 << G4endl
446 << "If you want to use DNA processes on liquid water, you should better use the NistManager to create the water material."
447 << G4endl
448 << "Since this message is displayed, it means that the DNA models will not be called."
449 << "Please note that this message will only appear once even if you are using other methods of G4DNAMolecularMaterial."
450 << G4endl;
451
452 G4Exception(methodName,"MATERIAL_NOT_DEFINE_USING_ATOM_COUNT",JustWarning,exceptionDescription);
453 fWarningPrinted[lookForMaterial] = true;
454 }
455}
@ JustWarning
std::map< const G4Material *, bool, CompareMaterial > fWarningPrinted
const G4String & GetName() const
Definition: G4Material.hh:177

Referenced by GetDensityTableFor(), and GetNumMolPerVolTableFor().

◆ RecordMolecularMaterial()

void G4DNAMolecularMaterial::RecordMolecularMaterial ( G4Material parentMaterial,
G4Material molecularMaterial,
G4double  fraction 
)
protected

Definition at line 151 of file G4DNAMolecularMaterial.cc.

152{
153 ComponentMap& matComponent = (*fpCompFractionTable)[parentMaterial->GetIndex()];
154
155 if(matComponent.empty())
156 {
157 matComponent[molecularMaterial] = fraction;
158 return;
159 }
160
161 ComponentMap::iterator it = matComponent.find(molecularMaterial);
162
163 if(it == matComponent.end())
164 {
165 matComponent[molecularMaterial] = fraction;
166 }
167 else
168 {
169 matComponent[molecularMaterial] = it->second + fraction;
170 }
171}
size_t GetIndex() const
Definition: G4Material.hh:261

Referenced by SearchMolecularMaterial().

◆ SearchMolecularMaterial()

void G4DNAMolecularMaterial::SearchMolecularMaterial ( G4Material parentMaterial,
G4Material material,
double  currentFraction 
)
protected

Definition at line 173 of file G4DNAMolecularMaterial.cc.

174{
175 if(material->GetMassOfMolecule() != 0.0)
176 {
177 RecordMolecularMaterial(parentMaterial,material,currentFraction);
178 return;
179 }
180
181 G4Material* compMat(0);
182 G4double fraction = -1;
183 std::map<G4Material*,G4double> matComponent = material->GetMatComponents();
184 std::map<G4Material*,G4double>::iterator it = matComponent.begin();
185
186 for( ; it!=matComponent.end() ; it++)
187 {
188 compMat = it->first;
189 fraction = it->second;
190 if(compMat->GetMassOfMolecule() == 0.0)
191 {
192 SearchMolecularMaterial(parentMaterial,compMat,currentFraction*fraction);
193 }
194 else
195 {
196 RecordMolecularMaterial(parentMaterial,compMat,currentFraction*fraction);
197 }
198
199 compMat = 0;
200 fraction = -1;
201 }
202}
double G4double
Definition: G4Types.hh:64
void RecordMolecularMaterial(G4Material *parentMaterial, G4Material *molecularMaterial, G4double fraction)
G4double GetMassOfMolecule() const
Definition: G4Material.hh:241
std::map< G4Material *, G4double > GetMatComponents() const
Definition: G4Material.hh:236

Referenced by Initialize(), and SearchMolecularMaterial().

Member Data Documentation

◆ fAskedDensityTable

std::map<const G4Material*,std::vector<double>*,CompareMaterial> G4DNAMolecularMaterial::fAskedDensityTable
mutableprotected

Definition at line 85 of file G4DNAMolecularMaterial.hh.

Referenced by GetDensityTableFor(), and ~G4DNAMolecularMaterial().

◆ fAskedNumPerVolTable

std::map<const G4Material*,std::vector<double>*,CompareMaterial> G4DNAMolecularMaterial::fAskedNumPerVolTable
mutableprotected

Definition at line 86 of file G4DNAMolecularMaterial.hh.

Referenced by GetNumMolPerVolTableFor(), and ~G4DNAMolecularMaterial().

◆ fInstance

G4DNAMolecularMaterial * G4DNAMolecularMaterial::fInstance
staticprotected

Definition at line 66 of file G4DNAMolecularMaterial.hh.

Referenced by Create(), DeleteInstance(), G4DNAMolecularMaterial(), and Instance().

◆ fIsInitialized

G4bool G4DNAMolecularMaterial::fIsInitialized
protected

◆ fpCompDensityTable

std::vector<ComponentMap>* G4DNAMolecularMaterial::fpCompDensityTable
protected

◆ fpCompFractionTable

std::vector<ComponentMap>* G4DNAMolecularMaterial::fpCompFractionTable
protected

◆ fpCompNumMolPerVolTable

std::vector<ComponentMap>* G4DNAMolecularMaterial::fpCompNumMolPerVolTable
protected

◆ fWarningPrinted

std::map<const G4Material*,bool,CompareMaterial> G4DNAMolecularMaterial::fWarningPrinted
mutableprotected

Definition at line 87 of file G4DNAMolecularMaterial.hh.

Referenced by PrintNotAMolecularMaterial().


The documentation for this class was generated from the following files: