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