Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4QNeutronCaptureRatio Class Reference

#include <G4QNeutronCaptureRatio.hh>

Public Member Functions

 ~G4QNeutronCaptureRatio ()
 
G4double GetRatio (G4double pIU, G4int tgZ, G4int tgN)
 

Static Public Member Functions

static G4QNeutronCaptureRatioGetPointer ()
 

Protected Member Functions

 G4QNeutronCaptureRatio ()
 

Detailed Description

Definition at line 53 of file G4QNeutronCaptureRatio.hh.

Constructor & Destructor Documentation

◆ G4QNeutronCaptureRatio()

G4QNeutronCaptureRatio::G4QNeutronCaptureRatio ( )
inlineprotected

Definition at line 57 of file G4QNeutronCaptureRatio.hh.

57{} // Constructor

◆ ~G4QNeutronCaptureRatio()

G4QNeutronCaptureRatio::~G4QNeutronCaptureRatio ( )
inline

Definition at line 61 of file G4QNeutronCaptureRatio.hh.

61{} // Destructor

Member Function Documentation

◆ GetPointer()

G4QNeutronCaptureRatio * G4QNeutronCaptureRatio::GetPointer ( )
static

Definition at line 48 of file G4QNeutronCaptureRatio.cc.

49{
50 static G4QNeutronCaptureRatio theRatios; // *** Static body of the NeutCaptureRatio ***
51 return &theRatios;
52}

Referenced by G4QInelastic::GetMeanFreePath(), and G4QNGamma::GetMeanFreePath().

◆ GetRatio()

G4double G4QNeutronCaptureRatio::GetRatio ( G4double  pIU,
G4int  tgZ,
G4int  tgN 
)

Definition at line 55 of file G4QNeutronCaptureRatio.cc.

56{
57 // Table parameters
58 static const G4int npp=100; // Number of steps in the R(s) LinTable
59 static const G4int mpp=npp+1; // Number of elements in the R(s) LinTable
60 static const G4double pma=6.; // The first LinTabEl(mom=0)=1., mom>pma -> logTab
61 static const G4double dp=pma/npp; // Step of the linear Table
62 static const G4int nls=150; // Number of steps in the R(lns) logTable
63 static const G4int mls=nls+1; // Number of elements in the R(lns) logTable
64 static const G4double lpi=1.79; // The min ln(p) logTabEl(p=5.99 < pma=6.)
65 static const G4double lpa=8.; // The max ln(p) logTabEl(p=5.99 - 2981 GeV)
66 static const G4double mi=std::exp(lpi);// The min mom of logTabEl(~ 5.99 GeV)
67 static const G4double max_s=std::exp(lpa);// The max mom of logTabEl(~ 2981 GeV)
68 static const G4double dl=(lpa-lpi)/nls;// Step of the logarithmic Table
69 static const G4double edl=std::exp(dl);// Multiplication step of the logarithmic Table
70 static const G4double toler=.0001; // Tolarence (GeV) defining the same momentum
71 static G4double lastP=0.; // Last mometum value for which R was calculated
72 static G4double lastR=0.; // Last ratio R which was calculated
73 // Local Associative Data Base:
74 static std::vector<G4int> vZ; // Vector of calculated Z (target)
75 static std::vector<G4int> vN; // Vector of calculated N (target)
76 static std::vector<G4double> vH; // Vector of max mom initialized in the LinTable
77 static std::vector<G4int> vJ; // Vector of topBin number initialized in LinTable
78 static std::vector<G4double> vM; // Vector of relMax ln(p) initialized in LogTable
79 static std::vector<G4int> vK; // Vector of topBin number initialized in LogTable
80 static std::vector<G4double*> vT; // Vector of pointers to LinTable in C++ heap
81 static std::vector<G4double*> vL; // Vector of pointers to LogTable in C++ heap
82 // Last values of the Associative Data Base:
83 static G4int lastZ=0; // theLast of calculated A
84 static G4int lastN=0; // theLast of calculated A
85 static G4double lastH=0.; // theLast of max mom initialized in the LinTable
86 static G4int lastJ=0; // theLast of topBinNumber initialized in LinTable
87 static G4double lastM=0.; // theLast of relMax ln(p) initialized in LogTab.
88 static G4int lastK=0; // theLast of topBinNumber initialized in LogTable
89 static G4double* lastT=0; // theLast of pointer to LinTable in the C++ heap
90 static G4double* lastL=0; // theLast of pointer to LogTable in the C++ heap
91 // LogTable is created only if necessary. R(p>2981GeV) calcul by formula for any nuclei
92 G4int A=tgN+tgZ;
93 if(pIU > 50) return 0.;
94 if(pIU > 30 && ((tgN==1 && tgZ==1) || (tgN==8 && tgZ==7))) return 0.;
95 if(pIU > 20 && tgN==2 && tgZ==1) return 0.;
96 if(pIU > 15 && ((tgN==1 && tgZ==2) || (tgN==8 && tgZ==8))) return 0.;
97 if(pIU<toler || A<1) return 1.; // Fake use of toler as non zero number
98 if(A>247)
99 {
100 G4cout<<"-*-Warning-*-G4NeutronCaptureRatio::GetRatio:A="<<A<<">247, return 0"<<G4endl;
101 return 0.;
102 }
103 G4int nDB=vZ.size(); // A number of nuclei already initialized in AMDB
104 if(nDB && lastZ==tgZ && lastN==tgN && std::fabs(pIU-lastP)<toler) return lastR;
105 if(pIU>max_s)
106 {
107 lastR=CalcCap2In_Ratio(s,tgZ,tgN); //@@ Probably user ought to be notified about bigP
108 return lastR;
109 }
110 G4bool found=false;
111 G4int i=-1;
112 if(nDB) for (i=0; i<nDB; i++) if(tgZ==vZ[i] && tgN==vN[i]) // Sirch for this Z,N in AMDB
113 {
114 found=true; // The (Z,N) is found
115 break;
116 }
117 if(!nDB || !found) // Create new line in the AMDB
118 {
119 lastZ = tgZ;
120 lastN = tgN;
121 lastT = new G4double[mpp]; // Create the linear Table
122 lastJ = static_cast<int>(pIU/dp)+1; // MaxBin to be initialized
123 if(lastJ>npp)
124 {
125 lastJ=npp;
126 lastH=pma;
127 }
128 else lastH = lastJ*dp; // Calculate max initialized s for LinTab
129 G4double pv=0;
130 lastT[0]=1.;
131 for(G4int j=1; j<=lastJ; j++) // Calculate LinTab values
132 {
133 pv+=dp;
134 lastT[j]=CalcCap2In_Ratio(pv,tgZ,tgN); // ??
135 }
136 lastL=new G4double[mls]; // Create the logarithmic Table
137 G4double ls=std::log(s);
138 lastK = static_cast<int>((ls-lpi)/dl)+1; // MaxBin to be initialized in LogTaB
139 if(lastK>nls)
140 {
141 lastK=nls;
142 lastM=lpa-lpi;
143 }
144 else lastM = lastK*dl; // Calculate max initialized ln(s)-lpi for LogTab
145 pv=mi;
146 for(G4int j=0; j<=lastK; j++) // Calculate LogTab values
147 {
148 lastL[j]=CalcCap2In_Ratio(pv,tgZ,tgN);
149 if(j!=lastK) pv*=edl;
150 }
151 i++; // Make a new record to AMDB and position on it
152 vZ.push_back(lastZ);
153 vN.push_back(lastN);
154 vH.push_back(lastH);
155 vJ.push_back(lastJ);
156 vM.push_back(lastM);
157 vK.push_back(lastK);
158 vT.push_back(lastT);
159 vL.push_back(lastL);
160 }
161 else // The A value was found in AMDB
162 {
163 lastZ=vZ[i];
164 lastN=vN[i];
165 lastH=vH[i];
166 lastJ=vJ[i];
167 lastM=vM[i];
168 lastK=vK[i];
169 lastT=vT[i];
170 lastL=vL[i];
171 if(s>lastH) // At least LinTab must be updated
172 {
173 G4int nextN=lastJ+1; // The next bin to be initialized
174 if(lastJ<npp)
175 {
176 lastJ = static_cast<int>(pIU/dp)+1;// MaxBin to be initialized
177 G4double pv=lastH;
178 if(lastJ>npp)
179 {
180 lastJ=npp;
181 lastH=pma;
182 }
183 else lastH = lastJ*dp; // Calculate max initialized s for LinTab
184 for(G4int j=nextN; j<=lastJ; j++)// Calculate LogTab values
185 {
186 pv+=dp;
187 lastT[j]=CalcCap2In_Ratio(pv,tgZ,tgN);
188 }
189 } // End of LinTab update
190 if(lastJ>=nextN)
191 {
192 vH[i]=lastH;
193 vJ[i]=lastJ;
194 }
195 G4int nextK=lastK+1;
196 if(pIU>pma && lastK<nls) // LogTab must be updated
197 {
198 G4double pv=std::exp(lastM+lpi); // Define starting poit (lastM will be changed)
199 G4double ls=std::log(s);
200 lastK = static_cast<int>((ls-lpi)/dl)+1; // MaxBin to be initialized in LogTaB
201 if(lastK>nls)
202 {
203 lastK=nls;
204 lastM=lpa-lpi;
205 }
206 else lastM = lastK*dl; // Calculate max initialized ln(p)-lpi for LogTab
207 for(G4int j=nextK; j<=lastK; j++)// Calculate LogTab values
208 {
209 pv*=edl;
210 lastL[j]=CalcCap2In_Ratio(pv,tgZ,tgN);
211 }
212 } // End of LogTab update
213 if(lastK>=nextK)
214 {
215 vM[i]=lastM;
216 vK[i]=lastK;
217 }
218 }
219 }
220 // Now one can use tabeles to calculate the value
221 if(pIU<pma) // Use linear table
222 {
223 G4int n=static_cast<int>(pIU/dp); // Low edge number of the bin
224 G4double d=s-n*dp; // Linear shift
225 G4double v=lastT[n]; // Base
226 lastR=v+d*(lastT[n+1]-v)/dp; // Result
227 }
228 else // Use log table
229 {
230 G4double ls=std::log(pIU)-lpi; // ln(p)-l_min
231 G4int n=static_cast<int>(ls/dl); // Low edge number of the bin
232 G4double d=ls-n*dl; // Log shift
233 G4double v=lastL[n]; // Base
234 lastR=v+d*(lastL[n+1]-v)/dl; // Result
235 }
236 if(lastR<0.) lastR=0.;
237 if(lastR>1.) lastR=1.;
238 return lastR;
239} // End of GetRatio
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

Referenced by G4QInelastic::GetMeanFreePath(), and G4QNGamma::GetMeanFreePath().


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