- Timestamp:
- Nov 5, 2010, 3:45:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/processes/electromagnetic/utils/src/G4EmMultiModel.cc
r1337 r1340 24 24 // ******************************************************************** 25 25 // 26 // $Id: G4EmMultiModel.cc,v 1. 6 2007/05/22 17:31:58vnivanch Exp $27 // GEANT4 tag $Name: geant4-09-04-beta-01$26 // $Id: G4EmMultiModel.cc,v 1.8 2010/08/17 17:36:59 vnivanch Exp $ 27 // GEANT4 tag $Name: emutils-V09-03-23 $ 28 28 // 29 29 // ------------------------------------------------------------------- … … 40 40 // Modifications: 41 41 // 15-04-05 optimize internal interface (V.Ivanchenko) 42 // 43 44 // Class Description: 45 // 46 // Energy loss model using several G4VEmModels 47 48 // ------------------------------------------------------------------- 42 // 04-07-10 updated interfaces according to g4 9.4 (V.Ivanchenko) 49 43 // 50 44 … … 59 53 60 54 G4EmMultiModel::G4EmMultiModel(const G4String& nam) 61 : G4VEmModel(nam), 62 nModels(0) 55 : G4VEmModel(nam), nModels(0) 63 56 { 64 57 model.clear(); 65 tsecmin.clear();66 58 cross_section.clear(); 67 59 } … … 70 62 71 63 G4EmMultiModel::~G4EmMultiModel() 64 {} 65 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 67 68 void G4EmMultiModel::AddModel(G4VEmModel* p) 72 69 { 73 if(nModels) { 74 for(G4int i=0; i<nModels; i++) { 75 delete model[i]; 76 } 77 } 70 cross_section.push_back(0.0); 71 model.push_back(p); 72 ++nModels; 78 73 } 79 74 … … 83 78 const G4DataVector& cuts) 84 79 { 85 if(nModels) { 86 for(G4int i=0; i<nModels; i++) { 80 if(nModels > 0) { 81 G4cout << "### Initialisation of EM MultiModel " << GetName() 82 << " including following list of models:" << G4endl; 83 for(G4int i=0; i<nModels; ++i) { 84 G4cout << " " << (model[i])->GetName(); 85 (model[i])->SetParticleChange(pParticleChange, GetModelOfFluctuations()); 87 86 (model[i])->Initialise(p, cuts); 88 87 } 88 G4cout << G4endl; 89 89 } 90 }91 92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....93 94 G4double G4EmMultiModel::MinEnergyCut(const G4ParticleDefinition* p,95 const G4MaterialCutsCouple* couple)96 {97 G4double cut = DBL_MAX;98 if(nModels) {99 cut = (model[0])->MinEnergyCut(p, couple);100 }101 return cut;102 90 } 103 91 … … 106 94 G4double G4EmMultiModel::ComputeDEDX(const G4MaterialCutsCouple* couple, 107 95 const G4ParticleDefinition* p, 108 109 96 G4double kineticEnergy, 97 G4double cutEnergy) 110 98 { 111 G4double dedx = 0.0; 99 SetCurrentCouple(couple); 100 G4double dedx = 0.0; 112 101 113 if(nModels) { 114 dedx = (model[0])->ComputeDEDX(couple, p, cutEnergy, kineticEnergy); 102 if(nModels > 0) { 103 for(G4int i=0; i<nModels; i++) { 104 dedx += (model[i])->ComputeDEDX(couple, p, cutEnergy, kineticEnergy); 105 } 115 106 } 116 107 … … 120 111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 121 112 122 G4double G4EmMultiModel::CrossSection(const G4MaterialCutsCouple* couple, 123 const G4ParticleDefinition* p, 124 G4double kineticEnergy, 125 G4double cutEnergy, 126 G4double maxKinEnergy) 113 G4double G4EmMultiModel::ComputeCrossSectionPerAtom(const G4ParticleDefinition* p, 114 G4double kinEnergy, 115 G4double Z, 116 G4double A, 117 G4double cutEnergy, 118 G4double maxEnergy) 127 119 { 128 G4double cross = 0.0; 129 G4double t1 = cutEnergy; 130 G4double t2 = cutEnergy; 131 if(nModels) { 132 for(G4int i=0; i<nModels; i++) { 133 t1 = std::max(t2, tsecmin[i]); 134 t2 = std::min(maxKinEnergy, tsecmin[i+1]); 135 cross += (model[i])->CrossSection(couple, p, kineticEnergy, t1, t2); 120 G4double cross = 0.0; 121 if(nModels>0) { 122 for(G4int i=0; i<nModels; ++i) { 123 (model[i])->SetCurrentCouple(CurrentCouple()); 124 cross += (model[i])->ComputeCrossSectionPerAtom(p, kinEnergy, Z, A, 125 cutEnergy, maxEnergy); 136 126 } 137 127 } … … 144 134 const G4MaterialCutsCouple* couple, 145 135 const G4DynamicParticle* dp, 146 G4double tmin,136 G4double minEnergy, 147 137 G4double maxEnergy) 148 138 { 139 SetCurrentCouple(couple); 149 140 if(nModels > 0) { 150 141 G4int i; 151 142 G4double cross = 0.0; 152 G4double t1 = tmin; 153 G4double t2 = tmin; 154 for(i=0; i<nModels; i++) { 155 t1 = std::max(t2, tsecmin[i]); 156 t2 = std::min(maxEnergy, tsecmin[i+1]); 157 cross += (model[i])->CrossSection(couple, dp->GetDefinition(), 158 dp->GetKineticEnergy(), t1, t2); 143 for(i=0; i<nModels; ++i) { 144 cross += (model[i])->CrossSection(couple, dp->GetParticleDefinition(), 145 dp->GetKineticEnergy(), minEnergy, maxEnergy); 159 146 cross_section[i] = cross; 160 147 } 161 148 162 149 cross *= G4UniformRand(); 163 t2 = tmin;164 150 165 for(i=0; i<nModels; i++) { 166 t1 = std::max(t2, tsecmin[i]); 167 t2 = std::min(maxEnergy, tsecmin[i+1]); 151 for(i=0; i<nModels; ++i) { 168 152 if(cross <= cross_section[i]) { 169 (model[i])->SampleSecondaries(vdp, couple, dp, t1, t2);170 break;153 (model[i])->SampleSecondaries(vdp, couple, dp, minEnergy, maxEnergy); 154 return; 171 155 } 172 156 } … … 176 160 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 177 161 178 G4double G4EmMultiModel:: MaxSecondaryEnergy(const G4ParticleDefinition*,179 G4double kinEnergy)180 {181 G4cout << "Warning! G4EmMultiModel::"182 << "MaxSecondaryEnergy(const G4ParticleDefinition*,G4double kinEnergy)"183 << " should not be used!" << G4endl;184 return kinEnergy;185 }186 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....188 189 void G4EmMultiModel::DefineForRegion(const G4Region* r)190 {191 if(nModels) {192 for(G4int i=0; i<nModels; i++) {(model[i])->DefineForRegion(r);}193 }194 }195 196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....197 198 void G4EmMultiModel::AddModel(G4VEmModel* p, G4double tmin, G4double tmax)199 {200 if(tmin < tmax && 0.0 < tmin) {201 202 if(nModels == 0) {203 tsecmin.push_back(tmin);204 tsecmin.push_back(tmax);205 cross_section.push_back(0.0);206 model.push_back(p);207 nModels++;208 209 } else {210 G4int i, j;211 G4bool increment = false;212 for(i=0; i<nModels; i++) {213 214 if(tmin < tsecmin[i]) {215 G4double t2 = std::min(tsecmin[i+1],tmax);216 if(tmin < t2) {217 tsecmin.push_back(0.0);218 cross_section.push_back(0.0);219 model.push_back(0);220 for(j=nModels; j>i; j--) {221 model[j] = model[j-1];222 tsecmin[j+1] = tsecmin[j];223 }224 model[i] = p;225 tsecmin[i+1] = t2;226 tsecmin[i] = tmin;227 increment = true;228 }229 } else if(i == nModels-1) {230 G4double t1 = std::min(tsecmin[i+1],tmin);231 G4double t2 = std::max(tsecmin[i+1],tmax);232 if(t1 < t2) {233 tsecmin.push_back(t2);234 cross_section.push_back(0.0);235 model.push_back(p);236 increment = true;237 }238 }239 }240 if(increment) nModels++;241 }242 }243 }244 245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....246
Note: See TracChangeset
for help on using the changeset viewer.