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