Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // $Id: G4EmMultiModel.cc,v 1.4 2005/04/15 11:40:46 vnivanch Exp $ >> 24 // GEANT4 tag $Name: geant4-08-00-patch-01 $ 26 // 25 // 27 // ------------------------------------------- 26 // ------------------------------------------------------------------- 28 // 27 // 29 // GEANT4 Class file 28 // GEANT4 Class file 30 // 29 // 31 // 30 // 32 // File name: G4EmMultiModel 31 // File name: G4EmMultiModel 33 // 32 // 34 // Author: Vladimir Ivanchenko 33 // Author: Vladimir Ivanchenko 35 // 34 // 36 // Creation date: 03.05.2004 35 // Creation date: 03.05.2004 37 // 36 // 38 // Modifications: 37 // Modifications: 39 // 15-04-05 optimize internal interface (V.Iva 38 // 15-04-05 optimize internal interface (V.Ivanchenko) 40 // 04-07-10 updated interfaces according to g4 << 39 // >> 40 >> 41 // Class Description: >> 42 // >> 43 // Energy loss model using several G4VEmModels >> 44 >> 45 // ------------------------------------------------------------------- 41 // 46 // 42 47 43 48 44 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 45 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 46 51 47 #include "G4EmMultiModel.hh" 52 #include "G4EmMultiModel.hh" 48 #include "Randomize.hh" 53 #include "Randomize.hh" 49 #include "G4EmParameters.hh" << 50 54 51 //....oooOO0OOooo........oooOO0OOooo........oo 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 52 56 53 G4EmMultiModel::G4EmMultiModel(const G4String& 57 G4EmMultiModel::G4EmMultiModel(const G4String& nam) 54 : G4VEmModel(nam) << 58 : G4VEmModel(nam), >> 59 nModels(0) 55 { 60 { 56 model.clear(); 61 model.clear(); >> 62 tsecmin.clear(); 57 cross_section.clear(); 63 cross_section.clear(); 58 } 64 } 59 65 60 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 61 67 62 G4EmMultiModel::~G4EmMultiModel() = default; << 68 G4EmMultiModel::~G4EmMultiModel() 63 << 64 //....oooOO0OOooo........oooOO0OOooo........oo << 65 << 66 void G4EmMultiModel::AddModel(G4VEmModel* p) << 67 { 69 { 68 cross_section.push_back(0.0); << 70 if(nModels) { 69 model.push_back(p); << 71 for(G4int i=0; i<nModels; i++) { 70 ++nModels; << 72 delete model[i]; >> 73 } >> 74 } 71 } 75 } 72 76 73 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 74 78 75 void G4EmMultiModel::Initialise(const G4Partic 79 void G4EmMultiModel::Initialise(const G4ParticleDefinition* p, 76 const G4DataVe 80 const G4DataVector& cuts) 77 { 81 { 78 G4EmParameters* param = G4EmParameters::Inst << 82 if(nModels) { 79 G4int verb = IsMaster() ? param->Verbose() : << 83 for(G4int i=0; i<nModels; i++) { 80 if(verb > 0) { << 84 (model[i])->Initialise(p, cuts); 81 G4cout << "### Initialisation of EM MultiM << 85 } 82 << " including following list of " << nMo << 83 } << 84 for(G4int i=0; i<nModels; ++i) { << 85 G4cout << " " << (model[i])->GetName(); << 86 (model[i])->SetParticleChange(pParticleCha << 87 (model[i])->Initialise(p, cuts); << 88 } 86 } 89 if(verb > 0) { G4cout << G4endl; } << 90 } 87 } 91 88 92 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 93 90 94 G4double G4EmMultiModel::ComputeDEDXPerVolume( << 91 G4double G4EmMultiModel::MinEnergyCut(const G4ParticleDefinition* p, 95 const G4ParticleDefinition* p, << 92 const G4MaterialCutsCouple* couple) 96 G4double kineticEnergy, << 93 { 97 G4double cutEnergy) << 94 G4double cut = DBL_MAX; >> 95 if(nModels) { >> 96 cut = (model[0])->MinEnergyCut(p, couple); >> 97 } >> 98 return cut; >> 99 } >> 100 >> 101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 102 >> 103 G4double G4EmMultiModel::ComputeDEDX(const G4MaterialCutsCouple* couple, >> 104 const G4ParticleDefinition* p, >> 105 G4double kineticEnergy, >> 106 G4double cutEnergy) 98 { 107 { 99 G4double dedx = 0.0; << 108 G4double dedx = 0.0; 100 for(G4int i=0; i<nModels; ++i) { << 109 101 dedx += (model[i])->ComputeDEDXPerVolume(m << 110 if(nModels) { >> 111 dedx = (model[0])->ComputeDEDX(couple, p, cutEnergy, kineticEnergy); 102 } 112 } 103 113 104 return dedx; 114 return dedx; 105 } 115 } 106 116 107 //....oooOO0OOooo........oooOO0OOooo........oo 117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 108 118 109 G4double G4EmMultiModel::ComputeCrossSectionPe << 119 G4double G4EmMultiModel::CrossSection(const G4MaterialCutsCouple* couple, 110 << 120 const G4ParticleDefinition* p, 111 << 121 G4double kineticEnergy, 112 << 122 G4double cutEnergy, 113 << 123 G4double maxKinEnergy) 114 << 124 { 115 { << 125 G4double cross = 0.0; 116 G4double cross = 0.0; << 126 G4double t1 = cutEnergy; 117 for(G4int i=0; i<nModels; ++i) { << 127 G4double t2 = cutEnergy; 118 (model[i])->SetCurrentCouple(CurrentCouple << 128 if(nModels) { 119 cross += (model[i])->ComputeCrossSectionPe << 129 for(G4int i=0; i<nModels; i++) { 120 cutEnergy, maxEnergy); << 130 t1 = std::max(t2, tsecmin[i]); >> 131 t2 = std::min(maxKinEnergy, tsecmin[i+1]); >> 132 cross += (model[i])->CrossSection(couple, p, kineticEnergy, t1, t2); >> 133 } 121 } 134 } 122 return cross; 135 return cross; 123 } 136 } 124 137 125 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 139 127 void G4EmMultiModel::SampleSecondaries(std::ve << 140 std::vector<G4DynamicParticle*>* G4EmMultiModel::SampleSecondaries( 128 const G << 141 const G4MaterialCutsCouple* couple, 129 const G << 142 const G4DynamicParticle* dp, 130 G4doubl << 143 G4double tmin, 131 G4doubl << 144 G4double maxEnergy) 132 { 145 { 133 SetCurrentCouple(couple); << 146 std::vector<G4DynamicParticle*>* vdp = 0; 134 if(nModels > 0) { << 147 >> 148 if(nModels) { 135 G4int i; 149 G4int i; 136 G4double cross = 0.0; 150 G4double cross = 0.0; 137 for(i=0; i<nModels; ++i) { << 151 G4double t1 = tmin; 138 cross += (model[i])->CrossSection(couple << 152 G4double t2 = tmin; 139 dp->Ge << 153 for(i=0; i<nModels; i++) { >> 154 t1 = std::max(t2, tsecmin[i]); >> 155 t2 = std::min(maxEnergy, tsecmin[i+1]); >> 156 cross += (model[i])->CrossSection(couple, dp->GetDefinition(), >> 157 dp->GetKineticEnergy(), t1, t2); 140 cross_section[i] = cross; 158 cross_section[i] = cross; 141 } 159 } 142 160 143 cross *= G4UniformRand(); 161 cross *= G4UniformRand(); >> 162 t2 = tmin; 144 163 145 for(i=0; i<nModels; ++i) { << 164 for(i=0; i<nModels; i++) { >> 165 t1 = std::max(t2, tsecmin[i]); >> 166 t2 = std::min(maxEnergy, tsecmin[i+1]); 146 if(cross <= cross_section[i]) { 167 if(cross <= cross_section[i]) { 147 (model[i])->SampleSecondaries(vdp, cou << 168 vdp = (model[i])->SampleSecondaries(couple, dp, t1, t2); 148 return; << 169 break; >> 170 } >> 171 } >> 172 } >> 173 >> 174 return vdp; >> 175 } >> 176 >> 177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 178 >> 179 G4double G4EmMultiModel:: MaxSecondaryEnergy(const G4ParticleDefinition*, >> 180 G4double kinEnergy) >> 181 { >> 182 G4cout << "Warning! G4EmMultiModel::" >> 183 << "MaxSecondaryEnergy(const G4ParticleDefinition*,G4double kinEnergy)" >> 184 << " should not be used!" << G4endl; >> 185 return kinEnergy; >> 186 } >> 187 >> 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 189 >> 190 void G4EmMultiModel::DefineForRegion(const G4Region* r) >> 191 { >> 192 if(nModels) { >> 193 for(G4int i=0; i<nModels; i++) {(model[i])->DefineForRegion(r);} >> 194 } >> 195 } >> 196 >> 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 198 >> 199 void G4EmMultiModel::AddModel(G4VEmModel* p, G4double tmin, G4double tmax) >> 200 { >> 201 if(tmin < tmax && 0.0 < tmin) { >> 202 >> 203 if(nModels == 0) { >> 204 tsecmin.push_back(tmin); >> 205 tsecmin.push_back(tmax); >> 206 cross_section.push_back(0.0); >> 207 model.push_back(p); >> 208 nModels++; >> 209 >> 210 } else { >> 211 G4int i, j; >> 212 G4bool increment = false; >> 213 for(i=0; i<nModels; i++) { >> 214 >> 215 if(tmin < tsecmin[i]) { >> 216 G4double t2 = std::min(tsecmin[i+1],tmax); >> 217 if(tmin < t2) { >> 218 tsecmin.push_back(0.0); >> 219 cross_section.push_back(0.0); >> 220 model.push_back(0); >> 221 for(j=nModels; j>i; j--) { >> 222 model[j] = model[j-1]; >> 223 tsecmin[j+1] = tsecmin[j]; >> 224 } >> 225 model[i] = p; >> 226 tsecmin[i+1] = t2; >> 227 tsecmin[i] = tmin; >> 228 increment = true; >> 229 } >> 230 } else if(i == nModels-1) { >> 231 G4double t1 = std::min(tsecmin[i+1],tmin); >> 232 G4double t2 = std::max(tsecmin[i+1],tmax); >> 233 if(t1 < t2) { >> 234 tsecmin.push_back(t2); >> 235 cross_section.push_back(0.0); >> 236 model.push_back(p); >> 237 increment = true; >> 238 } >> 239 } 149 } 240 } >> 241 if(increment) nModels++; 150 } 242 } 151 } 243 } 152 } 244 } 153 245 154 //....oooOO0OOooo........oooOO0OOooo........oo 246 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 155 247 156 248