74 if(0 == theInstance) {
76 theInstance = &manager;
88 if( dedx_vector[i] ) {
89 dedx_vector[i]->clearAndDestroy();
90 delete dedx_vector[i];
93 nmax = range_vector.size();
95 if( range_vector[i] ) {
96 range_vector[i]->clearAndDestroy();
97 delete range_vector[i];
100 nmax = inv_range_vector.size();
102 if( inv_range_vector[i] ) {
103 inv_range_vector[i]->clearAndDestroy();
104 delete inv_range_vector[i];
107 nmax = xsection_vector.size();
109 if( xsection_vector[i] ) {
110 xsection_vector[i]->clearAndDestroy();
111 delete xsection_vector[i];
118 delete emConfigurator;
119 delete emElectronIonPair;
125 G4EmManager::G4EmManager()
130 startInitialisation =
false;
131 all_tables_are_built =
false;
133 lossFluctuationFlag =
true;
134 subCutoffFlag =
false;
135 rndmStepFlag =
false;
137 maxRangeVariation = 1.0;
139 minKinEnergy = 0.1*
keV;
140 maxKinEnergy = 10.0*
TeV;
143 maxKinEnergyForMuons = 10.*
TeV;
145 integralActive =
false;
146 buildCSDARange =
false;
147 minEnergyActive =
false;
148 maxEnergyActive =
false;
149 maxEnergyForMuonsActive =
false;
150 stepFunctionActive =
false;
154 factorForAngleLimit = 1.0;
160 emElectronIonPair = 0;
175 for (
G4int i=0; i<n_loss; ++i) {
176 if(loss_vector[i] == p) {
return; }
179 G4cout <<
"G4EmManager::Register G4VEnergyLossProcess : "
183 loss_vector.push_back(p);
184 part_vector.push_back(0);
185 base_part_vector.push_back(0);
186 dedx_vector.push_back(0);
187 range_vector.push_back(0);
188 inv_range_vector.push_back(0);
189 tables_are_built.push_back(
false);
190 isActive.push_back(
true);
191 all_tables_are_built =
false;
195 if(stepFunctionActive) {
208 G4int n = msc_vector.size();
209 for (
G4int i=0; i<
n; ++i) {
210 if(msc_vector[i] == p) {
return; }
213 G4cout <<
"G4EmManager::Register G4VMultipleScattering : "
216 msc_vector.push_back(p);
224 G4int n = emp_vector.size();
225 for (
G4int i=0; i<
n; ++i) {
226 if(emp_vector[i] == p) {
return; }
229 G4cout <<
"G4EmManager::Register G4VEmProcess : "
232 emp_vector.push_back(p);
241 if(!p || !part) {
return; }
242 for (
G4int i=0; i<n_loss; ++i) {
243 if(loss_vector[i] == p) {
return; }
246 G4cout <<
"G4EmManager::RegisterExtraParticle "
251 loss_vector.push_back(p);
252 part_vector.push_back(part);
254 dedx_vector.push_back(0);
255 range_vector.push_back(0);
256 inv_range_vector.push_back(0);
257 tables_are_built.push_back(
false);
258 all_tables_are_built =
false;
268 G4cout <<
"G4EmManager::PreparePhysicsTable for "
271 <<
" loss_vector " << loss_vector.size() <<
G4endl;
276 startInitialisation =
true;
282 for (
G4int j=0; j<n_loss; ++j) {
283 if (p == loss_vector[j]) {
284 if (!part_vector[j]) { part_vector[j] = particle; }
297 G4cout <<
"G4EmManager::PreparePhysicsTable for "
307 startInitialisation =
true;
317 G4cout <<
"G4EmManager::PreparePhysicsTable for "
334 if(0 == run && startInitialisation) {
335 emConfigurator->
Clear();
346 G4cout <<
"### G4EmManager::BuildDEDXTable() is requested for "
351 if(0 == run && startInitialisation) {
352 emConfigurator->
Clear();
353 firstParticle = aParticle;
355 startInitialisation =
false;
358 if ( aParticle == firstParticle ) {
359 all_tables_are_built =
true;
362 G4cout <<
"### G4EmManager start initilisation for first particle "
366 for (
G4int i=0; i<n_loss; ++i) {
373 if(0 == run) { base_part_vector[i] = el->
BaseParticle(); }
374 tables_are_built[i] =
false;
375 all_tables_are_built=
false;
383 G4cout <<
" active= " << isActive[i]
384 <<
" table= " << tables_are_built[i]
386 if(base_part_vector[i]) {
387 G4cout <<
" base particle "
388 << base_part_vector[i]->GetParticleName();
393 tables_are_built[i] =
true;
401 SetParameters(aParticle, p);
403 if (all_tables_are_built) {
return; }
406 all_tables_are_built =
true;
408 for(
G4int i=0; i<n_loss; ++i) {
409 if(p == loss_vector[i] && !tables_are_built[i] && !base_part_vector[i]) {
414 <<
" start BuildTable " <<
G4endl;
417 if(curr_proc) { CopyTables(curr_part, curr_proc); }
419 if ( !tables_are_built[i] ) { all_tables_are_built =
false; }
423 G4cout <<
"### G4EmManager::BuildDEDXTable end: "
424 <<
"all_tables_are_built= " << all_tables_are_built
427 if(all_tables_are_built) {
428 G4cout <<
"### All dEdx and Range tables are built #####" <<
G4endl;
438 for (
G4int j=0; j<n_loss; ++j) {
444 if (!tables_are_built[j] && part == base_part_vector[j]) {
445 tables_are_built[j] =
true;
455 loss_map[part_vector[j]] = proc;
458 <<
" for " << part_vector[j]->GetParticleName()
460 <<
" tables are assigned "
477 G4cout <<
"G4EmManager::BuildTables() for "
481 std::vector<G4PhysicsTable*> t_list;
482 std::vector<G4VEnergyLossProcess*> loss_list;
490 for (i=0; i<n_loss; ++i) {
492 if (p && aParticle == part_vector[i] && !tables_are_built[i]) {
494 !em || (em && !isActive[iem]) ) {
502 t_list.push_back(dedx);
503 loss_list.push_back(p);
504 tables_are_built[i] =
true;
508 G4int n_dedx = t_list.size();
509 if (0 == n_dedx || !em) {
510 G4cout <<
"G4EmManager WARNING: no DEDX processes for "
517 G4cout <<
"G4EmManager::BuildTables() start to build range tables"
518 <<
" and the sum of " << n_dedx <<
" processes"
520 <<
" buildCSDARange= " << buildCSDARange
521 <<
" nSubRegions= " << nSubRegions
533 dedx_vector[iem] = dedx;
537 range_vector[iem] =
range;
541 inv_range_vector[iem] = invrange;
554 std::vector<G4PhysicsTable*> listSub;
555 std::vector<G4PhysicsTable*> listCSDA;
557 for (i=0; i<n_dedx; ++i) {
561 if (0 < nSubRegions) {
564 listSub.push_back(dedx);
571 listCSDA.push_back(dedx);
575 if (0 < nSubRegions) {
577 if (1 < listSub.size()) {
600 loss_map[aParticle] = em;
603 G4cout <<
"G4EmManager::BuildTables: Tables are built for "
615 return buildCSDARange;
622 lossFluctuationFlag = val;
623 for(
G4int i=0; i<n_loss; ++i) {
624 if(loss_vector[i]) { loss_vector[i]->SetLossFluctuations(val); }
633 for(
G4int i=0; i<n_loss; ++i) {
634 if(loss_vector[i]) { loss_vector[i]->ActivateSubCutoff(val, r); }
643 integralActive =
true;
644 for(
G4int i=0; i<n_loss; ++i) {
645 if(loss_vector[i]) { loss_vector[i]->SetIntegral(val); }
647 size_t emp = emp_vector.size();
648 for (
size_t k=0; k<emp; ++k) {
649 if(emp_vector[k]) { emp_vector[k]->SetIntegral(val); }
658 for(
G4int i=0; i<n_loss; ++i) {
659 if(loss_vector[i]) { loss_vector[i]->SetMinSubRange(val); }
668 for(
G4int i=0; i<n_loss; ++i) {
669 if(loss_vector[i]) { loss_vector[i]->SetRandomStep(val); }
677 minEnergyActive =
true;
679 for(
G4int i=0; i<n_loss; ++i) {
680 if(loss_vector[i]) { loss_vector[i]->SetMinKinEnergy(val); }
682 size_t emp = emp_vector.size();
683 for (
size_t k=0; k<emp; ++k) {
684 if(emp_vector[k]) { emp_vector[k]->SetMinKinEnergy(val); }
692 maxEnergyActive =
true;
694 for(
G4int i=0; i<n_loss; ++i) {
695 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergy(val); }
697 size_t emp = emp_vector.size();
698 for (
size_t k=0; k<emp; ++k) {
699 if(emp_vector[k]) { emp_vector[k]->SetMaxKinEnergy(val); }
707 for(
G4int i=0; i<n_loss; ++i) {
708 if(loss_vector[i]) { loss_vector[i]->SetMaxKinEnergyForCSDARange(val); }
716 maxEnergyForMuonsActive =
true;
717 maxKinEnergyForMuons = val;
724 for(
G4int i=0; i<n_loss; ++i) {
725 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinning(val); }
733 for(
G4int i=0; i<n_loss; ++i) {
734 if(loss_vector[i]) { loss_vector[i]->SetDEDXBinningForCSDARange(val); }
742 G4int n = val/
G4int(std::log10(maxKinEnergy/minKinEnergy) + 0.5);
744 G4cout <<
"G4EmManager::SetLambdaBinning WARNING "
745 <<
"too small number of bins " << val <<
" ignored"
751 size_t emp = emp_vector.size();
752 for (
size_t k=0; k<emp; ++k) {
753 if(emp_vector[k]) { emp_vector[k]->SetLambdaBinning(val); }
761 return nbinsPerDecade;
796 stepFunctionActive =
true;
797 maxRangeVariation = v1;
799 for(
G4int i=0; i<n_loss; ++i) {
800 if(loss_vector[i]) { loss_vector[i]->SetStepFunction(v1, v2); }
808 for(
G4int i=0; i<n_loss; ++i) {
809 if(loss_vector[i]) { loss_vector[i]->SetLinearLossLimit(val); }
817 buildCSDARange = val;
825 if(stepFunctionActive) {
832 if(maxEnergyForMuonsActive) {
906 if(val > 0.0) { factorForAngleLimit = val; }
913 return factorForAngleLimit;
941 return emConfigurator;
948 return emElectronIonPair;
void BuildRangeTable(const G4PhysicsTable *dedxTable, G4PhysicsTable *rangeTable, G4bool isIonisation=false)
void SetDEDXTable(G4PhysicsTable *p, G4EmTableType tType)
void SetIntegral(G4bool val)
void SetIonisation(G4bool val)
G4bool BuildCSDARange() const
void Register(G4VEnergyLossProcess *p)
G4PhysicsTable * SubLambdaTable() const
G4bool SplineFlag() const
void SetMaxEnergy(G4double val)
void SetMaxEnergyForCSDARange(G4double val)
G4PhysicsTable * RangeTableForLoss() const
void SetSplineFlag(G4bool val)
void SetRandomStep(G4bool val)
void AddCollaborativeProcess(G4VEnergyLossProcess *)
void SetVerbose(G4int val)
void SetStepFunction(G4double v1, G4double v2)
void SetLossFluctuations(G4bool val)
G4PhysicsTable * CSDARangeTable() const
void SetDEDXBinningForCSDARange(G4int val)
G4PhysicsTable * IonisationTableForSubsec() const
G4PhysicsTable * IonisationTable() const
void SetSubCutoff(G4bool val, const G4Region *r=0)
G4PhysicsTable * BuildLambdaTable(G4EmTableType tType=fRestricted)
static G4NistManager * Instance()
void PreparePhysicsTable(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
static G4PhysicsTable * PreparePhysicsTable(G4PhysicsTable *physTable)
const G4String & GetParticleName() const
static G4EmManager * Instance()
G4double MaxKinEnergy() const
void SetInitialisationFlag(G4bool flag)
void SetBremsstrahlungTh(G4double val)
G4PhysicsTable * LambdaTable() const
G4ElectronIonPair * ElectronIonPair()
void SetInverseRangeTable(G4PhysicsTable *p)
const G4ParticleDefinition * SecondaryParticle() const
void SetIntegral(G4bool val)
G4GLOB_DLL std::ostream G4cout
void SetFactorForAngleLimit(G4double val)
G4PhysicsTable * DEDXTable() const
G4double FactorForAngleLimit() const
const G4ParticleDefinition const G4Material *G4double range
void SetBuildCSDARange(G4bool val)
G4double BremsstrahlungTh() const
void SetLossFluctuations(G4bool val)
void SetDEDXBinning(G4int val)
G4int NumberOfSubCutoffRegions() const
G4int GetNumberOfBinsPerDecade() const
void SetMaxKinEnergy(G4double e)
const G4ParticleDefinition * BaseParticle() const
void BuildInverseRangeTable(const G4PhysicsTable *rangeTable, G4PhysicsTable *invRangeTable, G4bool isIonisation=false)
G4PhysicsTable * DEDXTableForSubsec() const
const G4String & GetProcessName() const
G4LossTableBuilder * GetTableBuilder()
G4EmConfigurator * EmConfigurator()
void SetLinearLossLimit(G4double val)
void BuildDEDXTable(G4PhysicsTable *dedxTable, const std::vector< G4PhysicsTable * > &)
void SetLambdaBinning(G4int val)
void SetVerbose(G4int value)
virtual const G4ProcessManager * GetProcessManager()
void SetLambdaTable(G4PhysicsTable *p)
void RegisterExtraParticle(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
G4PhysicsTable * InverseRangeTable() const
G4double GetPDGMass() const
void SetLPMFlag(G4bool val)
void InitialiseProcess(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *)
const G4ParticleDefinition * Particle() const
void PrepareModels(const G4ParticleDefinition *aParticle, G4VEnergyLossProcess *p)
void SetStepFunction(G4double v1, G4double v2)
void SetCSDARangeTable(G4PhysicsTable *pRange)
void BuildPhysicsTable(const G4ParticleDefinition *aParticle)
G4bool GetProcessActivation(G4VProcess *aProcess) const
static G4Electron * Electron()
void SetSecondaryRangeTable(G4PhysicsTable *p)
G4EmSaturation * EmSaturation()
G4PhysicsTable * DEDXunRestrictedTable() const
void SetSubLambdaTable(G4PhysicsTable *p)
void SetMinSubRange(G4double val)
void ActivateSubCutoff(G4bool val, const G4Region *region=0)
void SetRangeTableForLoss(G4PhysicsTable *p)
void SetMinEnergy(G4double val)
void SetMaxEnergyForMuons(G4double val)
G4PhysicsTable * BuildDEDXTable(G4EmTableType tType=fRestricted)
void SetVerboseLevel(G4int value)
void SetRandomStep(G4bool val)
void SetSplineFlag(G4bool flag)
G4double MinKinEnergy() const
G4bool IsIonisationProcess() const
void SetMinKinEnergy(G4double e)