Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
G4PAIModelData Class Reference

#include <G4PAIModelData.hh>

Public Member Functions

 G4PAIModelData (G4double tmin, G4double tmax, G4int verbose)
 
 ~G4PAIModelData ()
 
void Initialise (const G4MaterialCutsCouple *, G4double cut, G4PAIModel *)
 
G4double DEDXPerVolume (G4int coupleIndex, G4double scaledTkin, G4double cut) const
 
G4double CrossSectionPerVolume (G4int coupleIndex, G4double scaledTkin, G4double tcut, G4double tmax) const
 
G4double SampleAlongStepTransfer (G4int coupleIndex, G4double kinEnergy, G4double scaledTkin, G4double stepFactor) const
 
G4double SamplePostStepTransfer (G4int coupleIndex, G4double scaledTkin) const
 

Detailed Description

Definition at line 68 of file G4PAIModelData.hh.

Constructor & Destructor Documentation

G4PAIModelData::G4PAIModelData ( G4double  tmin,
G4double  tmax,
G4int  verbose 
)

Definition at line 58 of file G4PAIModelData.cc.

References G4cout, G4endl, python.hepunit::GeV, python.hepunit::keV, G4INCL::Math::max(), python.hepunit::MeV, and python.hepunit::TeV.

59 {
60  const G4int nPerDecade = 10;
61  const G4double lowestTkin = 50*keV;
62  const G4double highestTkin = 10*TeV;
63 
64  fPAIySection.SetVerbose(ver);
65 
66  fLowestKineticEnergy = std::max(tmin, lowestTkin);
67  fHighestKineticEnergy = tmax;
68  if(tmax < 10*fLowestKineticEnergy) {
69  fHighestKineticEnergy = 10*fLowestKineticEnergy;
70  } else if(tmax > highestTkin) {
71  fHighestKineticEnergy = std::max(highestTkin, 10*fLowestKineticEnergy);
72  }
73  fTotBin = (G4int)(nPerDecade*
74  std::log10(fHighestKineticEnergy/fLowestKineticEnergy));
75 
76  fParticleEnergyVector = new G4PhysicsLogVector(fLowestKineticEnergy,
77  fHighestKineticEnergy,
78  fTotBin);
79  if(0 < ver) {
80  G4cout << "### G4PAIModelData: Nbins= " << fTotBin
81  << " Tmin(MeV)= " << fLowestKineticEnergy/MeV
82  << " Tmax(GeV)= " << fHighestKineticEnergy/GeV
83  << " tmin(keV)= " << tmin/keV << G4endl;
84  }
85 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void SetVerbose(G4int v)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4PAIModelData::~G4PAIModelData ( )

Definition at line 89 of file G4PAIModelData.cc.

References n.

90 {
91  size_t n = fPAIxscBank.size();
92  if(0 < n) {
93  for(size_t i=0; i<n; ++i) {
94  if(fPAIxscBank[i]) {
95  delete fPAIxscBank[i];
96  }
97  if(fPAIdEdxBank[i]) {
98  delete fPAIdEdxBank[i];
99  }
100  }
101  }
102 }
const G4int n

Member Function Documentation

G4double G4PAIModelData::CrossSectionPerVolume ( G4int  coupleIndex,
G4double  scaledTkin,
G4double  tcut,
G4double  tmax 
) const

Definition at line 227 of file G4PAIModelData.cc.

Referenced by G4PAIModel::CrossSectionPerVolume().

230 {
231  G4double cross, cross1, cross2;
232 
233  // iPlace is in interval from 0 to (N-1)
234  size_t iPlace = fParticleEnergyVector->FindBin(scaledTkin, 0);
235  size_t nPlace = fParticleEnergyVector->GetVectorLength() - 1;
236 
237  G4bool one = true;
238  if(scaledTkin >= fParticleEnergyVector->Energy(nPlace)) { iPlace = nPlace; }
239  else if(scaledTkin > fParticleEnergyVector->Energy(0)) {
240  one = false;
241  }
242  G4PhysicsTable* table = fPAIxscBank[coupleIndex];
243 
244  //G4cout<<"iPlace = "<<iPlace<<"; tmax = "
245  // <<tmax<<"; cutEnergy = "<<cutEnergy<<G4endl;
246  cross1 = (*table)(iPlace)->Value(tmax)/tmax;
247  //G4cout<<"cross1 = "<<cross1<<G4endl;
248  cross2 = (*table)(iPlace)->Value(tcut)/tcut;
249  //G4cout<<"cross2 = "<<cross2<<G4endl;
250  cross = (cross2-cross1);
251  //G4cout<<"cross = "<<cross<<G4endl;
252  if(!one) {
253  cross2 = (*table)(iPlace+1)->Value(tcut)/tcut
254  - (*table)(iPlace+1)->Value(tmax)/tmax;
255 
256  G4double E1 = fParticleEnergyVector->Energy(iPlace);
257  G4double E2 = fParticleEnergyVector->Energy(iPlace+1);
258  G4double W = 1.0/(E2 - E1);
259  G4double W1 = (E2 - scaledTkin)*W;
260  G4double W2 = (scaledTkin - E1)*W;
261  cross *= W1;
262  cross += W2*cross2;
263  }
264 
265  if( cross < 0.0) { cross = 0.0; }
266  return cross;
267 }
size_t GetVectorLength() const
bool G4bool
Definition: G4Types.hh:79
size_t FindBin(G4double energy, size_t idx) const
G4double Energy(size_t index) const
double G4double
Definition: G4Types.hh:76
G4double G4PAIModelData::DEDXPerVolume ( G4int  coupleIndex,
G4double  scaledTkin,
G4double  cut 
) const

Definition at line 191 of file G4PAIModelData.cc.

Referenced by G4PAIModel::ComputeDEDXPerVolume().

193 {
194  // VI: iPlace is the low edge index of the bin
195  // iPlace is in interval from 0 to (N-1)
196  size_t iPlace = fParticleEnergyVector->FindBin(scaledTkin, 0);
197  size_t nPlace = fParticleEnergyVector->GetVectorLength() - 1;
198 
199  G4bool one = true;
200  if(scaledTkin >= fParticleEnergyVector->Energy(nPlace)) { iPlace = nPlace; }
201  else if(scaledTkin > fParticleEnergyVector->Energy(0)) {
202  one = false;
203  }
204 
205  // VI: apply interpolation of the vector
206  G4double dEdx = fdEdxTable[coupleIndex]->Value(scaledTkin);
207  G4double del = (*(fPAIdEdxBank[coupleIndex]))(iPlace)->Value(cut);
208  if(!one) {
209  G4double del2 = (*(fPAIdEdxBank[coupleIndex]))(iPlace+1)->Value(cut);
210  G4double E1 = fParticleEnergyVector->Energy(iPlace);
211  G4double E2 = fParticleEnergyVector->Energy(iPlace+1);
212  G4double W = 1.0/(E2 - E1);
213  G4double W1 = (E2 - scaledTkin)*W;
214  G4double W2 = (scaledTkin - E1)*W;
215  del *= W1;
216  del += W2*del2;
217  }
218  dEdx -= del;
219 
220  if( dEdx < 0.) { dEdx = 0.; }
221  return dEdx;
222 }
size_t GetVectorLength() const
bool G4bool
Definition: G4Types.hh:79
size_t FindBin(G4double energy, size_t idx) const
G4double Energy(size_t index) const
double G4double
Definition: G4Types.hh:76
void G4PAIModelData::Initialise ( const G4MaterialCutsCouple couple,
G4double  cut,
G4PAIModel model 
)

Definition at line 106 of file G4PAIModelData.cc.

References G4PAIModel::ComputeMaxEnergy(), python.hepunit::eV, G4MaterialCutsCouple::GetMaterial(), G4PhysicsTable::insertAt(), n, python.hepunit::proton_mass_c2, G4PhysicsFreeVector::PutValue(), G4PhysicsVector::PutValue(), and G4PhysicsVector::Value().

Referenced by G4PAIModel::Initialise().

108 {
109  const G4Material* mat = couple->GetMaterial();
110  fSandia.Initialize(const_cast<G4Material*>(mat));
111 
112  G4PhysicsTable* PAItransferTable = new G4PhysicsTable(fTotBin+1);
113  G4PhysicsTable* PAIdEdxTable = new G4PhysicsTable(fTotBin+1);
114 
115  G4PhysicsLogVector* dEdxCutVector =
116  new G4PhysicsLogVector(fLowestKineticEnergy,
117  fHighestKineticEnergy,
118  fTotBin);
119 
120  G4PhysicsLogVector* dEdxMeanVector =
121  new G4PhysicsLogVector(fLowestKineticEnergy,
122  fHighestKineticEnergy,
123  fTotBin);
124 
125  G4PhysicsLogVector* dNdxCutVector =
126  new G4PhysicsLogVector(fLowestKineticEnergy,
127  fHighestKineticEnergy,
128  fTotBin);
129 
130  // low energy Sandia interval
131  G4double Tmin = fSandia.GetSandiaMatTablePAI(0,0);
132 
133  // energy safety
134  const G4double deltaLow = 100.*eV;
135 
136  for (G4int i = 0; i <= fTotBin; ++i) {
137 
138  G4double kinEnergy = fParticleEnergyVector->Energy(i);
139  G4double Tmax = model->ComputeMaxEnergy(kinEnergy);
140  G4double tau = kinEnergy/proton_mass_c2;
141  G4double bg2 = tau*( tau + 2. );
142 
143  if (Tmax < Tmin + deltaLow ) { Tmax = Tmin + deltaLow; }
144 
145  fPAIySection.Initialize(mat, Tmax, bg2, &fSandia);
146 
147  //G4cout << i << ". TransferMax(keV)= "<< Tmax/keV << " cut(keV)= "
148  // << cut/keV << " E(MeV)= " << kinEnergy/MeV << G4endl;
149 
150  G4int n = fPAIySection.GetSplineSize();
151  G4PhysicsFreeVector* transferVector = new G4PhysicsFreeVector(n);
152  G4PhysicsFreeVector* dEdxVector = new G4PhysicsFreeVector(n);
153 
154  for( G4int k = 0; k < n; k++ )
155  {
156  G4double t = fPAIySection.GetSplineEnergy(k+1);
157  transferVector->PutValue(k , t,
158  t*fPAIySection.GetIntegralPAIySection(k+1));
159  dEdxVector->PutValue(k, t, fPAIySection.GetIntegralPAIdEdx(k+1));
160  }
161  // G4cout << *transferVector << G4endl;
162 
163  G4double ionloss = fPAIySection.GetMeanEnergyLoss();// total <dE/dx>
164 
165  if(ionloss < 0.0) ionloss = 0.0;
166 
167  dEdxMeanVector->PutValue(i,ionloss);
168 
169  G4double dNdxCut = transferVector->Value(cut)/cut;
170  G4double dEdxCut = dEdxVector->Value(cut)/cut;
171  //G4cout << "i= " << i << " x= " << dNdxCut << G4endl;
172  if(dNdxCut < 0.0) { dNdxCut = 0.0; }
173  dNdxCutVector->PutValue(i, dNdxCut);
174  dEdxCutVector->PutValue(i, dEdxCut);
175 
176  PAItransferTable->insertAt(i,transferVector);
177  PAIdEdxTable->insertAt(i,dEdxVector);
178 
179  } // end of Tkin loop
180 
181  fPAIxscBank.push_back(PAItransferTable);
182  fPAIdEdxBank.push_back(PAIdEdxTable);
183  fdEdxTable.push_back(dEdxMeanVector);
184 
185  fdNdxCutTable.push_back(dNdxCutVector);
186  fdEdxCutTable.push_back(dEdxCutVector);
187 }
void PutValue(size_t binNumber, G4double binValue, G4double dataValue)
G4double GetMeanEnergyLoss() const
G4double GetSandiaMatTablePAI(G4int, G4int)
int G4int
Definition: G4Types.hh:78
G4double GetIntegralPAIdEdx(G4int i) const
void Initialize(const G4Material *material, G4double maxEnergyTransfer, G4double betaGammaSq, G4SandiaTable *)
G4double GetSplineEnergy(G4int i) const
void PutValue(size_t index, G4double theValue)
float proton_mass_c2
Definition: hepunit.py:275
G4double GetIntegralPAIySection(G4int i) const
const G4int n
G4double Energy(size_t index) const
G4double Value(G4double theEnergy, size_t &lastidx) const
void insertAt(size_t, G4PhysicsVector *)
G4int GetSplineSize() const
double G4double
Definition: G4Types.hh:76
G4double ComputeMaxEnergy(G4double scaledEnergy)
Definition: G4PAIModel.hh:158
void Initialize(G4Material *)
const G4Material * GetMaterial() const
G4double G4PAIModelData::SampleAlongStepTransfer ( G4int  coupleIndex,
G4double  kinEnergy,
G4double  scaledTkin,
G4double  stepFactor 
) const

Definition at line 271 of file G4PAIModelData.cc.

References G4PhysicsVector::Energy(), G4Poisson(), G4UniformRand, and position.

Referenced by G4PAIModel::SampleFluctuations().

275 {
276  G4double loss = 0.0;
277  G4double omega;
278  G4double position, E1, E2, W1, W2, W, dNdxCut1, dNdxCut2, meanNumber;
279 
280  size_t iPlace = fParticleEnergyVector->FindBin(scaledTkin, 0);
281  size_t nPlace = fParticleEnergyVector->GetVectorLength() - 1;
282 
283  G4bool one = true;
284  if(scaledTkin >= fParticleEnergyVector->Energy(nPlace)) { iPlace = nPlace; }
285  else if(scaledTkin > fParticleEnergyVector->Energy(0)) {
286  one = false;
287  }
288  G4PhysicsLogVector* vcut = fdNdxCutTable[coupleIndex];
289  G4PhysicsVector* v1 = (*(fPAIxscBank[coupleIndex]))(iPlace);
290  G4PhysicsVector* v2 = 0;
291 
292  dNdxCut1 = (*vcut)[iPlace];
293  G4double e1 = v1->Energy(0);
294  G4double e2 = e1;
295 
296  G4double meanN1 = ((*v1)[0]/e1 - dNdxCut1)*stepFactor;
297  meanNumber = meanN1;
298 
299  //G4cout<<"iPlace = "<<iPlace<< " meanN1= " << meanN1
300  // << " dNdxCut1= " << dNdxCut1 << G4endl;
301 
302  dNdxCut2 = dNdxCut1;
303  W1 = 1.0;
304  W2 = 0.0;
305  if(!one) {
306  v2 = (*(fPAIxscBank[coupleIndex]))(iPlace+1);
307  dNdxCut2 = (*vcut)[iPlace+1];
308  e2 = v2->Energy(0);
309  G4double meanN2 = ((*v2)[0]/e2 - dNdxCut2)*stepFactor;
310  E1 = fParticleEnergyVector->Energy(iPlace);
311  E2 = fParticleEnergyVector->Energy(iPlace+1);
312  W = 1.0/(E2 - E1);
313  W1 = (E2 - scaledTkin)*W;
314  W2 = (scaledTkin - E1)*W;
315  meanNumber = W1*meanN1 + W2*meanN2;
316  //G4cout<<"meanN= " << meanNumber << " meanN2= " << meanN2
317  // << " dNdxCut2= " << dNdxCut2 << G4endl;
318  }
319  if(meanNumber < 0.0) { return 0.0; }
320 
321  G4int numOfCollisions = G4Poisson(meanNumber);
322 
323  //G4cout << "N= " << numOfCollisions << G4endl;
324 
325  if(0 == numOfCollisions) { return 0.0; }
326 
327  for(G4int i=0; i< numOfCollisions; ++i) {
328  G4double rand = G4UniformRand();
329  position = dNdxCut1 + ((*v1)[0]/e1 - dNdxCut1)*rand;
330  omega = GetEnergyTransfer(coupleIndex, iPlace, position);
331  //G4cout << "omega(keV)= " << omega/keV << G4endl;
332  if(!one) {
333  position = dNdxCut2 + ((*v2)[0]/e2 - dNdxCut2)*rand;
334  G4double omega2 = GetEnergyTransfer(coupleIndex, iPlace+1, position);
335  omega = omega*W1 + omega2*W2;
336  }
337  //G4cout << "omega(keV)= " << omega/keV << G4endl;
338 
339  loss += omega;
340  if(loss > kinEnergy) { break; }
341  }
342 
343  // G4cout<<"PAIModelData AlongStepLoss = "<<loss/keV<<" keV, on step = "
344  //<<step/mm<<" mm"<<G4endl;
345  if(loss > kinEnergy) { loss = kinEnergy; }
346  else if(loss < 0.) { loss = 0.; }
347  return loss;
348 }
G4long G4Poisson(G4double mean)
Definition: G4Poisson.hh:51
size_t GetVectorLength() const
int G4int
Definition: G4Types.hh:78
#define G4UniformRand()
Definition: Randomize.hh:87
bool G4bool
Definition: G4Types.hh:79
size_t FindBin(G4double energy, size_t idx) const
G4double Energy(size_t index) const
int position
Definition: filter.cc:7
double G4double
Definition: G4Types.hh:76
G4double G4PAIModelData::SamplePostStepTransfer ( G4int  coupleIndex,
G4double  scaledTkin 
) const

Definition at line 355 of file G4PAIModelData.cc.

References G4UniformRand, and position.

Referenced by G4PAIModel::SampleSecondaries().

357 {
358  //G4cout<<"G4PAIModelData::GetPostStepTransfer"<<G4endl;
359  G4double transfer = 0.0;
360  G4double rand = G4UniformRand();
361 
362  size_t nPlace = fParticleEnergyVector->GetVectorLength() - 1;
363 
364  // size_t iTransfer, iTr1, iTr2;
365  G4double position, dNdxCut1, dNdxCut2, E1, E2, W1, W2, W;
366 
367  G4PhysicsVector* cutv = fdNdxCutTable[coupleIndex];
368 
369  // Fermi plato, try from left
370  if(scaledTkin >= fParticleEnergyVector->GetMaxEnergy())
371  {
372  position = (*cutv)[nPlace]*rand;
373  transfer = GetEnergyTransfer(coupleIndex, nPlace, position);
374  }
375  else if(scaledTkin <= fParticleEnergyVector->Energy(0))
376  {
377  position = (*cutv)[0]*rand;
378  transfer = GetEnergyTransfer(coupleIndex, 0, position);
379  }
380  else
381  {
382  size_t iPlace = fParticleEnergyVector->FindBin(scaledTkin, 0);
383 
384  dNdxCut1 = (*cutv)[iPlace];
385  dNdxCut2 = (*cutv)[iPlace+1];
386 
387  E1 = fParticleEnergyVector->Energy(iPlace);
388  E2 = fParticleEnergyVector->Energy(iPlace+1);
389  W = 1.0/(E2 - E1);
390  W1 = (E2 - scaledTkin)*W;
391  W2 = (scaledTkin - E1)*W;
392 
393  //G4cout<<"iPlace= " << " dNdxCut1 = "<<dNdxCut1
394  // <<" dNdxCut2 = "<<dNdxCut2<< " W1= " << W1 << " W2= " << W2 <<G4endl;
395 
396  position = dNdxCut1*rand;
397  G4double tr1 = GetEnergyTransfer(coupleIndex, iPlace, position);
398 
399  position = dNdxCut2*rand;
400  G4double tr2 = GetEnergyTransfer(coupleIndex, iPlace+1, position);
401 
402  transfer = tr1*W1 + tr2*W2;
403  }
404  //G4cout<<"PAImodel PostStepTransfer = "<<transfer/keV<<" keV"<<G4endl;
405  if(transfer < 0.0 ) { transfer = 0.0; }
406  return transfer;
407 }
G4double GetMaxEnergy() const
size_t GetVectorLength() const
#define G4UniformRand()
Definition: Randomize.hh:87
size_t FindBin(G4double energy, size_t idx) const
G4double Energy(size_t index) const
int position
Definition: filter.cc:7
double G4double
Definition: G4Types.hh:76

The documentation for this class was generated from the following files: