414{
415
416 static G4bool amInAUnitTest =
false;
418 {
419 amInAUnitTest = true;
421 ed <<
"The ProductionCuts table is empty " <<
G4endl;
422 ed <<
"This should happen only in Unit Tests" <<
G4endl;
423 G4Exception(
"G4PenelopeRayleighModelMI::CrossSectionPerVolume()",
425 }
426
428 if (amInAUnitTest)
429 {
430
432
434 G4int iZ = theElementVector->at(j)->GetZasInt();
435 if (!fLogAtomicCrossSection[iZ]) {
436 ReadDataFile(iZ);
437 }
438 }
439 if (fIsMIActive)
440 ReadMolInterferenceData(matname);
441 if (!fLogFormFactorTable->count(material))
442 BuildFormFactorTable(material);
443 if (!(fSamplingTable->count(material)))
444 InitializeSamplingAlgorithm(material);
445 if (!fPMaxTable->count(material))
446 GetPMaxTable(material);
447 }
448 G4bool useMIFF = fIsMIActive && (fMolInterferenceData->count(matname) || matname.find(
"MedMat") != std::string::npos);
449 if (!useMIFF)
450 {
451 if (fVerboseLevel > 2)
452 G4cout <<
"Rayleigh CS of: " << matname <<
" calculated through CSperAtom!" <<
G4endl;
454 }
455
456
457 if (fVerboseLevel > 2)
458 G4cout <<
"Rayleigh CS of: " << matname
459 <<
" calculated through integration of the DCS" <<
G4endl;
460
462
463
465 return cs;
466
467
471 if (crystalExtension != 0) {
472 G4cout <<
"The material has a crystalline structure, a dedicated diffraction model is used!" <<
G4endl;
473 return 0;
474 }
475 }
476
477
482
483
484 std::vector<G4double> *StoichiometricFactors = new std::vector<G4double>;
485 for (std::size_t i=0;i<nElements;++i) {
486 G4double fraction = fractionVector[i];
487 G4double atomicWeigth = (*elementVector)[i]->GetA()/(g/mole);
488 StoichiometricFactors->push_back(fraction/atomicWeigth);
489 }
490 G4double MaxStoichiometricFactor = 0.;
491 for (std::size_t i=0;i<nElements;++i) {
492 if ((*StoichiometricFactors)[i] > MaxStoichiometricFactor)
493 MaxStoichiometricFactor = (*StoichiometricFactors)[i];
494 }
495 for (std::size_t i=0;i<nElements;++i) {
496 (*StoichiometricFactors)[i] /= MaxStoichiometricFactor;
497 }
498
499
501 for (std::size_t i=0;i<nElements;++i)
502 atPerMol += (*StoichiometricFactors)[i];
504 if (atPerMol) moleculeDensity = atomDensity/atPerMol;
505
506 if (fVerboseLevel > 2)
507 G4cout <<
"Material " << material->
GetName() <<
" has " << atPerMol <<
" atoms "
508 <<
"per molecule and " << moleculeDensity/(cm*cm*cm) <<
" molecule/cm3" <<
G4endl;
509
510
512 for (std::size_t i=0;i<nElements;++i)
513 MolWeight += (*StoichiometricFactors)[i]*(*elementVector)[i]->GetA()/(g/mole);
514
515 if (fVerboseLevel > 2)
516 G4cout <<
"Molecular weight of " << matname <<
": " << MolWeight <<
" g/mol" <<
G4endl;
517
519 for (
G4int k=0; k<fNtheta; k++) {
521 G4double F2 = GetFSquared(material,CalculateQSquared(theta,energy));
522 IntegrandFun[k] = (*fAngularFunction)[k]*F2;
523 }
524
525 G4double constant =
pi*classic_electr_radius*classic_electr_radius;
526 cs = constant*IntegrateFun(IntegrandFun,fNtheta,fDTheta);
527
528
529 G4double csvolume = cs*moleculeDensity;
530
531
532 if (fVerboseLevel > 2)
533 G4cout <<
"Rayleigh CS of " << matname <<
" at " <<
energy/keV
534 << " keV: " << cs/barn << " barn"
535 <<
", mean free path: " << 1./csvolume/mm <<
" mm" <<
G4endl;
536
537 delete StoichiometricFactors;
538
539 return csvolume;
540}
std::vector< const G4Element * > G4ElementVector
G4VMaterialExtension * RetrieveExtension(const G4String &name)
const G4ElementVector * GetElementVector() const
G4double GetTotNbOfAtomsPerVolume() const
virtual G4bool IsExtended() const
const G4double * GetFractionVector() const
size_t GetNumberOfElements() const
const G4String & GetName() const
G4double Energy(const std::size_t index) const
static G4ProductionCutsTable * GetProductionCutsTable()
G4double LowEnergyLimit() const
virtual G4double CrossSectionPerVolume(const G4Material *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)