160 secondaryParticle(0),
166 theDEDXunRestrictedTable(0),
167 theIonisationTable(0),
168 theIonisationSubTable(0),
169 theRangeTableForLoss(0),
170 theCSDARangeTable(0),
171 theSecondaryRangeTable(0),
172 theInverseRangeTable(0),
174 theSubLambdaTable(0),
179 lossFluctuationFlag(true),
181 tablesAreBuilt(false),
186 useDeexcitation(false),
195 lowestKinEnergy = 1.*
eV;
198 minKinEnergy = 0.1*
keV;
199 maxKinEnergy = 10.0*
TeV;
201 maxKinEnergyCSDA = 1.0*
GeV;
233 atomDeexcitation = 0;
240 secParticles.reserve(5);
249 <<
" " <<
this <<
" " << baseParticle <<
G4endl;
253 if ( !baseParticle ) {
255 if(theIonisationTable == theDEDXTable) { theIonisationTable = 0; }
258 if(theDEDXSubTable) {
259 if(theIonisationSubTable == theDEDXSubTable)
260 theIonisationSubTable = 0;
262 delete theDEDXSubTable;
265 if(theIonisationTable) {
267 delete theIonisationTable;
269 if(theIonisationSubTable) {
271 delete theIonisationSubTable;
273 if(theDEDXunRestrictedTable && theCSDARangeTable) {
275 delete theDEDXunRestrictedTable;
277 if(theCSDARangeTable) {
279 delete theCSDARangeTable;
281 if(theRangeTableForLoss) {
283 delete theRangeTableForLoss;
285 if(theInverseRangeTable) {
287 delete theInverseRangeTable;
291 delete theLambdaTable;
293 if(theSubLambdaTable) {
295 delete theSubLambdaTable;
306 void G4VEnergyLossProcess::Clean()
312 delete [] idxSCoffRegions;
314 tablesAreBuilt =
false;
335 modelManager->
AddEmModel(order, p, fluc, region);
351 G4int n = emModels.size();
352 if(index >= n) {
for(
G4int i=n; i<=
index; ++i) {emModels.push_back(0);} }
361 if(index >= 0 && index <
G4int(emModels.size())) { p = emModels[
index]; }
369 return modelManager->
GetModel(idx, ver);
385 G4cout <<
"G4VEnergyLossProcess::PreparePhysicsTable for "
394 preStepKinEnergy = 0.0;
403 if( !particle ) { particle = &
part; }
408 if(pname !=
"deuteron" && pname !=
"triton" &&
409 pname !=
"alpha+" && pname !=
"helium" &&
410 pname !=
"hydrogen") {
416 if(pname !=
"He3" && pname !=
"alpha") { particle = theGenericIon; }
420 if( particle != &part ) {
427 G4cout <<
"### G4VEnergyLossProcess::PreparePhysicsTable() interrupted for "
429 <<
" particle " << particle <<
" GenericIon " << theGenericIon
446 theDEDXAtMaxEnergy.resize(n, 0.0);
447 theRangeAtMaxEnergy.resize(n, 0.0);
448 theEnergyOfCrossSectionMax.resize(n, 0.0);
449 theCrossSectionMax.resize(n,
DBL_MAX);
458 theDEDXunRestrictedTable =
468 theRangeTableForLoss =
470 theInverseRangeTable =
495 massRatio = (baseParticle->
GetPDGMass())/initialMass;
498 if(chargeSqRatio > 0.0) { reduceFactor = 1.0/(chargeSqRatio*massRatio); }
503 for(
G4int i=0; i<nmod; ++i) {
510 theCuts = modelManager->
Initialise(particle, secondaryParticle,
514 if (nSCoffRegions>0) {
517 if(nSCoffRegions>0) { idxSCoffRegions =
new G4bool[
n]; }
518 for (
size_t j=0; j<
n; ++j) {
524 if(nSCoffRegions>0) {
526 for(
G4int i=0; i<nSCoffRegions; ++i) {
527 if( pcuts == scoffRegions[i]->GetProductionCuts()) { reg =
true; }
529 idxSCoffRegions[j] = reg;
535 G4cout <<
"G4VEnergyLossProcess::Initialise() is done "
537 <<
" isIon= " << isIon;
539 G4cout <<
" chargeSqRatio= " << chargeSqRatio
540 <<
" massRatio= " << massRatio
541 <<
" reduceFactor= " << reduceFactor <<
G4endl;
543 G4cout <<
" SubCutoff Regime is ON for regions: " <<
G4endl;
544 for (
G4int i=0; i<nSCoffRegions; ++i) {
557 G4cout <<
"### G4VEnergyLossProcess::BuildPhysicsTable() for "
562 G4cout <<
" TablesAreBuilt= " << tablesAreBuilt
563 <<
" isIon= " << isIon <<
" " <<
this <<
G4endl;
566 if(&part == particle) {
567 if(!tablesAreBuilt) {
580 num ==
"e+" || num ==
"mu+" ||
581 num ==
"mu-" || num ==
"proton"||
582 num ==
"pi+" || num ==
"pi-" ||
583 num ==
"kaon+" || num ==
"kaon-" ||
584 num ==
"alpha" || num ==
"anti_proton" ||
585 num ==
"GenericIon")))
596 if(atomDeexcitation) {
597 if(atomDeexcitation->
IsPIXEActive()) { useDeexcitation =
true; }
602 G4cout <<
"### G4VEnergyLossProcess::BuildPhysicsTable() done for "
605 if(isIonisation) {
G4cout <<
" isIonisation flag = 1"; }
615 G4cout <<
"G4VEnergyLossProcess::BuildDEDXTable() of type " << tType
625 emax = maxKinEnergyCSDA;
627 table = theDEDXunRestrictedTable;
629 table = theDEDXTable;
630 if(theIonisationTable)
633 table = theDEDXSubTable;
634 if(theIonisationSubTable)
637 G4cout <<
"G4VEnergyLossProcess::BuildDEDXTable WARNING: wrong type "
647 G4cout << numOfCouples <<
" materials"
648 <<
" minKinEnergy= " << minKinEnergy
649 <<
" maxKinEnergy= " << emax
651 <<
" EmTableType= " << tType
652 <<
" table= " << table <<
" " <<
this
655 if(!table)
return table;
662 for(
size_t i=0; i<numOfCouples; ++i) {
665 G4cout <<
"G4VEnergyLossProcess::BuildDEDXVector flagTable= "
691 G4cout <<
"G4VEnergyLossProcess::BuildDEDXTable(): table is built for "
708 table = theLambdaTable;
710 table = theSubLambdaTable;
712 G4cout <<
"G4VEnergyLossProcess::BuildLambdaTable WARNING: wrong type "
717 G4cout <<
"G4VEnergyLossProcess::BuildLambdaTable() of type "
718 << tType <<
" for process "
721 <<
" EmTableType= " << tType
722 <<
" table= " << table
725 if(!table) {
return table;}
737 for(
size_t i=0; i<numOfCouples; ++i) {
746 if(0.0 >= emin) { emin =
eV; }
747 else if(maxKinEnergy <= emin) { emin = 0.5*maxKinEnergy; }
748 G4int bin =
G4int(nBins*std::log(maxKinEnergy/emin)/scale + 0.5);
749 if(bin < 3) { bin = 3; }
762 G4cout <<
"Lambda table is built for "
779 <<
" dE/dx and range tables from "
781 <<
" to " <<
G4BestUnit(maxKinEnergy,
"Energy")
782 <<
" in " << nBins <<
" bins" <<
G4endl
783 <<
" Lambda tables from threshold to "
785 <<
" in " << nBins <<
" bins, spline: "
788 if(theRangeTableForLoss && isIonisation) {
789 G4cout <<
" finalRange(mm)= " << finalRange/
mm
790 <<
", dRoverRange= " << dRoverRange
791 <<
", integral: " << integral
792 <<
", fluct: " << lossFluctuationFlag
793 <<
", linLossLimit= " << linLossLimit
798 if(theCSDARangeTable && isIonisation) {
799 G4cout <<
" CSDA range table up"
800 <<
" to " <<
G4BestUnit(maxKinEnergyCSDA,
"Energy")
801 <<
" in " << nBinsCSDA <<
" bins" <<
G4endl;
803 if(nSCoffRegions>0 && isIonisation) {
804 G4cout <<
" Subcutoff sampling in " << nSCoffRegions
808 G4cout <<
" DEDXTable address= " << theDEDXTable <<
G4endl;
809 if(theDEDXTable && isIonisation)
G4cout << (*theDEDXTable) <<
G4endl;
810 G4cout <<
"non restricted DEDXTable address= "
811 << theDEDXunRestrictedTable <<
G4endl;
812 if(theDEDXunRestrictedTable && isIonisation) {
815 if(theDEDXSubTable && isIonisation) {
818 G4cout <<
" CSDARangeTable address= " << theCSDARangeTable
820 if(theCSDARangeTable && isIonisation) {
823 G4cout <<
" RangeTableForLoss address= " << theRangeTableForLoss
825 if(theRangeTableForLoss && isIonisation) {
828 G4cout <<
" InverseRangeTable address= " << theInverseRangeTable
830 if(theInverseRangeTable && isIonisation) {
833 G4cout <<
" LambdaTable address= " << theLambdaTable <<
G4endl;
834 if(theLambdaTable && isIonisation) {
837 G4cout <<
" SubLambdaTable address= " << theSubLambdaTable <<
G4endl;
838 if(theSubLambdaTable && isIonisation) {
851 if (!reg) {reg = regionStore->
GetRegion(
"DefaultRegionForTheWorld",
false);}
855 for (
G4int i=0; i<nSCoffRegions; ++i) {
856 if (reg == scoffRegions[i]) {
865 scoffRegions.push_back(reg);
868 useSubCutoff =
false;
886 massRatio = baseParticle->
GetPDGMass()/newmass;
908 *selection = aGPILSelection;
910 fRange = GetScaledRangeForScaledEnergy(preStepScaledEnergy)*reduceFactor;
918 if(x > finR) { x = y + finR*(1.0 - dRoverRange)*(2.0 - finR/fRange); }
956 preStepScaledEnergy = preStepKinEnergy*massRatio;
959 if(!currentModel->
IsActive(preStepScaledEnergy)) {
return x; }
964 if(q2 != chargeSqRatio) {
966 fFactor = q2*biasFactor*(*theDensityFactor)[currentCoupleIndex];
967 reduceFactor = 1.0/(fFactor*massRatio);
980 return biasManager->
GetStepLimit(currentCoupleIndex, previousStepSize);
986 if(preStepScaledEnergy < mfpKinEnergy) {
987 if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); }
988 else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); }
991 if(preStepLambda <= 0.0) {
998 if(preStepLambda > 0.0) {
1022 G4cout <<
"G4VEnergyLossProcess::PostStepGetPhysicalInteractionLength ";
1025 <<
" in Material " << currentMaterial->
GetName()
1026 <<
" Ekin(MeV)= " << preStepKinEnergy/
MeV
1028 G4cout <<
"MeanFreePath = " << currentInteractionLength/
cm <<
"[cm]"
1029 <<
"InteractionLength= " << x/
cm <<
"[cm] " <<
G4endl;
1043 if(!isIonisation || !currentModel->
IsActive(preStepScaledEnergy)) {
1074 weight /= biasFactor;
1079 if (length >= fRange) {
1080 eloss = preStepKinEnergy;
1081 if (useDeexcitation) {
1083 eloss, currentCoupleIndex);
1084 if(scTracks.size() > 0) { FillSecondariesAlongStep(eloss, weight); }
1085 if(eloss < 0.0) { eloss = 0.0; }
1093 eloss = GetDEDXForScaledEnergy(preStepScaledEnergy)*length;
1096 if(eloss > preStepKinEnergy*linLossLimit) {
1100 G4double x = (fRange - length)/reduceFactor;
1101 eloss = preStepKinEnergy - ScaledKinEnergyForLoss(x)/massRatio;
1129 G4double cut = (*theCuts)[currentCoupleIndex];
1134 if(idxSCoffRegions[currentCoupleIndex]) {
1148 if(preSafety < rcut) {
1152 if(preSafety < rcut) { yes =
true; }
1156 G4double postSafety = preSafety - length;
1157 if(postSafety < rcut) {
1160 if(postSafety < rcut) { yes =
true; }
1168 cut = (*theSubCuts)[currentCoupleIndex];
1169 eloss -= GetSubDEDXForScaledEnergy(preStepScaledEnergy)*length;
1171 currentModel,currentCoupleIndex);
1192 eloss, eadd, length);
1193 if(eloss < 0.0) { eloss = 0.5*eloss_before; }
1197 if (lossFluctuationFlag) {
1200 (eloss + esec + lowestKinEnergy) < preStepKinEnergy) {
1220 if (useDeexcitation) {
1221 G4double esecfluo = preStepKinEnergy - esec;
1230 de, currentCoupleIndex);
1236 if(eloss >= esecfluo) {
1254 if(scTracks.size() > 0) { FillSecondariesAlongStep(eloss, weight); }
1257 G4double finalT = preStepKinEnergy - eloss - esec;
1258 if (finalT <= lowestKinEnergy) {
1264 currentMaterial,finalT));
1267 if(eloss < 0.0) { eloss = 0.0; }
1272 G4double del = finalT + eloss + esec - preStepKinEnergy;
1273 G4cout <<
"Final value eloss(MeV)= " << eloss/
MeV
1274 <<
" preStepKinEnergy= " << preStepKinEnergy
1275 <<
" postStepKinEnergy= " << finalT
1276 <<
" de(keV)= " << del/
keV
1277 <<
" lossFlag= " << lossFluctuationFlag
1299 G4int n = scTracks.size();
1302 for(
G4int i=0; i<
n; ++i) {
1325 G4double subcut = (*theSubCuts)[idx];
1327 if(cut <= subcut) {
return esec; }
1332 G4double cross = (*theDensityFactor)[idx]*chargeSqRatio
1333 *(((*theSubLambdaTable)[(*theDensityIdx)[idx]])->Value(e));
1337 if(length*cross <
perMillion) {
return esec; }
1359 fragment += del/length;
1360 if (fragment > 1.0)
break;
1363 secParticles.clear();
1369 std::vector<G4DynamicParticle*>::iterator it;
1370 for(it=secParticles.begin(); it!=secParticles.end(); ++it) {
1389 tracks.push_back(t);
1404 }
while (fragment <= 1.0);
1421 G4double postStepScaledEnergy = finalT*massRatio;
1441 G4double lx = GetLambdaForScaledEnergy(postStepScaledEnergy);
1465 weight /= biasFactor;
1470 G4double tcut = (*theCuts)[currentCoupleIndex];
1473 secParticles.clear();
1475 currentModel->
SampleSecondaries(&secParticles, currentCouple, dynParticle, tcut);
1482 track, currentModel,
1484 currentCoupleIndex, tcut,
1494 G4int num = secParticles.size();
1499 for (
G4int i=0; i<num; ++i) {
1500 if(secParticles[i]) {
1541 if ( baseParticle || part != particle )
return res;
1543 if(!StoreTable(part,theDEDXTable,ascii,directory,
"DEDX"))
1546 if(!StoreTable(part,theDEDXunRestrictedTable,ascii,directory,
"DEDXnr"))
1549 if(!StoreTable(part,theDEDXSubTable,ascii,directory,
"SubDEDX"))
1552 if(!StoreTable(part,theIonisationTable,ascii,directory,
"Ionisation"))
1555 if(!StoreTable(part,theIonisationSubTable,ascii,directory,
"SubIonisation"))
1559 !StoreTable(part,theCSDARangeTable,ascii,directory,
"CSDARange"))
1563 !StoreTable(part,theRangeTableForLoss,ascii,directory,
"Range"))
1567 !StoreTable(part,theInverseRangeTable,ascii,directory,
"InverseRange"))
1570 if(!StoreTable(part,theLambdaTable,ascii,directory,
"Lambda"))
1573 if(!StoreTable(part,theSubLambdaTable,ascii,directory,
"SubLambda"))
1580 <<
" in the directory <" << directory
1584 G4cout <<
"Fail to store Physics Tables for "
1587 <<
" in the directory <" << directory
1604 G4cout <<
"G4VEnergyLossProcess::RetrievePhysicsTable() for "
1606 <<
"; tables_are_built= " << tablesAreBuilt
1609 if(particle == part) {
1611 if ( !baseParticle ) {
1614 if(!RetrieveTable(part,theDEDXTable,ascii,directory,
"DEDX",fpi))
1618 if(!RetrieveTable(part,theDEDXTable,ascii,directory,
"Ionisation",
false))
1621 if(!RetrieveTable(part,theRangeTableForLoss,ascii,directory,
"Range",fpi))
1624 if(!RetrieveTable(part,theDEDXunRestrictedTable,ascii,directory,
"DEDXnr",
false))
1627 if(!RetrieveTable(part,theCSDARangeTable,ascii,directory,
"CSDARange",
false))
1630 if(!RetrieveTable(part,theInverseRangeTable,ascii,directory,
"InverseRange",fpi))
1633 if(!RetrieveTable(part,theLambdaTable,ascii,directory,
"Lambda",
true))
1637 if(nSCoffRegions > 0) {yes =
true;}
1639 if(!RetrieveTable(part,theDEDXSubTable,ascii,directory,
"SubDEDX",yes))
1642 if(!RetrieveTable(part,theSubLambdaTable,ascii,directory,
"SubLambda",yes))
1645 if(!fpi) yes =
false;
1646 if(!RetrieveTable(part,theIonisationSubTable,ascii,directory,
"SubIonisation",yes))
1679 G4bool isRetrieved =
false;
1686 size_t n = aTable->
length();
1687 for(
size_t i=0; i<
n; ++i) {
1688 if((*aTable)[i]) { (*aTable)[i]->SetSpline(
true); }
1693 <<
" is Retrieved from <" << filename <<
">"
1699 if(mandatory && !isRetrieved) {
1703 << filename <<
"> is not Retrieved"
1718 DefineMaterial(couple);
1722 tmax = std::min(tmax,(*theCuts)[currentCoupleIndex]);
1725 if(fm) { d = fm->
Dispersion(currentMaterial,dp,tmax,length); }
1735 DefineMaterial(couple);
1737 if(theLambdaTable) {
1738 cross = (*theDensityFactor)[currentCoupleIndex]*
1739 ((*theLambdaTable)[basedCoupleIndex])->Value(kineticEnergy);
1743 particle, kineticEnergy,
1744 (*theCuts)[currentCoupleIndex]);
1746 if(cross < 0.0) { cross = 0.0; }
1755 preStepLambda = GetLambdaForScaledEnergy(track.
GetKineticEnergy()*massRatio);
1757 if(0.0 < preStepLambda) { x = 1.0/preStepLambda; }
1810 if(add && nProcesses > 0) {
1811 for(
G4int i=0; i<nProcesses; ++i) {
1812 if(p == scProcesses[i]) {
1819 scProcesses.push_back(p);
1823 <<
" is added to the list of collaborative processes of "
1833 if(
fTotal == tType && theDEDXunRestrictedTable != p && !baseParticle) {
1834 if(theDEDXunRestrictedTable) {
1836 delete theDEDXunRestrictedTable;
1838 theDEDXunRestrictedTable =
p;
1844 for (
size_t i=0; i<
n; ++i) {
1847 if(pv) { dedx = pv->
Value(emax); }
1849 pv = (*p)[(*theDensityIdx)[i]];
1850 if(pv) { dedx = pv->
Value(emax)*(*theDensityFactor)[i]; }
1852 theDEDXAtMaxEnergy[i] = dedx;
1858 }
else if(
fRestricted == tType && theDEDXTable != p) {
1862 if(theDEDXTable && !baseParticle) {
1863 if(theDEDXTable == theIonisationTable) { theIonisationTable = 0; }
1865 delete theDEDXTable;
1869 if(theDEDXSubTable && !baseParticle) {
1870 if(theDEDXSubTable == theIonisationSubTable) { theIonisationSubTable = 0; }
1872 delete theDEDXSubTable;
1874 theDEDXSubTable =
p;
1875 }
else if(
fIsIonisation == tType && theIonisationTable != p) {
1876 if(theIonisationTable && theIonisationTable != theDEDXTable && !baseParticle) {
1878 delete theIonisationTable;
1880 theIonisationTable =
p;
1882 if(theIonisationSubTable && theIonisationSubTable != theDEDXSubTable && !baseParticle) {
1884 delete theIonisationSubTable;
1886 theIonisationSubTable =
p;
1894 if(theCSDARangeTable != p) { theCSDARangeTable =
p; }
1901 for (
size_t i=0; i<
n; ++i) {
1904 if(pv) { rmax = pv->
Value(emax); }
1906 pv = (*p)[(*theDensityIdx)[i]];
1907 if(pv) { rmax = pv->
Value(emax)/(*theDensityFactor)[i]; }
1909 theRangeAtMaxEnergy[i] = rmax;
1920 if(theRangeTableForLoss != p) {
1921 theRangeTableForLoss =
p;
1923 G4cout <<
"### Set Range table " << p
1934 if(theSecondaryRangeTable != p) {
1935 theSecondaryRangeTable =
p;
1937 G4cout <<
"### Set SecondaryRange table " << p
1948 if(theInverseRangeTable != p) {
1949 theInverseRangeTable =
p;
1951 G4cout <<
"### Set InverseRange table " << p
1963 G4cout <<
"### Set Lambda table " << p
1967 if(theLambdaTable != p) { theLambdaTable =
p; }
1968 tablesAreBuilt =
true;
1970 if(theLambdaTable) {
1971 size_t n = theLambdaTable->
length();
1978 for (i=0; i<
n; ++i) {
1979 pv = (*theLambdaTable)[i];
1985 for (
size_t j=0; j<nb; ++j) {
1994 theEnergyOfCrossSectionMax[i] = emax;
1995 theCrossSectionMax[i] =
smax;
1998 <<
" Max CS at i= " << i <<
" emax(MeV)= " << emax/
MeV
1999 <<
" lambda= " << smax <<
G4endl;
2004 for (i=0; i<
n; ++i) {
2005 pv = (*theLambdaTable)[i];
2007 G4int j = (*theDensityIdx)[i];
2008 theEnergyOfCrossSectionMax[i] = theEnergyOfCrossSectionMax[j];
2009 theCrossSectionMax[i] = (*theDensityFactor)[i]*theCrossSectionMax[j];
2019 if(theSubLambdaTable != p) {
2020 theSubLambdaTable =
p;
2022 G4cout <<
"### Set SebLambda table " << p
2047 G4cout <<
"### SetCrossSectionBiasingFactor: for "
2049 <<
" biasFactor= " << f <<
" weightFlag= " << flag
2064 G4cout <<
"### ActivateForcedInteraction: for "
2066 <<
" length(mm)= " << length/
mm
2067 <<
" in G4Region <" << region
2068 <<
"> weightFlag= " << flag
2082 if (0.0 <= factor) {
2091 G4cout <<
"### ActivateSecondaryBiasing: for "
2093 <<
" factor= " << factor
2094 <<
" in G4Region <" << region
2095 <<
"> energyLimit(MeV)= " << energyLimit/
MeV