77 isInitialized =
false;
79 theDensityFactor =
new std::vector<G4double>;
80 theDensityIdx =
new std::vector<G4int>;
81 theFlag =
new std::vector<G4bool>;
88 delete theDensityFactor;
97 const std::vector<G4PhysicsTable*>& list)
99 size_t n_processes = list.size();
102 if(1 >= n_processes) {
return; }
104 size_t nCouples = dedxTable->size();
105 if(0 >= nCouples) {
return; }
107 for (
size_t i=0; i<nCouples; ++i) {
115 for (
size_t j=0; j<npoints; ++j) {
117 for (
size_t k=0; k<n_processes; ++k) {
136 size_t nCouples = dedxTable->size();
137 if(0 >= nCouples) {
return; }
142 for (
size_t i=0; i<nCouples; ++i) {
144 if( !(*theFlag)[i] ) {
continue; }
158 for (
size_t k=1; k<npoints; ++k) {
162 if(dedx1 > 0.0) {
break; }
171 if(npoints < 2) { npoints = 2; }
173 delete (*rangeTable)[i];
193 for (
size_t j=1; j<npoints; ++j) {
196 G4double de = (energy2 - energy1) * del;
201 for (
size_t k=0; k<
n; ++k) {
203 dedx1 = pv->
Value(energy);
204 if(dedx1 > 0.0) { sum += de/dedx1; }
223 size_t nCouples = rangeTable->size();
224 if(0 >= nCouples) {
return; }
226 for (
size_t i=0; i<nCouples; ++i) {
229 if( !(*theFlag)[i] ) {
continue; }
236 delete (*invRangeTable)[i];
240 for (
size_t j=0; j<npoints; ++j) {
256 size_t nCouples = table->size();
257 size_t nFlags = theFlag->size();
259 if(nCouples == nFlags && isInitialized) {
return; }
261 isInitialized =
true;
280 if(nFlags < nCouples) {
281 for(
size_t i=nFlags; i<nCouples; ++i) {
282 theDensityFactor->push_back(1.0);
284 for(
size_t i=nFlags; i<nCouples; ++i) { theDensityIdx->push_back(-1); }
285 for(
size_t i=nFlags; i<nCouples; ++i) { theFlag->push_back(
true); }
287 for(
size_t i=0; i<nCouples; ++i) {
291 (*theFlag)[i] = table->
GetFlag(i);
292 if ((*theDensityIdx)[i] < 0) {
293 (*theDensityIdx)[i] = i;
302 for(
size_t j=0; j<nCouples; ++j) {
304 if(j == i) {
continue; }
312 (*theDensityIdx)[i] = j;
314 (*theFlag)[i] =
false;
317 (*theDensityIdx)[j] = j;
318 (*theDensityFactor)[j] = 1.0;
319 (*theFlag)[j] =
true;
340 void G4LossTableBuilder::InitialiseCouples()
342 isInitialized =
true;
351 theDensityFactor->resize(nCouples, 1.0);
352 theDensityIdx->resize(nCouples, -1);
353 theFlag->resize(nCouples,
true);
355 for(
size_t i=0; i<nCouples; ++i) {
359 if ((*theDensityIdx)[i] < 0) {
360 (*theDensityIdx)[i] = i;
369 for(
size_t j=0; j<nCouples; ++j) {
371 if(j == i) {
continue; }
379 (*theDensityIdx)[i] = j;
381 (*theFlag)[i] =
false;
384 (*theDensityIdx)[j] = j;
385 (*theDensityFactor)[j] = 1.0;
386 (*theFlag)[j] =
true;
415 if(!table) {
return table; }
433 for(
size_t i=0; i<numOfCouples; ++i) {
449 if(0.0 >= tmin) { tmin =
eV; }
455 n *=
G4int(std::log10(emax/tmin) + 0.5);
462 for(
G4int j=0; j<=
n; ++j) {
G4int NumberOfBinsPerDecade() const
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
static void SetPhysicsVector(G4PhysicsTable *physTable, size_t idx, G4PhysicsVector *vec)
G4PhysicsTable * BuildTableForModel(G4PhysicsTable *table, G4VEmModel *model, const G4ParticleDefinition *, G4double emin, G4double emax, G4bool spline)
virtual G4double MinPrimaryEnergy(const G4Material *, const G4ParticleDefinition *, G4double cut=0.0)
G4double GetDensity() const
G4bool GetFlag(size_t idx) const
size_t GetVectorLength() const
void FillSecondDerivatives()
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
size_t GetTableSize() const
void PutValue(size_t index, G4double theValue)
static constexpr double eV
virtual ~G4LossTableBuilder()
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
G4double Energy(size_t index) const
G4double Value(G4double theEnergy, size_t &lastidx) const
static const G4double emax
void BuildDEDXTable(G4PhysicsTable *dedxTable, const std::vector< G4PhysicsTable * > &)
static G4ProductionCutsTable * GetProductionCutsTable()
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
void InitialiseBaseMaterials(G4PhysicsTable *table)
G4double energy(const ThreeVector &p, const G4double m)
static G4EmParameters * Instance()
const G4Material * GetBaseMaterial() const
void PutValues(size_t index, G4double e, G4double dataValue)
G4bool GetFlag(size_t i) const
G4ProductionCuts * GetProductionCuts() const
const XML_Char XML_Content * model
virtual G4double Value(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
const G4Material * GetMaterial() const