38 :
G4VEmModel(nam),
fName(nam), fpParticleChangeForGamma(0), fSampledMat(
"")
110 G4double crossSectionTimesNbMolPerVol (0);
136 crossSectionTimesNbMolPerVol = nbOfMoleculePerVolumeUnit * model->
CrossSectionPerVolume(material, materialName, p, ekin, emin, emax);
138 crossSectionTimesNbMolPerVol = 0.;
150 std::map<G4Material*, G4double> componentsMap = material->
GetMatComponents();
153 std::map<G4Material*, G4double>::const_iterator it = componentsMap.begin();
156 unsigned int componentNumber = componentsMap.size();
160 for(
unsigned int i=0; i<componentNumber; ++i)
180 crossSectionTimesNbMolPerVol =
181 nbMoleculeOfComponentInCompositeMat * model->
CrossSectionPerVolume(component, componentName, p, ekin, emin, emax);
183 crossSectionTimesNbMolPerVol = 0.;
187 fMaterialCS[componentName] = crossSectionTimesNbMolPerVol;
191 fCSsumTot += crossSectionTimesNbMolPerVol;
197 crossSectionTimesNbMolPerVol =
fCSsumTot;
203 return crossSectionTimesNbMolPerVol;
249 std::map<const G4String , G4double>::const_iterator it =
fMaterialCS.begin();
250 std::map<const G4String , G4double>::const_iterator ite =
fMaterialCS.end();
257 G4Exception(
"G4DNAModelManager::SampleSecondaries",
"em0006",
259 "The random component selection has failed: we ran into the end of the map without having a selected component");
264 cumulCS += it->second;
270 if(rand<cumulCS || cumulCS >=
DBL_MAX)
273 materialName = it->
first;
287 G4Exception(
"G4DNAModelManager::SampleSecondaries",
"em0006",
289 "The random component selection has failed: while loop ended without a selected component.");
301 if(materialName.find(
"_MODIFIED")!=G4String::npos)
303 materialName = materialName.substr(0,materialName.size()-9);
339 G4MaterialTable::iterator it;
351 unsigned int compositeSize = componentMap.size();
354 if(componentMap.empty())
366 std::map<G4Material*, G4double>::const_iterator itComp = componentMap.begin();
370 for(
unsigned int k=0; k<compositeSize; ++k)
410 for(
size_t i=0, ie=materialTable->size(); i<ie; i++)
413 G4Material* currentMaterial = materialTable->at(i);
422 for(; it != ite; it++)
426 if(materialName == currentMatName)
455 G4int modelNbForMaterial (0);
469 ++modelNbForMaterial;
475 if(modelNbForMaterial>1)
489 std::map<G4double, G4int, std::less<G4double> > sortMap;
495 for(
unsigned int ii=0, em=models.size(); ii<em; ++ii)
497 G4double lowLim = models[ii]->GetLowELimit(matName, pName);
498 G4double highLim = models[ii]->GetHighELimit(matName, pName);
500 if(sortMap.find(lowLim) != sortMap.end() )
505 sortMap[lowLim] = ii;
507 if(sortMap.find(highLim) != sortMap.end() )
509 highLim -= smallDiff;
512 sortMap[highLim] = ii;
519 std::map<G4double, G4int>::iterator it = sortMap.begin();
522 G4double dummyLim = it->first - smallDiff;
527 for(
unsigned int ii=0, eii=models.size(); ii<eii; ++ii)
529 G4double lim1 = it->first - smallDiff;
530 G4int count1 = it->second;
535 G4double lim2 = it->first + smallDiff;
536 G4int count2 = it->second;
545 if( (count1 != count2) || ( std::abs(dummyLim - lim1) > 1.*
eV ) )
549 std::ostringstream oss;
550 oss<<
"The material "<<matName<<
" and the particle "<<pName;
551 oss<<
" have several models registered for the "<<
fName<<
" interaction and their energy ranges ";
552 oss<<
"do not match. \nEnergy ranges: \n";
554 for(
int iii=0, eiii=models.size(); iii<eiii; ++iii)
556 oss<<models[iii]->GetName()<<
"\n";
557 oss<<
"low: "<<models[iii]->GetLowELimit(matName, pName)/
eV<<
" eV \n";
558 oss<<
"high: "<<models[iii]->GetHighELimit(matName, pName)/
eV<<
" eV \n";
561 G4Exception(
"G4DNAModelManager::InsertModelInTable",
"em0006",
572 else if(modelNbForMaterial==0)
599 for(
int i=0, ie=models.size(); i<ie; ++i)
602 if( ekin >= models[i]->GetLowELimit(material, particle)
603 && ekin < models[i]->GetHighELimit(material, particle) )
void SetHighEnergyLimit(G4double)
static G4MaterialTable * GetMaterialTable()
const G4String & GetParticleName() const
G4double GetNumMoleculePerVolumeUnitForMaterial(const G4Material *mat)
virtual G4double CrossSectionPerVolume(const G4Material *material, const G4String &materialName, const G4ParticleDefinition *p, G4double ekin, G4double emin, G4double emax)=0
CrossSectionPerVolume Every model must implement its own CrossSectionPerVolume method. It is used by the process to determine the step path and must return a cross section times a number of molecules per volume unit.
static const G4double emax
G4String fSampledMat
for the user to retrieve selected material/component
std::map< const G4String, G4double > fMaterialCS
map used to share information between CrossSectionPerVolume and SampleSecondaries ...
const std::vector< double > * GetNumMolPerVolTableFor(const G4Material *) const
Retrieve a table of molecular densities (number of molecules per unit volume) in the G4 unit system f...
const G4String & GetName() const
virtual G4double CrossSectionPerVolume(const G4Material *material, const G4ParticleDefinition *p, G4double ekin, G4double emin, G4double emax)
CrossSectionPerVolume Method called by the process and used to call the CrossSectionPerVolume method ...
void InsertModelInTable(const G4String &matName, const G4String &pName)
InsertModelInTable Used to put a model in the table after performing some checks. ...
G4VDNAModel * GetDNAModel(const G4String &material, const G4String &particle, G4double ekin)
GetDNAModel.
G4double fCSsumTot
value which contains the sum of all the component cross sections in case of a composite material ...
void BuildMaterialMolPerVolTable()
static G4DNAMolecularMaterial * Instance()
G4DNAModelInterface(const G4String &nam)
G4DNAModelManager Constructor.
virtual void Initialise(const G4ParticleDefinition *particle, const G4DataVector &cuts)
Initialise Initialise method to call all the initialise methods of the registered models...
static constexpr double eV
std::vector< G4VDNAModel * > fRegisteredModels
vector containing all the registered models
G4ParticleChangeForGamma * fpParticleChangeForGamma
pointer used to change the characteristics of the current particle
MaterialParticleModelTable fMaterialParticleModelTable
map: [materialName][particleName] = vector of models
G4double G4ParticleHPJENDLHEData::G4double result
std::vector< G4Material * > G4MaterialTable
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::map< G4String, const std::vector< double > * > fMaterialMolPerVol
const G4String & GetName() const
void SetLowEnergyLimit(G4double)
void BuildMaterialParticleModelTable(const G4ParticleDefinition *p)
BuildMaterialParticleModelTable Method used to build a map allowing the code to quickly retrieve the ...
G4double GetKineticEnergy() const
const G4String fName
name of the interaction
virtual ~G4DNAModelInterface()
~G4DNAModelManager Destructor
const G4Material * GetMaterial() const
G4ParticleChangeForGamma * GetParticleChangeForGamma()
const G4ParticleDefinition * GetParticleDefinition() const
const std::map< G4Material *, G4double > & GetMatComponents() const
const XML_Char XML_Content * model
G4double GetNumMolPerVolUnitForComponentInComposite(const G4Material *component, const G4Material *composite)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4String &materialName, const G4DynamicParticle *, G4ParticleChangeForGamma *particleChangeForGamma, G4double tmin=0, G4double tmax=DBL_MAX)=0
SampleSecondaries Each model must implement SampleSecondaries to decide if a particle will be created...
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *fVect, const G4MaterialCutsCouple *couple, const G4DynamicParticle *aDynamicElectron, G4double tmin, G4double tmax)
SampleSecondaries Used to call the SampleSecondaries method of the registered models. A sampling is done to select a component if the material is a composite one.
void RegisterModel(G4VDNAModel *model)
RegisterModel Method used to associate a model with the interaction.