126 for (
G4int i=0; i<n_loss; ++i) {
128 if( loss_vector[i] ) {
129 delete loss_vector[i];
132 size_t msc = msc_vector.size();
133 for (
size_t j=0; j<msc; ++j) {
134 if( msc_vector[j] ) {
delete msc_vector[j]; }
136 size_t emp = emp_vector.size();
137 for (
size_t k=0; k<emp; ++k) {
138 if( emp_vector[k] ) {
delete emp_vector[k]; }
140 size_t mod = mod_vector.size();
141 size_t fmod = fmod_vector.size();
143 for (
size_t a=0; a<mod; ++a) {
145 if(
nullptr != mod_vector[a] ) {
146 for (
size_t b=0; b<fmod; ++b) {
147 if((
G4VEmModel*)(fmod_vector[b]) == mod_vector[a]) {
148 fmod_vector[b] =
nullptr;
151 delete mod_vector[a];
152 mod_vector[a] =
nullptr;
155 for (
size_t b=0; b<fmod; ++b) {
156 if( fmod_vector[b] ) {
delete fmod_vector[b]; }
160 delete emCorrections;
161 delete emConfigurator;
162 delete emElectronIonPair;
163 delete atomDeexcitation;
164 delete subcutProducer;
169 G4LossTableManager::G4LossTableManager()
175 startInitialisation =
false;
176 all_tables_are_built =
false;
177 currentLoss =
nullptr;
178 currentParticle =
nullptr;
179 firstParticle =
nullptr;
181 verbose = theParameters->
Verbose();
183 theGenericIon=
nullptr;
190 emConfigurator =
nullptr;
191 emElectronIonPair =
nullptr;
192 atomDeexcitation =
nullptr;
193 subcutProducer =
nullptr;
200 all_tables_are_built =
false;
201 currentLoss =
nullptr;
202 currentParticle =
nullptr;
206 range_vector.clear();
207 inv_range_vector.clear();
211 base_part_vector.clear();
212 tables_are_built.clear();
223 for (
G4int i=0; i<n_loss; ++i) {
224 if(loss_vector[i] == p) {
return; }
227 G4cout <<
"G4LossTableManager::Register G4VEnergyLossProcess : "
231 loss_vector.push_back(p);
232 part_vector.push_back(
nullptr);
233 base_part_vector.push_back(
nullptr);
234 dedx_vector.push_back(
nullptr);
235 range_vector.push_back(
nullptr);
236 inv_range_vector.push_back(
nullptr);
237 tables_are_built.push_back(
false);
238 isActive.push_back(
true);
239 all_tables_are_built =
false;
244 void G4LossTableManager::ResetParameters()
246 verbose = theParameters->
Verbose();
253 if(emConfigurator) { emConfigurator->
SetVerbose(verbose); };
254 if(emElectronIonPair) { emElectronIonPair->
SetVerbose(verbose); };
255 if(atomDeexcitation) {
266 for (
G4int i=0; i<n_loss; ++i) {
267 if(loss_vector[i] == p) { loss_vector[i] =
nullptr; }
276 G4int n = msc_vector.size();
277 for (
G4int i=0; i<
n; ++i) {
278 if(msc_vector[i] == p) {
return; }
281 G4cout <<
"G4LossTableManager::Register G4VMultipleScattering : "
284 msc_vector.push_back(p);
292 size_t msc = msc_vector.size();
293 for (
size_t i=0; i<msc; ++i) {
294 if(msc_vector[i] == p) { msc_vector[i] =
nullptr; }
303 G4int n = emp_vector.size();
304 for (
G4int i=0; i<
n; ++i) {
305 if(emp_vector[i] == p) {
return; }
308 G4cout <<
"G4LossTableManager::Register G4VEmProcess : "
311 emp_vector.push_back(p);
319 size_t emp = emp_vector.size();
320 for (
size_t i=0; i<emp; ++i) {
321 if(emp_vector[i] == p) { emp_vector[i] =
nullptr; }
329 mod_vector.push_back(p);
331 G4cout <<
"G4LossTableManager::Register G4VEmModel : "
332 << p->
GetName() <<
" " << p <<
" " << mod_vector.size() <<
G4endl;
341 size_t n = mod_vector.size();
342 for (
size_t i=0; i<
n; ++i) {
343 if(mod_vector[i] == p) {
344 mod_vector[i] =
nullptr;
354 fmod_vector.push_back(p);
356 G4cout <<
"G4LossTableManager::Register G4VEmFluctuationModel : "
365 size_t n = fmod_vector.size();
366 for (
size_t i=0; i<
n; ++i) {
367 if(fmod_vector[i] == p) { fmod_vector[i] =
nullptr; }
377 if(!p || !part) {
return; }
378 for (
G4int i=0; i<n_loss; ++i) {
379 if(loss_vector[i] == p) {
return; }
382 G4cout <<
"G4LossTableManager::RegisterExtraParticle "
387 loss_vector.push_back(p);
388 part_vector.push_back(part);
390 dedx_vector.push_back(
nullptr);
391 range_vector.push_back(
nullptr);
392 inv_range_vector.push_back(
nullptr);
393 tables_are_built.push_back(
false);
394 all_tables_are_built =
false;
405 G4cout <<
"G4LossTableManager::PreparePhysicsTable for "
408 <<
" loss_vector " << loss_vector.size() <<
G4endl;
411 isMaster = theMaster;
413 if(!startInitialisation) {
416 G4cout <<
"====== G4LossTableManager::PreparePhysicsTable start ====="
423 if(emConfigurator) { emConfigurator->
PrepareModels(particle, p); }
426 for (
G4int j=0; j<n_loss; ++j) {
427 if (p == loss_vector[j] && !part_vector[j]) {
428 part_vector[j] = particle;
430 theGenericIon = particle;
435 startInitialisation =
true;
445 G4cout <<
"G4LossTableManager::PreparePhysicsTable for "
449 isMaster = theMaster;
451 if(!startInitialisation) {
454 G4cout <<
"====== G4LossTableManager::PreparePhysicsTable start ====="
461 if(emConfigurator) { emConfigurator->
PrepareModels(particle, p); }
463 startInitialisation =
true;
474 G4cout <<
"G4LossTableManager::PreparePhysicsTable for "
479 isMaster = theMaster;
481 if(!startInitialisation) {
484 G4cout <<
"====== G4LossTableManager::PreparePhysicsTable start ====="
491 if(emConfigurator) { emConfigurator->
PrepareModels(particle, p); }
493 startInitialisation =
true;
501 if(-1 == run && startInitialisation) {
502 if(emConfigurator) { emConfigurator->
Clear(); }
513 G4cout <<
"### G4LossTableManager::LocalPhysicsTable() for "
519 if(-1 == run && startInitialisation) {
520 if(emConfigurator) { emConfigurator->
Clear(); }
521 firstParticle = aParticle;
524 if(startInitialisation) {
527 G4cout <<
"===== G4LossTableManager::LocalPhysicsTable() for run "
528 << run <<
" =====" <<
G4endl;
530 currentParticle =
nullptr;
531 startInitialisation =
false;
532 for (
G4int i=0; i<n_loss; ++i) {
534 tables_are_built[i] =
false;
536 tables_are_built[i] =
true;
537 part_vector[i] =
nullptr;
542 all_tables_are_built=
true;
543 for (
G4int i=0; i<n_loss; ++i) {
544 if(p == loss_vector[i]) {
545 tables_are_built[i] =
true;
553 loss_map[part_vector[i]] =
p;
561 G4cout <<
" for " << part_vector[i]->GetParticleName();
563 G4cout <<
" active= " << isActive[i]
564 <<
" table= " << tables_are_built[i]
569 }
else if(!tables_are_built[i]) {
570 all_tables_are_built =
false;
575 G4cout <<
"### G4LossTableManager::LocalPhysicsTable end"
578 if(all_tables_are_built) {
580 G4cout <<
"%%%%% All dEdx and Range tables for worker are ready for run "
581 << run <<
" %%%%%" <<
G4endl;
593 G4cout <<
"### G4LossTableManager::BuildPhysicsTable() for "
598 if(-1 == run && startInitialisation) {
599 if(emConfigurator) { emConfigurator->
Clear(); }
600 firstParticle = aParticle;
602 if(startInitialisation) {
605 G4cout <<
"===== G4LossTableManager::BuildPhysicsTable() for run "
606 << run <<
" ===== " << atomDeexcitation <<
G4endl;
608 currentParticle =
nullptr;
609 all_tables_are_built=
true;
613 if ( startInitialisation && aParticle == firstParticle ) {
615 startInitialisation =
false;
617 G4cout <<
"### G4LossTableManager start initilisation for first particle "
621 for (
G4int i=0; i<n_loss; ++i) {
627 tables_are_built[i] =
false;
628 all_tables_are_built=
false;
631 tables_are_built[i] =
true;
639 G4cout <<
" active= " << isActive[i]
640 <<
" table= " << tables_are_built[i]
642 if(base_part_vector[i]) {
643 G4cout <<
" base particle "
644 << base_part_vector[i]->GetParticleName();
649 tables_are_built[i] =
true;
650 part_vector[i] =
nullptr;
656 if (all_tables_are_built) {
return; }
659 all_tables_are_built =
true;
661 for(
G4int i=0; i<n_loss; ++i) {
662 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) {
667 <<
" " << tables_are_built[i] <<
" " << base_part_vector[i] <<
G4endl;
671 CopyTables(curr_part, curr_proc);
673 loss_map[aParticle] =
p;
679 if ( !tables_are_built[i] ) { all_tables_are_built =
false; }
682 G4cout <<
"### G4LossTableManager::BuildPhysicsTable end: "
683 <<
"all_tables_are_built= " << all_tables_are_built <<
" "
686 if(all_tables_are_built) {
688 G4cout <<
"%%%%% All dEdx and Range tables are built for master run= "
689 << run <<
" %%%%%" <<
G4endl;
699 for (
G4int j=0; j<n_loss; ++j) {
703 if (!tables_are_built[j] && part == base_part_vector[j]) {
704 tables_are_built[j] =
true;
717 loss_map[part_vector[j]] = proc;
723 <<
" for " << part_vector[j]->GetParticleName()
725 <<
" tables are assigned"
742 G4cout <<
"G4LossTableManager::BuildTables() for "
746 std::vector<G4PhysicsTable*> t_list;
747 std::vector<G4VEnergyLossProcess*> loss_list;
748 std::vector<G4bool> build_flags;
759 for (i=0; i<n_loss; ++i) {
762 G4bool yes = (aParticle == part_vector[i]);
767 for(
G4int j=0; j<nvec; ++j) {
769 if(ptr == (*pvec)[j]) {
776 if(yes && isActive[i]) {
783 if (!tables_are_built[i]) {
789 tables_are_built[i] =
true;
794 loss_list.push_back(p);
795 build_flags.push_back(val);
800 G4int n_dedx = t_list.size();
801 if (0 == n_dedx || !em) {
802 G4cout <<
"G4LossTableManager WARNING: no DEDX processes for "
809 G4cout <<
"G4LossTableManager::BuildTables() start to build range tables"
810 <<
" and the sum of " << n_dedx <<
" processes"
813 <<
" nSubRegions= " << nSubRegions;
820 if(subcutProducer) { nSubRegions = 0; }
842 dedx_vector[iem] = dedx;
846 range_vector[iem] = range;
850 inv_range_vector[iem] = invrange;
862 std::vector<G4PhysicsTable*> listSub;
863 std::vector<G4PhysicsTable*> listCSDA;
865 for (i=0; i<n_dedx; ++i) {
871 if (0 < nSubRegions) {
874 listSub.push_back(dedx);
883 listCSDA.push_back(dedx);
887 if (0 < nSubRegions) {
889 if (1 < listSub.size()) {
912 G4cout <<
"G4LossTableManager::BuildTables: Tables are built for "
923 void G4LossTableManager::ParticleHaveNoLoss(
927 ed <<
"Energy loss process not found for " << aParticle->
GetParticleName()
929 G4Exception(
"G4LossTableManager::ParticleHaveNoLoss",
"em0001",
942 const std::vector<G4VEnergyLossProcess*>&
957 const std::vector<G4VMultipleScattering*>&
975 return emConfigurator;
982 if(!emElectronIonPair) {
985 return emElectronIonPair;
992 if(atomDeexcitation != p) {
993 delete atomDeexcitation;
994 atomDeexcitation =
p;
1002 if(subcutProducer != p) {
1003 delete subcutProducer;
1012 G4String ss =
"G4LossTableManager::" + tit;
G4EmConfigurator * EmConfigurator()
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
void SetDEDXTable(G4PhysicsTable *p, G4EmTableType tType)
G4int WorkerVerbose() const
static G4LossTableManager * Instance()
void InitialiseAtomicDeexcitation()
std::ostringstream G4ExceptionDescription
void SetVerbose(G4int verb)
void SetIonisation(G4bool val)
G4PhysicsTable * SubLambdaTable() const
void DeRegister(G4VEnergyLossProcess *p)
G4PhysicsTable * RangeTableForLoss() const
void push_back(G4PhysicsVector *)
void AddCollaborativeProcess(G4VEnergyLossProcess *)
G4PhysicsTable * CSDARangeTable() const
const G4String & GetName() const
G4PhysicsTable * IonisationTableForSubsec() const
G4PhysicsTable * IonisationTable() const
const std::vector< G4VEmProcess * > & GetEmProcessVector()
G4PhysicsTable * BuildLambdaTable(G4EmTableType tType=fRestricted)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
const G4String & GetParticleName() const
void SetVerboseLevel(G4int)
void SetInitialisationFlag(G4bool flag)
G4bool BuildCSDARange() const
G4EmSaturation * GetEmSaturation()
G4PhysicsTable * LambdaTable() const
void SetInverseRangeTable(G4PhysicsTable *p)
const G4ParticleDefinition * SecondaryParticle() const
void SetSubCutProducer(G4VSubCutProducer *)
G4GLOB_DLL std::ostream G4cout
G4PhysicsTable * DEDXTable() const
G4ElectronIonPair * ElectronIonPair()
G4EmSaturation * EmSaturation()
G4int NumberOfSubCutoffRegions() const
void Register(G4VEnergyLossProcess *p)
const G4ParticleDefinition * BaseParticle() const
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
G4PhysicsTable * DEDXTableForSubsec() const
const G4String & GetProcessName() const
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
void RegisterExtraParticle(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void BuildDEDXTable(G4PhysicsTable *dedxTable, const std::vector< G4PhysicsTable * > &)
void SetVerbose(G4int value)
void SetLambdaTable(G4PhysicsTable *p)
const G4String & GetName() const
G4PhysicsTable * InverseRangeTable() const
void BuildPhysicsTable(const G4ParticleDefinition *aParticle)
const G4ParticleDefinition * Particle() const
G4ProcessManager * GetProcessManager() const
void PrepareModels(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
static G4EmParameters * Instance()
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p, G4bool theMaster)
void SetCSDARangeTable(G4PhysicsTable *pRange)
void SetVerbose(G4int val)
void LocalPhysicsTables(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
static G4Electron * Electron()
const G4String & GetName() const
void SetSecondaryRangeTable(G4PhysicsTable *p)
G4PhysicsTable * DEDXunRestrictedTable() const
void SetSubLambdaTable(G4PhysicsTable *p)
void SetRangeTableForLoss(G4PhysicsTable *p)
void SetAtomDeexcitation(G4VAtomDeexcitation *)
G4PhysicsTable * BuildDEDXTable(G4EmTableType tType=fRestricted)
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
G4ProcessVector * GetProcessList() const
void SetSplineFlag(G4bool flag)
G4bool IsIonisationProcess() const