Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:13

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // -------------------------------------------------------------------
0028 //
0029 // GEANT4 Class header file
0030 //
0031 // File name:     G4EmModelManager
0032 //
0033 // Author:        Vladimir Ivanchenko
0034 //
0035 // Creation date: 07.05.2002
0036 //
0037 // Modifications:
0038 //
0039 // 03-12-02 V.Ivanchenko fix a bug in model selection
0040 // 20-01-03 Migrade to cut per region (V.Ivanchenko)
0041 // 27-01-03 Make models region aware (V.Ivanchenko)
0042 // 13-02-03 The set of models is defined for region (V.Ivanchenko)
0043 // 26-03-03 Add GetDEDXDispersion (V.Ivanchenko)
0044 // 13-04-03 Add startFromNull (V.Ivanchenko)
0045 // 13-05-03 Add calculation of precise range (V.Ivanchenko)
0046 // 21-07-03 Add UpdateEmModel method (V.Ivanchenko)
0047 // 03-11-03 Substitute STL vector for G4RegionModels (V.Ivanchenko)
0048 // 11-04-05 Remove access to fluctuation models (V.Ivanchenko)
0049 // 10-01-06 PreciseRange -> CSDARange (V.Ivantchenko)
0050 // 20-01-06 Introduce G4EmTableType and reducing number of methods (VI)
0051 // 13-05-06 Add GetModel by index method (VI)
0052 // 15-03-07 Add maxCutInRange (V.Ivanchenko)
0053 // 08-04-08 Simplify Select method for only one G4RegionModel (VI)
0054 // 03-08-09 Removed unused members and simplify model search if only one
0055 //          model is used (VI)
0056 // 14-07-11 Use pointer to the vector of cuts and not local copy (VI)
0057 //
0058 // Class Description:
0059 //
0060 // It is the unified energy loss process it calculates the continuous
0061 // energy loss for charged particles using a set of Energy Loss
0062 // models valid for different energy regions. There are a possibility
0063 // to create and access to dE/dx and range tables, or to calculate
0064 // that information on fly.
0065 
0066 // -------------------------------------------------------------------
0067 //
0068 
0069 #ifndef G4EmModelManager_h
0070 #define G4EmModelManager_h 1
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0073 
0074 #include "globals.hh"
0075 #include "G4DataVector.hh"
0076 #include "G4EmTableType.hh"
0077 #include "G4EmProcessSubType.hh"
0078 #include "G4Region.hh"
0079 
0080 #include "G4VEmModel.hh"
0081 #include "G4VEmFluctuationModel.hh"
0082 #include "G4DynamicParticle.hh"
0083 #include <iostream>
0084 
0085 class G4RegionModels
0086 {
0087 
0088 friend class G4EmModelManager;
0089 
0090 private:
0091 
0092   G4RegionModels(G4int nMod, std::vector<G4int>& indx, 
0093                  G4DataVector& lowE, const G4Region* reg);
0094 
0095   ~G4RegionModels();
0096 
0097   inline G4int SelectIndex(G4double e) const {
0098     G4int idx = 0;
0099     if (nModelsForRegion>1) {
0100       idx = nModelsForRegion;
0101       // Loop checking, 03-Aug-2015, Vladimir Ivanchenko
0102       do {--idx;} while (idx > 0 && e <= lowKineticEnergy[idx]);
0103     }
0104     return theListOfModelIndexes[idx];
0105   };
0106 
0107   inline G4int ModelIndex(G4int n) const {
0108     return theListOfModelIndexes[n];
0109   };
0110 
0111   inline G4int NumberOfModels() const {
0112     return nModelsForRegion;
0113   };
0114 
0115   inline G4double LowEdgeEnergy(G4int n) const {
0116     return lowKineticEnergy[n];
0117   };
0118 
0119   inline const G4Region* Region() const {
0120     return theRegion;
0121   };
0122 
0123   G4RegionModels(G4RegionModels &) = delete;
0124   G4RegionModels & operator=(const G4RegionModels &right) = delete;
0125 
0126   const G4Region*    theRegion;
0127   G4int              nModelsForRegion;
0128   G4int*             theListOfModelIndexes;
0129   G4double*          lowKineticEnergy;
0130 
0131 };
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0134 
0135 class G4Region;
0136 class G4ParticleDefinition;
0137 class G4PhysicsVector;
0138 class G4MaterialCutsCouple;
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0141 
0142 class G4EmModelManager
0143 {
0144 public:
0145 
0146   G4EmModelManager();
0147 
0148   ~G4EmModelManager();
0149 
0150   void Clear();
0151 
0152   const G4DataVector* Initialise(const G4ParticleDefinition* part,
0153                                  const G4ParticleDefinition* secPart,
0154                                  G4int verb);
0155 
0156   void FillDEDXVector(G4PhysicsVector*, const G4MaterialCutsCouple*, 
0157                       G4EmTableType t = fRestricted);
0158 
0159   void FillLambdaVector(G4PhysicsVector*, const G4MaterialCutsCouple*, 
0160                         G4bool startFromNull = true, 
0161                         G4EmTableType t = fRestricted);
0162 
0163   void AddEmModel(G4int, G4VEmModel*, G4VEmFluctuationModel* fm, 
0164                   const G4Region* r);
0165 
0166   // Get model pointer from the model list
0167   G4VEmModel* GetModel(G4int idx, G4bool ver = false) const;
0168 
0169   // Get model pointer from the model list for a given material cuts couple
0170   // no check on material cuts couple index
0171   G4VEmModel* GetRegionModel(G4int idx, std::size_t index_couple);
0172 
0173   // total number of models for material cut couples
0174   // no check on material cuts couple index
0175   G4int NumberOfRegionModels(std::size_t index_couple) const;
0176 
0177   // Automatic documentation
0178   void DumpModelList(std::ostream& out, G4int verb);
0179 
0180   // Select model for given material cuts couple index
0181   inline G4VEmModel* SelectModel(G4double energy, std::size_t index);
0182 
0183   // Access to cuts
0184   inline const G4DataVector* Cuts() const;
0185 
0186   // Set flag of fluorescence
0187   inline void SetFluoFlag(G4bool val);
0188 
0189   // total number of models
0190   inline G4int NumberOfModels() const;
0191 
0192   // hide  assignment operator
0193   G4EmModelManager(G4EmModelManager &) = delete;
0194   G4EmModelManager & operator=(const G4EmModelManager &right) = delete;
0195 
0196 private:
0197 
0198   const G4ParticleDefinition* particle = nullptr;
0199   const G4DataVector*         theCuts = nullptr;
0200   G4DataVector*               theCutsNew = nullptr;
0201 
0202   // may be changed in run time
0203   G4RegionModels*             currRegionModel = nullptr;
0204   G4VEmModel*                 currModel = nullptr;
0205 
0206   G4int                       nEmModels = 0;
0207   G4int                       nRegions = 0;
0208 
0209   G4int                       verboseLevel = 0;
0210   G4bool                      severalModels = true;
0211   G4bool                      fluoFlag = false;
0212 
0213   std::vector<G4VEmModel*>             models;
0214   std::vector<G4VEmFluctuationModel*>  flucModels;
0215   std::vector<const G4Region*>         regions;
0216   std::vector<G4int>                   orderOfModels;
0217   std::vector<G4int>                   isUsed;
0218 
0219   std::vector<G4int>            idxOfRegionModels;
0220   std::vector<G4RegionModels*>  setOfRegionModels;
0221 };
0222 
0223 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0224 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0225 
0226 inline 
0227 G4VEmModel* G4EmModelManager::SelectModel(G4double kinEnergy, std::size_t index)
0228 {
0229   if(severalModels) {
0230     if(nRegions > 1) {
0231       currRegionModel = setOfRegionModels[idxOfRegionModels[index]];
0232     }
0233     currModel = models[currRegionModel->SelectIndex(kinEnergy)];
0234   }
0235   return currModel;
0236 }
0237 
0238 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0239 
0240 inline const G4DataVector* G4EmModelManager::Cuts() const
0241 {
0242   return theCuts;
0243 }
0244 
0245 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0246 
0247 inline void G4EmModelManager::SetFluoFlag(G4bool val)
0248 {
0249   fluoFlag = val;
0250 }
0251 
0252 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0253 
0254 inline G4int G4EmModelManager::NumberOfModels() const
0255 {
0256   return nEmModels;
0257 }
0258 
0259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0260 
0261 #endif
0262