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