75 isInitialized =
false;
77 theDensityFactor =
new std::vector<G4double>;
78 theDensityIdx =
new std::vector<G4int>;
79 theFlag =
new std::vector<G4bool>;
86 delete theDensityFactor;
95 const std::vector<G4PhysicsTable*>& list)
97 size_t n_processes = list.size();
99 if(1 >= n_processes) {
return; }
101 size_t nCouples = dedxTable->size();
102 if(0 >= nCouples) {
return; }
104 for (
size_t i=0; i<nCouples; ++i) {
112 for (
size_t j=0; j<npoints; ++j) {
114 for (
size_t k=0; k<n_processes; ++k) {
133 size_t nCouples = dedxTable->size();
134 if(0 >= nCouples) {
return; }
139 for (
size_t i=0; i<nCouples; ++i) {
141 if( !(*theFlag)[i] ) {
continue; }
154 for (
size_t k=1; k<npoints; ++k) {
158 if(dedx1 > 0.0) {
break; }
167 if(npoints < 2) { npoints = 2; }
169 delete (*rangeTable)[i];
189 for (
size_t j=1; j<npoints; ++j) {
192 G4double de = (energy2 - energy1) * del;
197 for (
size_t k=0; k<n; ++k) {
199 dedx1 = pv->
Value(energy);
200 if(dedx1 > 0.0) { sum += de/dedx1; }
218 size_t nCouples = rangeTable->size();
219 if(0 >= nCouples) {
return; }
221 for (
size_t i=0; i<nCouples; ++i) {
224 if( !(*theFlag)[i] ) {
continue; }
231 delete (*invRangeTable)[i];
235 for (
size_t j=0; j<npoints; ++j) {
251 size_t nCouples = table->size();
252 size_t nFlags = theFlag->size();
254 if(nCouples == nFlags && isInitialized) {
return; }
256 isInitialized =
true;
275 if(nFlags < nCouples) {
276 for(
size_t i=nFlags; i<nCouples; ++i) { theDensityFactor->push_back(1.0); }
277 for(
size_t i=nFlags; i<nCouples; ++i) { theDensityIdx->push_back(-1); }
278 for(
size_t i=nFlags; i<nCouples; ++i) { theFlag->push_back(
true); }
280 for(
size_t i=0; i<nCouples; ++i) {
284 (*theFlag)[i] = table->
GetFlag(i);
285 if ((*theDensityIdx)[i] < 0) {
286 (*theDensityIdx)[i] = i;
295 for(
size_t j=0; j<nCouples; ++j) {
297 if(j == i) {
continue; }
305 (*theDensityIdx)[i] = j;
307 (*theFlag)[i] =
false;
310 (*theDensityIdx)[j] = j;
311 (*theDensityFactor)[j] = 1.0;
312 (*theFlag)[j] =
true;
333void G4LossTableBuilder::InitialiseCouples()
335 isInitialized =
true;
344 theDensityFactor->resize(nCouples, 1.0);
345 theDensityIdx->resize(nCouples, -1);
346 theFlag->resize(nCouples,
true);
348 for(
size_t i=0; i<nCouples; ++i) {
352 if ((*theDensityIdx)[i] < 0) {
353 (*theDensityIdx)[i] = i;
362 for(
size_t j=0; j<nCouples; ++j) {
364 if(j == i) {
continue; }
372 (*theDensityIdx)[i] = j;
374 (*theFlag)[i] =
false;
377 (*theDensityIdx)[j] = j;
378 (*theDensityFactor)[j] = 1.0;
379 (*theFlag)[j] =
true;
408 if(!table) {
return table; }
417 G4int nbins =
G4int(std::log10(emax/emin) + 0.5)
419 if(nbins < 3) { nbins = 3; }
429 for(
size_t i=0; i<numOfCouples; ++i) {
445 if(0.0 >= tmin) { tmin = eV; }
450 }
else if(tmin > emin) {
451 G4int bin = nbins*
G4int(std::log10(emax/tmin) + 0.5);
452 if(bin < 3) { bin = 3; }
456 }
else if(!bVector) {
466 for(
G4int j=0; j<n; ++j) {
void PutValues(size_t binNumber, G4double binValue, G4double dataValue)
void BuildDEDXTable(G4PhysicsTable *dedxTable, const std::vector< G4PhysicsTable * > &)
virtual ~G4LossTableBuilder()
G4PhysicsTable * BuildTableForModel(G4PhysicsTable *table, G4VEmModel *model, const G4ParticleDefinition *, G4double emin, G4double emax, G4bool spline)
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
void InitialiseBaseMaterials(G4PhysicsTable *table)
G4bool GetFlag(size_t idx) const
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
static G4LossTableManager * Instance()
G4int GetNumberOfBinsPerDecade() const
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
G4double GetDensity() const
const G4Material * GetBaseMaterial() const
static void SetPhysicsVector(G4PhysicsTable *physTable, size_t idx, G4PhysicsVector *vec)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
G4bool GetFlag(size_t i) const
G4double Value(G4double theEnergy)
size_t GetVectorLength() const
G4double Energy(size_t index) const
void FillSecondDerivatives()
void PutValue(size_t index, G4double theValue)
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
virtual G4double Value(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
virtual G4double MinPrimaryEnergy(const G4Material *, const G4ParticleDefinition *)