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.hh 72944 2013-08-14 13:43:07Z gcosmo $ 26 // 27 // 27 // ------------------------------------------- 28 // ------------------------------------------------------------------- 28 // 29 // 29 // GEANT4 Class header file 30 // GEANT4 Class header file 30 // 31 // 31 // File name: G4EmModelManager 32 // File name: G4EmModelManager 32 // 33 // 33 // Author: Vladimir Ivanchenko 34 // Author: Vladimir Ivanchenko 34 // 35 // 35 // Creation date: 07.05.2002 36 // Creation date: 07.05.2002 36 // 37 // 37 // Modifications: 38 // Modifications: 38 // 39 // 39 // 03-12-02 V.Ivanchenko fix a bug in model se 40 // 03-12-02 V.Ivanchenko fix a bug in model selection 40 // 20-01-03 Migrade to cut per region (V.Ivanc 41 // 20-01-03 Migrade to cut per region (V.Ivanchenko) 41 // 27-01-03 Make models region aware (V.Ivanch 42 // 27-01-03 Make models region aware (V.Ivanchenko) 42 // 13-02-03 The set of models is defined for r 43 // 13-02-03 The set of models is defined for region (V.Ivanchenko) 43 // 26-03-03 Add GetDEDXDispersion (V.Ivanchenk 44 // 26-03-03 Add GetDEDXDispersion (V.Ivanchenko) 44 // 13-04-03 Add startFromNull (V.Ivanchenko) 45 // 13-04-03 Add startFromNull (V.Ivanchenko) 45 // 13-05-03 Add calculation of precise range ( 46 // 13-05-03 Add calculation of precise range (V.Ivanchenko) 46 // 21-07-03 Add UpdateEmModel method (V.Ivanch 47 // 21-07-03 Add UpdateEmModel method (V.Ivanchenko) 47 // 03-11-03 Substitute STL vector for G4Region 48 // 03-11-03 Substitute STL vector for G4RegionModels (V.Ivanchenko) 48 // 11-04-05 Remove access to fluctuation model 49 // 11-04-05 Remove access to fluctuation models (V.Ivanchenko) 49 // 10-01-06 PreciseRange -> CSDARange (V.Ivant 50 // 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko) 50 // 20-01-06 Introduce G4EmTableType and reduci 51 // 20-01-06 Introduce G4EmTableType and reducing number of methods (VI) 51 // 13-05-06 Add GetModel by index method (VI) 52 // 13-05-06 Add GetModel by index method (VI) 52 // 15-03-07 Add maxCutInRange (V.Ivanchenko) 53 // 15-03-07 Add maxCutInRange (V.Ivanchenko) 53 // 08-04-08 Simplify Select method for only on 54 // 08-04-08 Simplify Select method for only one G4RegionModel (VI) 54 // 03-08-09 Removed unused members and simplif 55 // 03-08-09 Removed unused members and simplify model search if only one 55 // model is used (VI) 56 // model is used (VI) 56 // 14-07-11 Use pointer to the vector of cuts 57 // 14-07-11 Use pointer to the vector of cuts and not local copy (VI) 57 // 58 // 58 // Class Description: 59 // Class Description: 59 // 60 // 60 // It is the unified energy loss process it ca 61 // It is the unified energy loss process it calculates the continuous 61 // energy loss for charged particles using a s 62 // energy loss for charged particles using a set of Energy Loss 62 // models valid for different energy regions. 63 // models valid for different energy regions. There are a possibility 63 // to create and access to dE/dx and range tab 64 // to create and access to dE/dx and range tables, or to calculate 64 // that information on fly. 65 // that information on fly. 65 66 66 // ------------------------------------------- 67 // ------------------------------------------------------------------- 67 // 68 // 68 69 >> 70 69 #ifndef G4EmModelManager_h 71 #ifndef G4EmModelManager_h 70 #define G4EmModelManager_h 1 72 #define G4EmModelManager_h 1 71 73 72 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 73 75 74 #include "globals.hh" 76 #include "globals.hh" 75 #include "G4DataVector.hh" 77 #include "G4DataVector.hh" 76 #include "G4EmTableType.hh" 78 #include "G4EmTableType.hh" 77 #include "G4EmProcessSubType.hh" 79 #include "G4EmProcessSubType.hh" 78 #include "G4Region.hh" 80 #include "G4Region.hh" 79 81 80 #include "G4VEmModel.hh" << 81 #include "G4VEmFluctuationModel.hh" << 82 #include "G4DynamicParticle.hh" << 83 #include <iostream> << 84 << 85 class G4RegionModels 82 class G4RegionModels 86 { 83 { 87 84 88 friend class G4EmModelManager; 85 friend class G4EmModelManager; 89 86 >> 87 public: >> 88 90 private: 89 private: 91 90 92 G4RegionModels(G4int nMod, std::vector<G4int 91 G4RegionModels(G4int nMod, std::vector<G4int>& indx, 93 G4DataVector& lowE, const G4R << 92 G4DataVector& lowE, const G4Region* reg); 94 93 95 ~G4RegionModels(); 94 ~G4RegionModels(); 96 95 97 inline G4int SelectIndex(G4double e) const { 96 inline G4int SelectIndex(G4double e) const { 98 G4int idx = 0; 97 G4int idx = 0; 99 if (nModelsForRegion>1) { 98 if (nModelsForRegion>1) { 100 idx = nModelsForRegion; 99 idx = nModelsForRegion; 101 // Loop checking, 03-Aug-2015, Vladimir << 102 do {--idx;} while (idx > 0 && e <= lowKi 100 do {--idx;} while (idx > 0 && e <= lowKineticEnergy[idx]); 103 } 101 } 104 return theListOfModelIndexes[idx]; 102 return theListOfModelIndexes[idx]; 105 }; 103 }; 106 104 107 inline G4int ModelIndex(G4int n) const { 105 inline G4int ModelIndex(G4int n) const { 108 return theListOfModelIndexes[n]; 106 return theListOfModelIndexes[n]; 109 }; 107 }; 110 108 111 inline G4int NumberOfModels() const { 109 inline G4int NumberOfModels() const { 112 return nModelsForRegion; 110 return nModelsForRegion; 113 }; 111 }; 114 112 115 inline G4double LowEdgeEnergy(G4int n) const 113 inline G4double LowEdgeEnergy(G4int n) const { 116 return lowKineticEnergy[n]; 114 return lowKineticEnergy[n]; 117 }; 115 }; 118 116 119 inline const G4Region* Region() const { 117 inline const G4Region* Region() const { 120 return theRegion; 118 return theRegion; 121 }; 119 }; 122 120 123 G4RegionModels(G4RegionModels &) = delete; << 121 G4RegionModels(G4RegionModels &); 124 G4RegionModels & operator=(const G4RegionMod << 122 G4RegionModels & operator=(const G4RegionModels &right); 125 123 126 const G4Region* theRegion; 124 const G4Region* theRegion; 127 G4int nModelsForRegion; 125 G4int nModelsForRegion; 128 G4int* theListOfModelIndexes; 126 G4int* theListOfModelIndexes; 129 G4double* lowKineticEnergy; 127 G4double* lowKineticEnergy; 130 128 131 }; 129 }; 132 130 133 //....oooOO0OOooo........oooOO0OOooo........oo << 131 #include "G4VEmModel.hh" >> 132 #include "G4VEmFluctuationModel.hh" >> 133 #include "G4DynamicParticle.hh" 134 134 135 class G4Region; 135 class G4Region; 136 class G4ParticleDefinition; 136 class G4ParticleDefinition; 137 class G4PhysicsVector; 137 class G4PhysicsVector; 138 class G4MaterialCutsCouple; 138 class G4MaterialCutsCouple; 139 139 140 //....oooOO0OOooo........oooOO0OOooo........oo 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 141 141 142 class G4EmModelManager 142 class G4EmModelManager 143 { 143 { 144 public: 144 public: 145 145 146 G4EmModelManager(); 146 G4EmModelManager(); 147 147 148 ~G4EmModelManager(); 148 ~G4EmModelManager(); 149 149 150 void Clear(); 150 void Clear(); 151 151 152 const G4DataVector* Initialise(const G4Parti 152 const G4DataVector* Initialise(const G4ParticleDefinition* part, 153 const G4Parti 153 const G4ParticleDefinition* secPart, 154 G4int verb); << 154 G4double minSubRange, >> 155 G4int verb); 155 156 156 void FillDEDXVector(G4PhysicsVector*, const 157 void FillDEDXVector(G4PhysicsVector*, const G4MaterialCutsCouple*, 157 G4EmTableType t = fRestr << 158 G4EmTableType t = fRestricted); 158 159 159 void FillLambdaVector(G4PhysicsVector*, cons 160 void FillLambdaVector(G4PhysicsVector*, const G4MaterialCutsCouple*, 160 G4bool startFromNull = 161 G4bool startFromNull = true, 161 G4EmTableType t = fRes << 162 G4EmTableType t = fRestricted); 162 << 163 void AddEmModel(G4int, G4VEmModel*, G4VEmFlu << 164 const G4Region* r); << 165 163 166 // Get model pointer from the model list << 164 G4VEmModel* GetModel(G4int, G4bool ver = false); 167 G4VEmModel* GetModel(G4int idx, G4bool ver = << 168 165 169 // Get model pointer from the model list for << 166 void AddEmModel(G4int, G4VEmModel*, G4VEmFluctuationModel*, const G4Region*); 170 // no check on material cuts couple index << 167 171 G4VEmModel* GetRegionModel(G4int idx, std::s << 168 void UpdateEmModel(const G4String&, G4double, G4double); 172 169 173 // total number of models for material cut c << 170 void DumpModelList(G4int verb); 174 // no check on material cuts couple index << 175 G4int NumberOfRegionModels(std::size_t index << 176 171 177 // Automatic documentation << 172 inline G4VEmModel* SelectModel(G4double& energy, size_t& index); 178 void DumpModelList(std::ostream& out, G4int << 179 173 180 // Select model for given material cuts coup << 181 inline G4VEmModel* SelectModel(G4double ener << 182 << 183 // Access to cuts << 184 inline const G4DataVector* Cuts() const; 174 inline const G4DataVector* Cuts() const; 185 175 186 // Set flag of fluorescence << 176 inline const G4DataVector* SubCutoff() const; >> 177 187 inline void SetFluoFlag(G4bool val); 178 inline void SetFluoFlag(G4bool val); 188 179 189 // total number of models << 190 inline G4int NumberOfModels() const; 180 inline G4int NumberOfModels() const; 191 181 >> 182 private: >> 183 >> 184 inline G4double ComputeDEDX(G4VEmModel* model, >> 185 const G4MaterialCutsCouple*, >> 186 G4double kinEnergy, >> 187 G4double cutEnergy, >> 188 G4double minEnergy); >> 189 192 // hide assignment operator 190 // hide assignment operator 193 G4EmModelManager(G4EmModelManager &) = delet << 194 G4EmModelManager & operator=(const G4EmModel << 195 191 196 private: << 192 G4EmModelManager(G4EmModelManager &); >> 193 G4EmModelManager & operator=(const G4EmModelManager &right); 197 194 198 const G4ParticleDefinition* particle = nullp << 195 // ===================================================================== 199 const G4DataVector* theCuts = nullpt << 200 G4DataVector* theCutsNew = nul << 201 196 202 // may be changed in run time << 197 private: 203 G4RegionModels* currRegionModel << 204 G4VEmModel* currModel = null << 205 198 206 G4int nEmModels = 0; << 199 const G4DataVector* theCuts; 207 G4int nRegions = 0; << 200 G4DataVector* theCutsNew; >> 201 G4DataVector* theSubCuts; >> 202 >> 203 std::vector<G4VEmModel*> models; >> 204 std::vector<G4VEmFluctuationModel*> flucModels; >> 205 std::vector<const G4Region*> regions; >> 206 std::vector<G4int> orderOfModels; >> 207 std::vector<G4int> isUsed; 208 208 209 G4int verboseLevel = 0 << 209 G4int nEmModels; 210 G4bool severalModels = << 210 G4int nRegions; 211 G4bool fluoFlag = false << 212 << 213 std::vector<G4VEmModel*> models; << 214 std::vector<G4VEmFluctuationModel*> flucMod << 215 std::vector<const G4Region*> regions << 216 std::vector<G4int> orderOf << 217 std::vector<G4int> isUsed; << 218 211 219 std::vector<G4int> idxOfRegionMod 212 std::vector<G4int> idxOfRegionModels; 220 std::vector<G4RegionModels*> setOfRegionMod 213 std::vector<G4RegionModels*> setOfRegionModels; >> 214 >> 215 G4double maxSubCutInRange; >> 216 >> 217 const G4ParticleDefinition* particle; >> 218 >> 219 G4int verboseLevel; >> 220 G4bool severalModels; >> 221 G4bool fluoFlag; >> 222 >> 223 // may be changed in run time >> 224 G4RegionModels* currRegionModel; >> 225 G4VEmModel* currModel; 221 }; 226 }; 222 227 223 //....oooOO0OOooo........oooOO0OOooo........oo 228 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 224 //....oooOO0OOooo........oooOO0OOooo........oo 229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 225 230 226 inline << 231 inline G4VEmModel* G4EmModelManager::SelectModel(G4double& kinEnergy, 227 G4VEmModel* G4EmModelManager::SelectModel(G4do << 232 size_t& index) 228 { 233 { 229 if(severalModels) { 234 if(severalModels) { 230 if(nRegions > 1) { 235 if(nRegions > 1) { 231 currRegionModel = setOfRegionModels[idxO 236 currRegionModel = setOfRegionModels[idxOfRegionModels[index]]; 232 } 237 } 233 currModel = models[currRegionModel->Select 238 currModel = models[currRegionModel->SelectIndex(kinEnergy)]; 234 } 239 } 235 return currModel; 240 return currModel; 236 } 241 } 237 242 238 //....oooOO0OOooo........oooOO0OOooo........oo 243 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 239 244 240 inline const G4DataVector* G4EmModelManager::C 245 inline const G4DataVector* G4EmModelManager::Cuts() const 241 { 246 { 242 return theCuts; 247 return theCuts; 243 } 248 } 244 249 245 //....oooOO0OOooo........oooOO0OOooo........oo 250 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 246 251 >> 252 inline const G4DataVector* G4EmModelManager::SubCutoff() const >> 253 { >> 254 return theSubCuts; >> 255 } >> 256 >> 257 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 258 247 inline void G4EmModelManager::SetFluoFlag(G4bo 259 inline void G4EmModelManager::SetFluoFlag(G4bool val) 248 { 260 { 249 fluoFlag = val; 261 fluoFlag = val; 250 } 262 } 251 263 252 //....oooOO0OOooo........oooOO0OOooo........oo 264 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 253 265 254 inline G4int G4EmModelManager::NumberOfModels( 266 inline G4int G4EmModelManager::NumberOfModels() const 255 { 267 { 256 return nEmModels; 268 return nEmModels; >> 269 } >> 270 >> 271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 272 >> 273 inline G4double >> 274 G4EmModelManager::ComputeDEDX(G4VEmModel* model, >> 275 const G4MaterialCutsCouple* couple, >> 276 G4double e, >> 277 G4double cut, >> 278 G4double emin) >> 279 { >> 280 G4double dedx = 0.0; >> 281 if(model && cut > emin) { >> 282 dedx = model->ComputeDEDX(couple,particle,e,cut); >> 283 if(emin > 0.0) {dedx -= model->ComputeDEDX(couple,particle,e,emin);} >> 284 } >> 285 return dedx; 257 } 286 } 258 287 259 //....oooOO0OOooo........oooOO0OOooo........oo 288 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 260 289 261 #endif 290 #endif 262 291 263 292