Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4FastPathHadronicCrossSection::fastPathEntry Struct Reference

#include <G4FastPathHadronicCrossSection.hh>

Public Member Functions

 fastPathEntry (const G4ParticleDefinition *par, const G4Material *mat, G4double min_cutoff)
 
 ~fastPathEntry ()
 
G4double GetCrossSection (G4double ene) const
 
void Initialize (G4CrossSectionDataStore *)
 

Public Attributes

const G4ParticleDefinition *const particle
 
const G4Material *const material
 
const G4double min_cutoff
 
XSParamphysicsVector
 

Detailed Description

Definition at line 54 of file G4FastPathHadronicCrossSection.hh.

Constructor & Destructor Documentation

◆ fastPathEntry()

fastPathEntry::fastPathEntry ( const G4ParticleDefinition par,
const G4Material mat,
G4double  min_cutoff 
)

Definition at line 65 of file G4FastPathHadronicCrossSection.cc.

65 :
66 particle(part),material(mat),min_cutoff(min),physicsVector(nullptr)
67 {
68 DBG("Initializing a fastPathEntry");
69#ifdef FPDEBUG
70 count = 0;
71 slowpath_sum=0.;
72 max_delta=0.;
73 min_delta=0.;
74 sum_delta=0.;
75 sum_delta_square=0.;
76#endif
77}
#define DBG(msg)

◆ ~fastPathEntry()

fastPathEntry::~fastPathEntry ( )

Definition at line 79 of file G4FastPathHadronicCrossSection.cc.

80{
81 DBG("Deleting fastPathEntry");
82 DBG("Dumping status for: "<<(particle?particle->GetParticleName():"PART_NONE")<<" "\
83 <<(material?material->GetName():"MAT_NONE")<<" min_cutoff:"<<min_cutoff<<" "\
84 <<" count:"<<count<<" slowpath_sum:"<<slowpath_sum<<" max_delta:"<<max_delta\
85 <<" min_delta"<<min_delta<<" sum_delta"<<sum_delta<<" sum_delta_squared:"<<sum_delta_square);
86 delete physicsVector;
87}
const G4String & GetName() const
Definition: G4Material.hh:175
const G4String & GetParticleName() const

Member Function Documentation

◆ GetCrossSection()

G4double G4FastPathHadronicCrossSection::fastPathEntry::GetCrossSection ( G4double  ene) const
inline

Definition at line 58 of file G4FastPathHadronicCrossSection.hh.

58{ return physicsVector->Value(ene); }
G4double Value(G4double theEnergy, std::size_t &lastidx) const

◆ Initialize()

void fastPathEntry::Initialize ( G4CrossSectionDataStore xsds)

Definition at line 95 of file G4FastPathHadronicCrossSection.cc.

96{
97 //Check this method is called when G4CrossSectionDataStore is in the correct state:
98 // FastPath is enabled and we are indeed initializing
101 using std::log10;
102 std::vector<Point_t> data_in;
103 const fastPathParameters& params = xsds->GetFastPathParameters();
104 G4double xs;
105
106 //G4double max_query = params.queryMax;
107 //G4int count = sampleCount;
108 //G4double tol = dpTol;
109
110 //Shift so max and min are >= 1.
111 //Don't forget to shift back before computing XS
112 G4double min = params.sampleMin;
113 G4double max = params.sampleMax;
114 G4double shift = 0.0;
115 if(min < 1.0){
116 shift = 1.0 - min;
117 }
118 min += shift;
119 max += shift;
120
121 G4double log_max = std::log10(params.sampleMax);
122 G4double log_min = std::log10(params.sampleMin);
123 G4double log_step = (log_max-log_min)/(1.0*params.sampleCount);
124
125 G4double max_xs = 0.0;
126
127 //Utility particle to calculate XS, with 0 kin energy by default
128 static const G4ThreeVector constDirection(0.,0.,1.);
129 G4DynamicParticle* probingParticle = new G4DynamicParticle( particle , constDirection , 0 );
130
131 //add the cutoff energy
132 probingParticle->SetKineticEnergy(min_cutoff);
133 //Sample cross-section
134 xs = xsds->GetCrossSection(probingParticle,material);
135 data_in.push_back({min_cutoff,xs});
136
137 G4double currEnergy = 0.0;
138 //log results
139 auto exp10 = [](G4double x){ return std::exp( M_LN10*x); };
140 for(G4double log_currEnergy = log_min; log_currEnergy < log_max; log_currEnergy += log_step){
141 currEnergy = exp10(log_currEnergy) - shift;
142 if (currEnergy < min_cutoff) continue;
143 probingParticle->SetKineticEnergy(currEnergy);
144 xs=xsds->GetCrossSection(probingParticle,material);
145 //G4cout << "PRUTH: energy value " << currEnergy << ", XS value " << xs << G4endl;
146 if (xs > max_xs) max_xs = xs;
147 data_in.push_back({currEnergy,xs});
148 } // --- end of loop i
149 probingParticle->SetKineticEnergy(max-shift);
150 xs = xsds->GetCrossSection(probingParticle,material);
151 data_in.push_back({max-shift,xs});
152
153 G4double tol = max_xs * 0.01;
154 std::vector<Point_t> decimated_data;
155 simplify_function(tol, data_in, decimated_data);
156 std::vector<Point_t> debiased_data;
157 RemoveBias( data_in, decimated_data, debiased_data);
158 if ( physicsVector != nullptr ) delete physicsVector;
159 physicsVector = new XSParam(decimated_data.size());
160 G4int physicsVectorIndex = 0;
161 for(size_t i = 0; i < decimated_data.size(); i++){
162 physicsVector->PutValue(physicsVectorIndex++, decimated_data[i].e, decimated_data[i].xs);
163 }
164 //xsds->DumpFastPath(particle,material,G4cout);
165}
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
const G4FastPathHadronicCrossSection::fastPathParameters & GetFastPathParameters() const
const G4FastPathHadronicCrossSection::controlFlag & GetFastPathControlFlags() const
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
void SetKineticEnergy(G4double aEnergy)
void PutValue(std::size_t index, G4double energy, G4double dValue)
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments

Member Data Documentation

◆ material

const G4Material* const G4FastPathHadronicCrossSection::fastPathEntry::material

Definition at line 61 of file G4FastPathHadronicCrossSection.hh.

Referenced by Initialize(), operator<<(), and ~fastPathEntry().

◆ min_cutoff

const G4double G4FastPathHadronicCrossSection::fastPathEntry::min_cutoff

Definition at line 62 of file G4FastPathHadronicCrossSection.hh.

Referenced by Initialize(), operator<<(), and ~fastPathEntry().

◆ particle

const G4ParticleDefinition* const G4FastPathHadronicCrossSection::fastPathEntry::particle

Definition at line 60 of file G4FastPathHadronicCrossSection.hh.

Referenced by Initialize(), operator<<(), and ~fastPathEntry().

◆ physicsVector

XSParam* G4FastPathHadronicCrossSection::fastPathEntry::physicsVector

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