58G4DataVector* G4JAEAElasticScatteringModel::ES_Data[]={
nullptr};
61 :
G4VEmModel(
"G4JAEAElasticScatteringModel"),isInitialised(false)
65 lowEnergyLimit = 10 * keV;
75 G4cout <<
"G4JAEAElasticScatteringModel is constructed " <<
G4endl;
85 for(
G4int i=0; i<=maxZ; ++i) {
103 if (verboseLevel > 1)
105 G4cout <<
"Calling Initialise() of G4JAEAElasticScatteringModel." <<
G4endl
118 char* path = std::getenv(
"G4LEDATA");
123 for(
G4int i=0; i<numOfCouples; ++i)
131 for (
G4int j=0; j<nelm; ++j)
135 else if(Z > maxZ) { Z = maxZ; }
136 if( (!dataCS[Z]) ) { ReadData(Z, path); }
141 if(isInitialised) {
return; }
143 isInitialised =
true;
157void G4JAEAElasticScatteringModel::ReadData(
size_t Z,
const char* path)
160 if (verboseLevel > 1)
162 G4cout <<
"Calling ReadData() of G4JAEAElasticScatteringModel"
166 if(dataCS[Z]) {
return; }
168 const char* datadir = path;
172 datadir = std::getenv(
"G4LEDATA");
175 G4Exception(
"G4JAEAElasticScatteringModel::ReadData()",
"em0006",
177 "Environment variable G4LEDATA not defined");
188std::ostringstream ostCS;
189ostCS << datadir <<
"/JAEAESData/amp_Z_" << Z ;
190std::ifstream ES_Data_Buffer(ostCS.str().c_str(),ios::binary);
191if( !ES_Data_Buffer.is_open() )
194 ed <<
"G4JAEAElasticScattertingModel data file <" << ostCS.str().c_str()
195 <<
"> is not opened!" <<
G4endl;
198 "G4LEDATA version should be G4EMLOW7.11 or later. Elastic Scattering Data are not loaded");
203 if(verboseLevel > 3) {
204 G4cout <<
"File " << ostCS.str()
205 <<
" is opened by G4JAEAElasticScatteringModel" <<
G4endl;
213while (ES_Data_Buffer.read(
reinterpret_cast<char*
>(&buffer_var),
sizeof(
float)))
215 ES_Data[Z]->push_back(buffer_var);
227 for (
G4int i=0;i<300;++i)
228 dataCS[Z]->PutValue(i,10.*i*1e-3,ES_Data[Z]->at(i)*1e-22);
246 if (verboseLevel > 2)
248 G4cout <<
"G4JAEAElasticScatteringModel::ComputeCrossSectionPerAtom()"
252 if(GammaEnergy < lowEnergyLimit) {
return 0.0; }
258 if(intZ < 1 || intZ > maxZ) {
return xs; }
267 if(!pv) {
return xs; }
275 }
else if(e >= pv->
Energy(0)) {
281 G4cout <<
"****** DEBUG: tcs value for Z=" << Z <<
" at energy (MeV)="
283 G4cout <<
" cs (Geant4 internal unit)=" << xs <<
G4endl;
284 G4cout <<
" -> first E*E*cs value in CS data file (iu) =" << (*pv)[0]
286 G4cout <<
" -> last E*E*cs value in CS data file (iu) =" << (*pv)[n]
288 G4cout <<
"*********************************************************"
298 std::vector<G4DynamicParticle*>*,
303 if (verboseLevel > 2) {
304 G4cout <<
"Calling SampleSecondaries() of G4JAEAElasticScatteringModel."
311 if (photonEnergy0 <= lowEnergyLimit)
324 Xi1=gammaPolarization0.
x();
325 Xi2=gammaPolarization0.
y();
326 Xi3=gammaPolarization0.
z();
328 G4double polarization_magnitude=Xi1*Xi1+Xi2*Xi2+Xi3*Xi3;
329 if ((polarization_magnitude)>0 || (Xi1*Xi1>0) || (Xi2*Xi2>0) || (Xi3*Xi3>0))
331 G4cout<<
"WARNING: G4JAEAElasticScatteringModel is only compatible with non-polarized photons."<<
G4endl;
342G4int energyindex=round(100*photonEnergy0)-1;
349for (
G4int i=0;i<=180;++i)
351 a1=ES_Data[Z]->at(4*i+300+181*4*(energyindex));
352 a2=ES_Data[Z]->at(4*i+1+300+181*4*(energyindex));
353 a3=ES_Data[Z]->at(4*i+2+300+181*4*(energyindex));
354 a4=ES_Data[Z]->at(4*i+3+300+181*4*(energyindex));
355 distribution[i]=a1*a1+a2*a2+a3*a3+a4*a4;
356 normdist += distribution[i];
361 for (
G4int i =0;i<=180;++i)
362 pdf[i]=distribution[i]/normdist;
365 for (
G4int i=0; i<=180;++i)
367 cdfsum=cdfsum+pdf[i];
372 G4double *cdfptr=lower_bound(cdf,cdf+181,r);
374 G4double cdfinv = (r-cdf[cdfindex])/(cdf[cdfindex+1]-cdf[cdfindex]);
375 G4double theta = (cdfindex+cdfinv)/180.;
377 theta = theta*CLHEP::pi;
389G4ThreeVector finaldirection(sin(theta)*cos(phi), sin(theta)*sin(phi), cos(theta));
405 G4AutoLock l(&G4JAEAElasticScatteringModelMutex);
406 if(!dataCS[Z]) { ReadData(Z); }
std::vector< G4Element * > G4ElementVector
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4MUTEX_INITIALIZER
G4GLOB_DLL std::ostream G4cout
Hep3Vector & rotateUz(const Hep3Vector &)
const G4ThreeVector & GetMomentumDirection() const
G4ParticleDefinition * GetDefinition() const
G4double GetKineticEnergy() const
const G4ThreeVector & GetPolarization() const
virtual void InitialiseLocal(const G4ParticleDefinition *, G4VEmModel *masterModel)
virtual void Initialise(const G4ParticleDefinition *, const G4DataVector &)
virtual G4double ComputeCrossSectionPerAtom(const G4ParticleDefinition *, G4double kinEnergy, G4double Z, G4double A=0, G4double cut=0, G4double emax=DBL_MAX)
virtual ~G4JAEAElasticScatteringModel()
virtual void InitialiseForElement(const G4ParticleDefinition *, G4int Z)
virtual void SampleSecondaries(std::vector< G4DynamicParticle * > *, const G4MaterialCutsCouple *, const G4DynamicParticle *, G4double tmin, G4double maxEnergy)
G4JAEAElasticScatteringModel()
const G4Material * GetMaterial() const
const G4ElementVector * GetElementVector() const
size_t GetNumberOfElements() const
void SetProposedKineticEnergy(G4double proposedKinEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4double Energy(std::size_t index) const
G4double Value(G4double theEnergy, std::size_t &lastidx) const
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
void SetElementSelectors(std::vector< G4EmElementSelector * > *)
G4ParticleChangeForGamma * GetParticleChangeForGamma()
G4double LowEnergyLimit() const
std::vector< G4EmElementSelector * > * GetElementSelectors()
G4double HighEnergyLimit() const
const G4Element * SelectRandomAtom(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy, G4double cutEnergy=0.0, G4double maxEnergy=DBL_MAX)
void InitialiseElementSelectors(const G4ParticleDefinition *, const G4DataVector &)
void ProposeTrackStatus(G4TrackStatus status)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)