128 for (
G4int i=0; i<n_loss; ++i) {
129 if( loss_vector[i] ) {
delete loss_vector[i]; }
131 size_t msc = msc_vector.size();
132 for (
size_t j=0; j<msc; ++j) {
133 if( msc_vector[j] ) {
delete msc_vector[j]; }
135 size_t emp = emp_vector.size();
136 for (
size_t k=0; k<emp; ++k) {
137 if( emp_vector[k] ) {
delete emp_vector[k]; }
139 size_t mod = mod_vector.size();
140 size_t fmod = fmod_vector.size();
141 for (
size_t a=0;
a<mod; ++
a) {
142 if( mod_vector[
a] ) {
143 for (
size_t b=0;
b<fmod; ++
b) {
144 if((
G4VEmModel*)(fmod_vector[
b]) == mod_vector[a]) {
148 delete mod_vector[
a];
151 for (
size_t b=0;
b<fmod; ++
b) {
152 if( fmod_vector[
b] ) {
delete fmod_vector[
b]; }
157 delete emCorrections;
159 delete emConfigurator;
160 delete emElectronIonPair;
161 delete atomDeexcitation;
166 G4LossTableManager::G4LossTableManager()
170 startInitialisation =
false;
171 all_tables_are_built =
false;
175 lossFluctuationFlag =
true;
176 subCutoffFlag =
false;
177 rndmStepFlag =
false;
179 maxRangeVariation = 1.0;
181 minKinEnergy = 0.1*
keV;
182 maxKinEnergy = 10.0*
TeV;
185 maxKinEnergyForMuons = 10.*
TeV;
187 integralActive =
false;
188 buildCSDARange =
false;
189 minEnergyActive =
false;
190 maxEnergyActive =
false;
191 maxEnergyForMuonsActive =
false;
192 stepFunctionActive =
false;
197 factorForAngleLimit = 1.0;
208 atomDeexcitation = 0;
215 all_tables_are_built =
false;
221 range_vector.clear();
222 inv_range_vector.clear();
226 base_part_vector.clear();
227 tables_are_built.clear();
238 for (
G4int i=0; i<n_loss; ++i) {
239 if(loss_vector[i] == p) {
return; }
242 G4cout <<
"G4LossTableManager::Register G4VEnergyLossProcess : "
246 loss_vector.push_back(p);
247 part_vector.push_back(0);
248 base_part_vector.push_back(0);
249 dedx_vector.push_back(0);
250 range_vector.push_back(0);
251 inv_range_vector.push_back(0);
252 tables_are_built.push_back(
false);
253 isActive.push_back(
true);
254 all_tables_are_built =
false;
270 for (
G4int i=0; i<n_loss; ++i) {
271 if(loss_vector[i] == p) { loss_vector[i] = 0; }
280 G4int n = msc_vector.size();
281 for (
G4int i=0; i<
n; ++i) {
282 if(msc_vector[i] == p) {
return; }
285 G4cout <<
"G4LossTableManager::Register G4VMultipleScattering : "
288 msc_vector.push_back(p);
296 size_t msc = msc_vector.size();
297 for (
size_t i=0; i<msc; ++i) {
298 if(msc_vector[i] == p) { msc_vector[i] = 0; }
307 G4int n = emp_vector.size();
308 for (
G4int i=0; i<
n; ++i) {
309 if(emp_vector[i] == p) {
return; }
312 G4cout <<
"G4LossTableManager::Register G4VEmProcess : "
315 emp_vector.push_back(p);
323 size_t emp = emp_vector.size();
324 for (
size_t i=0; i<emp; ++i) {
325 if(emp_vector[i] == p) { emp_vector[i] = 0; }
333 mod_vector.push_back(p);
335 G4cout <<
"G4LossTableManager::Register G4VEmModel : "
344 size_t n = mod_vector.size();
345 for (
size_t i=0; i<
n; ++i) {
346 if(mod_vector[i] == p) { mod_vector[i] = 0; }
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] = 0; }
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(0);
391 range_vector.push_back(0);
392 inv_range_vector.push_back(0);
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 ====="
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 ====="
463 startInitialisation =
true;
474 G4cout <<
"G4LossTableManager::PreparePhysicsTable for "
479 isMaster = theMaster;
481 if(!startInitialisation) {
484 G4cout <<
"====== G4LossTableManager::PreparePhysicsTable start ====="
493 startInitialisation =
true;
501 if(-1 == run && startInitialisation) {
502 emConfigurator->
Clear();
513 G4cout <<
"### G4LossTableManager::SlavePhysicsTable() for "
519 if(-1 == run && startInitialisation) {
520 emConfigurator->
Clear();
521 firstParticle = aParticle;
524 if(startInitialisation) {
527 G4cout <<
"===== G4LossTableManager::SlavePhysicsTable() for run "
528 << run <<
" =====" <<
G4endl;
530 if(atomDeexcitation) {
534 startInitialisation =
false;
535 for (
G4int i=0; i<n_loss; ++i) {
537 tables_are_built[i] =
false;
539 tables_are_built[i] =
true;
545 all_tables_are_built=
true;
546 for (
G4int i=0; i<n_loss; ++i) {
547 if(p == loss_vector[i]) {
548 tables_are_built[i] =
true;
561 loss_map[part_vector[i]] = loss_vector[i];
567 G4cout <<
" for " << part_vector[i]->GetParticleName();
569 G4cout <<
" active= " << isActive[i]
570 <<
" table= " << tables_are_built[i]
575 }
else if(!tables_are_built[i]) {
576 all_tables_are_built =
false;
581 SetParameters(aParticle, p);
584 G4cout <<
"### G4LossTableManager::SlavePhysicsTable end"
587 if(all_tables_are_built) {
589 G4cout <<
"%%%%% All dEdx and Range tables for worker are ready for run "
590 << run <<
" %%%%%" <<
G4endl;
602 G4cout <<
"### G4LossTableManager::BuildPhysicsTable() for "
607 if(-1 == run && startInitialisation) {
608 emConfigurator->
Clear();
609 firstParticle = aParticle;
611 if(startInitialisation) {
614 G4cout <<
"===== G4LossTableManager::BuildPhysicsTable() for run "
615 << run <<
" =====" <<
G4endl;
617 if(atomDeexcitation) {
621 startInitialisation =
false;
622 all_tables_are_built=
true;
626 if ( aParticle == firstParticle ) {
629 G4cout <<
"### G4LossTableManager start initilisation for first particle "
633 for (
G4int i=0; i<n_loss; ++i) {
644 tables_are_built[i] =
false;
645 all_tables_are_built=
false;
648 tables_are_built[i] =
true;
656 G4cout <<
" active= " << isActive[i]
657 <<
" table= " << tables_are_built[i]
659 if(base_part_vector[i]) {
660 G4cout <<
" base particle "
661 << base_part_vector[i]->GetParticleName();
666 tables_are_built[i] =
true;
674 SetParameters(aParticle, p);
676 if (all_tables_are_built) {
return; }
679 all_tables_are_built =
true;
681 for(
G4int i=0; i<n_loss; ++i) {
682 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) {
689 if(curr_proc) { CopyTables(curr_part, curr_proc); }
691 if ( !tables_are_built[i] ) { all_tables_are_built =
false; }
696 G4cout <<
"### G4LossTableManager::BuildPhysicsTable end: "
697 <<
"all_tables_are_built= " << all_tables_are_built
700 if(all_tables_are_built) {
702 G4cout <<
"%%%%% All dEdx and Range tables are built for master run= "
703 << run <<
" %%%%%" <<
G4endl;
713 for (
G4int j=0; j<n_loss; ++j) {
717 if (!tables_are_built[j] && part == base_part_vector[j]) {
718 tables_are_built[j] =
true;
731 loss_map[part_vector[j]] = proc;
735 <<
" for " << part_vector[j]->GetParticleName()
737 <<
" tables are assigned "
754 G4cout <<
"G4LossTableManager::BuildTables() for "
758 std::vector<G4PhysicsTable*> t_list;
759 std::vector<G4VEnergyLossProcess*> loss_list;
767 for (i=0; i<n_loss; ++i) {
769 if (p && aParticle == part_vector[i] && !tables_are_built[i]) {
778 t_list.push_back(dedx);
779 loss_list.push_back(p);
780 tables_are_built[i] =
true;
784 G4int n_dedx = t_list.size();
785 if (0 == n_dedx || !em) {
786 G4cout <<
"G4LossTableManager WARNING: no DEDX processes for "
793 G4cout <<
"G4LossTableManager::BuildTables() start to build range tables"
794 <<
" and the sum of " << n_dedx <<
" processes"
796 <<
" buildCSDARange= " << buildCSDARange
797 <<
" nSubRegions= " << nSubRegions
820 dedx_vector[iem] = dedx;
824 range_vector[iem] =
range;
828 inv_range_vector[iem] = invrange;
840 std::vector<G4PhysicsTable*> listSub;
841 std::vector<G4PhysicsTable*> listCSDA;
843 for (i=0; i<n_dedx; ++i) {
847 if (0 < nSubRegions) {
850 listSub.push_back(dedx);
857 listCSDA.push_back(dedx);
861 if (0 < nSubRegions) {
863 if (1 < listSub.size()) {
886 G4cout <<
"G4LossTableManager::BuildTables: Tables are built for "
903 void G4LossTableManager::ParticleHaveNoLoss(
907 ed <<
"Energy loss process not found for " << aParticle->
GetParticleName()
909 G4Exception(
"G4LossTableManager::ParticleHaveNoLoss",
"em0001",
918 return buildCSDARange;
925 lossFluctuationFlag = val;
926 for(
G4int i=0; i<n_loss; ++i) {
927 if(loss_vector[i]) { loss_vector[i]->SetLossFluctuations(val); }
936 for(
G4int i=0; i<n_loss; ++i) {
937 if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); }
946 integralActive =
true;
947 for(
G4int i=0; i<n_loss; ++i) {
948 if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); }
950 size_t emp = emp_vector.size();
951 for (
size_t k=0; k<emp; ++k) {
952 if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); }
961 for(
G4int i=0; i<n_loss; ++i) {
962 if(loss_vector[i]) { loss_vector[i]->SetMinSubRange(val); }
971 for(
G4int i=0; i<n_loss; ++i) {
972 if(loss_vector[i]) { loss_vector[i]->SetRandomStep(val); }
980 minEnergyActive =
true;
982 for(
G4int i=0; i<n_loss; ++i) {
983 if(loss_vector[i]) { loss_vector[i]->SetMinKinEnergy(val); }
985 size_t emp = emp_vector.size();
986 for (
size_t k=0; k<emp; ++k) {
987 if(emp_vector[k]) { emp_vector[k]->SetMinKinEnergy(val); }
995 maxEnergyActive =
true;
997 for(
G4int i=0; i<n_loss; ++i) {
998 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergy(val); }
1000 size_t emp = emp_vector.size();
1001 for (
size_t k=0; k<emp; ++k) {
1002 if(emp_vector[k]) { emp_vector[k]->SetMaxKinEnergy(val); }
1010 for(
G4int i=0; i<n_loss; ++i) {
1011 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergyForCSDARange(val); }
1019 maxEnergyForMuonsActive =
true;
1020 maxKinEnergyForMuons = val;
1027 for(
G4int i=0; i<n_loss; ++i) {
1028 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinning(val); }
1036 for(
G4int i=0; i<n_loss; ++i) {
1037 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinningForCSDARange(val); }
1045 G4int n = val/
G4int(std::log10(maxKinEnergy/minKinEnergy) + 0.5);
1047 G4cout <<
"G4LossTableManager::SetLambdaBinning WARNING "
1048 <<
"too small number of bins " << val <<
" ignored"
1054 size_t emp = emp_vector.size();
1055 for (
size_t k=0; k<emp; ++k) {
1056 if(emp_vector[k]) { emp_vector[k]->SetLambdaBinning(val); }
1064 return nbinsPerDecade;
1072 for(
G4int i=0; i<n_loss; ++i) {
1073 if(loss_vector[i]) { loss_vector[i]->SetVerboseLevel(val); }
1075 size_t msc = msc_vector.size();
1076 for (
size_t j=0; j<msc; ++j) {
1077 if(msc_vector[j]) { msc_vector[j]->SetVerboseLevel(val); }
1079 size_t emp = emp_vector.size();
1080 for (
size_t k=0; k<emp; ++k) {
1081 if(emp_vector[k]) { emp_vector[k]->SetVerboseLevel(val); }
1095 stepFunctionActive =
true;
1096 maxRangeVariation = v1;
1098 for(
G4int i=0; i<n_loss; ++i) {
1099 if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); }
1107 for(
G4int i=0; i<n_loss; ++i) {
1108 if(loss_vector[i]) { loss_vector[i]->SetLinearLossLimit(val); }
1116 buildCSDARange = val;
1125 if(stepFunctionActive) {
1132 if(maxEnergyForMuonsActive) {
1140 const std::vector<G4VEnergyLossProcess*>&
1155 const std::vector<G4VMultipleScattering*>&
1215 if(val > 0.0) { factorForAngleLimit = val; }
1222 return factorForAngleLimit;
1229 return minKinEnergy;
1236 return maxKinEnergy;
1243 return emCorrections;
1250 return emSaturation;
1257 return emConfigurator;
1264 return emElectronIonPair;
1271 return atomDeexcitation;
1278 return tableBuilder;
1285 atomDeexcitation =
p;
1293 if(aParticle != currentParticle) {
1294 currentParticle = aParticle;
1295 std::map<PD,G4VEnergyLossProcess*,std::less<PD> >::const_iterator pos;
1296 if ((pos = loss_map.find(aParticle)) != loss_map.end()) {
1297 currentLoss = (*pos).second;
1301 if ((pos = loss_map.find(theGenericIon)) != loss_map.end()) {
1302 currentLoss = (*pos).second;
1318 if(currentLoss) { x = currentLoss->
GetDEDX(kineticEnergy, couple); }
1330 if(currentLoss) { x = currentLoss->
GetDEDXForSubsec(kineticEnergy, couple); }
1342 if(currentLoss) { x = currentLoss->
GetCSDARange(kineticEnergy, couple); }
1355 if(currentLoss) { x = currentLoss->
GetRangeForLoss(kineticEnergy, couple); }
1367 if(currentLoss) { x = currentLoss->
GetRange(kineticEnergy, couple); }
G4double GetKineticEnergy(G4double &range, const G4MaterialCutsCouple *)
G4EmConfigurator * EmConfigurator()
void SetRandomStep(G4bool val)
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
void SetDEDXTable(G4PhysicsTable *p, G4EmTableType tType)
void SetIntegral(G4bool val)
G4bool SplineFlag() const
static G4LossTableManager * Instance()
void InitialiseAtomicDeexcitation()
std::ostringstream G4ExceptionDescription
G4double GetDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
void SetIonisation(G4bool val)
void SetBremsstrahlungTh(G4double val)
G4double GetDEDX(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4PhysicsTable * SubLambdaTable() const
G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple, const G4DynamicParticle *dp, G4double &length)
void DeRegister(G4VEnergyLossProcess *p)
G4PhysicsTable * RangeTableForLoss() const
void SetLambdaBinning(G4int val)
G4double GetSubDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4bool BuildCSDARange() const
G4double GetRangeForLoss(G4double &kineticEnergy, const G4MaterialCutsCouple *)
void AddCollaborativeProcess(G4VEnergyLossProcess *)
void SetStepFunction(G4double v1, G4double v2)
G4PhysicsTable * CSDARangeTable() const
G4double GetCSDARange(G4double &kineticEnergy, const G4MaterialCutsCouple *)
G4EnergyLossMessenger * GetMessenger()
G4double FactorForAngleLimit() const
void SetFactorForAngleLimit(G4double val)
G4PhysicsTable * IonisationTableForSubsec() const
G4double GetDEDXForSubsec(G4double &kineticEnergy, const G4MaterialCutsCouple *)
const std::vector< G4VEmProcess * > & GetEmProcessVector()
G4PhysicsTable * BuildLambdaTable(G4EmTableType tType=fRestricted)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
const G4String & GetParticleName() const
G4double GetCSDARange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
G4LossTableBuilder * GetTableBuilder()
void SetVerboseLevel(G4int)
void SetBuildCSDARange(G4bool val)
void SetInitialisationFlag(G4bool flag)
G4PhysicsTable * LambdaTable() const
void SetInverseRangeTable(G4PhysicsTable *p)
const G4ParticleDefinition * SecondaryParticle() const
G4GLOB_DLL std::ostream G4cout
G4PhysicsTable * DEDXTable() const
G4double MinKinEnergy() const
void SetLPMFlag(G4bool val)
const G4ParticleDefinition const G4Material *G4double range
G4EmCorrections * EmCorrections()
void SetLossFluctuations(G4bool val)
G4ElectronIonPair * ElectronIonPair()
G4EmSaturation * EmSaturation()
void SetMaxEnergyForCSDARange(G4double val)
G4int NumberOfSubCutoffRegions() const
const G4String & GetParticleType() const
void SetMaxKinEnergy(G4double e)
void Register(G4VEnergyLossProcess *p)
const G4ParticleDefinition * BaseParticle() const
const G4ParticleDefinition * GetParticleDefinition() const
void SetDEDXBinningForCSDARange(G4int val)
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
G4PhysicsTable * DEDXTableForSubsec() const
G4double GetEnergy(const G4ParticleDefinition *aParticle, G4double range, const G4MaterialCutsCouple *couple)
const G4String & GetProcessName() const
const std::vector< G4VEnergyLossProcess * > & GetEnergyLossProcessVector()
void SetSubCutoff(G4bool val, const G4Region *r=0)
G4double BremsstrahlungTh() const
G4double GetRangeFromRestricteDEDX(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
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 SetMinSubRange(G4double val)
void SetMinEnergy(G4double val)
G4VEnergyLossProcess * GetEnergyLossProcess(const G4ParticleDefinition *)
void SetLambdaTable(G4PhysicsTable *p)
void SetMaxEnergy(G4double val)
void SetStepFunction(G4double v1, G4double v2)
G4PhysicsTable * InverseRangeTable() const
void BuildPhysicsTable(const G4ParticleDefinition *aParticle)
G4double GetPDGMass() const
const G4ParticleDefinition * Particle() const
void SetLinearLossLimit(G4double val)
G4int GetNumberOfBinsPerDecade() const
void PrepareModels(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p, G4bool theMaster)
void SetCSDARangeTable(G4PhysicsTable *pRange)
G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple, const G4DynamicParticle *dp, G4double length)
void SetVerbose(G4int val)
void LocalPhysicsTables(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
void SetDEDXBinning(G4int val)
void SetMaxEnergyForMuons(G4double val)
static G4Electron * Electron()
void SetIntegral(G4bool val)
void SetLossFluctuations(G4bool val)
const G4String & GetName() const
void SetSecondaryRangeTable(G4PhysicsTable *p)
G4VAtomDeexcitation * AtomDeexcitation()
G4PhysicsTable * DEDXunRestrictedTable() const
void SetSubLambdaTable(G4PhysicsTable *p)
void ActivateSubCutoff(G4bool val, const G4Region *region=0)
void SetRangeTableForLoss(G4PhysicsTable *p)
G4double MaxKinEnergy() const
G4double GetRange(const G4ParticleDefinition *aParticle, G4double kineticEnergy, const G4MaterialCutsCouple *couple)
void SetAtomDeexcitation(G4VAtomDeexcitation *)
G4PhysicsTable * BuildDEDXTable(G4EmTableType tType=fRestricted)
void SetSplineFlag(G4bool val)
const std::vector< G4VMultipleScattering * > & GetMultipleScatteringVector()
void SetVerboseLevel(G4int value)
G4double GetRange(G4double &kineticEnergy, const G4MaterialCutsCouple *)
void SetRandomStep(G4bool val)
void SetSplineFlag(G4bool flag)
G4bool IsIonisationProcess() const
void SetMinKinEnergy(G4double e)