Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VRangeToEnergyConverter Class Referenceabstract

#include <G4VRangeToEnergyConverter.hh>

Inheritance diagram for G4VRangeToEnergyConverter:
Collaboration diagram for G4VRangeToEnergyConverter:

Public Member Functions

 G4VRangeToEnergyConverter ()
 
 G4VRangeToEnergyConverter (const G4VRangeToEnergyConverter &right)
 
G4VRangeToEnergyConverteroperator= (const G4VRangeToEnergyConverter &right)
 
virtual ~G4VRangeToEnergyConverter ()
 
G4int operator== (const G4VRangeToEnergyConverter &right) const
 
G4int operator!= (const G4VRangeToEnergyConverter &right) const
 
virtual G4double Convert (G4double rangeCut, const G4Material *material)
 
const G4ParticleDefinitionGetParticleType () const
 
const G4PhysicsTableGetLossTable () const
 
virtual void Reset ()
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 

Static Public Member Functions

static void SetEnergyRange (G4double lowedge, G4double highedge)
 
static G4double GetLowEdgeEnergy ()
 
static G4double GetHighEdgeEnergy ()
 
static G4double GetMaxEnergyCut ()
 
static void SetMaxEnergyCut (G4double value)
 

Protected Types

typedef G4PhysicsTable G4LossTable
 
typedef G4PhysicsLogVector G4LossVector
 
typedef G4PhysicsLogVector G4RangeVector
 

Protected Member Functions

virtual void BuildLossTable ()
 
virtual G4double ComputeLoss (G4double AtomicNumber, G4double KineticEnergy)=0
 
virtual void BuildRangeVector (const G4Material *aMaterial, G4RangeVector *rangeVector)
 
G4double ConvertCutToKineticEnergy (G4RangeVector *theRangeVector, G4double theCutInLength, size_t materialIndex) const
 

Protected Attributes

G4double fMaxEnergyCut
 
const G4ParticleDefinitiontheParticle
 
G4LossTabletheLossTable
 
G4int NumberOfElements
 
const G4int TotBin
 
std::vector< G4RangeVector * > fRangeVectorStore
 

Static Protected Attributes

static G4double LowestEnergy = 0.99e-3*MeV
 
static G4double HighestEnergy = 100.0e6*MeV
 
static G4double MaxEnergyCut = 10.0*GeV
 

Detailed Description

Definition at line 58 of file G4VRangeToEnergyConverter.hh.

Member Typedef Documentation

Constructor & Destructor Documentation

G4VRangeToEnergyConverter::G4VRangeToEnergyConverter ( )

Definition at line 48 of file G4VRangeToEnergyConverter.cc.

G4VRangeToEnergyConverter::G4VRangeToEnergyConverter ( const G4VRangeToEnergyConverter right)

Definition at line 55 of file G4VRangeToEnergyConverter.cc.

55  : theParticle(right.theParticle), theLossTable(0), TotBin(right.TotBin)
56 {
57  fMaxEnergyCut = 0.;
58  if (theLossTable) {
60  delete theLossTable;
61  theLossTable=0;
62  }
63  *this = right;
64 }
void clearAndDestroy()
const G4ParticleDefinition * theParticle

Here is the call graph for this function:

G4VRangeToEnergyConverter::~G4VRangeToEnergyConverter ( )
virtual

Definition at line 117 of file G4VRangeToEnergyConverter.cc.

118 {
119  Reset();
120  // Comment out Reset() for MT application
121 
131 
132 }

Here is the call graph for this function:

Member Function Documentation

void G4VRangeToEnergyConverter::BuildLossTable ( )
protectedvirtual

Definition at line 293 of file G4VRangeToEnergyConverter.cc.

294 {
295  if (size_t(NumberOfElements) == G4Element::GetNumberOfElements()) return;
296 
297  // clear Loss table and Range vectors
298  Reset();
299 
300  // Build dE/dx tables for elements
302  theLossTable = new G4LossTable();
304 #ifdef G4VERBOSE
305  if (GetVerboseLevel()>3) {
306  G4cout << "G4VRangeToEnergyConverter::BuildLossTable() ";
307  G4cout << "Create theLossTable[" << theLossTable << "]";
308  G4cout << " NumberOfElements=" << NumberOfElements <<G4endl;
309  }
310 #endif
311 
312 
313  // fill the loss table
314  for (size_t j=0; j<size_t(NumberOfElements); j++){
315  G4double Value;
316  G4LossVector* aVector= 0;
318  for (size_t i=0; i<=size_t(TotBin); i++) {
319  Value = ComputeLoss( (*G4Element::GetElementTable())[j]->GetZ(),
320  aVector->Energy(i)
321  );
322  aVector->PutValue(i,Value);
323  }
324  theLossTable->insert(aVector);
325  }
326 }
void insert(G4PhysicsVector *)
virtual G4double ComputeLoss(G4double AtomicNumber, G4double KineticEnergy)=0
G4GLOB_DLL std::ostream G4cout
static size_t GetNumberOfElements()
Definition: G4Element.cc:405
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static G4ElementTable * GetElementTable()
Definition: G4Element.cc:398

Here is the call graph for this function:

Here is the caller graph for this function:

void G4VRangeToEnergyConverter::BuildRangeVector ( const G4Material aMaterial,
G4RangeVector rangeVector 
)
protectedvirtual

Reimplemented in G4RToEConvForGamma.

Definition at line 331 of file G4VRangeToEnergyConverter.cc.

333 {
334  // create range vector for a material
335  const G4ElementVector* elementVector = aMaterial->GetElementVector();
336  const G4double* atomicNumDensityVector = aMaterial->GetAtomicNumDensityVector();
337  G4int NumEl = aMaterial->GetNumberOfElements();
338 
339  // calculate parameters of the low energy part first
340  size_t i;
341  std::vector<G4double> lossV;
342  for ( size_t ib=0; ib<=size_t(TotBin); ib++) {
343  G4double loss=0.;
344  for (i=0; i<size_t(NumEl); i++) {
345  G4int IndEl = (*elementVector)[i]->GetIndex();
346  loss += atomicNumDensityVector[i]*
347  (*((*theLossTable)[IndEl]))[ib];
348  }
349  lossV.push_back(loss);
350  }
351 
352  // Integrate with Simpson formula with logarithmic binning
353  G4double dltau = 1.0;
354  if (LowestEnergy>0.) {
355  G4double ltt =std::log(MaxEnergyCut/LowestEnergy);
356  dltau = ltt/TotBin;
357  }
358 
359  G4double s0 = 0.;
360  G4double Value;
361  for ( i=0; i<=size_t(TotBin); i++) {
362  G4double t = rangeVector->GetLowEdgeEnergy(i);
363  G4double q = t/lossV[i];
364  if (i==0) s0 += 0.5*q;
365  else s0 += q;
366 
367  if (i==0) {
368  Value = (s0 + 0.5*q)*dltau ;
369  } else {
370  Value = (s0 - 0.5*q)*dltau ;
371  }
372  rangeVector->PutValue(i,Value);
373  }
374 }
std::vector< G4Element * > G4ElementVector
const G4ElementVector * GetElementVector() const
Definition: G4Material.hh:190
int G4int
Definition: G4Types.hh:78
const G4double * GetAtomicNumDensityVector() const
Definition: G4Material.hh:216
size_t GetNumberOfElements() const
Definition: G4Material.hh:186
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

Here is the caller graph for this function:

virtual G4double G4VRangeToEnergyConverter::ComputeLoss ( G4double  AtomicNumber,
G4double  KineticEnergy 
)
protectedpure virtual

Implemented in G4RToEConvForProton, G4RToEConvForGamma, G4RToEConvForElectron, and G4RToEConvForPositron.

Here is the caller graph for this function:

G4double G4VRangeToEnergyConverter::Convert ( G4double  rangeCut,
const G4Material material 
)
virtual

Reimplemented in G4RToEConvForProton.

Definition at line 148 of file G4VRangeToEnergyConverter.cc.

150 {
151 #ifdef G4VERBOSE
152  if (GetVerboseLevel()>3) {
153  G4cout << "G4VRangeToEnergyConverter::Convert() ";
154  G4cout << "Convert for " << material->GetName()
155  << " with Range Cut " << rangeCut/mm << "[mm]" << G4endl;
156  }
157 #endif
158 
159  G4double theKineticEnergyCuts = 0.;
160 
161  if (fMaxEnergyCut != MaxEnergyCut) {
163  // clear loss table and renge vectors
164  Reset();
165  }
166 
167  // Build the energy loss table
168  BuildLossTable();
169 
170  // Build range vector for every material, convert cut into energy-cut,
171  // fill theKineticEnergyCuts and delete the range vector
172  static const G4double tune = 0.025*mm*g/cm3 ,lowen = 30.*keV ;
173 
174  // check density
175  G4double density = material->GetDensity() ;
176  if(density <= 0.) {
177 #ifdef G4VERBOSE
178  if (GetVerboseLevel()>0) {
179  G4cout << "G4VRangeToEnergyConverter::Convert() ";
180  G4cout << material->GetName() << "has zero density "
181  << "( " << density << ")" << G4endl;
182  }
183 #endif
184  return 0.;
185  }
186 
187  // initialize RangeVectorStore
189  G4int ext_size = table->size() - fRangeVectorStore.size();
190  for (int i=0; i<ext_size; i++) fRangeVectorStore.push_back(0);
191 
192  // Build Range Vector
193  G4int idx = material->GetIndex();
194  G4RangeVector* rangeVector = fRangeVectorStore.at(idx);
195  if (rangeVector == 0) {
196  rangeVector = new G4RangeVector(LowestEnergy, MaxEnergyCut, TotBin);
197  BuildRangeVector(material, rangeVector);
198  fRangeVectorStore.at(idx) = rangeVector;
199  }
200 
201  // Convert Range Cut ro Kinetic Energy Cut
202  theKineticEnergyCuts = ConvertCutToKineticEnergy(rangeVector, rangeCut, idx);
203 
204  if( ((theParticle->GetParticleName()=="e-")||(theParticle->GetParticleName()=="e+"))
205  && (theKineticEnergyCuts < lowen) ) {
206  // corr. should be switched on smoothly
207  theKineticEnergyCuts /= (1.+(1.-theKineticEnergyCuts/lowen)*
208  tune/(rangeCut*density));
209  }
210 
211  if(theKineticEnergyCuts < LowestEnergy) {
212  theKineticEnergyCuts = LowestEnergy ;
213  } else if(theKineticEnergyCuts > MaxEnergyCut) {
214  theKineticEnergyCuts = MaxEnergyCut;
215  }
216 
217  return theKineticEnergyCuts;
218 }
static constexpr double mm
Definition: G4SIunits.hh:115
size_t GetIndex() const
Definition: G4Material.hh:262
const G4String & GetName() const
Definition: G4Material.hh:178
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:587
std::vector< G4Material * > G4MaterialTable
G4double GetDensity() const
Definition: G4Material.hh:180
virtual void BuildRangeVector(const G4Material *aMaterial, G4RangeVector *rangeVector)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
function g(Y1, Y2, PT2)
Definition: hijing1.383.f:5205
G4GLOB_DLL std::ostream G4cout
G4double ConvertCutToKineticEnergy(G4RangeVector *theRangeVector, G4double theCutInLength, size_t materialIndex) const
static constexpr double cm3
Definition: G4SIunits.hh:121
std::vector< G4RangeVector * > fRangeVectorStore
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
static constexpr double keV
Definition: G4SIunits.hh:216
const G4ParticleDefinition * theParticle

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4VRangeToEnergyConverter::ConvertCutToKineticEnergy ( G4RangeVector theRangeVector,
G4double  theCutInLength,
size_t  materialIndex 
) const
protected

Definition at line 379 of file G4VRangeToEnergyConverter.cc.

388 {
389  const G4double epsilon=0.01;
390 
391  // find max. range and the corresponding energy (rmax,Tmax)
392  G4double rmax= -1.e10*mm;
393 
394  G4double T1 = LowestEnergy;
395  G4double r1 =(*rangeVector)[0] ;
396 
397  G4double T2 = MaxEnergyCut;
398 
399  // check theCutInLength < r1
400  if ( theCutInLength <= r1 ) { return T1; }
401 
402  // scan range vector to find nearest bin
403  // ( suppose that r(Ti) > r(Tj) if Ti >Tj )
404  for (size_t ibin=0; ibin<=size_t(TotBin); ibin++) {
405  G4double T=rangeVector->GetLowEdgeEnergy(ibin);
406  G4double r=(*rangeVector)[ibin];
407  if ( r>rmax ) rmax=r;
408  if (r <theCutInLength ) {
409  T1 = T;
410  r1 = r;
411  } else if (r >theCutInLength ) {
412  T2 = T;
413  break;
414  }
415  }
416 
417  // check cut in length is smaller than range max
418  if ( theCutInLength >= rmax ) {
419 #ifdef G4VERBOSE
420  if (GetVerboseLevel()>2) {
421  G4cout << "G4VRangeToEnergyConverter::ConvertCutToKineticEnergy ";
422  G4cout << " for " << theParticle->GetParticleName() << G4endl;
423  G4cout << "The cut in range [" << theCutInLength/mm << " (mm)] ";
424  G4cout << " is too big " ;
425  G4cout << " for material idx=" << materialIndex <<G4endl;
426  }
427 #endif
428  return MaxEnergyCut;
429  }
430 
431  // convert range to energy
432  G4double T3 = std::sqrt(T1*T2);
433  G4double r3 = rangeVector->Value(T3);
434  const size_t MAX_LOOP = 1000;
435  for (size_t loop_count=0; loop_count<MAX_LOOP; ++loop_count){
436  if (std::fabs(1.-r3/theCutInLength)<epsilon ) break;
437  if ( theCutInLength <= r3 ) {
438  T2 = T3;
439  } else {
440  T1 = T3;
441  }
442  T3 = std::sqrt(T1*T2);
443  r3 = rangeVector->Value(T3);
444  }
445 
446  return T3;
447 }
static constexpr double mm
Definition: G4SIunits.hh:115
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
double epsilon(double density, double temperature)
const G4ParticleDefinition * theParticle

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4VRangeToEnergyConverter::GetHighEdgeEnergy ( )
static

Definition at line 249 of file G4VRangeToEnergyConverter.cc.

250 {
251  return HighestEnergy;
252 }

Here is the caller graph for this function:

const G4PhysicsTable* G4VRangeToEnergyConverter::GetLossTable ( ) const
G4double G4VRangeToEnergyConverter::GetLowEdgeEnergy ( )
static

Definition at line 243 of file G4VRangeToEnergyConverter.cc.

244 {
245  return LowestEnergy;
246 }

Here is the caller graph for this function:

G4double G4VRangeToEnergyConverter::GetMaxEnergyCut ( )
static

Definition at line 257 of file G4VRangeToEnergyConverter.cc.

258 {
259  return MaxEnergyCut;
260 }

Here is the caller graph for this function:

const G4ParticleDefinition * G4VRangeToEnergyConverter::GetParticleType ( ) const
inline

Definition at line 172 of file G4VRangeToEnergyConverter.hh.

173 {
174  return theParticle;
175 }
const G4ParticleDefinition * theParticle
G4int G4VRangeToEnergyConverter::GetVerboseLevel ( ) const
inline

Definition at line 165 of file G4VRangeToEnergyConverter.hh.

166 {
167  return verboseLevel;
168 }

Here is the caller graph for this function:

G4int G4VRangeToEnergyConverter::operator!= ( const G4VRangeToEnergyConverter right) const

Definition at line 139 of file G4VRangeToEnergyConverter.cc.

140 {
141  return this != &right;
142 }
G4VRangeToEnergyConverter & G4VRangeToEnergyConverter::operator= ( const G4VRangeToEnergyConverter right)

Definition at line 66 of file G4VRangeToEnergyConverter.cc.

67 {
68  if (this == &right) return *this;
69  if (theLossTable) {
71  delete theLossTable;
72  theLossTable=0;
73  }
74 
77  theParticle = right.theParticle;
78  verboseLevel = right.verboseLevel;
79 
80  // create the loss table
81  theLossTable = new G4LossTable();
83  // fill the loss table
84  for (size_t j=0; j<size_t(NumberOfElements); j++){
86  for (size_t i=0; i<=size_t(TotBin); i++) {
87  G4double Value = (*((*right.theLossTable)[j]))[i];
88  aVector->PutValue(i,Value);
89  }
90  theLossTable->insert(aVector);
91  }
92 
93  // clean up range vector store
94  for (size_t idx=0; idx<fRangeVectorStore.size(); idx++){
95  delete fRangeVectorStore.at(idx);
96  }
97  fRangeVectorStore.clear();
98 
99  // copy range vector store
100  for (size_t j=0; j<((right.fRangeVectorStore).size()); j++){
101  G4RangeVector* vector = (right.fRangeVectorStore).at(j);
102  G4RangeVector* rangeVector = 0;
103  if (vector !=0 ) {
104  rangeVector = new G4RangeVector(LowestEnergy, MaxEnergyCut, TotBin);
106  for (size_t i=0; i<=size_t(TotBin); i++) {
107  G4double Value = (*vector)[i];
108  rangeVector->PutValue(i,Value);
109  }
110  }
111  fRangeVectorStore.push_back(rangeVector);
112  }
113  return *this;
114 }
void insert(G4PhysicsVector *)
static size_t GetNumberOfElements()
Definition: G4Element.cc:405
std::vector< G4RangeVector * > fRangeVectorStore
double G4double
Definition: G4Types.hh:76
void clearAndDestroy()
const G4ParticleDefinition * theParticle

Here is the call graph for this function:

G4int G4VRangeToEnergyConverter::operator== ( const G4VRangeToEnergyConverter right) const

Definition at line 134 of file G4VRangeToEnergyConverter.cc.

135 {
136  return this == &right;
137 }
void G4VRangeToEnergyConverter::Reset ( )
virtual

Reimplemented in G4RToEConvForProton.

Definition at line 270 of file G4VRangeToEnergyConverter.cc.

271 {
272  // delete loss table
273  if (theLossTable) {
275  delete theLossTable;
276  }
277  theLossTable=0;
279 
280  //clear RangeVectorStore
281  for (size_t idx=0; idx<fRangeVectorStore.size(); idx++){
282  delete fRangeVectorStore.at(idx);
283  }
284  fRangeVectorStore.clear();
285 }
std::vector< G4RangeVector * > fRangeVectorStore
void clearAndDestroy()

Here is the call graph for this function:

Here is the caller graph for this function:

void G4VRangeToEnergyConverter::SetEnergyRange ( G4double  lowedge,
G4double  highedge 
)
static

Definition at line 223 of file G4VRangeToEnergyConverter.cc.

225 {
226  // check LowestEnergy/ HighestEnergy
227  if ( (lowedge<0.0)||(highedge<=lowedge) ){
228 #ifdef G4VERBOSE
229  G4cerr << "Error in G4VRangeToEnergyConverter::SetEnergyRange";
230  G4cerr << " : illegal energy range" << "(" << lowedge/GeV;
231  G4cerr << "," << highedge/GeV << ") [GeV]" << G4endl;
232 #endif
233  G4Exception( "G4VRangeToEnergyConverter::SetEnergyRange()",
234  "ProcCuts101",
235  JustWarning, "Illegal energy range ");
236  } else {
237  LowestEnergy = lowedge;
238  HighestEnergy = highedge;
239  }
240 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static constexpr double GeV
Definition: G4SIunits.hh:217
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

void G4VRangeToEnergyConverter::SetMaxEnergyCut ( G4double  value)
static

Definition at line 262 of file G4VRangeToEnergyConverter.cc.

263 {
265 }
const XML_Char int const XML_Char * value
Definition: expat.h:331

Here is the caller graph for this function:

void G4VRangeToEnergyConverter::SetVerboseLevel ( G4int  value)
inline

Definition at line 159 of file G4VRangeToEnergyConverter.hh.

160 {
161  verboseLevel = value;
162 }
const XML_Char int const XML_Char * value
Definition: expat.h:331

Here is the caller graph for this function:

Member Data Documentation

G4double G4VRangeToEnergyConverter::fMaxEnergyCut
protected

Definition at line 112 of file G4VRangeToEnergyConverter.hh.

std::vector< G4RangeVector* > G4VRangeToEnergyConverter::fRangeVectorStore
protected

Definition at line 136 of file G4VRangeToEnergyConverter.hh.

G4double G4VRangeToEnergyConverter::HighestEnergy = 100.0e6*MeV
staticprotected

Definition at line 110 of file G4VRangeToEnergyConverter.hh.

G4double G4VRangeToEnergyConverter::LowestEnergy = 0.99e-3*MeV
staticprotected

Definition at line 110 of file G4VRangeToEnergyConverter.hh.

G4double G4VRangeToEnergyConverter::MaxEnergyCut = 10.0*GeV
staticprotected

Definition at line 111 of file G4VRangeToEnergyConverter.hh.

G4int G4VRangeToEnergyConverter::NumberOfElements
protected

Definition at line 117 of file G4VRangeToEnergyConverter.hh.

G4LossTable* G4VRangeToEnergyConverter::theLossTable
protected

Definition at line 116 of file G4VRangeToEnergyConverter.hh.

const G4ParticleDefinition* G4VRangeToEnergyConverter::theParticle
protected

Definition at line 114 of file G4VRangeToEnergyConverter.hh.

const G4int G4VRangeToEnergyConverter::TotBin
protected

Definition at line 120 of file G4VRangeToEnergyConverter.hh.


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