Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // ------------------------------------------- 27 // ------------------------------------------------------------------- 28 // 28 // 29 // GEANT4 Class file 29 // GEANT4 Class file 30 // 30 // 31 // 31 // 32 // File name: G4EmModelManager 32 // File name: G4EmModelManager 33 // 33 // 34 // Author: Vladimir Ivanchenko 34 // Author: Vladimir Ivanchenko 35 // 35 // 36 // Creation date: 07.05.2002 36 // Creation date: 07.05.2002 37 // 37 // 38 // Modifications: V.Ivanchenko 38 // Modifications: V.Ivanchenko 39 // 39 // 40 // Class Description: 40 // Class Description: 41 // 41 // 42 // It is the unified energy loss process it ca 42 // It is the unified energy loss process it calculates the continuous 43 // energy loss for charged particles using a s 43 // energy loss for charged particles using a set of Energy Loss 44 // models valid for different energy regions. 44 // models valid for different energy regions. There are a possibility 45 // to create and access to dE/dx and range tab 45 // to create and access to dE/dx and range tables, or to calculate 46 // that information on fly. 46 // that information on fly. 47 // ------------------------------------------- 47 // ------------------------------------------------------------------- 48 // 48 // 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 50 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 51 51 52 #include "G4EmModelManager.hh" 52 #include "G4EmModelManager.hh" 53 #include "G4SystemOfUnits.hh" 53 #include "G4SystemOfUnits.hh" 54 #include "G4PhysicsTable.hh" 54 #include "G4PhysicsTable.hh" 55 #include "G4PhysicsVector.hh" 55 #include "G4PhysicsVector.hh" 56 #include "G4VMscModel.hh" << 57 << 58 #include "G4Step.hh" << 59 #include "G4ParticleDefinition.hh" << 60 #include "G4PhysicsVector.hh" << 61 #include "G4MaterialCutsCouple.hh" << 62 #include "G4ProductionCutsTable.hh" << 63 #include "G4RegionStore.hh" << 64 #include "G4Gamma.hh" << 65 #include "G4Electron.hh" << 66 #include "G4Positron.hh" << 67 #include "G4UnitsTable.hh" << 68 #include "G4DataVector.hh" << 69 56 70 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 71 58 72 G4RegionModels::G4RegionModels(G4int nMod, std 59 G4RegionModels::G4RegionModels(G4int nMod, std::vector<G4int>& indx, 73 G4DataVector& l 60 G4DataVector& lowE, const G4Region* reg) 74 { 61 { 75 nModelsForRegion = nMod; 62 nModelsForRegion = nMod; 76 theListOfModelIndexes = new G4int [nModelsFo 63 theListOfModelIndexes = new G4int [nModelsForRegion]; 77 lowKineticEnergy = new G4double [nModel 64 lowKineticEnergy = new G4double [nModelsForRegion+1]; 78 for (G4int i=0; i<nModelsForRegion; ++i) { 65 for (G4int i=0; i<nModelsForRegion; ++i) { 79 theListOfModelIndexes[i] = indx[i]; 66 theListOfModelIndexes[i] = indx[i]; 80 lowKineticEnergy[i] = lowE[i]; 67 lowKineticEnergy[i] = lowE[i]; 81 } 68 } 82 lowKineticEnergy[nModelsForRegion] = lowE[nM 69 lowKineticEnergy[nModelsForRegion] = lowE[nModelsForRegion]; 83 theRegion = reg; 70 theRegion = reg; 84 } 71 } 85 72 86 //....oooOO0OOooo........oooOO0OOooo........oo 73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 87 74 88 G4RegionModels::~G4RegionModels() 75 G4RegionModels::~G4RegionModels() 89 { 76 { 90 delete [] theListOfModelIndexes; 77 delete [] theListOfModelIndexes; 91 delete [] lowKineticEnergy; 78 delete [] lowKineticEnergy; 92 } 79 } 93 80 94 //....oooOO0OOooo........oooOO0OOooo........oo 81 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 82 >> 83 #include "G4Step.hh" >> 84 #include "G4ParticleDefinition.hh" >> 85 #include "G4PhysicsVector.hh" >> 86 #include "G4MaterialCutsCouple.hh" >> 87 #include "G4ProductionCutsTable.hh" >> 88 #include "G4RegionStore.hh" >> 89 #include "G4Gamma.hh" >> 90 #include "G4Electron.hh" >> 91 #include "G4Positron.hh" >> 92 #include "G4UnitsTable.hh" >> 93 #include "G4DataVector.hh" >> 94 95 //....oooOO0OOooo........oooOO0OOooo........oo 95 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 96 96 97 G4EmModelManager::G4EmModelManager() << 97 G4EmModelManager::G4EmModelManager(): >> 98 nEmModels(0), >> 99 nRegions(0), >> 100 particle(0), >> 101 verboseLevel(0) 98 { 102 { >> 103 maxSubCutInRange = 0.7*mm; 99 models.reserve(4); 104 models.reserve(4); 100 flucModels.reserve(4); 105 flucModels.reserve(4); 101 regions.reserve(4); 106 regions.reserve(4); 102 orderOfModels.reserve(4); 107 orderOfModels.reserve(4); 103 isUsed.reserve(4); 108 isUsed.reserve(4); >> 109 severalModels = true; >> 110 fluoFlag = false; >> 111 currRegionModel = nullptr; >> 112 currModel = nullptr; >> 113 theCuts = nullptr; >> 114 theCutsNew = nullptr; >> 115 theSubCuts = nullptr; 104 } 116 } 105 117 106 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 107 119 108 G4EmModelManager::~G4EmModelManager() 120 G4EmModelManager::~G4EmModelManager() 109 { 121 { 110 verboseLevel = 0; // no verbosity at destruc 122 verboseLevel = 0; // no verbosity at destruction 111 Clear(); 123 Clear(); 112 delete theCutsNew; 124 delete theCutsNew; >> 125 delete theSubCuts; 113 } 126 } 114 127 115 //....oooOO0OOooo........oooOO0OOooo........oo 128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 116 129 117 void G4EmModelManager::Clear() 130 void G4EmModelManager::Clear() 118 { 131 { 119 if(1 < verboseLevel) { 132 if(1 < verboseLevel) { 120 G4cout << "G4EmModelManager::Clear()" << G 133 G4cout << "G4EmModelManager::Clear()" << G4endl; 121 } 134 } 122 std::size_t n = setOfRegionModels.size(); << 135 size_t n = setOfRegionModels.size(); 123 for(std::size_t i=0; i<n; ++i) { << 136 if(n > 0) { 124 delete setOfRegionModels[i]; << 137 for(size_t i=0; i<n; ++i) { 125 setOfRegionModels[i] = nullptr; << 138 delete setOfRegionModels[i]; >> 139 setOfRegionModels[i] = nullptr; >> 140 } 126 } 141 } 127 } 142 } 128 143 129 //....oooOO0OOooo........oooOO0OOooo........oo 144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 130 145 131 void G4EmModelManager::AddEmModel(G4int num, G 146 void G4EmModelManager::AddEmModel(G4int num, G4VEmModel* p, 132 G4VEmFluctua 147 G4VEmFluctuationModel* fm, const G4Region* r) 133 { 148 { 134 if(nullptr == p) { << 149 if(!p) { 135 G4cout << "G4EmModelManager::AddEmModel WA 150 G4cout << "G4EmModelManager::AddEmModel WARNING: no model defined." 136 << G4endl; 151 << G4endl; 137 return; 152 return; 138 } 153 } 139 models.push_back(p); 154 models.push_back(p); 140 flucModels.push_back(fm); 155 flucModels.push_back(fm); 141 regions.push_back(r); 156 regions.push_back(r); 142 orderOfModels.push_back(num); 157 orderOfModels.push_back(num); 143 isUsed.push_back(0); 158 isUsed.push_back(0); 144 p->DefineForRegion(r); 159 p->DefineForRegion(r); 145 ++nEmModels; 160 ++nEmModels; 146 } 161 } 147 162 148 //....oooOO0OOooo........oooOO0OOooo........oo 163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 149 164 150 G4VEmModel* G4EmModelManager::GetModel(G4int i << 165 void G4EmModelManager::UpdateEmModel(const G4String& nam, >> 166 G4double emin, G4double emax) >> 167 { >> 168 if (nEmModels > 0) { >> 169 for(G4int i=0; i<nEmModels; ++i) { >> 170 if(nam == models[i]->GetName()) { >> 171 models[i]->SetLowEnergyLimit(emin); >> 172 models[i]->SetHighEnergyLimit(emax); >> 173 break; >> 174 } >> 175 } >> 176 } >> 177 G4cout << "G4EmModelManager::UpdateEmModel WARNING: no model <" >> 178 << nam << "> is found out" >> 179 << G4endl; >> 180 } >> 181 >> 182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 183 >> 184 G4VEmModel* G4EmModelManager::GetModel(G4int i, G4bool ver) 151 { 185 { 152 G4VEmModel* model = nullptr; 186 G4VEmModel* model = nullptr; 153 if(idx >= 0 && idx < nEmModels) { model = mo << 187 if(i < nEmModels) { model = models[i]; } 154 else if(verboseLevel > 0 && ver) { 188 else if(verboseLevel > 0 && ver) { 155 G4cout << "G4EmModelManager::GetModel WARN 189 G4cout << "G4EmModelManager::GetModel WARNING: " 156 << "index " << idx << " is wrong Nm << 190 << "index " << i << " is wrong Nmodels= " 157 << nEmModels; 191 << nEmModels; 158 if(nullptr != particle) { << 192 if(particle) { G4cout << " for " << particle->GetParticleName(); } 159 G4cout << " for " << particle->GetPartic << 160 } << 161 G4cout<< G4endl; 193 G4cout<< G4endl; 162 } 194 } 163 return model; 195 return model; 164 } 196 } 165 197 166 //....oooOO0OOooo........oooOO0OOooo........oo 198 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 167 199 168 G4VEmModel* G4EmModelManager::GetRegionModel(G << 200 G4VEmModel* G4EmModelManager::GetRegionModel(G4int k, size_t idx) 169 { 201 { 170 G4RegionModels* rm = setOfRegionModels[idxOf 202 G4RegionModels* rm = setOfRegionModels[idxOfRegionModels[idx]]; 171 return (k < rm->NumberOfModels()) ? models[r << 203 G4VEmModel* mod = models[rm->ModelIndex(k)]; >> 204 return mod; 172 } 205 } 173 206 174 //....oooOO0OOooo........oooOO0OOooo........oo 207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 175 208 176 G4int G4EmModelManager::NumberOfRegionModels(s << 209 G4int G4EmModelManager::NumberOfRegionModels(size_t idx) const 177 { 210 { 178 G4RegionModels* rm = setOfRegionModels[idxOf 211 G4RegionModels* rm = setOfRegionModels[idxOfRegionModels[idx]]; 179 return rm->NumberOfModels(); 212 return rm->NumberOfModels(); 180 } 213 } 181 214 182 //....oooOO0OOooo........oooOO0OOooo........oo 215 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 183 216 184 const G4DataVector* 217 const G4DataVector* 185 G4EmModelManager::Initialise(const G4ParticleD 218 G4EmModelManager::Initialise(const G4ParticleDefinition* p, 186 const G4ParticleD 219 const G4ParticleDefinition* secondaryParticle, 187 G4int verb) << 220 G4double minSubRange, >> 221 G4int val) 188 { 222 { 189 verboseLevel = verb; << 223 verboseLevel = val; >> 224 G4String partname = p->GetParticleName(); 190 if(1 < verboseLevel) { 225 if(1 < verboseLevel) { 191 G4cout << "G4EmModelManager::Initialise() 226 G4cout << "G4EmModelManager::Initialise() for " 192 << p->GetParticleName() << " Nmode << 227 << partname << " Nmodels= " << nEmModels << G4endl; 193 } 228 } 194 // Are models defined? 229 // Are models defined? 195 if(nEmModels < 1) { 230 if(nEmModels < 1) { 196 G4ExceptionDescription ed; 231 G4ExceptionDescription ed; 197 ed << "No models found out for " << p->Get 232 ed << "No models found out for " << p->GetParticleName() 198 << " !"; 233 << " !"; 199 G4Exception("G4EmModelManager::Initialise" 234 G4Exception("G4EmModelManager::Initialise","em0002", 200 FatalException, ed); 235 FatalException, ed); 201 } 236 } 202 237 203 particle = p; 238 particle = p; 204 Clear(); // needed if run is not first 239 Clear(); // needed if run is not first 205 240 206 G4RegionStore* regionStore = G4RegionStore:: 241 G4RegionStore* regionStore = G4RegionStore::GetInstance(); 207 const G4Region* world = 242 const G4Region* world = 208 regionStore->GetRegion("DefaultRegionForTh 243 regionStore->GetRegion("DefaultRegionForTheWorld", false); 209 244 210 // Identify the list of regions with differe 245 // Identify the list of regions with different set of models 211 nRegions = 1; 246 nRegions = 1; 212 std::vector<const G4Region*> setr; 247 std::vector<const G4Region*> setr; 213 setr.push_back(world); 248 setr.push_back(world); 214 G4bool isWorld = false; 249 G4bool isWorld = false; 215 250 216 for (G4int ii=0; ii<nEmModels; ++ii) { 251 for (G4int ii=0; ii<nEmModels; ++ii) { 217 const G4Region* r = regions[ii]; 252 const G4Region* r = regions[ii]; 218 if ( r == nullptr || r == world) { << 253 if ( r == 0 || r == world) { 219 isWorld = true; 254 isWorld = true; 220 regions[ii] = world; 255 regions[ii] = world; 221 } else { 256 } else { 222 G4bool newRegion = true; 257 G4bool newRegion = true; 223 if (nRegions>1) { 258 if (nRegions>1) { 224 for (G4int j=1; j<nRegions; ++j) { 259 for (G4int j=1; j<nRegions; ++j) { 225 if ( r == setr[j] ) { newRegion = fa 260 if ( r == setr[j] ) { newRegion = false; } 226 } 261 } 227 } 262 } 228 if (newRegion) { 263 if (newRegion) { 229 setr.push_back(r); 264 setr.push_back(r); 230 ++nRegions; << 265 nRegions++; 231 } 266 } 232 } 267 } 233 } 268 } 234 // Are models defined? 269 // Are models defined? 235 if(!isWorld) { 270 if(!isWorld) { 236 G4ExceptionDescription ed; 271 G4ExceptionDescription ed; 237 ed << "No models defined for the World vol 272 ed << "No models defined for the World volume for " 238 << p->GetParticleName() << " !"; 273 << p->GetParticleName() << " !"; 239 G4Exception("G4EmModelManager::Initialise" 274 G4Exception("G4EmModelManager::Initialise","em0002", 240 FatalException, ed); 275 FatalException, ed); 241 } 276 } 242 277 243 G4ProductionCutsTable* theCoupleTable= 278 G4ProductionCutsTable* theCoupleTable= 244 G4ProductionCutsTable::GetProductionCutsTa 279 G4ProductionCutsTable::GetProductionCutsTable(); 245 std::size_t numOfCouples = theCoupleTable->G << 280 size_t numOfCouples = theCoupleTable->GetTableSize(); 246 281 247 // prepare vectors, shortcut for the case of 282 // prepare vectors, shortcut for the case of only 1 model 248 // or only one region 283 // or only one region 249 if(nRegions > 1 && nEmModels > 1) { 284 if(nRegions > 1 && nEmModels > 1) { 250 idxOfRegionModels.resize(numOfCouples,0); 285 idxOfRegionModels.resize(numOfCouples,0); 251 setOfRegionModels.resize((std::size_t)nReg << 286 setOfRegionModels.resize((size_t)nRegions,0); 252 } else { 287 } else { 253 idxOfRegionModels.resize(1,0); 288 idxOfRegionModels.resize(1,0); 254 setOfRegionModels.resize(1,nullptr); << 289 setOfRegionModels.resize(1,0); 255 } 290 } 256 291 257 std::vector<G4int> modelAtRegion(nEmModel 292 std::vector<G4int> modelAtRegion(nEmModels); 258 std::vector<G4int> modelOrd(nEmModels); 293 std::vector<G4int> modelOrd(nEmModels); 259 G4DataVector eLow(nEmModels+1); 294 G4DataVector eLow(nEmModels+1); 260 G4DataVector eHigh(nEmModels); 295 G4DataVector eHigh(nEmModels); 261 296 262 if(1 < verboseLevel) { 297 if(1 < verboseLevel) { 263 G4cout << " Nregions= " << nRegions 298 G4cout << " Nregions= " << nRegions 264 << " Nmodels= " << nEmModels << G4 299 << " Nmodels= " << nEmModels << G4endl; 265 } 300 } 266 301 267 // Order models for regions 302 // Order models for regions 268 for (G4int reg=0; reg<nRegions; ++reg) { 303 for (G4int reg=0; reg<nRegions; ++reg) { 269 const G4Region* region = setr[reg]; 304 const G4Region* region = setr[reg]; 270 G4int n = 0; 305 G4int n = 0; 271 306 272 for (G4int ii=0; ii<nEmModels; ++ii) { 307 for (G4int ii=0; ii<nEmModels; ++ii) { 273 308 274 G4VEmModel* model = models[ii]; 309 G4VEmModel* model = models[ii]; 275 if ( region == regions[ii] ) { 310 if ( region == regions[ii] ) { 276 311 277 G4double tmin = model->LowEnergyLimit( 312 G4double tmin = model->LowEnergyLimit(); 278 G4double tmax = model->HighEnergyLimit 313 G4double tmax = model->HighEnergyLimit(); 279 G4int ord = orderOfModels[ii]; 314 G4int ord = orderOfModels[ii]; 280 G4bool push = true; 315 G4bool push = true; 281 G4bool insert = false; 316 G4bool insert = false; 282 G4int idx = n; 317 G4int idx = n; 283 318 284 if(1 < verboseLevel) { 319 if(1 < verboseLevel) { 285 G4cout << "Model #" << ii 320 G4cout << "Model #" << ii 286 << " <" << model->GetName() < 321 << " <" << model->GetName() << "> for region <"; 287 if (region) G4cout << region->GetNam 322 if (region) G4cout << region->GetName(); 288 G4cout << "> " 323 G4cout << "> " 289 << " tmin(MeV)= " << tmin/MeV 324 << " tmin(MeV)= " << tmin/MeV 290 << "; tmax(MeV)= " << tmax/Me 325 << "; tmax(MeV)= " << tmax/MeV 291 << "; order= " << ord 326 << "; order= " << ord 292 << "; tminAct= " << model->LowEnergyActiv 327 << "; tminAct= " << model->LowEnergyActivationLimit()/MeV 293 << "; tmaxAct= " << model->HighEnergyActi 328 << "; tmaxAct= " << model->HighEnergyActivationLimit()/MeV 294 << G4endl; 329 << G4endl; 295 } 330 } 296 331 297 static const G4double limitdelta = 0.01*eV; 332 static const G4double limitdelta = 0.01*eV; 298 if(n > 0) { 333 if(n > 0) { 299 334 300 // extend energy range to previous m 335 // extend energy range to previous models 301 tmin = std::min(tmin, eHigh[n-1]); 336 tmin = std::min(tmin, eHigh[n-1]); 302 tmax = std::max(tmax, eLow[0]); 337 tmax = std::max(tmax, eLow[0]); 303 //G4cout << "tmin= " << tmin << " t 338 //G4cout << "tmin= " << tmin << " tmax= " 304 // << tmax << " ord= " << 339 // << tmax << " ord= " << ord <<G4endl; 305 // empty energy range 340 // empty energy range 306 if( tmax - tmin <= limitdelta) { pus 341 if( tmax - tmin <= limitdelta) { push = false; } 307 // low-energy model 342 // low-energy model 308 else if (tmax == eLow[0]) { 343 else if (tmax == eLow[0]) { 309 push = false; 344 push = false; 310 insert = true; 345 insert = true; 311 idx = 0; 346 idx = 0; 312 // resolve intersections 347 // resolve intersections 313 } else if(tmin < eHigh[n-1]) { 348 } else if(tmin < eHigh[n-1]) { 314 // compare order 349 // compare order 315 for(G4int k=0; k<n; ++k) { 350 for(G4int k=0; k<n; ++k) { 316 // new model has higher order pa 351 // new model has higher order parameter, 317 // so, its application area may be red 352 // so, its application area may be reduced 318 // to avoid intersections 353 // to avoid intersections 319 if(ord >= modelOrd[k]) { 354 if(ord >= modelOrd[k]) { 320 if(tmin < eHigh[k] && tmin >= 355 if(tmin < eHigh[k] && tmin >= eLow[k]) { tmin = eHigh[k]; } 321 if(tmax <= eHigh[k] && tmax > 356 if(tmax <= eHigh[k] && tmax > eLow[k]) { tmax = eLow[k]; } 322 if(tmax > eHigh[k] && tmin < e 357 if(tmax > eHigh[k] && tmin < eLow[k]) { 323 if(tmax - eHigh[k] > eLow[k] 358 if(tmax - eHigh[k] > eLow[k] - tmin) { tmin = eHigh[k]; } 324 else { tmax = eLow[k]; } 359 else { tmax = eLow[k]; } 325 } 360 } 326 if( tmax - tmin <= limitdelta) 361 if( tmax - tmin <= limitdelta) { 327 push = false; 362 push = false; 328 break; 363 break; 329 } 364 } 330 } 365 } 331 } 366 } 332 // this model has lower order parameter 367 // this model has lower order parameter than possible 333 // other models, with which there may be 368 // other models, with which there may be intersections 334 // so, appliction area of such models ma 369 // so, appliction area of such models may be reduced 335 370 336 // insert below the first model 371 // insert below the first model 337 if (tmax <= eLow[0]) { 372 if (tmax <= eLow[0]) { 338 push = false; 373 push = false; 339 insert = true; 374 insert = true; 340 idx = 0; 375 idx = 0; 341 // resolve intersections 376 // resolve intersections 342 } else if(tmin < eHigh[n-1]) { 377 } else if(tmin < eHigh[n-1]) { 343 // last energy interval 378 // last energy interval 344 if(tmin > eLow[n-1] && tmax >= eHigh[n 379 if(tmin > eLow[n-1] && tmax >= eHigh[n-1]) { 345 eHigh[n-1] = tmin; 380 eHigh[n-1] = tmin; 346 // first energy interval 381 // first energy interval 347 } else if(tmin <= eLow[0] && tmax < eH 382 } else if(tmin <= eLow[0] && tmax < eHigh[0]) { 348 eLow[0] = tmax; 383 eLow[0] = tmax; 349 push = false; 384 push = false; 350 insert = true; 385 insert = true; 351 idx = 0; 386 idx = 0; 352 // loop over all models 387 // loop over all models 353 } else { 388 } else { 354 for(G4int k=n-1; k>=0; --k) { 389 for(G4int k=n-1; k>=0; --k) { 355 if(tmin <= eLow[k] && tmax >= eHigh[k]) 390 if(tmin <= eLow[k] && tmax >= eHigh[k]) { 356 // full overlap exclude previous model 391 // full overlap exclude previous model 357 isUsed[modelAtRegion[k]] = 0; 392 isUsed[modelAtRegion[k]] = 0; 358 idx = k; 393 idx = k; 359 if(k < n-1) { 394 if(k < n-1) { 360 // shift upper models and change ind 395 // shift upper models and change index 361 for(G4int kk=k; kk<n-1; ++kk) { 396 for(G4int kk=k; kk<n-1; ++kk) { 362 modelAtRegion[kk] = modelAtRegion[kk+1]; 397 modelAtRegion[kk] = modelAtRegion[kk+1]; 363 modelOrd[kk] = modelOrd[kk+1]; 398 modelOrd[kk] = modelOrd[kk+1]; 364 eLow[kk] = eLow[kk+1]; 399 eLow[kk] = eLow[kk+1]; 365 eHigh[kk] = eHigh[kk+1]; 400 eHigh[kk] = eHigh[kk+1]; 366 } 401 } 367 ++k; 402 ++k; 368 } 403 } 369 --n; 404 --n; 370 } else { 405 } else { 371 // partially reduce previous model are 406 // partially reduce previous model area 372 if(tmin <= eLow[k] && tmax > eLow[k]) 407 if(tmin <= eLow[k] && tmax > eLow[k]) { 373 eLow[k] = tmax; 408 eLow[k] = tmax; 374 idx = k; 409 idx = k; 375 insert = true; 410 insert = true; 376 push = false; 411 push = false; 377 } else if(tmin < eHigh[k] && tmax >= e 412 } else if(tmin < eHigh[k] && tmax >= eHigh[k]) { 378 eHigh[k] = tmin; 413 eHigh[k] = tmin; 379 idx = k + 1; 414 idx = k + 1; 380 if(idx < n) { 415 if(idx < n) { 381 insert = true; 416 insert = true; 382 push = false; 417 push = false; 383 } 418 } 384 } else if(tmin > eLow[k] && tmax < eHi 419 } else if(tmin > eLow[k] && tmax < eHigh[k]) { 385 if(eHigh[k] - tmax > tmin - eLow[k]) 420 if(eHigh[k] - tmax > tmin - eLow[k]) { 386 eLow[k] = tmax; 421 eLow[k] = tmax; 387 idx = k; 422 idx = k; 388 insert = true; 423 insert = true; 389 push = false; 424 push = false; 390 } else { 425 } else { 391 eHigh[k] = tmin; 426 eHigh[k] = tmin; 392 idx = k + 1; 427 idx = k + 1; 393 if(idx < n) { 428 if(idx < n) { 394 insert = true; 429 insert = true; 395 push = false; 430 push = false; 396 } 431 } 397 } 432 } 398 } 433 } 399 } 434 } 400 } 435 } 401 } 436 } 402 } 437 } 403 } 438 } 404 } 439 } 405 // provide space for the new model 440 // provide space for the new model 406 if(insert) { 441 if(insert) { 407 for(G4int k=n-1; k>=idx; --k) { 442 for(G4int k=n-1; k>=idx; --k) { 408 modelAtRegion[k+1] = modelAtRegion 443 modelAtRegion[k+1] = modelAtRegion[k]; 409 modelOrd[k+1] = modelOrd[k]; 444 modelOrd[k+1] = modelOrd[k]; 410 eLow[k+1] = eLow[k]; 445 eLow[k+1] = eLow[k]; 411 eHigh[k+1] = eHigh[k]; 446 eHigh[k+1] = eHigh[k]; 412 } 447 } 413 } 448 } 414 //G4cout << "push= " << push << " inse 449 //G4cout << "push= " << push << " insert= " << insert 415 // << " idx= " << idx <<G4endl; 450 // << " idx= " << idx <<G4endl; 416 // the model is added 451 // the model is added 417 if (push || insert) { 452 if (push || insert) { 418 ++n; 453 ++n; 419 modelAtRegion[idx] = ii; 454 modelAtRegion[idx] = ii; 420 modelOrd[idx] = ord; 455 modelOrd[idx] = ord; 421 eLow[idx] = tmin; 456 eLow[idx] = tmin; 422 eHigh[idx] = tmax; 457 eHigh[idx] = tmax; 423 isUsed[ii] = 1; 458 isUsed[ii] = 1; 424 } 459 } 425 // exclude models with zero energy range 460 // exclude models with zero energy range 426 for(G4int k=n-1; k>=0; --k) { 461 for(G4int k=n-1; k>=0; --k) { 427 if(eHigh[k] - eLow[k] <= limitdelta) { 462 if(eHigh[k] - eLow[k] <= limitdelta) { 428 isUsed[modelAtRegion[k]] = 0; 463 isUsed[modelAtRegion[k]] = 0; 429 if(k < n-1) { 464 if(k < n-1) { 430 for(G4int kk=k; kk<n-1; ++kk) { 465 for(G4int kk=k; kk<n-1; ++kk) { 431 modelAtRegion[kk] = modelAtRegion[kk+1]; 466 modelAtRegion[kk] = modelAtRegion[kk+1]; 432 modelOrd[kk] = modelOrd[kk+1]; 467 modelOrd[kk] = modelOrd[kk+1]; 433 eLow[kk] = eLow[kk+1]; 468 eLow[kk] = eLow[kk+1]; 434 eHigh[kk] = eHigh[kk+1]; 469 eHigh[kk] = eHigh[kk+1]; 435 } 470 } 436 } 471 } 437 --n; 472 --n; 438 } 473 } 439 } 474 } 440 } 475 } 441 } 476 } 442 eLow[0] = 0.0; 477 eLow[0] = 0.0; 443 eLow[n] = eHigh[n-1]; 478 eLow[n] = eHigh[n-1]; 444 479 445 if(1 < verboseLevel) { 480 if(1 < verboseLevel) { 446 G4cout << "### New G4RegionModels set wi 481 G4cout << "### New G4RegionModels set with " << n 447 << " models for region <"; 482 << " models for region <"; 448 if (region) { G4cout << region->GetName( 483 if (region) { G4cout << region->GetName(); } 449 G4cout << "> Elow(MeV)= "; 484 G4cout << "> Elow(MeV)= "; 450 for(G4int iii=0; iii<=n; ++iii) {G4cout 485 for(G4int iii=0; iii<=n; ++iii) {G4cout << eLow[iii]/MeV << " ";} 451 G4cout << G4endl; 486 G4cout << G4endl; 452 } 487 } 453 auto rm = new G4RegionModels(n, modelAtReg << 488 G4RegionModels* rm = new G4RegionModels(n, modelAtRegion, eLow, region); 454 setOfRegionModels[reg] = rm; 489 setOfRegionModels[reg] = rm; 455 // shortcut 490 // shortcut 456 if(1 == nEmModels) { break; } 491 if(1 == nEmModels) { break; } 457 } 492 } 458 493 459 currRegionModel = setOfRegionModels[0]; 494 currRegionModel = setOfRegionModels[0]; 460 currModel = models[0]; 495 currModel = models[0]; 461 496 462 // Access to materials and build cuts 497 // Access to materials and build cuts 463 std::size_t idx = 1; << 498 size_t idx = 1; 464 if(nullptr != secondaryParticle) { << 499 if(secondaryParticle) { 465 if( secondaryParticle == G4Gamma::Gamma() 500 if( secondaryParticle == G4Gamma::Gamma() ) { idx = 0; } 466 else if( secondaryParticle == G4Electron:: 501 else if( secondaryParticle == G4Electron::Electron()) { idx = 1; } 467 else if( secondaryParticle == G4Positron:: 502 else if( secondaryParticle == G4Positron::Positron()) { idx = 2; } 468 else { idx = 3; } 503 else { idx = 3; } 469 } 504 } 470 505 471 theCuts = 506 theCuts = 472 static_cast<const G4DataVector*>(theCouple 507 static_cast<const G4DataVector*>(theCoupleTable->GetEnergyCutsVector(idx)); 473 508 474 // for the second run the check on cuts shou 509 // for the second run the check on cuts should be repeated 475 if(nullptr != theCutsNew) { *theCutsNew = *t << 510 if(theCutsNew) { *theCutsNew = *theCuts; } >> 511 >> 512 if(minSubRange < 1.0) { >> 513 if( !theSubCuts ) { theSubCuts = new G4DataVector(); } >> 514 theSubCuts->resize(numOfCouples,DBL_MAX); >> 515 } 476 516 477 // G4cout << "========Start define cuts" << 517 // G4cout << "========Start define cuts" << G4endl; 478 // define cut values 518 // define cut values 479 for(std::size_t i=0; i<numOfCouples; ++i) { << 519 for(size_t i=0; i<numOfCouples; ++i) { 480 520 481 const G4MaterialCutsCouple* couple = 521 const G4MaterialCutsCouple* couple = 482 theCoupleTable->GetMaterialCutsCouple((G << 522 theCoupleTable->GetMaterialCutsCouple(i); 483 const G4Material* material = couple->GetMa 523 const G4Material* material = couple->GetMaterial(); 484 const G4ProductionCuts* pcuts = couple->Ge 524 const G4ProductionCuts* pcuts = couple->GetProductionCuts(); 485 525 486 G4int reg = 0; 526 G4int reg = 0; 487 if(nRegions > 1 && nEmModels > 1) { 527 if(nRegions > 1 && nEmModels > 1) { 488 reg = nRegions; 528 reg = nRegions; 489 // Loop checking, 03-Aug-2015, Vladimir 529 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko 490 do {--reg;} while (reg>0 && pcuts != (se 530 do {--reg;} while (reg>0 && pcuts != (setr[reg]->GetProductionCuts())); 491 idxOfRegionModels[i] = reg; 531 idxOfRegionModels[i] = reg; 492 } 532 } 493 if(1 < verboseLevel) { 533 if(1 < verboseLevel) { 494 G4cout << "G4EmModelManager::Initialise( 534 G4cout << "G4EmModelManager::Initialise() for " 495 << material->GetName() 535 << material->GetName() 496 << " indexOfCouple= " << i 536 << " indexOfCouple= " << i 497 << " indexOfRegion= " << reg 537 << " indexOfRegion= " << reg 498 << G4endl; 538 << G4endl; 499 } 539 } 500 540 501 G4double cut = (*theCuts)[i]; 541 G4double cut = (*theCuts)[i]; 502 if(nullptr != secondaryParticle) { << 542 if(secondaryParticle) { >> 543 >> 544 // compute subcut >> 545 if( cut < DBL_MAX && minSubRange < 1.0) { >> 546 G4double subcut = minSubRange*cut; >> 547 G4double rcut = std::min(minSubRange*pcuts->GetProductionCut(idx), >> 548 maxSubCutInRange); >> 549 G4double tcutmax = >> 550 theCoupleTable->ConvertRangeToEnergy(secondaryParticle, >> 551 material,rcut); >> 552 if(tcutmax < subcut) { subcut = tcutmax; } >> 553 (*theSubCuts)[i] = subcut; >> 554 } 503 555 504 // note that idxOfRegionModels[] not alw 556 // note that idxOfRegionModels[] not always filled 505 G4int inn = 0; 557 G4int inn = 0; 506 G4int nnm = 1; 558 G4int nnm = 1; 507 if(nRegions > 1 && nEmModels > 1) { 559 if(nRegions > 1 && nEmModels > 1) { 508 inn = idxOfRegionModels[i]; 560 inn = idxOfRegionModels[i]; 509 } 561 } 510 // check cuts and introduce upper limits 562 // check cuts and introduce upper limits 511 //G4cout << "idx= " << i << " cut(keV)= 563 //G4cout << "idx= " << i << " cut(keV)= " << cut/keV << G4endl; 512 currRegionModel = setOfRegionModels[inn] 564 currRegionModel = setOfRegionModels[inn]; 513 nnm = currRegionModel->NumberOfModels(); 565 nnm = currRegionModel->NumberOfModels(); 514 566 515 //G4cout << "idx= " << i << " Nmod= " << 567 //G4cout << "idx= " << i << " Nmod= " << nnm << G4endl; 516 568 517 for(G4int jj=0; jj<nnm; ++jj) { 569 for(G4int jj=0; jj<nnm; ++jj) { 518 //G4cout << "jj= " << jj << " modidx= 570 //G4cout << "jj= " << jj << " modidx= " 519 // << currRegionModel->ModelInde 571 // << currRegionModel->ModelIndex(jj) << G4endl; 520 currModel = models[currRegionModel->Mo 572 currModel = models[currRegionModel->ModelIndex(jj)]; 521 G4double cutlim = currModel->MinEnergy 573 G4double cutlim = currModel->MinEnergyCut(particle,couple); 522 if(cutlim > cut) { 574 if(cutlim > cut) { 523 if(nullptr == theCutsNew) { theCutsN << 575 if(!theCutsNew) { theCutsNew = new G4DataVector(*theCuts); } 524 (*theCutsNew)[i] = cutlim; 576 (*theCutsNew)[i] = cutlim; 525 /* 577 /* 526 G4cout << "### " << partname << " en 578 G4cout << "### " << partname << " energy loss model in " 527 << material->GetName() 579 << material->GetName() 528 << " Cut was changed from " 580 << " Cut was changed from " << cut/keV << " keV to " 529 << cutlim/keV << " keV " << " 581 << cutlim/keV << " keV " << " due to " 530 << currModel->GetName() << G4 582 << currModel->GetName() << G4endl; 531 */ 583 */ 532 } 584 } 533 } 585 } 534 } 586 } 535 } 587 } 536 if(nullptr != theCutsNew) { theCuts = theCut << 588 if(theCutsNew) { theCuts = theCutsNew; } 537 589 538 // initialize models 590 // initialize models 539 G4int nn = 0; 591 G4int nn = 0; 540 severalModels = true; 592 severalModels = true; 541 for(G4int jj=0; jj<nEmModels; ++jj) { 593 for(G4int jj=0; jj<nEmModels; ++jj) { 542 if(1 == isUsed[jj]) { 594 if(1 == isUsed[jj]) { 543 ++nn; 595 ++nn; 544 currModel = models[jj]; 596 currModel = models[jj]; 545 currModel->Initialise(particle, *theCuts 597 currModel->Initialise(particle, *theCuts); 546 if(nullptr != flucModels[jj]) { flucMode << 598 if(flucModels[jj]) { flucModels[jj]->InitialiseMe(particle); } 547 } 599 } 548 } 600 } 549 if(1 == nn) { severalModels = false; } 601 if(1 == nn) { severalModels = false; } 550 602 551 if(1 < verboseLevel) { 603 if(1 < verboseLevel) { 552 G4cout << "G4EmModelManager for " << parti << 604 G4cout << "G4EmModelManager for " << partname 553 << " is initialised; nRegions= " < 605 << " is initialised; nRegions= " << nRegions 554 << " severalModels: " << severalMod 606 << " severalModels: " << severalModels 555 << G4endl; 607 << G4endl; 556 } 608 } >> 609 557 return theCuts; 610 return theCuts; 558 } 611 } 559 612 560 //....oooOO0OOooo........oooOO0OOooo........oo 613 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 561 614 562 void G4EmModelManager::FillDEDXVector(G4Physic 615 void G4EmModelManager::FillDEDXVector(G4PhysicsVector* aVector, 563 const G4 616 const G4MaterialCutsCouple* couple, 564 G4EmTabl 617 G4EmTableType tType) 565 { 618 { 566 std::size_t i = couple->GetIndex(); << 619 size_t i = couple->GetIndex(); 567 G4double cut = (fTotal == tType) ? DBL_MAX << 620 G4double cut = (*theCuts)[i]; >> 621 G4double emin = 0.0; >> 622 >> 623 if(fTotal == tType) { cut = DBL_MAX; } >> 624 else if(fSubRestricted == tType) { >> 625 emin = cut; >> 626 if(theSubCuts) { emin = (*theSubCuts)[i]; } >> 627 } 568 628 569 if(1 < verboseLevel) { 629 if(1 < verboseLevel) { 570 G4cout << "G4EmModelManager::FillDEDXVecto 630 G4cout << "G4EmModelManager::FillDEDXVector() for " 571 << couple->GetMaterial()->GetName() 631 << couple->GetMaterial()->GetName() 572 << " cut(MeV)= " << cut 632 << " cut(MeV)= " << cut >> 633 << " emin(MeV)= " << emin 573 << " Type " << tType 634 << " Type " << tType 574 << " for " << particle->GetParticl 635 << " for " << particle->GetParticleName() 575 << G4endl; 636 << G4endl; 576 } 637 } 577 638 578 G4int reg = 0; 639 G4int reg = 0; 579 if(nRegions > 1 && nEmModels > 1) { reg = id 640 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; } 580 const G4RegionModels* regModels = setOfRegio 641 const G4RegionModels* regModels = setOfRegionModels[reg]; 581 G4int nmod = regModels->NumberOfModels(); 642 G4int nmod = regModels->NumberOfModels(); 582 643 583 // Calculate energy losses vector 644 // Calculate energy losses vector 584 std::size_t totBinsLoss = aVector->GetVector << 645 >> 646 //G4cout << "nmod= " << nmod << G4endl; >> 647 size_t totBinsLoss = aVector->GetVectorLength(); 585 G4double del = 0.0; 648 G4double del = 0.0; 586 G4int k0 = 0; 649 G4int k0 = 0; 587 650 588 for(std::size_t j=0; j<totBinsLoss; ++j) { << 651 for(size_t j=0; j<totBinsLoss; ++j) { >> 652 589 G4double e = aVector->Energy(j); 653 G4double e = aVector->Energy(j); 590 654 591 // Choose a model of energy losses 655 // Choose a model of energy losses 592 G4int k = 0; 656 G4int k = 0; 593 if (nmod > 1) { 657 if (nmod > 1) { 594 k = nmod; 658 k = nmod; 595 // Loop checking, 03-Aug-2015, Vladimir 659 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko 596 do {--k;} while (k>0 && e <= regModels-> 660 do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k)); 597 //G4cout << "k= " << k << G4endl; 661 //G4cout << "k= " << k << G4endl; 598 if(k > 0 && k != k0) { 662 if(k > 0 && k != k0) { 599 k0 = k; 663 k0 = k; 600 G4double elow = regModels->LowEdgeEner 664 G4double elow = regModels->LowEdgeEnergy(k); 601 G4double dedx1 = << 665 G4double dedx1 = ComputeDEDX(models[regModels->ModelIndex(k-1)], 602 models[regModels->ModelIndex(k-1)]->Comput << 666 couple,elow,cut,emin); 603 G4double dedx2 = << 667 G4double dedx2 = ComputeDEDX(models[regModels->ModelIndex(k)], 604 models[regModels->ModelIndex(k)]->ComputeD << 668 couple,elow,cut,emin); 605 del = (dedx2 > 0.0) ? (dedx1/dedx2 - 1 << 669 del = 0.0; >> 670 if(dedx2 > 0.0) { del = (dedx1/dedx2 - 1.0)*elow; } 606 //G4cout << "elow= " << elow 671 //G4cout << "elow= " << elow 607 // << " dedx1= " << dedx1 << " d 672 // << " dedx1= " << dedx1 << " dedx2= " << dedx2 << G4endl; 608 } 673 } 609 } 674 } 610 G4double dedx = (1.0 + del/e)* << 675 G4double dedx = 611 models[regModels->ModelIndex(k)]->ComputeD << 676 ComputeDEDX(models[regModels->ModelIndex(k)],couple,e,cut,emin); >> 677 dedx *= (1.0 + del/e); 612 678 613 if(2 < verboseLevel) { 679 if(2 < verboseLevel) { 614 G4cout << "Material= " << couple->GetMat 680 G4cout << "Material= " << couple->GetMaterial()->GetName() 615 << " E(MeV)= " << e/MeV 681 << " E(MeV)= " << e/MeV 616 << " dEdx(MeV/mm)= " << dedx*mm/ 682 << " dEdx(MeV/mm)= " << dedx*mm/MeV 617 << " del= " << del*mm/MeV<< " k= 683 << " del= " << del*mm/MeV<< " k= " << k 618 << " modelIdx= " << regModels->Mo 684 << " modelIdx= " << regModels->ModelIndex(k) 619 << G4endl; 685 << G4endl; 620 } 686 } 621 dedx = std::max(dedx, 0.0); << 687 if(dedx < 0.0) { dedx = 0.0; } 622 aVector->PutValue(j, dedx); 688 aVector->PutValue(j, dedx); 623 } 689 } 624 } 690 } 625 691 626 //....oooOO0OOooo........oooOO0OOooo........oo 692 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 627 693 628 void G4EmModelManager::FillLambdaVector(G4Phys 694 void G4EmModelManager::FillLambdaVector(G4PhysicsVector* aVector, 629 const 695 const G4MaterialCutsCouple* couple, 630 G4bool 696 G4bool startFromNull, 631 G4EmTa 697 G4EmTableType tType) 632 { 698 { 633 std::size_t i = couple->GetIndex(); << 699 size_t i = couple->GetIndex(); 634 G4double cut = (*theCuts)[i]; 700 G4double cut = (*theCuts)[i]; 635 G4double tmax = DBL_MAX; 701 G4double tmax = DBL_MAX; >> 702 if (fSubRestricted == tType) { >> 703 tmax = cut; >> 704 if(theSubCuts) { cut = (*theSubCuts)[i]; } >> 705 } 636 706 637 G4int reg = 0; 707 G4int reg = 0; 638 if(nRegions > 1 && nEmModels > 1) { reg = i 708 if(nRegions > 1 && nEmModels > 1) { reg = idxOfRegionModels[i]; } 639 const G4RegionModels* regModels = setOfRegio 709 const G4RegionModels* regModels = setOfRegionModels[reg]; 640 G4int nmod = regModels->NumberOfModels(); 710 G4int nmod = regModels->NumberOfModels(); 641 if(1 < verboseLevel) { 711 if(1 < verboseLevel) { 642 G4cout << "G4EmModelManager::FillLambdaVec 712 G4cout << "G4EmModelManager::FillLambdaVector() for " 643 << particle->GetParticleName() 713 << particle->GetParticleName() 644 << " in " << couple->GetMaterial()- 714 << " in " << couple->GetMaterial()->GetName() 645 << " Emin(MeV)= " << aVector->Energ 715 << " Emin(MeV)= " << aVector->Energy(0) 646 << " Emax(MeV)= " << aVector->GetMa 716 << " Emax(MeV)= " << aVector->GetMaxEnergy() 647 << " cut= " << cut 717 << " cut= " << cut 648 << " Type " << tType 718 << " Type " << tType 649 << " nmod= " << nmod 719 << " nmod= " << nmod >> 720 << " theSubCuts " << theSubCuts 650 << G4endl; 721 << G4endl; 651 } 722 } 652 723 653 // Calculate lambda vector 724 // Calculate lambda vector 654 std::size_t totBinsLambda = aVector->GetVect << 725 size_t totBinsLambda = aVector->GetVectorLength(); 655 G4double del = 0.0; 726 G4double del = 0.0; 656 G4int k0 = 0; 727 G4int k0 = 0; 657 G4int k = 0; 728 G4int k = 0; 658 G4VEmModel* mod = models[regModels->ModelInd 729 G4VEmModel* mod = models[regModels->ModelIndex(0)]; 659 for(std::size_t j=0; j<totBinsLambda; ++j) { << 730 for(size_t j=0; j<totBinsLambda; ++j) { 660 731 661 G4double e = aVector->Energy(j); 732 G4double e = aVector->Energy(j); 662 733 663 // Choose a model 734 // Choose a model 664 if (nmod > 1) { 735 if (nmod > 1) { 665 k = nmod; 736 k = nmod; 666 // Loop checking, 03-Aug-2015, Vladimir 737 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko 667 do {--k;} while (k>0 && e <= regModels-> 738 do {--k;} while (k>0 && e <= regModels->LowEdgeEnergy(k)); 668 if(k > 0 && k != k0) { 739 if(k > 0 && k != k0) { 669 k0 = k; 740 k0 = k; 670 G4double elow = regModels->LowEdgeEner 741 G4double elow = regModels->LowEdgeEnergy(k); 671 G4VEmModel* mod1 = models[regModels->M 742 G4VEmModel* mod1 = models[regModels->ModelIndex(k-1)]; 672 G4double xs1 = mod1->CrossSection(cou 743 G4double xs1 = mod1->CrossSection(couple,particle,elow,cut,tmax); 673 mod = models[regModels->ModelIndex(k)] 744 mod = models[regModels->ModelIndex(k)]; 674 G4double xs2 = mod->CrossSection(coupl 745 G4double xs2 = mod->CrossSection(couple,particle,elow,cut,tmax); 675 del = (xs2 > 0.0) ? (xs1/xs2 - 1.0)*el << 746 del = 0.0; >> 747 if(xs2 > 0.0) { del = (xs1/xs2 - 1.0)*elow; } 676 //G4cout << "New model k=" << k << " E 748 //G4cout << "New model k=" << k << " E(MeV)= " << e/MeV 677 // << " Elow(MeV)= " << elow/MeV 749 // << " Elow(MeV)= " << elow/MeV << " del= " << del << G4endl; 678 } 750 } 679 } 751 } 680 G4double cross = (1.0 + del/e)*mod->CrossS << 752 G4double cross = mod->CrossSection(couple,particle,e,cut,tmax); >> 753 cross *= (1.0 + del/e); 681 if(fIsCrossSectionPrim == tType) { cross * 754 if(fIsCrossSectionPrim == tType) { cross *= e; } 682 755 683 if(j==0 && startFromNull) { cross = 0.0; } 756 if(j==0 && startFromNull) { cross = 0.0; } 684 757 685 if(2 < verboseLevel) { 758 if(2 < verboseLevel) { 686 G4cout << "FillLambdaVector: " << j << " 759 G4cout << "FillLambdaVector: " << j << ". e(MeV)= " << e/MeV 687 << " cross(1/mm)= " << cross*mm 760 << " cross(1/mm)= " << cross*mm 688 << " del= " << del*mm << " k= " < 761 << " del= " << del*mm << " k= " << k 689 << " modelIdx= " << regModels->Mo 762 << " modelIdx= " << regModels->ModelIndex(k) 690 << G4endl; 763 << G4endl; 691 } 764 } 692 cross = std::max(cross, 0.0); << 765 if(cross < 0.0) { cross = 0.0; } 693 aVector->PutValue(j, cross); 766 aVector->PutValue(j, cross); 694 } 767 } 695 } 768 } 696 769 697 //....oooOO0OOooo........oooOO0OOooo........oo 770 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 698 771 699 void G4EmModelManager::DumpModelList(std::ostr 772 void G4EmModelManager::DumpModelList(std::ostream& out, G4int verb) 700 { 773 { 701 if(verb == 0) { return; } 774 if(verb == 0) { return; } 702 for(G4int i=0; i<nRegions; ++i) { 775 for(G4int i=0; i<nRegions; ++i) { 703 G4RegionModels* r = setOfRegionModels[i]; 776 G4RegionModels* r = setOfRegionModels[i]; 704 const G4Region* reg = r->Region(); 777 const G4Region* reg = r->Region(); 705 G4int n = r->NumberOfModels(); 778 G4int n = r->NumberOfModels(); 706 if(n > 0) { 779 if(n > 0) { 707 out << " ===== EM models for the G4 780 out << " ===== EM models for the G4Region " << reg->GetName() 708 << " ======" << G4endl; 781 << " ======" << G4endl; 709 for(G4int j=0; j<n; ++j) { 782 for(G4int j=0; j<n; ++j) { 710 G4VEmModel* model = models[r->ModelInd 783 G4VEmModel* model = models[r->ModelIndex(j)]; 711 G4double emin = 784 G4double emin = 712 std::max(r->LowEdgeEnergy(j),model-> 785 std::max(r->LowEdgeEnergy(j),model->LowEnergyActivationLimit()); 713 G4double emax = 786 G4double emax = 714 std::min(r->LowEdgeEnergy(j+1),model 787 std::min(r->LowEdgeEnergy(j+1),model->HighEnergyActivationLimit()); 715 if(emax > emin) { 788 if(emax > emin) { 716 out << std::setw(20); 789 out << std::setw(20); 717 out << model->GetName() << " : Emin=" 790 out << model->GetName() << " : Emin=" 718 << std::setw(5) << G4BestUnit(emin,"En 791 << std::setw(5) << G4BestUnit(emin,"Energy") 719 << " Emax=" 792 << " Emax=" 720 << std::setw(5) << G4BestUnit(emax,"En 793 << std::setw(5) << G4BestUnit(emax,"Energy"); 721 G4PhysicsTable* table = model->GetCrossSec 794 G4PhysicsTable* table = model->GetCrossSectionTable(); 722 if(table) { 795 if(table) { 723 std::size_t kk = table->size(); << 796 size_t kk = table->size(); 724 for(std::size_t k=0; k<kk; ++k) { << 797 for(size_t k=0; k<kk; ++k) { 725 const G4PhysicsVector* v = (*table)[k] << 798 G4PhysicsVector* v = (*table)[k]; 726 if(v) { 799 if(v) { 727 G4int nn = G4int(v->GetVectorLength() - 1) << 800 G4int nn = v->GetVectorLength() - 1; 728 out << " Nbins=" << nn << " " 801 out << " Nbins=" << nn << " " 729 << std::setw(3) << G4BestUnit(v->Energ 802 << std::setw(3) << G4BestUnit(v->Energy(0),"Energy") 730 << " - " 803 << " - " 731 << std::setw(3) << G4BestUnit(v->Energ 804 << std::setw(3) << G4BestUnit(v->Energy(nn),"Energy"); 732 break; 805 break; 733 } 806 } 734 } 807 } 735 } 808 } 736 G4VEmAngularDistribution* an = model->GetA 809 G4VEmAngularDistribution* an = model->GetAngularDistribution(); 737 if(an) { out << " " << an->GetName(); } 810 if(an) { out << " " << an->GetName(); } 738 if(fluoFlag && model->DeexcitationFlag()) 811 if(fluoFlag && model->DeexcitationFlag()) { 739 out << " Fluo"; 812 out << " Fluo"; 740 } 813 } 741 out << G4endl; 814 out << G4endl; 742 auto msc = dynamic_cast<G4VMscModel* << 743 if(msc != nullptr) msc->DumpParamete << 744 } 815 } 745 } 816 } 746 } 817 } 747 if(1 == nEmModels) { break; } 818 if(1 == nEmModels) { break; } 748 } 819 } 749 if(theCutsNew) { 820 if(theCutsNew) { 750 out << " ===== Limit on energy thresh 821 out << " ===== Limit on energy threshold has been applied " << G4endl; 751 } 822 } 752 } 823 } 753 824 754 //....oooOO0OOooo........oooOO0OOooo........oo 825 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 755 826