- Timestamp:
- Jun 18, 2010, 11:42:07 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/utils/src/G4VEnergyLossProcess.cc
r1228 r1315 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4VEnergyLossProcess.cc,v 1.1 58 2009/10/29 18:07:08vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-0 3$26 // $Id: G4VEnergyLossProcess.cc,v 1.167 2010/05/26 10:41:34 vnivanch Exp $ 27 // GEANT4 tag $Name: geant4-09-04-beta-cand-01 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 336 336 { 337 337 modelManager->AddEmModel(order, p, fluc, region); 338 if(p) p->SetParticleChange(pParticleChange, fluc);338 if(p) { p->SetParticleChange(pParticleChange, fluc); } 339 339 } 340 340 … … 406 406 particle = ∂ 407 407 if(part.GetParticleType() == "nucleus") { 408 if(!theGenericIon) theGenericIon = G4GenericIon::GenericIon();408 if(!theGenericIon) { theGenericIon = G4GenericIon::GenericIon(); } 409 409 if(particle == theGenericIon) { isIon = true; } 410 410 else if(part.GetPDGCharge() > eplus) { … … 426 426 lManager->RegisterExtraParticle(&part, this); 427 427 } 428 if(1 < verboseLevel) { 429 G4cout << "### G4VEnergyLossProcess::PreparePhysicsTable() end for " 430 << part.GetParticleName() << G4endl; 431 } 428 432 return; 429 433 } 430 434 431 435 Clean(); 432 lManager-> EmConfigurator()->AddModels();436 lManager->PreparePhysicsTable(&part, this); 433 437 434 438 // Base particle and set of models can be defined here … … 502 506 G4bool reg = false; 503 507 for(G4int i=0; i<nSCoffRegions; ++i) { 504 if( pcuts == scoffRegions[i]->GetProductionCuts()) reg = true;508 if( pcuts == scoffRegions[i]->GetProductionCuts()) { reg = true; } 505 509 } 506 510 idxSCoffRegions[j] = reg; … … 509 513 G4bool reg = false; 510 514 for(G4int i=0; i<nDERegions; ++i) { 511 if( pcuts == deRegions[i]->GetProductionCuts()) reg = true;515 if( pcuts == deRegions[i]->GetProductionCuts()) { reg = true; } 512 516 } 513 517 idxDERegions[j] = reg; … … 515 519 } 516 520 } 517 518 lManager->EnergyLossProcessIsInitialised(particle, this);519 521 520 522 if (1 < verboseLevel) { … … 568 570 569 571 // Added tracking cut to avoid tracking artifacts 570 if(isIonisation) fParticleChange.SetLowEnergyLimit(lowestKinEnergy);572 if(isIonisation) { fParticleChange.SetLowEnergyLimit(lowestKinEnergy); } 571 573 572 574 if(1 < verboseLevel) { … … 574 576 << GetProcessName() 575 577 << " and particle " << part.GetParticleName(); 576 if(isIonisation) G4cout << " isIonisation flag = 1";578 if(isIonisation) { G4cout << " isIonisation flag = 1"; } 577 579 G4cout << G4endl; 578 580 } … … 590 592 } 591 593 G4PhysicsTable* table = 0; 592 G4double emin = minKinEnergy;593 594 G4double emax = maxKinEnergy; 594 595 G4int bin = nBins; … … 619 620 G4cout << numOfCouples << " materials" 620 621 << " minKinEnergy= " << minKinEnergy 621 << " maxKinEnergy= " << maxKinEnergy 622 << " maxKinEnergy= " << emax 623 << " nbin= " << bin 622 624 << " EmTableType= " << tType 623 625 << " table= " << table … … 642 644 theCoupleTable->GetMaterialCutsCouple(i); 643 645 if(!bVector) { 644 aVector = new G4PhysicsLogVector( emin, emax, bin);646 aVector = new G4PhysicsLogVector(minKinEnergy, emax, bin); 645 647 bVector = aVector; 646 648 } else { 647 649 aVector = new G4PhysicsLogVector(*bVector); 648 650 } 649 // G4PhysicsVector* aVector = new G4PhysicsLogVector(emin, emax, bin);650 651 aVector->SetSpline(splineFlag); 651 652 652 653 modelManager->FillDEDXVector(aVector, couple, tType); 653 if(splineFlag) aVector->FillSecondDerivatives();654 if(splineFlag) { aVector->FillSecondDerivatives(); } 654 655 655 656 // Insert vector for this material into the table … … 701 702 702 703 G4bool splineFlag = (G4LossTableManager::Instance())->SplineFlag(); 704 G4PhysicsLogVector* aVector = 0; 705 G4PhysicsLogVector* bVector = 0; 703 706 704 707 for(size_t i=0; i<numOfCouples; ++i) { … … 709 712 const G4MaterialCutsCouple* couple = 710 713 theCoupleTable->GetMaterialCutsCouple(i); 711 G4double cut = (*theCuts)[i]; 712 if(fSubRestricted == tType) cut = (*theSubCuts)[i]; 713 G4PhysicsVector* aVector = LambdaPhysicsVector(couple, cut); 714 if(!bVector) { 715 aVector = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins); 716 bVector = aVector; 717 } else { 718 aVector = new G4PhysicsLogVector(*bVector); 719 } 714 720 aVector->SetSpline(splineFlag); 715 721 716 722 modelManager->FillLambdaVector(aVector, couple, true, tType); 717 if(splineFlag) aVector->FillSecondDerivatives();723 if(splineFlag) { aVector->FillSecondDerivatives(); } 718 724 719 725 // Insert vector for this material into the table … … 881 887 if(x > finalRange && y < currentMinStep) { 882 888 x = y + finalRange*(1.0 - dRoverRange)*(2.0 - finalRange/fRange); 883 } else if (rndmStepFlag) { x = SampleRange();}889 } else if (rndmStepFlag) { x = SampleRange(); } 884 890 //G4cout<<GetProcessName()<<": e= "<<preStepKinEnergy 885 891 // <<" range= "<<fRange <<" cMinSt="<<currentMinStep … … 912 918 preStepScaledEnergy = preStepKinEnergy*massRatio; 913 919 SelectModel(preStepScaledEnergy); 914 if(!currentModel->IsActive(preStepScaledEnergy)) return x; 915 916 if(isIon) { 917 chargeSqRatio = 918 currentModel->GetChargeSquareRatio(currPart,currentMaterial,preStepKinEnergy); 920 if(!currentModel->IsActive(preStepScaledEnergy)) { return x; } 921 922 if(isIon) { 923 chargeSqRatio = currentModel->ChargeSquareRatio(track); 919 924 reduceFactor = 1.0/(chargeSqRatio*massRatio); 920 925 } 921 926 //G4cout << "q2= " << chargeSqRatio << " massRatio= " << massRatio << G4endl; 922 927 // initialisation for sampling of the interaction length 923 if(previousStepSize <= DBL_MIN) theNumberOfInteractionLengthLeft = -1.0;924 if(theNumberOfInteractionLengthLeft < 0.0) mfpKinEnergy = DBL_MAX;928 if(previousStepSize <= DBL_MIN) { theNumberOfInteractionLengthLeft = -1.0; } 929 if(theNumberOfInteractionLengthLeft < 0.0) { mfpKinEnergy = DBL_MAX; } 925 930 926 931 // compute mean free path 927 932 if(preStepScaledEnergy < mfpKinEnergy) { 928 if (integral) ComputeLambdaForScaledEnergy(preStepScaledEnergy);929 else preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy);930 if(preStepLambda <= DBL_MIN) mfpKinEnergy = 0.0;933 if (integral) { ComputeLambdaForScaledEnergy(preStepScaledEnergy); } 934 else { preStepLambda = GetLambdaForScaledEnergy(preStepScaledEnergy); } 935 if(preStepLambda <= DBL_MIN) { mfpKinEnergy = 0.0; } 931 936 } 932 937 … … 940 945 // subtract NumberOfInteractionLengthLeft 941 946 SubtractNumberOfInteractionLengthLeft(previousStepSize); 942 if(theNumberOfInteractionLengthLeft < 0.) 947 if(theNumberOfInteractionLengthLeft < 0.) { 943 948 theNumberOfInteractionLengthLeft = perMillion; 949 } 944 950 } 945 951 … … 966 972 // subtract NumberOfInteractionLengthLeft 967 973 SubtractNumberOfInteractionLengthLeft(previousStepSize); 968 if(theNumberOfInteractionLengthLeft < 0.) 974 if(theNumberOfInteractionLengthLeft < 0.) { 969 975 theNumberOfInteractionLengthLeft = perMillion; 976 } 970 977 } 971 978 currentInteractionLength = DBL_MAX; … … 987 994 // Get the actual (true) Step length 988 995 G4double length = step.GetStepLength(); 989 if(length <= DBL_MIN) return &fParticleChange;996 if(length <= DBL_MIN) { return &fParticleChange; } 990 997 G4double eloss = 0.0; 991 G4double esecdep = 0.0;992 998 993 999 /* … … 1071 1077 1072 1078 // Check boundary 1073 if(prePoint->GetStepStatus() == fGeomBoundary) yes = true;1079 if(prePoint->GetStepStatus() == fGeomBoundary) { yes = true; } 1074 1080 1075 1081 // Check PrePoint … … 1083 1089 } 1084 1090 1085 if(preSafety < rcut) yes = true;1091 if(preSafety < rcut) { yes = true; } 1086 1092 1087 1093 // Check PostPoint … … 1091 1097 postSafety = 1092 1098 safetyHelper->ComputeSafety(step.GetPostStepPoint()->GetPosition()); 1093 if(postSafety < rcut) yes = true;1099 if(postSafety < rcut) { yes = true; } 1094 1100 } 1095 1101 } … … 1103 1109 scTracks.clear(); 1104 1110 SampleSubCutSecondaries(scTracks, step, 1105 currentModel,currentMaterialIndex, 1106 esecdep); 1111 currentModel,currentMaterialIndex); 1107 1112 // add bremsstrahlung sampling 1108 1113 /* … … 1112 1117 scTracks, step, (scProcesses[i])-> 1113 1118 SelectModelForMaterial(preStepKinEnergy, currentMaterialIndex), 1114 currentMaterialIndex ,esecdep);1119 currentMaterialIndex); 1115 1120 } 1116 1121 } … … 1123 1128 G4Track* t = scTracks[i]; 1124 1129 G4double e = t->GetKineticEnergy(); 1125 if (t->GetDefinition() == thePositron) e += 2.0*electron_mass_c2;1130 if (t->GetDefinition() == thePositron) { e += 2.0*electron_mass_c2; } 1126 1131 esec += e; 1127 1132 pParticleChange->AddSecondary(t); … … 1133 1138 1134 1139 // Corrections, which cannot be tabulated 1135 currentModel->CorrectionsAlongStep(currentCouple, dynParticle, 1136 eloss, esecdep, length); 1140 if(isIon) { 1141 G4double eadd = 0.0; 1142 currentModel->CorrectionsAlongStep(currentCouple, dynParticle, 1143 eloss, eadd, length); 1144 } 1137 1145 1138 1146 // Sample fluctuations … … 1140 1148 G4VEmFluctuationModel* fluc = currentModel->GetModelOfFluctuations(); 1141 1149 if(fluc && 1142 (eloss + esec + esecdep +lowestKinEnergy) < preStepKinEnergy) {1150 (eloss + esec + lowestKinEnergy) < preStepKinEnergy) { 1143 1151 1144 1152 G4double tmax = … … 1158 1166 } 1159 1167 } 1160 // add low-energy subcutoff particles1161 eloss += esecdep;1162 if(eloss < 0.0) eloss = 0.0;1163 1168 1164 1169 // deexcitation 1165 elseif (useDeexcitation) {1166 if(idxDERegions[currentMaterialIndex] ) {1170 if (useDeexcitation) { 1171 if(idxDERegions[currentMaterialIndex] && eloss > 0.0) { 1167 1172 currentModel->SampleDeexcitationAlongStep(currentMaterial, track, eloss); 1168 if(eloss < 0.0) eloss = 0.0;1173 if(eloss < 0.0) { eloss = 0.0; } 1169 1174 } 1170 1175 } … … 1203 1208 const G4Step& step, 1204 1209 G4VEmModel* model, 1205 G4int idx, 1206 G4double& /*extraEdep*/) 1210 G4int idx) 1207 1211 { 1208 1212 // Fast check weather subcutoff can work 1209 1213 G4double subcut = (*theSubCuts)[idx]; 1210 1214 G4double cut = (*theCuts)[idx]; 1211 if(cut <= subcut) return;1215 if(cut <= subcut) { return; } 1212 1216 1213 1217 const G4Track* track = step.GetTrack(); … … 1218 1222 1219 1223 // negligible probability to get any interaction 1220 if(length*cross < perMillion) return;1224 if(length*cross < perMillion) { return; } 1221 1225 /* 1222 1226 if(-1 < verboseLevel) … … 1269 1273 if(addSec) { 1270 1274 G4Track* t = new G4Track((*it), pretime + fragment*dt, r); 1271 //G4Track* t = new G4Track((*it), pretime, r);1272 1275 t->SetTouchableHandle(track->GetTouchableHandle()); 1273 1276 tracks.push_back(t); … … 1296 1299 G4double postStepScaledEnergy = finalT*massRatio; 1297 1300 1298 if(!currentModel->IsActive(postStepScaledEnergy)) return &fParticleChange;1301 if(!currentModel->IsActive(postStepScaledEnergy)) { return &fParticleChange; } 1299 1302 /* 1300 1303 if(-1 < verboseLevel) { … … 1506 1509 G4bool mandatory) 1507 1510 { 1508 G4bool res = true;1511 G4bool isRetrieved = false; 1509 1512 G4String filename = GetPhysicsTableFileName(part,directory,tname,ascii); 1510 G4bool yes = aTable->ExistPhysicsTable(filename); 1511 if(yes) { 1512 if(!aTable) aTable = G4PhysicsTableHelper::PreparePhysicsTable(0); 1513 yes = G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii); 1514 1515 if((G4LossTableManager::Instance())->SplineFlag()) { 1516 size_t n = aTable->length(); 1517 for(size_t i=0; i<n; ++i) { 1518 if((*aTable)[i]) { 1519 (*aTable)[i]->SetSpline(true); 1513 if(aTable) { 1514 if(aTable->ExistPhysicsTable(filename)) { 1515 if(G4PhysicsTableHelper::RetrievePhysicsTable(aTable,filename,ascii)) { 1516 isRetrieved = true; 1517 if((G4LossTableManager::Instance())->SplineFlag()) { 1518 size_t n = aTable->length(); 1519 for(size_t i=0; i<n; ++i) { 1520 if((*aTable)[i]) { (*aTable)[i]->SetSpline(true); } 1521 } 1520 1522 } 1521 } 1522 } 1523 } 1524 if(yes) { 1525 if (0 < verboseLevel) { 1526 G4cout << tname << " table for " << part->GetParticleName() 1527 << " is Retrieved from <" << filename << ">" 1528 << G4endl; 1529 } 1530 } else { 1531 if(mandatory) res = false; 1532 if(mandatory || 1 < verboseLevel) { 1523 if (0 < verboseLevel) { 1524 G4cout << tname << " table for " << part->GetParticleName() 1525 << " is Retrieved from <" << filename << ">" 1526 << G4endl; 1527 } 1528 } 1529 } 1530 } 1531 if(mandatory && !isRetrieved) { 1532 if(0 < verboseLevel) { 1533 1533 G4cout << tname << " table for " << part->GetParticleName() 1534 1534 << " from file <" … … 1536 1536 << G4endl; 1537 1537 } 1538 } 1539 return res; 1538 return false; 1539 } 1540 return true; 1540 1541 } 1541 1542 … … 1574 1575 (*theCuts)[currentMaterialIndex]); 1575 1576 } 1576 1577 if(cross < 0.0) { cross = 0.0; } 1577 1578 return cross; 1578 1579 } … … 1585 1586 preStepLambda = GetLambdaForScaledEnergy(track.GetKineticEnergy()*massRatio); 1586 1587 G4double x = DBL_MAX; 1587 if(DBL_MIN < preStepLambda) x = 1.0/preStepLambda;1588 if(DBL_MIN < preStepLambda) { x = 1.0/preStepLambda; } 1588 1589 return x; 1589 1590 } … … 1622 1623 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1623 1624 1624 G4PhysicsVector* G4VEnergyLossProcess::LambdaPhysicsVector( 1625 const G4MaterialCutsCouple* couple, G4double cut) 1626 { 1625 G4PhysicsVector* 1626 G4VEnergyLossProcess::LambdaPhysicsVector(const G4MaterialCutsCouple* /*couple*/, 1627 G4double /*cut*/) 1628 { 1629 /* 1627 1630 G4double tmin = 1628 1631 std::max(MinPrimaryEnergy(particle, couple->GetMaterial(), cut), 1629 1632 minKinEnergy); 1630 if(tmin >= maxKinEnergy) tmin = 0.5*maxKinEnergy;1633 if(tmin >= maxKinEnergy) { tmin = 0.5*maxKinEnergy; } 1631 1634 G4PhysicsVector* v = new G4PhysicsLogVector(tmin, maxKinEnergy, nBins); 1635 */ 1636 G4PhysicsVector* v = new G4PhysicsLogVector(minKinEnergy, maxKinEnergy, nBins); 1632 1637 v->SetSpline((G4LossTableManager::Instance())->SplineFlag()); 1633 1638 return v; … … 1640 1645 { 1641 1646 G4bool add = true; 1642 if(p->GetProcessName() != "eBrem") add = false;1647 if(p->GetProcessName() != "eBrem") { add = false; } 1643 1648 if(add && nProcesses > 0) { 1644 1649 for(G4int i=0; i<nProcesses; ++i) { … … 1699 1704 void G4VEnergyLossProcess::SetCSDARangeTable(G4PhysicsTable* p) 1700 1705 { 1701 if(theCSDARangeTable != p) theCSDARangeTable = p;1706 if(theCSDARangeTable != p) { theCSDARangeTable = p; } 1702 1707 1703 1708 if(p) { … … 1768 1773 << " and process " << GetProcessName() << G4endl; 1769 1774 } 1770 if(theLambdaTable != p) theLambdaTable = p;1775 if(theLambdaTable != p) { theLambdaTable = p; } 1771 1776 tablesAreBuilt = true; 1772 1777 … … 1822 1827 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1823 1828 1829 const G4Element* G4VEnergyLossProcess::GetCurrentElement() const 1830 { 1831 const G4Element* elm = 0; 1832 if(currentModel) { elm = currentModel->GetCurrentElement(); } 1833 return elm; 1834 } 1835 1836 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 1837
Note: See TracChangeset
for help on using the changeset viewer.