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