Import Geant4 11.3.0 source tree
This commit is contained in:
@@ -355,7 +355,7 @@ void G4DNACPA100IonisationModel::SampleSecondaries(
|
||||
|
||||
// SI: only atomic deexcitation from K shell is considered
|
||||
// Hoang: only for water
|
||||
if (fpG4_WATER != nullptr && material == G4Material::GetMaterial("G4_WATER")) {
|
||||
if (material == G4Material::GetMaterial("G4_WATER")) {
|
||||
std::size_t secNumberInit = 0; // need to know at a certain point the energy of secondaries
|
||||
std::size_t secNumberFinal = 0; // So I'll make the diference and then sum the energies
|
||||
if ((fAtomDeexcitation != nullptr) && shell == 4) {
|
||||
|
||||
@@ -246,7 +246,7 @@ G4DNADoubleIonisationModel::G4DNADoubleIonisationModel(
|
||||
//------------------------------------------------------------------------------
|
||||
G4DNADoubleIonisationModel::~G4DNADoubleIonisationModel()
|
||||
{
|
||||
for (auto x : xs_tab_) {
|
||||
for (const auto& x : xs_tab_) {
|
||||
G4DNACrossSectionDataSet* table = x.second;
|
||||
if (table) { delete table; }
|
||||
}
|
||||
@@ -275,7 +275,7 @@ void G4DNADoubleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for protons
|
||||
auto proton = proton_def_->GetParticleName();
|
||||
const auto& proton = proton_def_->GetParticleName();
|
||||
elow_tab_[proton] = model_elow_tab_[1];
|
||||
eupp_tab_[proton] = 3.0 * MeV;
|
||||
|
||||
@@ -300,7 +300,7 @@ void G4DNADoubleIonisationModel::Initialise(
|
||||
|
||||
//**************************************************************************
|
||||
// for alpha particles
|
||||
auto alpha = alpha_def_->GetParticleName();
|
||||
const auto& alpha = alpha_def_->GetParticleName();
|
||||
elow_tab_[alpha] = model_elow_tab_[4];
|
||||
eupp_tab_[alpha] = 23.0 * MeV;
|
||||
|
||||
@@ -325,7 +325,7 @@ void G4DNADoubleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for carbon ions
|
||||
auto carbon = carbon_def_->GetParticleName();
|
||||
const auto& carbon = carbon_def_->GetParticleName();
|
||||
elow_tab_[carbon] = model_elow_tab_[5] * carbon_def_->GetAtomicMass();
|
||||
eupp_tab_[carbon] = 120.0 * MeV;
|
||||
|
||||
@@ -722,14 +722,13 @@ G4int G4DNADoubleIonisationModel::RandomSelect(
|
||||
while (shell > 0) {
|
||||
shell--;
|
||||
if (valuesBuffer[shell] > value) {
|
||||
if (valuesBuffer) { delete [] valuesBuffer; }
|
||||
delete [] valuesBuffer;
|
||||
return (G4int)shell;
|
||||
}
|
||||
value -= valuesBuffer[shell];
|
||||
}
|
||||
|
||||
if (valuesBuffer) { delete [] valuesBuffer; }
|
||||
|
||||
delete [] valuesBuffer;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -473,7 +473,7 @@ G4double G4DNAIRTMoleculeEncounterStepper::CalculateMinTimeStep(G4double current
|
||||
return fSampledMinTimeStep;
|
||||
}
|
||||
|
||||
auto fReactionSetInTime = fReactionSet->GetReactionsPerTime();
|
||||
const auto& fReactionSetInTime = fReactionSet->GetReactionsPerTime();
|
||||
fSampledMinTimeStep = fReactionSetInTime.begin()->get()->GetTime() - currentGlobalTime;
|
||||
|
||||
return fSampledMinTimeStep;
|
||||
|
||||
+2
-2
@@ -381,7 +381,7 @@ G4double G4DNAIndependentReactionTimeStepper::CalculateMinTimeStep(G4double /*cu
|
||||
if (sampledMinTimeStep < fTSTimeStep) {
|
||||
fTSTimeStep = sampledMinTimeStep;
|
||||
if (reactants) {
|
||||
fReactionSet->AddReactions(fTSTimeStep, const_cast<G4Track*>(pTrack), reactants);
|
||||
fReactionSet->AddReactions(fTSTimeStep, const_cast<G4Track*>(pTrack), std::move(reactants));
|
||||
|
||||
fSampledPositions[pTrack->GetTrackID()] = pTrack->GetPosition();
|
||||
for (const auto& it : *fReactants) {
|
||||
@@ -392,7 +392,7 @@ G4double G4DNAIndependentReactionTimeStepper::CalculateMinTimeStep(G4double /*cu
|
||||
}
|
||||
}
|
||||
else if (fTSTimeStep == sampledMinTimeStep && G4bool(reactants)) {
|
||||
fReactionSet->AddReactions(fTSTimeStep, const_cast<G4Track*>(pTrack), reactants);
|
||||
fReactionSet->AddReactions(fTSTimeStep, const_cast<G4Track*>(pTrack), std::move(reactants));
|
||||
|
||||
fSampledPositions[pTrack->GetTrackID()] = pTrack->GetPosition();
|
||||
for (const auto& it : *fReactants) {
|
||||
|
||||
@@ -142,9 +142,9 @@ std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAMolecularReaction::FindRea
|
||||
}
|
||||
|
||||
G4ITReactionPerTrackMap& reactionPerTrackMap = pReactionSet->GetReactionMap();
|
||||
for (auto tracks_i = reactionPerTrackMap.begin();
|
||||
tracks_i != reactionPerTrackMap.end();
|
||||
tracks_i = reactionPerTrackMap.begin())
|
||||
for (auto tracks_i = reactionPerTrackMap.cbegin();
|
||||
tracks_i != reactionPerTrackMap.cend();
|
||||
tracks_i = reactionPerTrackMap.cbegin())
|
||||
{
|
||||
G4Track* pTrackA = tracks_i->first;
|
||||
if (pTrackA->GetTrackStatus() == fStopAndKill)
|
||||
@@ -155,9 +155,9 @@ std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAMolecularReaction::FindRea
|
||||
G4ITReactionPerTrackPtr reactionPerTrack = tracks_i->second;
|
||||
G4ITReactionList& reactionList = reactionPerTrack->GetReactionList();
|
||||
|
||||
assert(reactionList.begin() != reactionList.end());
|
||||
assert(reactionList.cbegin() != reactionList.cend());
|
||||
|
||||
for (auto it = reactionList.begin(); it != reactionList.end(); it = reactionList.begin())
|
||||
for (auto it = reactionList.cbegin(); it != reactionList.cend(); it = reactionList.cbegin())
|
||||
{
|
||||
G4ITReactionPtr reaction(*it);
|
||||
G4Track* pTrackB = reaction->GetReactant(pTrackA);
|
||||
@@ -178,7 +178,7 @@ std::vector<std::unique_ptr<G4ITReactionChange>> G4DNAMolecularReaction::FindRea
|
||||
exceptionDescription);
|
||||
}
|
||||
|
||||
pReactionSet->SelectThisReaction(reaction);
|
||||
pReactionSet->SelectThisReaction(std::move(reaction));
|
||||
|
||||
if (TestReactibility(*pTrackA, *pTrackB, currentStepTime, reachedUserStepTimeLimit))
|
||||
{
|
||||
|
||||
@@ -470,7 +470,7 @@ G4double G4DNAMoleculeEncounterStepper::CalculateMinTimeStep(G4double /*currentG
|
||||
{
|
||||
fReactionSet->AddReactions(fTSTimeStep,
|
||||
const_cast<G4Track*>(pTrack),
|
||||
reactants);
|
||||
std::move(reactants));
|
||||
ResetReactants();
|
||||
}
|
||||
}
|
||||
@@ -478,7 +478,7 @@ G4double G4DNAMoleculeEncounterStepper::CalculateMinTimeStep(G4double /*currentG
|
||||
{
|
||||
fReactionSet->AddReactions(fTSTimeStep,
|
||||
const_cast<G4Track*>(pTrack),
|
||||
reactants);
|
||||
std::move(reactants));
|
||||
ResetReactants();
|
||||
}
|
||||
else if (reactants)
|
||||
|
||||
@@ -94,7 +94,7 @@ G4bool G4DNAMultipleIonisationManager::CheckShellEnergy(
|
||||
}
|
||||
|
||||
G4bool stop_process{false};
|
||||
for (int i = 0; i < num_shells; i++) {
|
||||
for (G4int i = 0; i < num_shells; i++) {
|
||||
if (shell_energy[i] < 0.0) {
|
||||
stop_process = true;
|
||||
break;
|
||||
|
||||
@@ -368,7 +368,7 @@ void G4DNAPTBElasticModel::SampleSecondaries(std::vector<G4DynamicParticle*>* /*
|
||||
}
|
||||
|
||||
G4double electronEnergy0 = aDynamicElectron->GetKineticEnergy();
|
||||
const std::size_t& materialID = couple->GetIndex();
|
||||
const std::size_t& materialID = couple->GetMaterial()->GetIndex();
|
||||
auto p = aDynamicElectron->GetParticleDefinition();
|
||||
|
||||
// set killBelowEnergy value for material
|
||||
|
||||
@@ -255,7 +255,7 @@ void G4DNAPTBExcitationModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
|
||||
const G4DynamicParticle* aDynamicParticle,
|
||||
G4double /*tmin*/, G4double /*tmax*/)
|
||||
{
|
||||
const std::size_t& materialID = (std::size_t)couple->GetIndex();
|
||||
const std::size_t& materialID = (std::size_t)couple->GetMaterial()->GetIndex();
|
||||
|
||||
// Get the incident particle kinetic energy
|
||||
G4double k = aDynamicParticle->GetKineticEnergy();
|
||||
|
||||
@@ -308,7 +308,7 @@ void G4DNAPTBIonisationModel::SampleSecondaries(std::vector<G4DynamicParticle*>*
|
||||
|
||||
// Get the current particle name
|
||||
const auto& p = aDynamicParticle->GetDefinition();
|
||||
auto materialName = pCouple->GetMaterial()->GetName();
|
||||
const auto& materialName = pCouple->GetMaterial()->GetName();
|
||||
// Get the energy limits
|
||||
G4double lowLim = fpModelData->GetLowELimit(materialID, p);
|
||||
G4double highLim = fpModelData->GetHighELimit(materialID, p);
|
||||
|
||||
@@ -88,7 +88,7 @@ void G4DNAQuadrupleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for protons
|
||||
auto proton = proton_def_->GetParticleName();
|
||||
const auto& proton = proton_def_->GetParticleName();
|
||||
elow_tab_[proton] = model_elow_tab_[1];
|
||||
eupp_tab_[proton] = 3.0 * MeV;
|
||||
|
||||
@@ -113,7 +113,7 @@ void G4DNAQuadrupleIonisationModel::Initialise(
|
||||
|
||||
//**************************************************************************
|
||||
// for alpha particles
|
||||
auto alpha = alpha_def_->GetParticleName();
|
||||
const auto& alpha = alpha_def_->GetParticleName();
|
||||
elow_tab_[alpha] = model_elow_tab_[4];
|
||||
eupp_tab_[alpha] = 23.0 * MeV;
|
||||
|
||||
@@ -138,7 +138,7 @@ void G4DNAQuadrupleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for carbon ions
|
||||
auto carbon = carbon_def_->GetParticleName();
|
||||
const auto& carbon = carbon_def_->GetParticleName();
|
||||
elow_tab_[carbon] = model_elow_tab_[5] * carbon_def_->GetAtomicMass();
|
||||
eupp_tab_[carbon] = 120.0 * MeV;
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void G4DNATripleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for protons
|
||||
auto proton = proton_def_->GetParticleName();
|
||||
const auto& proton = proton_def_->GetParticleName();
|
||||
elow_tab_[proton] = model_elow_tab_[1];
|
||||
eupp_tab_[proton] = 3.0 * MeV;
|
||||
|
||||
@@ -111,7 +111,7 @@ void G4DNATripleIonisationModel::Initialise(
|
||||
|
||||
//**************************************************************************
|
||||
// for alpha particles
|
||||
auto alpha = alpha_def_->GetParticleName();
|
||||
const auto& alpha = alpha_def_->GetParticleName();
|
||||
elow_tab_[alpha] = model_elow_tab_[4];
|
||||
eupp_tab_[alpha] = 23.0 * MeV;
|
||||
|
||||
@@ -136,7 +136,7 @@ void G4DNATripleIonisationModel::Initialise(
|
||||
|
||||
// *************************************************************************
|
||||
// for carbon ions
|
||||
auto carbon = carbon_def_->GetParticleName();
|
||||
const auto& carbon = carbon_def_->GetParticleName();
|
||||
elow_tab_[carbon] = model_elow_tab_[5] * carbon_def_->GetAtomicMass();
|
||||
eupp_tab_[carbon] = 120.0 * MeV;
|
||||
|
||||
|
||||
@@ -25,20 +25,16 @@
|
||||
//
|
||||
// AMR Simplification /4
|
||||
// read Diff XSection & Interpolate
|
||||
#include "globals.hh"
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
using namespace std;
|
||||
#include "globals.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
#include "CLHEP/Units/PhysicalConstants.h"
|
||||
|
||||
#include "G4LEPTSDiffXS.hh"
|
||||
#include "G4Exp.hh"
|
||||
|
||||
G4LEPTSDiffXS::G4LEPTSDiffXS(string file) {
|
||||
G4LEPTSDiffXS::G4LEPTSDiffXS(const G4String& file) {
|
||||
fileName = file;
|
||||
|
||||
readDXS();
|
||||
@@ -54,7 +50,7 @@ G4LEPTSDiffXS::G4LEPTSDiffXS(string file) {
|
||||
void G4LEPTSDiffXS::readDXS( ) {
|
||||
|
||||
FILE *fp;
|
||||
float data, data2;
|
||||
G4float data, data2;
|
||||
|
||||
if ((fp=fopen(fileName.c_str(), "r"))==nullptr){
|
||||
//G4cout << "Error reading " << fileName << G4endl;
|
||||
@@ -107,8 +103,8 @@ void G4LEPTSDiffXS::readDXS( ) {
|
||||
for(G4int eBin=1; eBin<=NumEn; eBin++){
|
||||
G4double A = DXS[0][aBin]; // Angle
|
||||
G4double E = Eb[eBin]; // Energy
|
||||
G4double p = sqrt(pow( (E/27.2/137),2) +2*E/27.2); // Momentum
|
||||
KT[eBin][aBin] = p *sqrt(2.-2.*cos(A*CLHEP::twopi/360.)); // Mom. Transfer
|
||||
G4double p = std::sqrt(std::pow( (E/27.2/137),2) +2*E/27.2); // Momentum
|
||||
KT[eBin][aBin] = p *std::sqrt(2.-2.*std::cos(A*CLHEP::twopi/360.)); // Mom. Transfer
|
||||
//G4cout << "aEpKt " << aBin << " " << A << " E " << E << " p " << p << " KT "
|
||||
// << KT[eBin][aBin] << " DXS " << DXS[eBin][aBin] << G4endl;
|
||||
}
|
||||
@@ -135,7 +131,7 @@ void G4LEPTSDiffXS::BuildCDXS(G4double E, G4double El) {
|
||||
for (G4int eBin=1;eBin<=NumEn;eBin++){
|
||||
G4double sum=0.0;
|
||||
for (G4int aBin=0;aBin<NumAng;aBin++){
|
||||
sum += pow(DXS[eBin][aBin], (1.0-El/E) );
|
||||
sum += std::pow(DXS[eBin][aBin], (1.0-El/E) );
|
||||
CDXS[eBin][aBin]=sum;
|
||||
}
|
||||
}
|
||||
@@ -197,7 +193,7 @@ void G4LEPTSDiffXS::InterpolateCDXS() { // *10 angles, linear
|
||||
ICDXS[eBin][ia] = (y1*(x2-x) + y2*(x-x1))/(x2-x1);
|
||||
}
|
||||
else { //log-log ordenada
|
||||
ICDXS[eBin][ia] = G4Exp( (log(y1)*log(x2/x)+log(y2)*log(x/x1))/log(x2/x1) );
|
||||
ICDXS[eBin][ia] = G4Exp( (std::log(y1)*std::log(x2/x)+std::log(y2)*std::log(x/x1))/std::log(x2/x1) );
|
||||
}
|
||||
|
||||
IKT[eBin][ia] = (z1*(x2-x) + z2*(x-x1))/(x2-x1);
|
||||
@@ -215,7 +211,6 @@ void G4LEPTSDiffXS::InterpolateCDXS() { // *10 angles, linear
|
||||
|
||||
|
||||
// from ICDXS
|
||||
#include "Randomize.hh"
|
||||
G4double G4LEPTSDiffXS::SampleAngle(G4double Energy) {
|
||||
G4int ii,jj,kk=0, Ebin;
|
||||
|
||||
@@ -265,8 +260,8 @@ G4double G4LEPTSDiffXS::SampleAngleMT(G4double Energy, G4double Elost) {
|
||||
|
||||
G4double Ei = Energy;
|
||||
G4double Ed = Energy - Elost;
|
||||
G4double Pi = sqrt( pow( (Ei/27.2/137),2) +2*Ei/27.2); //incidente
|
||||
G4double Pd = sqrt( pow( (Ed/27.2/137),2) +2*Ed/27.2); //dispersado
|
||||
G4double Pi = std::sqrt( std::pow( (Ei/27.2/137),2) +2*Ei/27.2); //incidente
|
||||
G4double Pd = std::sqrt( std::pow( (Ed/27.2/137),2) +2*Ed/27.2); //dispersado
|
||||
G4double Kmin = Pi - Pd;
|
||||
G4double Kmax = Pi + Pd;
|
||||
|
||||
@@ -317,7 +312,7 @@ G4double G4LEPTSDiffXS::SampleAngleMT(G4double Energy, G4double Elost) {
|
||||
|
||||
G4double co = (Pi*Pi + Pd*Pd - KR*KR) / (2*Pi*Pd); //cos ang. disp.
|
||||
if(co > 1) co =1;
|
||||
G4double x = acos(co); //*360/twopi; //ang. dispers.
|
||||
G4double x = std::acos(co); //*360/twopi; //ang. dispers.
|
||||
|
||||
// Elastic aprox.
|
||||
//x = 2*asin(KR/Pi/2)*360/twopi;
|
||||
@@ -328,10 +323,6 @@ G4double G4LEPTSDiffXS::SampleAngleMT(G4double Energy, G4double Elost) {
|
||||
|
||||
|
||||
void G4LEPTSDiffXS::PrintDXS(G4int NE) {
|
||||
// Debug
|
||||
//#include <string>
|
||||
//using namespace std;
|
||||
|
||||
|
||||
G4double dxs;
|
||||
|
||||
|
||||
@@ -23,45 +23,51 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LEPTSDistribution
|
||||
//
|
||||
// Author: Pedro Arce (CIEMAT), 2014
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4LEPTSDistribution.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
G4LEPTSDistribution::G4LEPTSDistribution()
|
||||
= default;
|
||||
|
||||
|
||||
void G4LEPTSDistribution::ReadFile(G4String fileName) {
|
||||
|
||||
void G4LEPTSDistribution::ReadFile(const G4String& fileName)
|
||||
{
|
||||
G4int eB, out, out2;
|
||||
float float_data1,float_data2;
|
||||
G4float float_data1,float_data2;
|
||||
G4double sum, esum;
|
||||
FILE * fp;
|
||||
|
||||
for (eB=0;eB<10000;eB++){
|
||||
for (eB=0; eB<10000; ++eB)
|
||||
{
|
||||
E[eB]=0.0;
|
||||
f[eB]=0.0;
|
||||
F[eB]=0.0;
|
||||
eF[eB]=0.0;
|
||||
}
|
||||
|
||||
if ((fp=fopen(fileName.c_str(), "r"))==nullptr){
|
||||
//G4cout << "Error reading " << fileName << G4endl;
|
||||
if ((fp=fopen(fileName.c_str(), "r"))==nullptr)
|
||||
{
|
||||
NoBins = 0;
|
||||
bFileFound = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bFileFound = true;
|
||||
// G4cout << "Read Distro (" << fileName << ") " << G4endl;
|
||||
|
||||
out=1;
|
||||
eB=1;
|
||||
while (out==1){
|
||||
while (out==1)
|
||||
{
|
||||
out = fscanf(fp,"%f \n",&float_data1);
|
||||
out2 = fscanf(fp,"%f \n",&float_data2);
|
||||
if (out==1 && out2==1){
|
||||
E[eB]=(G4double)float_data1;
|
||||
f[eB]=(G4double)float_data2;
|
||||
eB++;
|
||||
if (out==1 && out2==1)
|
||||
{
|
||||
E[eB]=(G4double)float_data1;
|
||||
f[eB]=(G4double)float_data2;
|
||||
++eB;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,12 +76,19 @@ void G4LEPTSDistribution::ReadFile(G4String fileName) {
|
||||
NoBins=eB-1; //=1272+1 or 9607+1;
|
||||
|
||||
if( NoBins >= NMAX )
|
||||
printf("ERROR !!!! Eloss NoBins= %d \n", NoBins);
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "ERROR !!!! Eloss NoBins = " << NoBins;
|
||||
G4Exception("G4LEPTSDistribution::ReadFile()", "ReadError",
|
||||
FatalException, message);
|
||||
}
|
||||
|
||||
sum=0.0;
|
||||
esum=0.0;
|
||||
for (eB=0;eB<=NoBins;eB++) {
|
||||
if( f[eB] > 0) {
|
||||
for (eB=0; eB<=NoBins; ++eB)
|
||||
{
|
||||
if( f[eB] > 0)
|
||||
{
|
||||
sum+=f[eB];
|
||||
esum+=E[eB]*f[eB];
|
||||
}
|
||||
@@ -83,24 +96,22 @@ void G4LEPTSDistribution::ReadFile(G4String fileName) {
|
||||
eF[eB]=esum;
|
||||
}
|
||||
|
||||
// if( verboseLevel >= 1 ) G4cout << "Norm: " << F[NoBins] << " NoBins: "<< NoBins << G4endl;
|
||||
|
||||
for (eB=0;eB<=NoBins;eB++) {
|
||||
for (eB=0; eB<=NoBins; ++eB)
|
||||
{
|
||||
eF[eB] = eF[eB]/F[eB];
|
||||
F[eB] = F[eB]/F[NoBins];
|
||||
}
|
||||
//for (eB=0;eB<=NoBins;eB++)
|
||||
//G4cout << "eff " << E[eB] << " " << f[eB] << " " << F[eB] << "\n";
|
||||
}
|
||||
|
||||
G4bool G4LEPTSDistribution::ReadFile( FILE* fp, G4int nData )
|
||||
{
|
||||
|
||||
G4int eB, out, out2;
|
||||
float float_data1,float_data2;
|
||||
G4float float_data1,float_data2;
|
||||
G4double sum, esum;
|
||||
|
||||
for (eB=0;eB<10000;eB++){
|
||||
for (eB=0; eB<10000; ++eB)
|
||||
{
|
||||
E[eB]=0.0;
|
||||
f[eB]=0.0;
|
||||
F[eB]=0.0;
|
||||
@@ -111,14 +122,17 @@ G4bool G4LEPTSDistribution::ReadFile( FILE* fp, G4int nData )
|
||||
out=1;
|
||||
eB=1;
|
||||
|
||||
for( G4int id = 0; id < nData; id++ ){
|
||||
for( G4int id = 0; id < nData; ++id )
|
||||
{
|
||||
out = fscanf(fp,"%f \n",&float_data1);
|
||||
out2 = fscanf(fp,"%f \n",&float_data2);
|
||||
if (out==1 && out2==1){
|
||||
E[eB]=(G4double)float_data1;
|
||||
f[eB]=(G4double)float_data2;
|
||||
eB++;
|
||||
}else{
|
||||
++eB;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -126,42 +140,46 @@ G4bool G4LEPTSDistribution::ReadFile( FILE* fp, G4int nData )
|
||||
NoBins=eB-1; //=1272+1 or 9607+1;
|
||||
|
||||
if( NoBins >= NMAX )
|
||||
printf("ERROR !!!! Eloss NoBins= %d \n", NoBins);
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "ERROR !!!! Eloss NoBins = " << NoBins;
|
||||
G4Exception("G4LEPTSDistribution::ReadFile()", "ReadError",
|
||||
FatalException, message);
|
||||
}
|
||||
|
||||
sum=0.0;
|
||||
esum=0.0;
|
||||
for (eB=0;eB<=NoBins;eB++) {
|
||||
if( f[eB] > 0) {
|
||||
for (eB=0; eB<=NoBins; ++eB)
|
||||
{
|
||||
if( f[eB] > 0)
|
||||
{
|
||||
sum+=f[eB];
|
||||
esum+=E[eB]*f[eB];
|
||||
}
|
||||
F[eB]=sum;
|
||||
eF[eB]=esum;
|
||||
}
|
||||
|
||||
//if( verboseLevel >= 1 ) G4cout << "Norm: " << F[NoBins] << " NoBins: "<< NoBins << G4endl;
|
||||
|
||||
for (eB=0;eB<=NoBins;eB++) {
|
||||
for (eB=0; eB<=NoBins; ++eB)
|
||||
{
|
||||
eF[eB] = eF[eB]/F[eB];
|
||||
F[eB] = F[eB]/F[NoBins];
|
||||
}
|
||||
//for (eB=0;eB<=NoBins;eB++)
|
||||
//G4cout << "eff " << E[eB] << " " << f[eB] << " " << F[eB] << "\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double G4LEPTSDistribution::Sample( G4double eMin, G4double eMax) {
|
||||
// Sample Energy from Cumulative distr. G4interval [eMin, eMax]
|
||||
G4double G4LEPTSDistribution::Sample( G4double eMin, G4double eMax )
|
||||
{
|
||||
// Sample Energy from Cumulative distr. G4interval [eMin, eMax]
|
||||
|
||||
if( eMin > eMax) return 0.0;
|
||||
|
||||
G4int i,j,k=0, iMin, iMax;
|
||||
|
||||
i=0; j=NoBins;
|
||||
while ((j-i)>1) {
|
||||
while ((j-i)>1)
|
||||
{
|
||||
k=(i+j)/2;
|
||||
if( E[k] < eMax ) i=k;
|
||||
else j=k;
|
||||
@@ -169,7 +187,8 @@ G4double G4LEPTSDistribution::Sample( G4double eMin, G4double eMax) {
|
||||
iMax = i;
|
||||
|
||||
i=0; j=NoBins;
|
||||
while ((j-i)>1) {
|
||||
while ((j-i)>1)
|
||||
{
|
||||
k=(i+j)/2;
|
||||
if( E[k] < eMin ) i=k;
|
||||
else j=k;
|
||||
@@ -179,7 +198,8 @@ G4double G4LEPTSDistribution::Sample( G4double eMin, G4double eMax) {
|
||||
G4double rnd = F[iMin] + (F[iMax] - F[iMin]) * G4UniformRand();
|
||||
|
||||
i=0; j=NoBins;
|
||||
while ((j-i)>1) {
|
||||
while ((j-i)>1)
|
||||
{
|
||||
k=(i+j)/2;
|
||||
if( F[k]<rnd) i=k;
|
||||
else j=k;
|
||||
|
||||
@@ -23,95 +23,104 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4LEPTSElossDistr
|
||||
//
|
||||
// Author: Pedro Arce (CIEMAT), 2014
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4LEPTSElossDistr.hh"
|
||||
#include "G4LEPTSDistribution.hh"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
|
||||
G4LEPTSElossDistr::G4LEPTSElossDistr(std::string file) {
|
||||
fileName = file;
|
||||
|
||||
G4LEPTSElossDistr::G4LEPTSElossDistr(const G4String& fname)
|
||||
{
|
||||
fileName = fname;
|
||||
ReadFile();
|
||||
}
|
||||
|
||||
|
||||
void G4LEPTSElossDistr::ReadFile()
|
||||
{
|
||||
theNDistributions = 0;
|
||||
|
||||
FILE * fp;
|
||||
|
||||
if ((fp=fopen(fileName.c_str(), "r"))==nullptr){
|
||||
//G4cout << "Error reading " << fileName << G4endl;
|
||||
if ((fp=fopen(fileName.c_str(), "r"))==nullptr)
|
||||
{
|
||||
NoBins = 0;
|
||||
bFileFound = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bFileFound = true;
|
||||
// G4cout << "Read Eloss Distro (" << fileName << ") " << G4endl;
|
||||
|
||||
G4int nEnergies;
|
||||
G4int nAngles;
|
||||
G4int nData;
|
||||
(void) fscanf(fp,"%i \n",&nEnergies);
|
||||
for( G4int ie = 0; ie < nEnergies; ie++ ){
|
||||
float energySep;
|
||||
for( G4int ie = 0; ie < nEnergies; ++ie )
|
||||
{
|
||||
G4float energySep;
|
||||
(void) fscanf(fp,"%f \n",&energySep);
|
||||
(void) fscanf(fp,"%i \n",&nAngles);
|
||||
for( G4int ia = 0; ia < nAngles; ia++ ){
|
||||
float angleSep;
|
||||
for( G4int ia = 0; ia < nAngles; ++ia )
|
||||
{
|
||||
G4float angleSep;
|
||||
(void) fscanf(fp,"%f \n",&angleSep);
|
||||
auto dist = new G4LEPTSDistribution();
|
||||
theNDistributions ++;
|
||||
mddist angleDist;
|
||||
auto dist = new G4LEPTSDistribution();
|
||||
++theNDistributions;
|
||||
std::map<G4double, G4LEPTSDistribution *> angleDist;
|
||||
angleDist[angleSep] = dist;
|
||||
theDistributions[energySep] = angleDist;
|
||||
theDistributions[energySep] = std::move(angleDist);
|
||||
|
||||
(void) fscanf(fp,"%i \n",&nData);
|
||||
if( dist->ReadFile( fp, nData ) ) {
|
||||
G4Exception("G4LEPTSElossDistr",
|
||||
"",
|
||||
FatalException,
|
||||
("End of file found while reading file"+ fileName).c_str());
|
||||
if( dist->ReadFile( fp, nData ) )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "End of file found while reading file: "
|
||||
<< fileName;
|
||||
G4Exception("G4LEPTSElossDistr::ReadFile()", "ReadError",
|
||||
FatalException, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4double G4LEPTSElossDistr::Sample( G4double eMin, G4double eMax)
|
||||
G4double G4LEPTSElossDistr::Sample( G4double eMin, G4double eMax )
|
||||
{
|
||||
// Sample Energy from Cumulative distr. G4interval [eMin, eMax]
|
||||
// Sample Energy from Cumulative distr. G4interval [eMin, eMax]
|
||||
|
||||
if( eMin > eMax) return 0.0;
|
||||
|
||||
//Get the distribution to do the sampling
|
||||
// Get the distribution to do the sampling
|
||||
G4LEPTSDistribution* distr = nullptr;
|
||||
if( theNDistributions == 1 ){
|
||||
distr = (*( (*(theDistributions.begin())).second ).begin()).second;
|
||||
} else{
|
||||
mdmddist::const_iterator itedd;
|
||||
for( itedd = theDistributions.begin(); itedd != theDistributions.end(); itedd++ ){
|
||||
if( theNDistributions == 1 )
|
||||
{
|
||||
distr = (*( (*(theDistributions.cbegin())).second ).cbegin()).second;
|
||||
}
|
||||
else
|
||||
{
|
||||
for( auto itedd = theDistributions.cbegin(); itedd != theDistributions.cend(); ++itedd ){
|
||||
G4double energySep = (*itedd).first;
|
||||
if( eMax < energySep ) {
|
||||
//tt if( eMax <= energySep ) {
|
||||
mddist dist1 = (*itedd).second;
|
||||
mddist::const_iterator ited;
|
||||
for( ited = dist1.begin(); ited != dist1.end(); ited++ ){
|
||||
G4double angleSep = (*ited).first;
|
||||
if( 1 < angleSep ) {
|
||||
distr = (*ited).second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if( eMax < energySep )
|
||||
{
|
||||
const auto& dist1 = (*itedd).second;
|
||||
for( auto ited = dist1.cbegin(); ited != dist1.cend(); ++ited )
|
||||
{
|
||||
G4double angleSep = (*ited).first;
|
||||
if( 1 < angleSep )
|
||||
{
|
||||
distr = (*ited).second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// G4cout << " LEPTSElossDistr::Sample( " << distr << " NDIST " << theNDistributions << G4endl; //GDEB
|
||||
return distr->Sample(eMin, eMax);
|
||||
return (nullptr != distr) ? distr->Sample(eMin, eMax) : 0.0;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ G4LEPTSExcitationModel::~G4LEPTSExcitationModel() = default;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
|
||||
void G4LEPTSExcitationModel::Initialise(const G4ParticleDefinition* aParticle,
|
||||
const G4DataVector&)
|
||||
const G4DataVector&)
|
||||
{
|
||||
Init();
|
||||
BuildPhysicsTable( *aParticle );
|
||||
@@ -57,7 +57,7 @@ void G4LEPTSExcitationModel::Initialise(const G4ParticleDefinition* aParticle,
|
||||
}
|
||||
|
||||
|
||||
std::map<G4int,std::vector<G4double> > G4LEPTSExcitationModel::ReadIXS(G4String fileTXS, const G4Material* aMaterial)
|
||||
std::map<G4int,std::vector<G4double> > G4LEPTSExcitationModel::ReadIXS(const G4String& fileTXS, const G4Material* aMaterial)
|
||||
{
|
||||
std::map<G4int,std::vector<G4double> > integralXS = G4VLEPTSModel::ReadIXS( fileTXS, aMaterial);
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ std::vector<G4String> G4VDNAModel::BuildApplyToMatVect(const G4String& materials
|
||||
|
||||
while (materialsNonIdentified.find_first_of('/') != std::string::npos) {
|
||||
// we select the first material and stop at the "/" caracter
|
||||
G4String mat = materialsNonIdentified.substr(0, materialsNonIdentified.find_first_of('/'));
|
||||
const G4String& mat = materialsNonIdentified.substr(0, materialsNonIdentified.find_first_of('/'));
|
||||
materialVect.push_back(mat);
|
||||
|
||||
// we remove the previous material from the materialsNonIdentified string
|
||||
@@ -162,7 +162,7 @@ std::vector<G4String> G4VDNAModel::BuildApplyToMatVect(const G4String& materials
|
||||
|
||||
// we don't find "/" anymore, it means we only have one material string left
|
||||
// we get it
|
||||
materialVect.push_back(materialsNonIdentified);
|
||||
materialVect.push_back(std::move(materialsNonIdentified));
|
||||
}
|
||||
|
||||
return materialVect;
|
||||
|
||||
@@ -112,7 +112,7 @@ void G4VLEPTSModel::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
|
||||
//LOOP TO MATERIALS IN GEOMETRY
|
||||
const G4MaterialTable * materialTable = G4Material::GetMaterialTable() ;
|
||||
std::vector<G4Material*>::const_iterator matite;
|
||||
for( matite = materialTable->begin(); matite != materialTable->end(); matite++ ) {
|
||||
for( matite = materialTable->cbegin(); matite != materialTable->cend(); ++matite ) {
|
||||
const G4Material * aMaterial = (*matite);
|
||||
G4String mateName = aMaterial->GetName();
|
||||
|
||||
@@ -322,7 +322,7 @@ G4double G4VLEPTSModel::SampleEnergyLoss(const G4Material* aMaterial, G4double e
|
||||
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
G4bool G4VLEPTSModel::ReadParam(G4String fnParam, const G4Material* aMaterial )
|
||||
G4bool G4VLEPTSModel::ReadParam(const G4String& fnParam, const G4Material* aMaterial )
|
||||
{
|
||||
std::ifstream fin(fnParam);
|
||||
if (!fin.is_open()) {
|
||||
@@ -361,7 +361,7 @@ G4bool G4VLEPTSModel::ReadParam(G4String fnParam, const G4Material* aMaterial )
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
std::map< G4int, std::vector<G4double> > G4VLEPTSModel::ReadIXS(G4String fnIXS, const G4Material* aMaterial )
|
||||
std::map< G4int, std::vector<G4double> > G4VLEPTSModel::ReadIXS(const G4String& fnIXS, const G4Material* aMaterial )
|
||||
{
|
||||
std::map< G4int, std::vector<G4double> > integralXS; // process type - energy
|
||||
//G4cout << "fnIXS (" << fnIXS << ")" << G4endl;
|
||||
|
||||
Reference in New Issue
Block a user