19 using namespace CLHEP;
27 :
G4VEmModel(
"DiscrScat"), fParticleChange(nullptr),fAnalogModel(
"pwe"),
28 fNumAngles(iNumAngles), fLowEnergyLimit(2*
keV)
60 G4cout <<
"G4DiscreteScatteringModel::Initialise start"<<
G4endl;
62 const G4int maxZ = 100;
64 char *path = getenv(
"G4GBFPDATA");
67 G4Exception(
"G4DiscreteScatteringModel::Initialise",
"em0006",
72 std::ostringstream eFullFileName;
73 eFullFileName << path;
80 for(
G4int i=0; i<numOfCouples; ++i)
87 for (
G4int j=0; j<nelm; ++j)
91 else if(Z > maxZ) { Z = maxZ; }
95 G4cout <<
"G4DiscreteScatteringModel::Initialise completed"<<
G4endl;
112 +
"_tcs_"+ss1.str()+
"_"+ss2.str()+
".dat";
115 std::ifstream in(tcsPath, std::ifstream::binary|std::ifstream::in);
120 message+=
"\" not found";
121 G4Exception(
"G4DiscreteScatteringModel::LoadData",
"em0003",
143 +ss1.str()+
"_"+ss2.str()+
".dat";
146 std::ifstream in2(cdfPath, std::ifstream::binary|std::ifstream::in);
151 message+=
"\" not found";
152 G4Exception(
"G4DiscreteScatteringModel::LoadData",
"em0003",
173 std::vector<G4PhysicsVector*> tempDataCDF;
175 for (
int j=0; j<numEnergies; j++)
197 std::ofstream file(
"tempDataFile.dat",
198 std::fstream::out | std::fstream::trunc);
205 file<<
"-1. 1. "<<fNumAngles<<
" "<<fNumAngles<<
G4endl;
212 while(in2>>temp1>>temp2)
215 file<<setprecision(16)<<temp1<<
" "<<temp2<<
G4endl;
222 if (cntr==fNumAngles)
225 std::ifstream inTemp(
"tempDataFile.dat",
226 std::ifstream::binary|std::ifstream::in);
227 tempDataCDF[j]->Retrieve(inTemp,
true);
230 inTemp.close(), inTemp.clear(), file.close(), file.clear();
231 file.open(
"tempDataFile.dat",std::fstream::out | std::fstream::trunc);
232 file<<
"-1. 1. "<<fNumAngles<<
" "<<fNumAngles<<
G4endl;
244 std::vector<G4DynamicParticle*>*,
256 E,cutEnergy,E)->GetZ());
304 G4cout <<
"G4DiscreteScatteringModel::SampleSecondaries():"
305 <<
" CDF was not inverted properly "<<k<<
G4endl;
324 newDirection.rotateUz(dir);
335 if (E==0.) {
return 1e30;}
355 G4double cost = sqrt(1.0 - sint*sint);
361 dir.set(dirx,diry,dirz);
static G4ElementData * fCdf
G4PhysicsVector * GetComponentDataByIndex(G4int Z, size_t idx)
void ReadData(G4int, const G4String &argFileName)
void AddComponent(G4int Z, G4int id, G4PhysicsVector *v)
std::vector< G4Element * > G4ElementVector
G4double GetKineticEnergy() const
CLHEP::Hep3Vector G4ThreeVector
G4ThreeVector GetNewDirection(G4double z1)
G4PhysicsVector * GetElementData(G4int Z)
G4ParticleDefinition * GetDefinition() const
G4DiscreteScatteringModel(G4int iNumAngles=1)
size_t GetVectorLength() const
const G4ElementVector * GetElementVector() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
void SetHighEnergyLimit(G4double)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double E, G4double Z, G4double A=0., G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
void InitialiseForElement(G4int Z, G4PhysicsVector *v)
G4GLOB_DLL std::ostream G4cout
size_t GetTableSize() const
const G4ThreeVector & GetMomentumDirection() const
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin=0.0, G4double maxEnergy=DBL_MAX)
static const double twopi
size_t FindBin(G4double energy, size_t idx) const
G4double Energy(size_t index) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual ~G4DiscreteScatteringModel()
G4double G4Log(G4double x)
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4double GetValueForElement(G4int Z, G4double kinEnergy)
G4ParticleChangeForGamma * fParticleChange
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
static G4ElementData * fTcs
size_t GetNumberOfElements() const
void SetLowEnergyLimit(G4double)
void InitialiseForComponent(G4int Z, G4int nComponents=0)
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
const G4Material * GetMaterial() const