#include <G4NeutronHPVector.hh>
Definition at line 50 of file G4NeutronHPVector.hh.
G4NeutronHPVector::G4NeutronHPVector | ( | ) |
Definition at line 80 of file G4NeutronHPVector.cc.
References DBL_MAX.
00081 { 00082 theData = new G4NeutronHPDataPoint[20]; 00083 nPoints=20; 00084 nEntries=0; 00085 Verbose=0; 00086 theIntegral=0; 00087 totalIntegral=-1; 00088 isFreed = 0; 00089 maxValue = -DBL_MAX; 00090 the15percentBorderCash = -DBL_MAX; 00091 the50percentBorderCash = -DBL_MAX; 00092 label = -DBL_MAX; 00093 00094 }
G4NeutronHPVector::G4NeutronHPVector | ( | G4int | n | ) |
Definition at line 96 of file G4NeutronHPVector.cc.
References DBL_MAX.
00097 { 00098 nPoints=std::max(n, 20); 00099 theData = new G4NeutronHPDataPoint[nPoints]; 00100 nEntries=0; 00101 Verbose=0; 00102 theIntegral=0; 00103 totalIntegral=-1; 00104 isFreed = 0; 00105 maxValue = -DBL_MAX; 00106 the15percentBorderCash = -DBL_MAX; 00107 the50percentBorderCash = -DBL_MAX; 00108 }
G4NeutronHPVector::~G4NeutronHPVector | ( | ) |
Definition at line 110 of file G4NeutronHPVector.cc.
00111 { 00112 // if(Verbose==1)G4cout <<"G4NeutronHPVector::~G4NeutronHPVector"<<G4endl; 00113 delete [] theData; 00114 // if(Verbose==1)G4cout <<"Vector: delete theData"<<G4endl; 00115 delete [] theIntegral; 00116 // if(Verbose==1)G4cout <<"Vector: delete theIntegral"<<G4endl; 00117 isFreed = 1; 00118 }
void G4NeutronHPVector::CleanUp | ( | ) | [inline] |
Definition at line 255 of file G4NeutronHPVector.hh.
References G4InterpolationManager::CleanUp(), G4NeutronHPHash::Clear(), and DBL_MAX.
Referenced by Merge().
00256 { 00257 nEntries=0; 00258 theManager.CleanUp(); 00259 maxValue = -DBL_MAX; 00260 theHash.Clear(); 00261 //080811 TK DB 00262 delete[] theIntegral; 00263 theIntegral = NULL; 00264 }
G4double* G4NeutronHPVector::Debug | ( | ) | [inline] |
void G4NeutronHPVector::Dump | ( | ) |
Definition at line 194 of file G4NeutronHPVector.cc.
References G4cout, G4endl, GetX(), and G4NeutronHPDataPoint::GetY().
00195 { 00196 G4cout << nEntries<<G4endl; 00197 for(G4int i=0; i<nEntries; i++) 00198 { 00199 G4cout << theData[i].GetX()<<" "; 00200 G4cout << theData[i].GetY()<<" "; 00201 // if (i!=1&&i==5*(i/5)) G4cout << G4endl; 00202 G4cout << G4endl; 00203 } 00204 G4cout << G4endl; 00205 }
G4double G4NeutronHPVector::Get15percentBorder | ( | ) |
Definition at line 441 of file G4NeutronHPVector.cc.
References DBL_MAX, GetVectorLength(), G4NeutronHPDataPoint::GetX(), and IntegrateAndNormalise().
00442 { 00443 if(the15percentBorderCash>-DBL_MAX/2.) return the15percentBorderCash; 00444 G4double result; 00445 if(GetVectorLength()==1) 00446 { 00447 result = theData[0].GetX(); 00448 the15percentBorderCash = result; 00449 } 00450 else 00451 { 00452 if(theIntegral==0) { IntegrateAndNormalise(); } 00453 G4int i; 00454 result = theData[GetVectorLength()-1].GetX(); 00455 for(i=0;i<GetVectorLength();i++) 00456 { 00457 if(theIntegral[i]/theIntegral[GetVectorLength()-1]>0.15) 00458 { 00459 result = theData[std::min(i+1, GetVectorLength()-1)].GetX(); 00460 the15percentBorderCash = result; 00461 break; 00462 } 00463 } 00464 the15percentBorderCash = result; 00465 } 00466 return result; 00467 }
G4double G4NeutronHPVector::Get50percentBorder | ( | ) |
Definition at line 469 of file G4NeutronHPVector.cc.
References DBL_MAX, GetVectorLength(), G4NeutronHPDataPoint::GetX(), IntegrateAndNormalise(), and G4NeutronHPInterpolator::Lin().
00470 { 00471 if(the50percentBorderCash>-DBL_MAX/2.) return the50percentBorderCash; 00472 G4double result; 00473 if(GetVectorLength()==1) 00474 { 00475 result = theData[0].GetX(); 00476 the50percentBorderCash = result; 00477 } 00478 else 00479 { 00480 if(theIntegral==0) { IntegrateAndNormalise(); } 00481 G4int i; 00482 G4double x = 0.5; 00483 result = theData[GetVectorLength()-1].GetX(); 00484 for(i=0;i<GetVectorLength();i++) 00485 { 00486 if(theIntegral[i]/theIntegral[GetVectorLength()-1]>x) 00487 { 00488 G4int it; 00489 it = i; 00490 if(it == GetVectorLength()-1) 00491 { 00492 result = theData[GetVectorLength()-1].GetX(); 00493 } 00494 else 00495 { 00496 G4double x1, x2, y1, y2; 00497 x1 = theIntegral[i-1]/theIntegral[GetVectorLength()-1]; 00498 x2 = theIntegral[i]/theIntegral[GetVectorLength()-1]; 00499 y1 = theData[i-1].GetX(); 00500 y2 = theData[i].GetX(); 00501 result = theLin.Lin(x, x1, x2, y1, y2); 00502 } 00503 the50percentBorderCash = result; 00504 break; 00505 } 00506 } 00507 the50percentBorderCash = result; 00508 } 00509 return result; 00510 }
std::vector<G4double> G4NeutronHPVector::GetBlocked | ( | ) | [inline] |
std::vector<G4double> G4NeutronHPVector::GetBuffered | ( | ) | [inline] |
Definition at line 119 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::GetX().
Referenced by G4NeutronHPElementData::Harmonise(), G4NeutronHPChannel::Harmonise(), G4NeutronHPArbitaryTab::Init(), and Merge().
00119 { return theData[i].GetX(); }
G4double G4NeutronHPVector::GetIntegral | ( | ) | [inline] |
Definition at line 471 of file G4NeutronHPVector.hh.
References Integrate().
Referenced by G4NeutronHPLabAngularEnergy::Sample().
00472 { 00473 if(totalIntegral<-0.5) Integrate(); 00474 return totalIntegral; 00475 }
const G4InterpolationManager& G4NeutronHPVector::GetInterpolationManager | ( | ) | const [inline] |
Definition at line 482 of file G4NeutronHPVector.hh.
Referenced by G4NeutronHPPartial::GetY(), G4NeutronHPPartial::Sample(), and G4NeutronHPLabAngularEnergy::Sample().
G4double G4NeutronHPVector::GetLabel | ( | ) | [inline] |
Definition at line 250 of file G4NeutronHPVector.hh.
Referenced by Merge(), G4NeutronHPLabAngularEnergy::Sample(), and G4NeutronHPArbitaryTab::Sample().
G4double G4NeutronHPVector::GetMeanX | ( | ) | [inline] |
Definition at line 502 of file G4NeutronHPVector.hh.
References G4NeutronHPInterpolator::GetBinIntegral(), G4InterpolationManager::GetScheme(), G4NeutronHPInterpolator::GetWeightedBinIntegral(), G4NeutronHPDataPoint::GetX(), and G4NeutronHPDataPoint::GetY().
Referenced by G4NeutronHPLabAngularEnergy::Sample().
00503 { 00504 G4double result; 00505 G4double running = 0; 00506 G4double weighted = 0; 00507 for(G4int i=1; i<nEntries; i++) 00508 { 00509 running += theInt.GetBinIntegral(theManager.GetScheme(i-1), 00510 theData[i-1].GetX(), theData[i].GetX(), 00511 theData[i-1].GetY(), theData[i].GetY()); 00512 weighted += theInt.GetWeightedBinIntegral(theManager.GetScheme(i-1), 00513 theData[i-1].GetX(), theData[i].GetX(), 00514 theData[i-1].GetY(), theData[i].GetY()); 00515 } 00516 result = weighted / running; 00517 return result; 00518 }
const G4NeutronHPDataPoint& G4NeutronHPVector::GetPoint | ( | G4int | i | ) | const [inline] |
Definition at line 127 of file G4NeutronHPVector.hh.
Referenced by G4NeutronHPIsoData::FillChannelData(), and operator=().
G4InterpolationScheme G4NeutronHPVector::GetScheme | ( | G4int | anIndex | ) | [inline] |
Definition at line 497 of file G4NeutronHPVector.hh.
References G4InterpolationManager::GetScheme().
Referenced by Merge().
00498 { 00499 return theManager.GetScheme(anIndex); 00500 }
G4int G4NeutronHPVector::GetVectorLength | ( | ) | const [inline] |
Definition at line 193 of file G4NeutronHPVector.hh.
Referenced by G4NeutronHPorLEInelasticData::BuildPhysicsTable(), G4NeutronHPData::DoPhysicsVector(), G4NeutronHPIsoData::FillChannelData(), Get15percentBorder(), Get50percentBorder(), G4NeutronHPPartial::GetNEntries(), G4NeutronHPPhotonDist::GetPhotons(), GetX(), GetY(), G4NeutronHPPartial::GetY(), G4NeutronHPElementData::Harmonise(), G4NeutronHPChannel::Harmonise(), G4NeutronIsoIsoCrossSections::Init(), Integrate(), IntegrateAndNormalise(), Merge(), operator+(), Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), SampleLin(), and ThinOut().
Definition at line 121 of file G4NeutronHPVector.hh.
References GetVectorLength(), and G4NeutronHPDataPoint::GetX().
Referenced by G4NeutronHPorLEInelasticData::BuildPhysicsTable(), G4NeutronHPData::DoPhysicsVector(), Dump(), G4NeutronHPPhotonDist::GetPhotons(), G4NeutronHPPartial::GetX(), GetXsec(), G4NeutronHPPartial::GetY(), Hash(), G4NeutronIsoIsoCrossSections::Init(), Integrate(), IntegrateAndNormalise(), operator+(), Sample(), G4NeutronHPLegendreStore::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), and ThinOut().
00122 { 00123 if (i<0) i=0; 00124 if(i>=GetVectorLength()) i=GetVectorLength()-1; 00125 return theData[i].GetX(); 00126 }
Definition at line 151 of file G4NeutronHPVector.hh.
References G4InterpolationManager::GetScheme(), G4NeutronHPDataPoint::GetX(), GetX(), G4NeutronHPDataPoint::GetY(), GetY(), and G4NeutronHPInterpolator::Interpolate().
00152 { 00153 G4int i; 00154 for(i=min ; i<nEntries; i++) 00155 { 00156 if(theData[i].GetX()>e) break; 00157 } 00158 G4int low = i-1; 00159 G4int high = i; 00160 if(i==0) 00161 { 00162 low = 0; 00163 high = 1; 00164 } 00165 else if(i==nEntries) 00166 { 00167 low = nEntries-2; 00168 high = nEntries-1; 00169 } 00170 G4double y; 00171 if(e<theData[nEntries-1].GetX()) 00172 { 00173 // Protect against doubled-up x values 00174 if( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 00175 { 00176 y = theData[low].GetY(); 00177 } 00178 else 00179 { 00180 y = theInt.Interpolate(theManager.GetScheme(high), e, 00181 theData[low].GetX(), theData[high].GetX(), 00182 theData[low].GetY(), theData[high].GetY()); 00183 } 00184 } 00185 else 00186 { 00187 y=theData[nEntries-1].GetY(); 00188 } 00189 return y; 00190 }
Definition at line 145 of file G4NeutronHPVector.cc.
References G4NeutronHPHash::GetMinIndex(), G4InterpolationManager::GetScheme(), G4NeutronHPDataPoint::GetX(), GetX(), G4NeutronHPDataPoint::GetY(), GetY(), Hash(), G4NeutronHPInterpolator::Interpolate(), and G4NeutronHPHash::Prepared().
00146 { 00147 if(nEntries == 0) return 0; 00148 if(!theHash.Prepared()) Hash(); 00149 G4int min = theHash.GetMinIndex(e); 00150 G4int i; 00151 for(i=min ; i<nEntries; i++) 00152 { 00153 //if(theData[i].GetX()>e) break; 00154 if(theData[i].GetX() >= e) break; 00155 } 00156 G4int low = i-1; 00157 G4int high = i; 00158 if(i==0) 00159 { 00160 low = 0; 00161 high = 1; 00162 } 00163 else if(i==nEntries) 00164 { 00165 low = nEntries-2; 00166 high = nEntries-1; 00167 } 00168 G4double y; 00169 if(e<theData[nEntries-1].GetX()) 00170 { 00171 // Protect against doubled-up x values 00172 //if( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 00173 if ( theData[high].GetX() !=0 00174 //080808 TKDB 00175 //&&( theData[high].GetX()-theData[low].GetX())/theData[high].GetX() < 0.000001) 00176 &&( std::abs( (theData[high].GetX()-theData[low].GetX())/theData[high].GetX() ) < 0.000001 ) ) 00177 { 00178 y = theData[low].GetY(); 00179 } 00180 else 00181 { 00182 y = theInt.Interpolate(theManager.GetScheme(high), e, 00183 theData[low].GetX(), theData[high].GetX(), 00184 theData[low].GetY(), theData[high].GetY()); 00185 } 00186 } 00187 else 00188 { 00189 y=theData[nEntries-1].GetY(); 00190 } 00191 return y; 00192 }
Definition at line 120 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::GetY().
Referenced by G4NeutronHPIsoData::GetXsec(), G4NeutronHPChannel::GetXsec(), GetY(), G4NeutronHPElementData::Harmonise(), G4NeutronHPChannel::Harmonise(), and Merge().
00120 { return theData[i].GetY(); }
Definition at line 202 of file G4NeutronHPVector.hh.
References GetVectorLength(), and G4NeutronHPDataPoint::GetY().
00203 { 00204 if (i<0) i=0; 00205 if(i>=GetVectorLength()) i=GetVectorLength()-1; 00206 return theData[i].GetY(); 00207 }
Definition at line 195 of file G4NeutronHPVector.hh.
References GetVectorLength(), and G4NeutronHPDataPoint::GetY().
00196 { 00197 if (i<0) i=0; 00198 if(i>=GetVectorLength()) i=GetVectorLength()-1; 00199 return theData[i].GetY(); 00200 }
Definition at line 192 of file G4NeutronHPVector.hh.
References GetXsec().
Referenced by G4NeutronHPorLEInelasticData::BuildPhysicsTable(), G4NeutronHPData::DoPhysicsVector(), G4NeutronIsoIsoCrossSections::GetCrossSection(), G4NeutronHPNeutronYield::GetDelayed(), G4NeutronHPWattSpectrum::GetFractionalProbability(), G4NeutronHPSimpleEvapSpectrum::GetFractionalProbability(), G4NeutronHPMadlandNixSpectrum::GetFractionalProbability(), G4NeutronHPFissionSpectrum::GetFractionalProbability(), G4NeutronHPEvapSpectrum::GetFractionalProbability(), G4NeutronHPArbitaryTab::GetFractionalProbability(), G4NeutronHPNeutronYield::GetMean(), G4NeutronHPProduct::GetMeanYield(), G4IsoProdCrossSections::GetProductionCrossSection(), G4NeutronIsoIsoCrossSections::GetProductIsotope(), G4NeutronHPNeutronYield::GetPrompt(), GetXsec(), G4NeutronHPInelasticBaseFS::GetXsec(), G4NeutronHPFissionBaseFS::GetXsec(), G4NeutronHPPartial::GetY(), Hash(), G4NeutronIsoIsoCrossSections::Init(), operator+(), G4NeutronHPWattSpectrum::Sample(), Sample(), G4NeutronHPSimpleEvapSpectrum::Sample(), G4NeutronHPProduct::Sample(), G4NeutronHPMadlandNixSpectrum::Sample(), G4NeutronHPLegendreStore::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPFissionSpectrum::Sample(), G4NeutronHPEvapSpectrum::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), ThinOut(), and Times().
00192 {return GetXsec(x);}
void G4NeutronHPVector::Hash | ( | ) | [inline] |
Definition at line 129 of file G4NeutronHPVector.hh.
References GetX(), GetY(), and G4NeutronHPHash::SetData().
Referenced by GetXsec(), and ReHash().
00130 { 00131 G4int i; 00132 G4double x, y; 00133 for(i=0 ; i<nEntries; i++) 00134 { 00135 if(0 == (i+1)%10) 00136 { 00137 x = GetX(i); 00138 y = GetY(i); 00139 theHash.SetData(i, x, y); 00140 } 00141 } 00142 }
void G4NeutronHPVector::Init | ( | std::ifstream & | aDataFile, | |
G4double | ux = 1. , |
|||
G4double | uy = 1. | |||
) | [inline] |
Definition at line 231 of file G4NeutronHPVector.hh.
References Init(), and G4InterpolationManager::Init().
00232 { 00233 G4int total; 00234 aDataFile >> total; 00235 if(theData!=0) delete [] theData; 00236 theData = new G4NeutronHPDataPoint[total]; 00237 nPoints=total; 00238 nEntries=0; 00239 theManager.Init(aDataFile); 00240 Init(aDataFile, total, ux, uy); 00241 }
void G4NeutronHPVector::Init | ( | std::ifstream & | aDataFile, | |
G4int | total, | |||
G4double | ux = 1. , |
|||
G4double | uy = 1. | |||
) | [inline] |
Definition at line 215 of file G4NeutronHPVector.hh.
References G4NeutronHPHash::SetData(), and SetData().
Referenced by G4NeutronIsoIsoCrossSections::Init(), G4NeutronHPWattSpectrum::Init(), Init(), G4NeutronHPSimpleEvapSpectrum::Init(), G4NeutronHPProduct::Init(), G4NeutronHPPhotonXSection::Init(), G4NeutronHPMadlandNixSpectrum::Init(), G4NeutronHPLabAngularEnergy::Init(), G4NeutronHPIsoData::Init(), G4NeutronHPInelasticCompFS::Init(), G4NeutronHPInelasticBaseFS::Init(), G4NeutronHPFissionSpectrum::Init(), G4NeutronHPFissionBaseFS::Init(), G4NeutronHPEvapSpectrum::Init(), G4NeutronHPArbitaryTab::Init(), G4IsoProdCrossSections::Init(), G4NeutronHPNeutronYield::InitDelayed(), G4NeutronHPPhotonDist::InitEnergies(), G4NeutronHPPhotonDist::InitMean(), G4NeutronHPNeutronYield::InitMean(), G4NeutronHPPhotonDist::InitPartials(), and G4NeutronHPNeutronYield::InitPrompt().
00216 { 00217 G4double x,y; 00218 for (G4int i=0;i<total;i++) 00219 { 00220 aDataFile >> x >> y; 00221 x*=ux; 00222 y*=uy; 00223 SetData(i,x,y); 00224 if(0 == nEntries%10) 00225 { 00226 theHash.SetData(nEntries-1, x, y); 00227 } 00228 } 00229 }
void G4NeutronHPVector::InitInterpolation | ( | std::ifstream & | aDataFile | ) | [inline] |
Definition at line 210 of file G4NeutronHPVector.hh.
References G4InterpolationManager::Init().
Referenced by G4NeutronHPPartial::InitData(), and G4NeutronHPPartial::InitInterpolation().
00211 { 00212 theManager.Init(aDataFile); 00213 }
void G4NeutronHPVector::Integrate | ( | ) | [inline] |
Definition at line 417 of file G4NeutronHPVector.hh.
References CHISTO, CLINLIN, CLINLOG, CLOGLIN, CLOGLOG, G4InterpolationManager::GetScheme(), GetVectorLength(), G4NeutronHPDataPoint::GetX(), GetX(), G4NeutronHPDataPoint::GetY(), HISTO, LINLIN, LINLOG, LOGLIN, LOGLOG, UHISTO, ULINLIN, ULINLOG, ULOGLIN, and ULOGLOG.
Referenced by GetIntegral().
00418 { 00419 G4int i; 00420 if(nEntries == 1) 00421 { 00422 totalIntegral = 0; 00423 return; 00424 } 00425 G4double sum = 0; 00426 for(i=1;i<GetVectorLength();i++) 00427 { 00428 if(std::abs((theData[i].GetX()-theData[i-1].GetX())/theData[i].GetX())>0.0000001) 00429 { 00430 G4double x1 = theData[i-1].GetX(); 00431 G4double x2 = theData[i].GetX(); 00432 G4double y1 = theData[i-1].GetY(); 00433 G4double y2 = theData[i].GetY(); 00434 G4InterpolationScheme aScheme = theManager.GetScheme(i); 00435 if(aScheme==LINLIN||aScheme==CLINLIN||aScheme==ULINLIN) 00436 { 00437 sum+= 0.5*(y2+y1)*(x2-x1); 00438 } 00439 else if(aScheme==LINLOG||aScheme==CLINLOG||aScheme==ULINLOG) 00440 { 00441 G4double a = y1; 00442 G4double b = (y2-y1)/(std::log(x2)-std::log(x1)); 00443 sum+= (a-b)*(x2-x1) + b*(x2*std::log(x2)-x1*std::log(x1)); 00444 } 00445 else if(aScheme==LOGLIN||aScheme==CLOGLIN||aScheme==ULOGLIN) 00446 { 00447 G4double a = std::log(y1); 00448 G4double b = (std::log(y2)-std::log(y1))/(x2-x1); 00449 sum += (std::exp(a)/b)*(std::exp(b*x2)-std::exp(b*x1)); 00450 } 00451 else if(aScheme==HISTO||aScheme==CHISTO||aScheme==UHISTO) 00452 { 00453 sum+= y1*(x2-x1); 00454 } 00455 else if(aScheme==LOGLOG||aScheme==CLOGLOG||aScheme==ULOGLOG) 00456 { 00457 G4double a = std::log(y1); 00458 G4double b = (std::log(y2)-std::log(y1))/(std::log(x2)-std::log(x1)); 00459 sum += (std::exp(a)/(b+1))*(std::pow(x2,b+1)-std::pow(x1,b+1)); 00460 } 00461 else 00462 { 00463 throw G4HadronicException(__FILE__, __LINE__, "Unknown interpolation scheme in G4NeutronHPVector::Integrate"); 00464 } 00465 00466 } 00467 } 00468 totalIntegral = sum; 00469 }
void G4NeutronHPVector::IntegrateAndNormalise | ( | ) | [inline] |
Definition at line 367 of file G4NeutronHPVector.hh.
References G4NeutronHPInterpolator::GetBinIntegral(), G4InterpolationManager::GetScheme(), GetVectorLength(), G4NeutronHPDataPoint::GetX(), GetX(), and G4NeutronHPDataPoint::GetY().
Referenced by Get15percentBorder(), Get50percentBorder(), Sample(), and SampleLin().
00368 { 00369 G4int i; 00370 if(theIntegral!=0) return; 00371 theIntegral = new G4double[nEntries]; 00372 if(nEntries == 1) 00373 { 00374 theIntegral[0] = 1; 00375 return; 00376 } 00377 theIntegral[0] = 0; 00378 G4double sum = 0; 00379 G4double x1 = 0; 00380 G4double x0 = 0; 00381 for(i=1;i<GetVectorLength();i++) 00382 { 00383 x1 = theData[i].GetX(); 00384 x0 = theData[i-1].GetX(); 00385 if (std::abs(x1-x0) > std::abs(x1*0.0000001) ) 00386 { 00387 //******************************************************************** 00388 //EMendoza -> the interpolation scheme is not always lin-lin 00389 /* 00390 sum+= 0.5*(theData[i].GetY()+theData[i-1].GetY())* 00391 (x1-x0); 00392 */ 00393 //******************************************************************** 00394 G4InterpolationScheme aScheme = theManager.GetScheme(i); 00395 G4double y0 = theData[i-1].GetY(); 00396 G4double y1 = theData[i].GetY(); 00397 G4double integ=theInt.GetBinIntegral(aScheme,x0,x1,y0,y1); 00398 #if defined WIN32-VC 00399 if(!_finite(integ)){integ=0;} 00400 #elif defined __IBMCPP__ 00401 if(isinf(integ)||isnan(integ)){integ=0;} 00402 #else 00403 if(std::isinf(integ)||std::isnan(integ)){integ=0;} 00404 #endif 00405 sum+=integ; 00406 //******************************************************************** 00407 } 00408 theIntegral[i] = sum; 00409 } 00410 G4double total = theIntegral[GetVectorLength()-1]; 00411 for(i=1;i<GetVectorLength();i++) 00412 { 00413 theIntegral[i]/=total; 00414 } 00415 }
void G4NeutronHPVector::Merge | ( | G4InterpolationScheme | aScheme, | |
G4double | aValue, | |||
G4NeutronHPVector * | active, | |||
G4NeutronHPVector * | passive | |||
) |
Definition at line 222 of file G4NeutronHPVector.cc.
References G4InterpolationManager::AppendScheme(), CleanUp(), GetEnergy(), GetLabel(), GetScheme(), GetVectorLength(), GetXsec(), G4NeutronHPInterpolator::Interpolate(), CLHEP::detail::n, G4NeutronHPHash::Prepared(), ReHash(), and SetData().
00224 { 00225 // interpolate between labels according to aScheme, cut at aValue, 00226 // continue in unknown areas by substraction of the last difference. 00227 00228 CleanUp(); 00229 G4int s_tmp = 0, n=0, m_tmp=0; 00230 G4NeutronHPVector * tmp; 00231 G4int a = s_tmp, p = n, t; 00232 while ( a<active->GetVectorLength() ) 00233 { 00234 if(active->GetEnergy(a) <= passive->GetEnergy(p)) 00235 { 00236 G4double xa = active->GetEnergy(a); 00237 G4double yy = theInt.Interpolate(aScheme, aValue, active->GetLabel(), passive->GetLabel(), 00238 active->GetXsec(a), passive->GetXsec(xa)); 00239 SetData(m_tmp, xa, yy); 00240 theManager.AppendScheme(m_tmp, active->GetScheme(a)); 00241 m_tmp++; 00242 a++; 00243 G4double xp = passive->GetEnergy(p); 00244 //if( std::abs(std::abs(xp-xa)/xa)<0.0000001&&a<active->GetVectorLength() ) 00245 if ( xa != 0 00246 && std::abs(std::abs(xp-xa)/xa) < 0.0000001 00247 && a < active->GetVectorLength() ) 00248 { 00249 p++; 00250 tmp = active; t=a; 00251 active = passive; a=p; 00252 passive = tmp; p=t; 00253 } 00254 } else { 00255 tmp = active; t=a; 00256 active = passive; a=p; 00257 passive = tmp; p=t; 00258 } 00259 } 00260 00261 G4double deltaX = passive->GetXsec(GetEnergy(m_tmp-1)) - GetXsec(m_tmp-1); 00262 while (p!=passive->GetVectorLength()&&passive->GetEnergy(p)<=aValue) 00263 { 00264 G4double anX; 00265 anX = passive->GetXsec(p)-deltaX; 00266 if(anX>0) 00267 { 00268 //if(std::abs(GetEnergy(m-1)-passive->GetEnergy(p))/passive->GetEnergy(p)>0.0000001) 00269 if ( passive->GetEnergy(p) == 0 00270 || std::abs(GetEnergy(m_tmp-1)-passive->GetEnergy(p))/passive->GetEnergy(p) > 0.0000001 ) 00271 { 00272 SetData(m_tmp, passive->GetEnergy(p), anX); 00273 theManager.AppendScheme(m_tmp++, passive->GetScheme(p)); 00274 } 00275 } 00276 p++; 00277 } 00278 // Rebuild the Hash; 00279 if(theHash.Prepared()) 00280 { 00281 ReHash(); 00282 } 00283 }
void G4NeutronHPVector::Merge | ( | G4NeutronHPVector * | active, | |
G4NeutronHPVector * | passive | |||
) | [inline] |
Definition at line 267 of file G4NeutronHPVector.hh.
References G4InterpolationManager::AppendScheme(), CleanUp(), GetEnergy(), GetScheme(), GetVectorLength(), GetXsec(), and SetData().
Referenced by G4NeutronHPLabAngularEnergy::Sample(), and G4NeutronHPDiscreteTwoBody::Sample().
00268 { 00269 CleanUp(); 00270 G4int s_tmp = 0, n=0, m_tmp=0; 00271 G4NeutronHPVector * tmp; 00272 G4int a = s_tmp, p = n, t; 00273 while (a<active->GetVectorLength()&&p<passive->GetVectorLength()) 00274 { 00275 if(active->GetEnergy(a) <= passive->GetEnergy(p)) 00276 { 00277 G4double xa = active->GetEnergy(a); 00278 G4double yy = active->GetXsec(a); 00279 SetData(m_tmp, xa, yy); 00280 theManager.AppendScheme(m_tmp, active->GetScheme(a)); 00281 m_tmp++; 00282 a++; 00283 G4double xp = passive->GetEnergy(p); 00284 00285 //080409 TKDB 00286 //if( std::abs(std::abs(xp-xa)/xa)<0.001 ) p++; 00287 if ( !( xa == 0 ) && std::abs(std::abs(xp-xa)/xa)<0.001 ) p++; 00288 } else { 00289 tmp = active; 00290 t=a; 00291 active = passive; 00292 a=p; 00293 passive = tmp; 00294 p=t; 00295 } 00296 } 00297 while (a!=active->GetVectorLength()) 00298 { 00299 SetData(m_tmp, active->GetEnergy(a), active->GetXsec(a)); 00300 theManager.AppendScheme(m_tmp++, active->GetScheme(a)); 00301 a++; 00302 } 00303 while (p!=passive->GetVectorLength()) 00304 { 00305 if(std::abs(GetEnergy(m_tmp-1)-passive->GetEnergy(p))/passive->GetEnergy(p)>0.001) 00306 //if(std::abs(GetEnergy(m)-passive->GetEnergy(p))/passive->GetEnergy(p)>0.001) 00307 { 00308 SetData(m_tmp, passive->GetEnergy(p), passive->GetXsec(p)); 00309 theManager.AppendScheme(m_tmp++, active->GetScheme(p)); 00310 } 00311 p++; 00312 } 00313 }
G4NeutronHPVector & G4NeutronHPVector::operator= | ( | const G4NeutronHPVector & | right | ) |
Definition at line 121 of file G4NeutronHPVector.cc.
References GetPoint(), label, nEntries, SetPoint(), the15percentBorderCash, the50percentBorderCash, theHash, theIntegral, theManager, totalIntegral, and Verbose.
00122 { 00123 if(&right == this) return *this; 00124 00125 G4int i; 00126 00127 totalIntegral = right.totalIntegral; 00128 if(right.theIntegral!=0) theIntegral = new G4double[right.nEntries]; 00129 for(i=0; i<right.nEntries; i++) 00130 { 00131 SetPoint(i, right.GetPoint(i)); // copy theData 00132 if(right.theIntegral!=0) theIntegral[i] = right.theIntegral[i]; 00133 } 00134 theManager = right.theManager; 00135 label = right.label; 00136 00137 Verbose = right.Verbose; 00138 the15percentBorderCash = right.the15percentBorderCash; 00139 the50percentBorderCash = right.the50percentBorderCash; 00140 theHash = right.theHash; 00141 return *this; 00142 }
void G4NeutronHPVector::ReHash | ( | ) | [inline] |
Definition at line 144 of file G4NeutronHPVector.hh.
References G4NeutronHPHash::Clear(), and Hash().
Referenced by Merge(), and ThinOut().
G4double G4NeutronHPVector::Sample | ( | ) |
Definition at line 348 of file G4NeutronHPVector.cc.
References G4cout, G4endl, G4UniformRand, GetVectorLength(), G4NeutronHPDataPoint::GetX(), GetX(), G4NeutronHPDataPoint::GetY(), GetY(), IntegrateAndNormalise(), and SetY().
Referenced by G4NeutronHPPhotonDist::GetPhotons(), G4NeutronHPPartial::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPEvapSpectrum::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), and G4NeutronHPArbitaryTab::Sample().
00349 { 00350 G4double result; 00351 G4int j; 00352 for(j=0; j<GetVectorLength(); j++) 00353 { 00354 if(GetY(j)<0) SetY(j, 0); 00355 } 00356 00357 if(theBuffered.size() !=0 && G4UniformRand()<0.5) 00358 { 00359 result = theBuffered[0]; 00360 theBuffered.erase(theBuffered.begin()); 00361 if(result < GetX(GetVectorLength()-1) ) return result; 00362 } 00363 if(GetVectorLength()==1) 00364 { 00365 result = theData[0].GetX(); 00366 } 00367 else 00368 { 00369 if(theIntegral==0) { IntegrateAndNormalise(); } 00370 do 00371 { 00372 //080808 00373 /* 00374 G4double rand; 00375 G4double value, test, baseline; 00376 baseline = theData[GetVectorLength()-1].GetX()-theData[0].GetX(); 00377 do 00378 { 00379 value = baseline*G4UniformRand(); 00380 value += theData[0].GetX(); 00381 test = GetY(value)/maxValue; 00382 rand = G4UniformRand(); 00383 } 00384 //while(test<rand); 00385 while( test < rand && test > 0 ); 00386 result = value; 00387 */ 00388 G4double rand; 00389 G4double value, test; 00390 do 00391 { 00392 rand = G4UniformRand(); 00393 G4int ibin = -1; 00394 for ( G4int i = 0 ; i < GetVectorLength() ; i++ ) 00395 { 00396 if ( rand < theIntegral[i] ) 00397 { 00398 ibin = i; 00399 break; 00400 } 00401 } 00402 if ( ibin < 0 ) G4cout << "TKDB 080807 " << rand << G4endl; 00403 // result 00404 rand = G4UniformRand(); 00405 G4double x1, x2; 00406 if ( ibin == 0 ) 00407 { 00408 x1 = theData[ ibin ].GetX(); 00409 value = x1; 00410 break; 00411 } 00412 else 00413 { 00414 x1 = theData[ ibin-1 ].GetX(); 00415 } 00416 00417 x2 = theData[ ibin ].GetX(); 00418 value = rand * ( x2 - x1 ) + x1; 00419 //*********************************************************************** 00420 /* 00421 test = GetY ( value ) / std::max ( GetY( ibin-1 ) , GetY ( ibin ) ); 00422 */ 00423 //*********************************************************************** 00424 //EMendoza - Always linear interpolation: 00425 G4double y1=theData[ ibin-1 ].GetY(); 00426 G4double y2=theData[ ibin ].GetY(); 00427 G4double mval=(y2-y1)/(x2-x1); 00428 G4double bval=y1-mval*x1; 00429 test =(mval*value+bval)/std::max ( GetY( ibin-1 ) , GetY ( ibin ) ); 00430 //*********************************************************************** 00431 } 00432 while ( G4UniformRand() > test ); 00433 result = value; 00434 //080807 00435 } 00436 while(IsBlocked(result)); 00437 } 00438 return result; 00439 }
G4double G4NeutronHPVector::SampleLin | ( | ) | [inline] |
Definition at line 318 of file G4NeutronHPVector.hh.
References G4UniformRand, GetVectorLength(), G4NeutronHPDataPoint::GetX(), IntegrateAndNormalise(), and G4NeutronHPInterpolator::Lin().
00319 { 00320 G4double result; 00321 if(theIntegral==0) IntegrateAndNormalise(); 00322 if(GetVectorLength()==1) 00323 { 00324 result = theData[0].GetX(); 00325 } 00326 else 00327 { 00328 G4int i; 00329 G4double rand = G4UniformRand(); 00330 00331 // this was replaced 00332 // for(i=1;i<GetVectorLength();i++) 00333 // { 00334 // if(rand<theIntegral[i]/theIntegral[GetVectorLength()-1]) break; 00335 // } 00336 00337 // by this (begin) 00338 for(i=GetVectorLength()-1; i>=0 ;i--) 00339 { 00340 if(rand>theIntegral[i]/theIntegral[GetVectorLength()-1]) break; 00341 } 00342 if(i!=GetVectorLength()-1) i++; 00343 // until this (end) 00344 00345 G4double x1, x2, y1, y2; 00346 y1 = theData[i-1].GetX(); 00347 x1 = theIntegral[i-1]; 00348 y2 = theData[i].GetX(); 00349 x2 = theIntegral[i]; 00350 if(std::abs((y2-y1)/y2)<0.0000001) // not really necessary, since the case is excluded by construction 00351 { 00352 y1 = theData[i-2].GetX(); 00353 x1 = theIntegral[i-2]; 00354 } 00355 result = theLin.Lin(rand, x1, x2, y1, y2); 00356 } 00357 return result; 00358 }
Definition at line 90 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::SetData().
Referenced by G4NeutronHPPartial::GetY(), G4NeutronHPElementData::Harmonise(), G4NeutronHPChannel::Harmonise(), G4NeutronIsoIsoCrossSections::Init(), Init(), Merge(), operator+(), G4NeutronHPLegendreStore::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), and SetPoint().
00091 { 00092 // G4cout <<"G4NeutronHPVector::SetData called"<<nPoints<<" "<<nEntries<<G4endl; 00093 Check(i); 00094 if(y>maxValue) maxValue=y; 00095 theData[i].SetData(x, y); 00096 }
Definition at line 102 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::SetX().
00103 { 00104 Check(i); 00105 theData[i].SetX(e); 00106 }
void G4NeutronHPVector::SetInterpolationManager | ( | G4InterpolationManager & | aMan | ) | [inline] |
void G4NeutronHPVector::SetInterpolationManager | ( | const G4InterpolationManager & | aManager | ) | [inline] |
Definition at line 477 of file G4NeutronHPVector.hh.
Referenced by G4NeutronHPPartial::GetY(), G4NeutronHPPartial::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), and G4NeutronHPContAngularPar::Sample().
void G4NeutronHPVector::SetLabel | ( | G4double | aLabel | ) | [inline] |
Definition at line 245 of file G4NeutronHPVector.hh.
Referenced by G4NeutronHPLabAngularEnergy::Init(), and G4NeutronHPArbitaryTab::Init().
void G4NeutronHPVector::SetPoint | ( | G4int | i, | |
const G4NeutronHPDataPoint & | it | |||
) | [inline] |
Definition at line 83 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::GetX(), G4NeutronHPDataPoint::GetY(), and SetData().
Referenced by G4NeutronHPIsoData::FillChannelData(), and operator=().
void G4NeutronHPVector::SetScheme | ( | G4int | aPoint, | |
const G4InterpolationScheme & | aScheme | |||
) | [inline] |
Definition at line 492 of file G4NeutronHPVector.hh.
References G4InterpolationManager::AppendScheme().
Referenced by G4NeutronHPPartial::GetY(), and G4NeutronHPPartial::Sample().
00493 { 00494 theManager.AppendScheme(aPoint, aScheme); 00495 }
void G4NeutronHPVector::SetVerbose | ( | G4int | ff | ) | [inline] |
Definition at line 97 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::SetX().
Referenced by G4NeutronHPPartial::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), and G4NeutronHPPartial::SetX().
00098 { 00099 Check(i); 00100 theData[i].SetX(e); 00101 }
Definition at line 113 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::SetY().
00114 { 00115 Check(i); 00116 if(x>maxValue) maxValue=x; 00117 theData[i].SetY(x); 00118 }
Definition at line 107 of file G4NeutronHPVector.hh.
References G4NeutronHPDataPoint::SetY().
Referenced by Sample(), G4NeutronHPPartial::Sample(), G4NeutronHPLabAngularEnergy::Sample(), G4NeutronHPDiscreteTwoBody::Sample(), G4NeutronHPContAngularPar::Sample(), G4NeutronHPPartial::SetY(), and Times().
00108 { 00109 Check(i); 00110 if(x>maxValue) maxValue=x; 00111 theData[i].SetY(x); 00112 }
void G4NeutronHPVector::ThinOut | ( | G4double | precision | ) |
Definition at line 285 of file G4NeutronHPVector.cc.
References GetVectorLength(), GetX(), G4NeutronHPDataPoint::GetX(), GetY(), G4NeutronHPDataPoint::GetY(), G4NeutronHPInterpolator::Lin(), G4NeutronHPHash::Prepared(), and ReHash().
Referenced by G4NeutronHPElementData::Init(), operator+(), and G4NeutronHPIsoData::ThinOut().
00286 { 00287 // anything in there? 00288 if(GetVectorLength()==0) return; 00289 // make the new vector 00290 G4NeutronHPDataPoint * aBuff = new G4NeutronHPDataPoint[nPoints]; 00291 G4double x, x1, x2, y, y1, y2; 00292 G4int count = 0, current = 2, start = 1; 00293 00294 // First element always goes and is never tested. 00295 aBuff[0] = theData[0]; 00296 00297 // Find the rest 00298 while(current < GetVectorLength()) 00299 { 00300 x1=aBuff[count].GetX(); 00301 y1=aBuff[count].GetY(); 00302 x2=theData[current].GetX(); 00303 y2=theData[current].GetY(); 00304 for(G4int j=start; j<current; j++) 00305 { 00306 x = theData[j].GetX(); 00307 if(x1-x2 == 0) y = (y2+y1)/2.; 00308 else y = theInt.Lin(x, x1, x2, y1, y2); 00309 if (std::abs(y-theData[j].GetY())>precision*y) 00310 { 00311 aBuff[++count] = theData[current-1]; // for this one, everything was fine 00312 start = current; // the next candidate 00313 break; 00314 } 00315 } 00316 current++ ; 00317 } 00318 // The last one also always goes, and is never tested. 00319 aBuff[++count] = theData[GetVectorLength()-1]; 00320 delete [] theData; 00321 theData = aBuff; 00322 nEntries = count+1; 00323 00324 // Rebuild the Hash; 00325 if(theHash.Prepared()) 00326 { 00327 ReHash(); 00328 } 00329 }
void G4NeutronHPVector::Times | ( | G4double | factor | ) | [inline] |
Definition at line 70 of file G4NeutronHPVector.hh.
References GetY(), and SetY().
Referenced by G4NeutronIsoIsoCrossSections::Init(), and G4NeutronHPChannel::UpdateData().
00071 { 00072 G4int i; 00073 for(i=0; i<nEntries; i++) 00074 { 00075 theData[i].SetY(theData[i].GetY()*factor); 00076 } 00077 if(theIntegral!=0) 00078 { 00079 theIntegral[i] *= factor; 00080 } 00081 }
G4NeutronHPVector& operator+ | ( | G4NeutronHPVector & | left, | |
G4NeutronHPVector & | right | |||
) | [friend] |
Definition at line 37 of file G4NeutronHPVector.cc.
00038 { 00039 G4NeutronHPVector * result = new G4NeutronHPVector; 00040 G4int j=0; 00041 G4double x; 00042 G4double y; 00043 G4int running = 0; 00044 for(G4int i=0; i<left.GetVectorLength(); i++) 00045 { 00046 while(j<right.GetVectorLength()) 00047 { 00048 if(right.GetX(j)<left.GetX(i)*1.001) 00049 { 00050 x = right.GetX(j); 00051 y = right.GetY(j)+left.GetY(x); 00052 result->SetData(running++, x, y); 00053 j++; 00054 } 00055 //else if(std::abs((right.GetX(j)-left.GetX(i))/(left.GetX(i)+right.GetX(j)))>0.001) 00056 else if( left.GetX(i)+right.GetX(j) == 0 00057 || std::abs((right.GetX(j)-left.GetX(i))/(left.GetX(i)+right.GetX(j))) > 0.001 ) 00058 { 00059 x = left.GetX(i); 00060 y = left.GetY(i)+right.GetY(x); 00061 result->SetData(running++, x, y); 00062 break; 00063 } 00064 else 00065 { 00066 break; 00067 } 00068 } 00069 if(j==right.GetVectorLength()) 00070 { 00071 x = left.GetX(i); 00072 y = left.GetY(i)+right.GetY(x); 00073 result->SetData(running++, x, y); 00074 } 00075 } 00076 result->ThinOut(0.02); 00077 return *result; 00078 }