69std::vector<G4double>* G4LossTableBuilder::theDensityFactor =
nullptr;
70std::vector<G4int>* G4LossTableBuilder::theDensityIdx =
nullptr;
71std::vector<G4bool>* G4LossTableBuilder::theFlag =
nullptr;
82 isInitialized =
false;
83 if(isMaster || !theFlag) {
86 if(isMaster || !theFlag) {
89 theDensityFactor =
new std::vector<G4double>;
90 theDensityIdx =
new std::vector<G4int>;
91 theFlag =
new std::vector<G4bool>;
106 delete theDensityFactor;
107 delete theDensityIdx;
109 theDensityFactor =
nullptr;
110 theDensityIdx =
nullptr;
119 return theDensityIdx;
126 return theDensityFactor;
134 return (idx < theFlag->size()) ? (*theFlag)[idx] :
false;
141 const std::vector<G4PhysicsTable*>& list)
144 size_t n_processes = list.size();
147 if(1 >= n_processes) {
return; }
149 size_t nCouples = dedxTable->size();
150 if(0 >= nCouples) {
return; }
152 for (
size_t i=0; i<nCouples; ++i) {
158 for (
size_t j=0; j<npoints; ++j) {
160 for (
size_t k=0; k<n_processes; ++k) {
179 size_t nCouples = dedxTable->size();
180 if(0 >= nCouples) {
return; }
185 for (
size_t i=0; i<nCouples; ++i) {
187 if((pv ==
nullptr) || (useBM && !(*theFlag)[i])) {
continue; }
199 for (
size_t k=1; k<npoints; ++k) {
203 if(dedx1 > 0.0) {
break; }
212 if(npoints < 2) { npoints = 2; }
214 delete (*rangeTable)[i];
234 for (
size_t j=1; j<npoints; ++j) {
237 G4double de = (energy2 - energy1) * del;
242 for (
size_t k=0; k<n; ++k) {
244 dedx1 = pv->
Value(energy);
245 if(dedx1 > 0.0) { sum += de/dedx1; }
264 size_t nCouples = rangeTable->size();
265 if(0 >= nCouples) {
return; }
267 for (
size_t i=0; i<nCouples; ++i) {
269 if((pv ==
nullptr) || (useBM && !(*theFlag)[i])) {
continue; }
274 delete (*invRangeTable)[i];
278 for (
size_t j=0; j<npoints; ++j) {
293 if(!isMaster) {
return; }
297 size_t nFlags = theFlag->size();
298 if(isInitialized && nFlags == nCouples) {
return; }
300 isInitialized =
true;
302 theDensityFactor->reserve(nCouples);
303 theDensityIdx->reserve(nCouples);
304 theFlag->reserve(nCouples);
306 for(
size_t i=0; i<nFlags; ++i) {
307 (*theFlag)[i] = (table) ? table->
GetFlag(i) :
true;
309 for(
size_t i=nFlags; i<nCouples; ++i) {
311 theDensityFactor->push_back(1.0);
312 theDensityIdx->push_back(i);
313 theFlag->push_back(yes);
316 for(
size_t i=0; i<nCouples; ++i) {
321 auto mat = couple->GetMaterial();
322 auto bmat = mat->GetBaseMaterial();
326 for(
size_t j=0; j<nCouples; ++j) {
327 if(j == i) {
continue; }
330 if(bcouple->GetMaterial() == bmat &&
331 bcouple->GetProductionCuts() == pcuts) {
334 (*theDensityFactor)[i] = mat->GetDensity()/bmat->GetDensity();
335 (*theDensityIdx)[i] = j;
336 (*theFlag)[i] =
false;
339 (*theDensityFactor)[j] = 1.0;
340 (*theDensityIdx)[j] = j;
341 (*theFlag)[j] =
true;
368 if(!table) {
return table; }
386 for(
size_t i=0; i<numOfCouples; ++i) {
398 if(0.0 >= tmin) { tmin = CLHEP::eV; }
404 n *= (
G4int)(std::log10(emax/tmin) + 0.5);
413 for(
G4int j=0; j<=n; ++j) {
#define G4MUTEX_INITIALIZER
#define G4MUTEXLOCK(mutex)
#define G4MUTEXUNLOCK(mutex)
static G4EmParameters * Instance()
G4int NumberOfBinsPerDecade() const
void PutValues(std::size_t index, G4double e, G4double dataValue)
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool useBM=false)
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool useBM=false)
void BuildDEDXTable(G4PhysicsTable *dedxTable, const std::vector< G4PhysicsTable * > &)
const std::vector< G4double > * GetDensityFactors() const
const std::vector< G4int > * GetCoupleIndexes() const
virtual ~G4LossTableBuilder()
void InitialiseBaseMaterials(const G4PhysicsTable *table=nullptr)
G4PhysicsTable * BuildTableForModel(G4PhysicsTable *table, G4VEmModel *model, const G4ParticleDefinition *, G4double emin, G4double emax, G4bool spline)
G4bool GetFlag(size_t idx)
G4LossTableBuilder(G4bool master=true)
G4ProductionCuts * GetProductionCuts() const
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
static void SetPhysicsVector(G4PhysicsTable *physTable, std::size_t idx, G4PhysicsVector *vec)
G4bool GetFlag(std::size_t i) const
G4double Energy(std::size_t index) const
G4double Value(G4double theEnergy, std::size_t &lastidx) const
void PutValue(std::size_t index, G4double theValue)
void FillSecondDerivatives()
std::size_t GetVectorLength() const
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
std::size_t GetTableSize() const
static G4ProductionCutsTable * GetProductionCutsTable()
virtual G4double MinPrimaryEnergy(const G4Material *, const G4ParticleDefinition *, G4double cut=0.0)
virtual G4double Value(const G4MaterialCutsCouple *, const G4ParticleDefinition *, G4double kineticEnergy)
G4bool UseBaseMaterials() const