Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-04 09:11:38

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 //
0032 // File name:     G4VEnergyLossProcess
0033 //
0034 // Author:        Vladimir Ivanchenko on base of Laszlo Urban code
0035 //
0036 // Creation date: 03.01.2002
0037 //
0038 // Modifications: Vladimir Ivanchenko
0039 //
0040 // Class Description:
0041 //
0042 // It is the unified energy loss process it calculates the continuous
0043 // energy loss for charged particles using a set of Energy Loss
0044 // models valid for different energy regions. There are a possibility
0045 // to create and access to dE/dx and range tables, or to calculate
0046 // that information on fly.
0047 
0048 // -------------------------------------------------------------------
0049 //
0050 
0051 #ifndef G4VEnergyLossProcess_h
0052 #define G4VEnergyLossProcess_h 1
0053 
0054 #include "G4VContinuousDiscreteProcess.hh"
0055 #include "globals.hh"
0056 #include "G4Material.hh"
0057 #include "G4MaterialCutsCouple.hh"
0058 #include "G4Track.hh"
0059 #include "G4EmModelManager.hh"
0060 #include "G4ParticleChangeForLoss.hh"
0061 #include "G4EmTableType.hh"
0062 #include "G4EmSecondaryParticleType.hh"
0063 #include "G4PhysicsTable.hh"
0064 #include "G4PhysicsVector.hh"
0065 
0066 class G4Step;
0067 class G4ParticleDefinition;
0068 class G4EmParameters;
0069 class G4VEmModel;
0070 class G4VEmFluctuationModel;
0071 class G4DataVector;
0072 class G4Region;
0073 class G4SafetyHelper;
0074 class G4VAtomDeexcitation;
0075 class G4VSubCutProducer;
0076 class G4EmBiasingManager;
0077 class G4LossTableManager;
0078 class G4EmDataHandler;
0079 
0080 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0081 
0082 class G4VEnergyLossProcess : public G4VContinuousDiscreteProcess
0083 {
0084 public:
0085 
0086   G4VEnergyLossProcess(const G4String& name = "EnergyLoss",
0087                        G4ProcessType type = fElectromagnetic);
0088 
0089   ~G4VEnergyLossProcess() override;
0090 
0091   //------------------------------------------------------------------------
0092   // Virtual methods to be implemented in concrete processes
0093   //------------------------------------------------------------------------
0094 
0095 protected:
0096 
0097   // description of specific process parameters
0098   virtual void StreamProcessInfo(std::ostream&) const {};
0099 
0100   virtual void InitialiseEnergyLossProcess(const G4ParticleDefinition*,
0101                                            const G4ParticleDefinition*) = 0;
0102 
0103 public:
0104 
0105   // used as low energy limit LambdaTable
0106   virtual G4double MinPrimaryEnergy(const G4ParticleDefinition*,
0107                                     const G4Material*, G4double cut);
0108 
0109   // print documentation in html format
0110   void ProcessDescription(std::ostream& outFile) const override;
0111 
0112   // prepare all tables
0113   void PreparePhysicsTable(const G4ParticleDefinition&) override;
0114 
0115   // build all tables
0116   void BuildPhysicsTable(const G4ParticleDefinition&) override;
0117 
0118   // build a table
0119   G4PhysicsTable* BuildDEDXTable(G4EmTableType tType = fRestricted);
0120 
0121   // build a table
0122   G4PhysicsTable* BuildLambdaTable(G4EmTableType tType = fRestricted);
0123 
0124   // Called before tracking of each new G4Track
0125   void StartTracking(G4Track*) override;
0126 
0127   // Step limit from AlongStep 
0128   G4double AlongStepGetPhysicalInteractionLength(
0129                                   const G4Track&,
0130                                   G4double  previousStepSize,
0131                                   G4double  currentMinimumStep,
0132                                   G4double& currentSafety,
0133                                   G4GPILSelection* selection) override;
0134 
0135   // Step limit from cross section
0136   G4double PostStepGetPhysicalInteractionLength(
0137                                   const G4Track& track,
0138                                   G4double previousStepSize,
0139                                   G4ForceCondition* condition) override;
0140 
0141   // AlongStep computations
0142   G4VParticleChange* AlongStepDoIt(const G4Track&, const G4Step&) override;
0143 
0144   // PostStep sampling of secondaries
0145   G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&) override;
0146 
0147   // Store all PhysicsTable in files.
0148   // Return false in case of any fatal failure at I/O  
0149   G4bool StorePhysicsTable(const G4ParticleDefinition*,
0150                            const G4String& directory,
0151                            G4bool ascii = false) override;
0152 
0153   // Retrieve all Physics from a files.
0154   // Return true if all the Physics Table are built.
0155   // Return false if any fatal failure. 
0156   G4bool RetrievePhysicsTable(const G4ParticleDefinition*,
0157                               const G4String& directory,
0158                               G4bool ascii) override;
0159 
0160 private:
0161 
0162   // summary printout after initialisation
0163   void StreamInfo(std::ostream& out, const G4ParticleDefinition& part,
0164                   G4bool rst=false) const;
0165 
0166   //------------------------------------------------------------------------
0167   // Public interface to cross section, mfp and sampling of fluctuations
0168   // These methods are not used in run time
0169   //------------------------------------------------------------------------
0170 
0171 public:
0172 
0173   // access to dispersion of restricted energy loss
0174   G4double GetDEDXDispersion(const G4MaterialCutsCouple *couple,
0175                              const G4DynamicParticle* dp,
0176                              G4double length);
0177 
0178   // Access to cross section table
0179   G4double CrossSectionPerVolume(G4double kineticEnergy,
0180                                  const G4MaterialCutsCouple* couple);
0181   G4double CrossSectionPerVolume(G4double kineticEnergy,
0182                                  const G4MaterialCutsCouple* couple,
0183                                  G4double logKineticEnergy);
0184 
0185   // access to cross section
0186   G4double MeanFreePath(const G4Track& track);
0187 
0188   // access to step limit
0189   G4double ContinuousStepLimit(const G4Track& track,
0190                                G4double previousStepSize,
0191                                G4double currentMinimumStep,
0192                                G4double& currentSafety);
0193 
0194 protected:
0195 
0196   // implementation of the pure virtual method
0197   G4double GetMeanFreePath(const G4Track& track,
0198                            G4double previousStepSize,
0199                            G4ForceCondition* condition) override;
0200 
0201   // implementation of the pure virtual method
0202   G4double GetContinuousStepLimit(const G4Track& track,
0203                                   G4double previousStepSize,
0204                                   G4double currentMinimumStep,
0205                                   G4double& currentSafety) override;
0206 
0207   // creation of an empty vector for cross sections for derived processes
0208   G4PhysicsVector* LambdaPhysicsVector(const G4MaterialCutsCouple*, 
0209                                        G4double cut);
0210 
0211   inline std::size_t CurrentMaterialCutsCoupleIndex() const;
0212 
0213   //------------------------------------------------------------------------
0214   // Specific methods to set, access, modify models
0215   //------------------------------------------------------------------------
0216 
0217   // Select model in run time
0218   inline void SelectModel(G4double kinEnergy);
0219 
0220 public:
0221   // Select model by energy and couple index
0222   // Not for run time processing
0223   inline G4VEmModel* SelectModelForMaterial(G4double kinEnergy, 
0224                                             std::size_t& idxCouple) const;
0225 
0226   // Add EM model coupled with fluctuation model for region, smaller value 
0227   // of order defines which pair of models will be selected for a given 
0228   // energy interval  
0229   void AddEmModel(G4int, G4VEmModel*, 
0230                   G4VEmFluctuationModel* fluc = nullptr,
0231                   const G4Region* region = nullptr);
0232 
0233   // Assign a model to a process local list, to enable the list in run time 
0234   // the derived process should execute AddEmModel(..) for all such models
0235   void SetEmModel(G4VEmModel*, G4int index=0);
0236 
0237   // Access to models
0238   inline std::size_t NumberOfModels() const;
0239   
0240   // Return a model from the local list
0241   inline G4VEmModel* EmModel(std::size_t index=0) const;
0242   
0243   // Access to models from G4EmModelManager list
0244   inline G4VEmModel* GetModelByIndex(std::size_t idx = 0, G4bool ver = false) const;
0245 
0246   // Assign a fluctuation model to a process
0247   inline void SetFluctModel(G4VEmFluctuationModel*);
0248   
0249   // Return the assigned fluctuation model
0250   inline G4VEmFluctuationModel* FluctModel() const;
0251     
0252   //------------------------------------------------------------------------
0253   // Define and access particle type 
0254   //------------------------------------------------------------------------
0255 
0256 protected:
0257   inline void SetParticle(const G4ParticleDefinition* p);
0258   inline void SetSecondaryParticle(const G4ParticleDefinition* p);
0259 
0260 public:
0261   inline void SetBaseParticle(const G4ParticleDefinition* p);
0262   inline const G4ParticleDefinition* Particle() const;
0263   inline const G4ParticleDefinition* BaseParticle() const;
0264   inline const G4ParticleDefinition* SecondaryParticle() const;
0265 
0266   // hide  assignment operator
0267   G4VEnergyLossProcess(G4VEnergyLossProcess &) = delete;
0268   G4VEnergyLossProcess & operator=(const G4VEnergyLossProcess &right) = delete;
0269 
0270   //------------------------------------------------------------------------
0271   // Get/set parameters to configure the process at initialisation time
0272   //------------------------------------------------------------------------
0273 
0274   // Add subcut processor for the region
0275   void ActivateSubCutoff(const G4Region* region);
0276 
0277   // Activate biasing
0278   void SetCrossSectionBiasingFactor(G4double f, G4bool flag = true);
0279 
0280   void ActivateForcedInteraction(G4double length, 
0281                                  const G4String& region,
0282                                  G4bool flag = true);
0283 
0284   void ActivateSecondaryBiasing(const G4String& region, G4double factor,
0285                                 G4double energyLimit);
0286 
0287   // obsolete method will be removed in the next major release
0288   void SetLossFluctuations(G4bool);
0289 
0290   // interpolation of cross section
0291   inline void SetSpline(G4bool val);
0292   inline void SetCrossSectionType(G4CrossSectionType val);
0293   inline G4CrossSectionType CrossSectionType() const;
0294 
0295   // Set/Get flag "isIonisation"
0296   void SetIonisation(G4bool val);
0297   inline G4bool IsIonisationProcess() const;
0298 
0299   // Redefine parameteters of stepping control
0300   void SetLinearLossLimit(G4double val);
0301   void SetStepFunction(G4double v1, G4double v2);
0302   void SetLowestEnergyLimit(G4double);
0303 
0304   inline G4int NumberOfSubCutoffRegions() const;
0305 
0306   //------------------------------------------------------------------------
0307   // Specific methods to path Physics Tables to the process
0308   //------------------------------------------------------------------------
0309 
0310   void SetDEDXTable(G4PhysicsTable* p, G4EmTableType tType);
0311   void SetCSDARangeTable(G4PhysicsTable* pRange);
0312   void SetRangeTableForLoss(G4PhysicsTable* p);
0313   void SetInverseRangeTable(G4PhysicsTable* p);
0314   void SetLambdaTable(G4PhysicsTable* p);
0315 
0316   // set properties of cross section shape
0317   void SetTwoPeaksXS(std::vector<G4TwoPeaksXS*>*);
0318   void SetEnergyOfCrossSectionMax(std::vector<G4double>*);
0319 
0320   //------------------------------------------------------------------------
0321   // Specific methods to define custom Physics Tables to the process
0322   //------------------------------------------------------------------------
0323 
0324   // Binning for dEdx, range, inverse range and lambda tables
0325   void SetDEDXBinning(G4int nbins);
0326 
0327   // Min kinetic energy for tables
0328   void SetMinKinEnergy(G4double e);
0329   inline G4double MinKinEnergy() const;
0330 
0331   // Max kinetic energy for tables
0332   void SetMaxKinEnergy(G4double e);
0333   inline G4double MaxKinEnergy() const;
0334 
0335   // Biasing parameters
0336   inline G4double CrossSectionBiasingFactor() const;
0337 
0338   // Return values for given G4MaterialCutsCouple
0339   inline G4double GetDEDX(G4double kineticEnergy, const G4MaterialCutsCouple*);
0340   inline G4double GetCSDADEDX(G4double kineticEnergy, 
0341                               const G4MaterialCutsCouple*);
0342   inline G4double GetDEDX(G4double kineticEnergy, const G4MaterialCutsCouple*,
0343                           G4double logKineticEnergy);
0344   inline G4double GetRange(G4double kineticEnergy, const G4MaterialCutsCouple*);
0345   inline G4double GetRange(G4double kineticEnergy, const G4MaterialCutsCouple*,
0346                            G4double logKineticEnergy);
0347   inline G4double GetCSDARange(G4double kineticEnergy, 
0348                                const G4MaterialCutsCouple*);
0349   inline G4double GetKineticEnergy(G4double range, 
0350                                    const G4MaterialCutsCouple*);
0351   inline G4double GetLambda(G4double kineticEnergy,const G4MaterialCutsCouple*);
0352   inline G4double GetLambda(G4double kineticEnergy,const G4MaterialCutsCouple*,
0353                             G4double logKineticEnergy);
0354 
0355   inline G4bool TablesAreBuilt() const;
0356 
0357   // Access to specific tables
0358   inline G4PhysicsTable* DEDXTable() const;
0359   inline G4PhysicsTable* DEDXunRestrictedTable() const;
0360   inline G4PhysicsTable* IonisationTable() const;
0361   inline G4PhysicsTable* CSDARangeTable() const;
0362   inline G4PhysicsTable* RangeTableForLoss() const;
0363   inline G4PhysicsTable* InverseRangeTable() const;
0364   inline G4PhysicsTable* LambdaTable() const;
0365   inline std::vector<G4TwoPeaksXS*>* TwoPeaksXS() const;
0366   inline std::vector<G4double>* EnergyOfCrossSectionMax() const;
0367 
0368   inline G4bool UseBaseMaterial() const;
0369 
0370   //------------------------------------------------------------------------
0371   // Run time method for simulation of ionisation
0372   //------------------------------------------------------------------------
0373 
0374   // access atom on which interaction happens
0375   const G4Element* GetCurrentElement() const;
0376 
0377   // Set scaling parameters for ions is needed to G4EmCalculator
0378   void SetDynamicMassCharge(G4double massratio, G4double charge2ratio);
0379 
0380 private:
0381 
0382   void FillSecondariesAlongStep(G4double weight);
0383 
0384   void PrintWarning(const G4String&, G4double val) const;
0385 
0386   // define material and indexes
0387   inline void DefineMaterial(const G4MaterialCutsCouple* couple);
0388 
0389   //------------------------------------------------------------------------
0390   // Compute values using scaling relation, mass and charge of based particle
0391   //------------------------------------------------------------------------
0392   inline G4double GetDEDXForScaledEnergy(G4double scaledKinE);
0393   inline G4double GetDEDXForScaledEnergy(G4double scaledKinE,
0394                                          G4double logScaledKinE);
0395   inline G4double GetIonisationForScaledEnergy(G4double scaledKinE);
0396   inline G4double GetScaledRangeForScaledEnergy(G4double scaledKinE);
0397   inline G4double GetScaledRangeForScaledEnergy(G4double scaledKinE,
0398                                                 G4double logScaledKinE);
0399 
0400   inline G4double GetLimitScaledRangeForScaledEnergy(G4double scaledKinE);
0401   inline G4double GetLimitScaledRangeForScaledEnergy(G4double scaledKinE,
0402                                                      G4double logScaledKinE);
0403 
0404   inline G4double ScaledKinEnergyForLoss(G4double range);
0405   inline G4double GetLambdaForScaledEnergy(G4double scaledKinE);
0406   inline G4double GetLambdaForScaledEnergy(G4double scaledKinE, 
0407                                            G4double logScaledKinE);
0408 
0409   inline G4double LogScaledEkin(const G4Track& aTrack);
0410   
0411   void ComputeLambdaForScaledEnergy(G4double scaledKinE,
0412                                     const G4Track& aTrack);
0413 
0414   G4bool IsRegionForCubcutProcessor(const G4Track& aTrack);
0415 
0416 protected:
0417 
0418   G4ParticleChangeForLoss     fParticleChange;
0419   const G4Material*           currentMaterial = nullptr;
0420   const G4MaterialCutsCouple* currentCouple = nullptr;
0421 
0422 private:
0423 
0424   G4LossTableManager*         lManager;
0425   G4EmModelManager*           modelManager;
0426   G4VEmModel*                 currentModel = nullptr;
0427   G4EmBiasingManager*         biasManager = nullptr;
0428   G4SafetyHelper*             safetyHelper;
0429   G4EmParameters*             theParameters;  
0430   G4VEmFluctuationModel*      fluctModel = nullptr;
0431   G4VAtomDeexcitation*        atomDeexcitation = nullptr;
0432   G4VSubCutProducer*          subcutProducer = nullptr;
0433 
0434   const G4ParticleDefinition* particle = nullptr;
0435   const G4ParticleDefinition* baseParticle = nullptr;
0436   const G4ParticleDefinition* secondaryParticle = nullptr;
0437   G4EmDataHandler* theData = nullptr;
0438 
0439   G4PhysicsTable* theDEDXTable = nullptr;
0440   G4PhysicsTable* theDEDXunRestrictedTable = nullptr;
0441   G4PhysicsTable* theIonisationTable = nullptr;
0442   G4PhysicsTable* theRangeTableForLoss = nullptr;
0443   G4PhysicsTable* theCSDARangeTable = nullptr;
0444   G4PhysicsTable* theInverseRangeTable = nullptr;
0445   G4PhysicsTable* theLambdaTable = nullptr;
0446 
0447   std::vector<const G4Region*>* scoffRegions = nullptr;
0448   std::vector<G4VEmModel*>*     emModels = nullptr;
0449   const std::vector<G4int>*     theDensityIdx = nullptr;
0450   const std::vector<G4double>*  theDensityFactor = nullptr;
0451   const G4DataVector*           theCuts = nullptr;
0452   const std::vector<G4bool>*    theFluctuationFlags = nullptr;
0453 
0454   std::vector<G4double>* theEnergyOfCrossSectionMax = nullptr;
0455   std::vector<G4TwoPeaksXS*>* fXSpeaks = nullptr;
0456 
0457   G4double lowestKinEnergy;
0458   G4double minKinEnergy;
0459   G4double maxKinEnergy;
0460   G4double maxKinEnergyCSDA;
0461 
0462   G4double linLossLimit = 0.01;
0463   G4double dRoverRange = 0.2;
0464   G4double finalRange;
0465   G4double lambdaFactor = 0.8;
0466   G4double invLambdaFactor;
0467   G4double biasFactor = 1.0;
0468 
0469   G4double massRatio = 1.0;
0470   G4double logMassRatio = 0.0;
0471   G4double fFactor = 1.0;
0472   G4double reduceFactor = 1.0;
0473   G4double chargeSqRatio = 1.0;
0474   G4double fRange = 0.0;
0475   G4double fRangeEnergy = 0.0;
0476 
0477 protected:
0478 
0479   G4double preStepLambda = 0.0;
0480   G4double preStepKinEnergy = 0.0;
0481   G4double preStepScaledEnergy = 0.0;
0482   G4double mfpKinEnergy = 0.0;
0483 
0484   std::size_t currentCoupleIndex = 0;
0485 
0486 private:
0487 
0488   G4int nBins;
0489   G4int nBinsCSDA;
0490   G4int numberOfModels = 0;
0491   G4int nSCoffRegions = 0;
0492   G4int secID = _DeltaElectron;
0493   G4int tripletID = _TripletElectron;
0494   G4int biasID = _DeltaEBelowCut;
0495   G4int epixeID = _ePIXE;
0496   G4int gpixeID = _GammaPIXE;
0497   G4int mainSecondaries = 1;
0498 
0499   std::size_t basedCoupleIndex = 0;
0500   std::size_t coupleIdxRange = 0;
0501   std::size_t idxDEDX = 0;
0502   std::size_t idxDEDXunRestricted = 0;
0503   std::size_t idxIonisation = 0;
0504   std::size_t idxRange = 0;
0505   std::size_t idxCSDA = 0;
0506   std::size_t idxSecRange = 0;
0507   std::size_t idxInverseRange = 0;
0508   std::size_t idxLambda = 0;
0509 
0510   G4GPILSelection aGPILSelection;
0511   G4CrossSectionType fXSType = fEmOnePeak;
0512 
0513   G4bool lossFluctuationFlag = true;
0514   G4bool useCutAsFinalRange = false;
0515   G4bool tablesAreBuilt = false;
0516   G4bool spline = true;
0517   G4bool isIon = false;
0518   G4bool isIonisation = false;
0519   G4bool useDeexcitation = false;
0520   G4bool biasFlag = false;
0521   G4bool weightFlag = false;
0522   G4bool isMaster = false;
0523   G4bool baseMat = false;
0524   
0525   // flags allowing define table parameters individual for the process
0526   G4bool actLinLossLimit = false;
0527   G4bool actBinning = false;
0528   G4bool actMinKinEnergy = false;
0529   G4bool actMaxKinEnergy = false;
0530 
0531   std::vector<G4DynamicParticle*> secParticles;
0532   std::vector<G4Track*> scTracks;
0533 };
0534 
0535 // ======== Run time inline methods ================
0536 
0537 inline std::size_t G4VEnergyLossProcess::CurrentMaterialCutsCoupleIndex() const 
0538 {
0539   return currentCoupleIndex;
0540 }
0541 
0542 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0543 
0544 inline void G4VEnergyLossProcess::SelectModel(G4double kinEnergy)
0545 {
0546   currentModel = modelManager->SelectModel(kinEnergy, currentCoupleIndex);
0547   currentModel->SetCurrentCouple(currentCouple);
0548 }
0549 
0550 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0551 
0552 inline G4VEmModel* G4VEnergyLossProcess::SelectModelForMaterial(
0553                    G4double kinEnergy, std::size_t& idx) const
0554 {
0555   return modelManager->SelectModel(kinEnergy, idx);
0556 }
0557 
0558 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0559 
0560 inline void 
0561 G4VEnergyLossProcess::DefineMaterial(const G4MaterialCutsCouple* couple)
0562 {
0563   if(couple != currentCouple) {
0564     currentCouple = couple;
0565     currentMaterial = couple->GetMaterial();
0566     basedCoupleIndex = currentCoupleIndex = couple->GetIndex();
0567     fFactor = chargeSqRatio*biasFactor;
0568     mfpKinEnergy = DBL_MAX;
0569     idxLambda = 0;
0570     if(baseMat) {
0571       basedCoupleIndex = (*theDensityIdx)[currentCoupleIndex];
0572       fFactor *= (*theDensityFactor)[currentCoupleIndex];
0573     }
0574     reduceFactor = 1.0/(fFactor*massRatio);
0575   }
0576 }
0577 
0578 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0579 
0580 inline G4double G4VEnergyLossProcess::GetDEDXForScaledEnergy(G4double e)
0581 {
0582   /*
0583   G4cout << "G4VEnergyLossProcess::GetDEDX: Idx= " 
0584            << basedCoupleIndex << " E(MeV)= " << e 
0585          << " Emin= " << minKinEnergy << "  Factor= " << fFactor 
0586          << "  " << theDEDXTable << G4endl; */
0587   G4double x = fFactor*(*theDEDXTable)[basedCoupleIndex]->Value(e, idxDEDX);
0588   if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
0589   return x;
0590 }
0591 
0592 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0593 
0594 inline
0595 G4double G4VEnergyLossProcess::GetDEDXForScaledEnergy(G4double e, G4double loge)
0596 {
0597   /*
0598   G4cout << "G4VEnergyLossProcess::GetDEDX: Idx= " 
0599            << basedCoupleIndex << " E(MeV)= " << e 
0600          << " Emin= " << minKinEnergy << "  Factor= " << fFactor 
0601          << "  " << theDEDXTable << G4endl; */
0602   G4double x = fFactor*(*theDEDXTable)[basedCoupleIndex]->LogVectorValue(e,loge);
0603   if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
0604   return x;
0605 }
0606 
0607 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0608 
0609 inline G4double G4VEnergyLossProcess::GetIonisationForScaledEnergy(G4double e)
0610 {
0611   G4double x = 
0612     fFactor*(*theIonisationTable)[basedCoupleIndex]->Value(e, idxIonisation);
0613   if(e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
0614   return x;
0615 }
0616 
0617 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0618 
0619 inline G4double G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e)
0620 {
0621   //G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= " 
0622   //         << basedCoupleIndex << " E(MeV)= " << e 
0623   //         << " lastIdx= " << lastIdx << "  " << theRangeTableForLoss << G4endl; 
0624   if(currentCoupleIndex != coupleIdxRange || fRangeEnergy != e) {
0625     coupleIdxRange = currentCoupleIndex;
0626     fRangeEnergy = e;
0627     fRange = reduceFactor*((*theRangeTableForLoss)[basedCoupleIndex])->Value(e, idxRange);
0628     if (fRange < 0.0) { fRange = 0.0; }
0629     else if (e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
0630   }
0631   //G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= " 
0632   //         << basedCoupleIndex << " E(MeV)= " << e 
0633   //         << " R=  " << computedRange << "  " << theRangeTableForLoss << G4endl;
0634   return fRange;
0635 }
0636 
0637 inline G4double
0638 G4VEnergyLossProcess::GetScaledRangeForScaledEnergy(G4double e, G4double loge)
0639 {
0640   //G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= " 
0641   //         << basedCoupleIndex << " E(MeV)= " << e 
0642   //         << " lastIdx= " << lastIdx << "  " << theRangeTableForLoss << G4endl; 
0643   if(currentCoupleIndex != coupleIdxRange || fRangeEnergy != e) {
0644     coupleIdxRange = currentCoupleIndex;
0645     fRangeEnergy = e;
0646     fRange = reduceFactor*((*theRangeTableForLoss)[basedCoupleIndex])->LogVectorValue(e, loge);
0647     if (fRange < 0.0) { fRange = 0.0; }
0648     else if (e < minKinEnergy) { fRange *= std::sqrt(e/minKinEnergy); }
0649   }
0650   //G4cout << "G4VEnergyLossProcess::GetScaledRange: Idx= " 
0651   //         << basedCoupleIndex << " E(MeV)= " << e 
0652   //         << " R=  " << fRange << "  " << theRangeTableForLoss << G4endl;
0653   return fRange;
0654 }
0655 
0656 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0657 
0658 inline G4double 
0659 G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(G4double e)
0660 {
0661   G4double x = ((*theCSDARangeTable)[basedCoupleIndex])->Value(e, idxCSDA);
0662   if (x < 0.0) { x = 0.0; }
0663   else if (e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
0664   return x;
0665 }
0666 
0667 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0668 
0669 inline G4double 
0670 G4VEnergyLossProcess::GetLimitScaledRangeForScaledEnergy(G4double e,
0671                                                          G4double loge)
0672 {
0673   G4double x = ((*theCSDARangeTable)[basedCoupleIndex])->LogVectorValue(e, loge);
0674   if (x < 0.0) { x = 0.0; }
0675   else if (e < minKinEnergy) { x *= std::sqrt(e/minKinEnergy); }
0676   return x;
0677 }
0678 
0679 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0680 
0681 inline G4double G4VEnergyLossProcess::ScaledKinEnergyForLoss(G4double r)
0682 {
0683   //G4cout << "G4VEnergyLossProcess::GetEnergy: Idx= " 
0684   //         << basedCoupleIndex << " R(mm)= " << r << "  " 
0685   //         << theInverseRangeTable << G4endl; 
0686   G4PhysicsVector* v = (*theInverseRangeTable)[basedCoupleIndex];
0687   G4double rmin = v->Energy(0);
0688   G4double e = 0.0; 
0689   if(r >= rmin) { e = v->Value(r, idxInverseRange); }
0690   else if(r > 0.0) {
0691     G4double x = r/rmin;
0692     e = minKinEnergy*x*x;
0693   }
0694   return e;
0695 }
0696 
0697 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0698 
0699 inline G4double G4VEnergyLossProcess::GetLambdaForScaledEnergy(G4double e)
0700 {
0701   return fFactor*((*theLambdaTable)[basedCoupleIndex])->Value(e, idxLambda);
0702 }
0703 
0704 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0705 
0706 inline G4double
0707 G4VEnergyLossProcess::GetLambdaForScaledEnergy(G4double e, G4double loge)
0708 {
0709   return fFactor*((*theLambdaTable)[basedCoupleIndex])->LogVectorValue(e, loge);
0710 }
0711 
0712 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0713 
0714 inline G4double G4VEnergyLossProcess::LogScaledEkin(const G4Track& track)
0715 {
0716   return track.GetDynamicParticle()->GetLogKineticEnergy() + logMassRatio;
0717 }
0718 
0719 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0720 
0721 inline G4double 
0722 G4VEnergyLossProcess::GetDEDX(G4double kinEnergy,
0723                               const G4MaterialCutsCouple* couple)
0724 {
0725   DefineMaterial(couple);
0726   return GetDEDXForScaledEnergy(kinEnergy*massRatio);
0727 }
0728 
0729 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0730 
0731 inline G4double 
0732 G4VEnergyLossProcess::GetDEDX(G4double kinEnergy,
0733                               const G4MaterialCutsCouple* couple,
0734                               G4double logKinEnergy)
0735 {
0736   DefineMaterial(couple);
0737   return GetDEDXForScaledEnergy(kinEnergy*massRatio, logKinEnergy+logMassRatio);
0738 }
0739 
0740 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0741 
0742 inline G4double 
0743 G4VEnergyLossProcess::GetRange(G4double kinEnergy,
0744                                const G4MaterialCutsCouple* couple)
0745 {
0746   DefineMaterial(couple);
0747   return GetScaledRangeForScaledEnergy(kinEnergy*massRatio);
0748 }
0749 
0750 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0751 
0752 inline G4double 
0753 G4VEnergyLossProcess::GetRange(G4double kinEnergy,
0754                                const G4MaterialCutsCouple* couple,
0755                                G4double logKinEnergy)
0756 {
0757   DefineMaterial(couple);
0758   return GetScaledRangeForScaledEnergy(kinEnergy*massRatio, logKinEnergy+logMassRatio);
0759 }
0760 
0761 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0762 
0763 inline G4double 
0764 G4VEnergyLossProcess::GetCSDARange(G4double kineticEnergy, 
0765                                    const G4MaterialCutsCouple* couple)
0766 {
0767   DefineMaterial(couple);
0768   return (nullptr == theCSDARangeTable) ? DBL_MAX : 
0769     GetLimitScaledRangeForScaledEnergy(kineticEnergy*massRatio)*reduceFactor;
0770 }
0771 
0772 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0773 
0774 inline G4double 
0775 G4VEnergyLossProcess::GetKineticEnergy(G4double range,
0776                                        const G4MaterialCutsCouple* couple)
0777 {
0778   DefineMaterial(couple);
0779   return ScaledKinEnergyForLoss(range/reduceFactor)/massRatio;
0780 }
0781 
0782 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0783 
0784 inline G4double 
0785 G4VEnergyLossProcess::GetLambda(G4double kinEnergy,
0786                                 const G4MaterialCutsCouple* couple)
0787 {
0788   DefineMaterial(couple);
0789   return (nullptr != theLambdaTable) ? 
0790     GetLambdaForScaledEnergy(kinEnergy*massRatio) : 0.0;
0791 }
0792 
0793 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0794 
0795 inline G4double 
0796 G4VEnergyLossProcess::GetLambda(G4double kinEnergy,
0797                                 const G4MaterialCutsCouple* couple,
0798                                 G4double logKinEnergy)
0799 {
0800   DefineMaterial(couple);
0801   return (nullptr != theLambdaTable) ?
0802     GetLambdaForScaledEnergy(kinEnergy*massRatio, logKinEnergy+logMassRatio) 
0803     :  0.0;
0804 }
0805 
0806 // ======== Get/Set inline methods used at initialisation ================
0807 
0808 inline void G4VEnergyLossProcess::SetFluctModel(G4VEmFluctuationModel* p)
0809 {
0810   fluctModel = p;
0811 }
0812 
0813 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0814 
0815 inline G4VEmFluctuationModel* G4VEnergyLossProcess::FluctModel() const
0816 {
0817   return fluctModel;
0818 }
0819 
0820 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0821 
0822 inline void G4VEnergyLossProcess::SetParticle(const G4ParticleDefinition* p)
0823 {
0824   particle = p;
0825 }
0826 
0827 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0828 
0829 inline void 
0830 G4VEnergyLossProcess::SetSecondaryParticle(const G4ParticleDefinition* p)
0831 {
0832   secondaryParticle = p;
0833 }
0834 
0835 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0836 
0837 inline void 
0838 G4VEnergyLossProcess::SetBaseParticle(const G4ParticleDefinition* p)
0839 {
0840   baseParticle = p;
0841 }
0842 
0843 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0844 
0845 inline const G4ParticleDefinition* G4VEnergyLossProcess::Particle() const
0846 {
0847   return particle;
0848 }
0849 
0850 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0851 
0852 inline const G4ParticleDefinition* G4VEnergyLossProcess::BaseParticle() const
0853 {
0854   return baseParticle;
0855 }
0856 
0857 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0858 
0859 inline const G4ParticleDefinition* 
0860 G4VEnergyLossProcess::SecondaryParticle() const
0861 {
0862   return secondaryParticle;
0863 }
0864 
0865 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0866 
0867 inline void G4VEnergyLossProcess::SetSpline(G4bool val)
0868 {
0869   spline = val;
0870 }
0871 
0872 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0873 
0874 inline void G4VEnergyLossProcess::SetCrossSectionType(G4CrossSectionType val)
0875 {
0876   fXSType = val;
0877 }
0878 
0879 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0880   
0881 inline G4CrossSectionType G4VEnergyLossProcess::CrossSectionType() const 
0882 {
0883   return fXSType;
0884 }
0885 
0886 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0887 
0888 inline G4bool G4VEnergyLossProcess::IsIonisationProcess() const
0889 {
0890   return isIonisation;
0891 }
0892 
0893 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0894 
0895 inline G4int G4VEnergyLossProcess::NumberOfSubCutoffRegions() const
0896 {
0897   return nSCoffRegions;
0898 }
0899 
0900 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0901 
0902 inline G4double G4VEnergyLossProcess::MinKinEnergy() const
0903 {
0904   return minKinEnergy;
0905 }
0906 
0907 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0908 
0909 inline G4double G4VEnergyLossProcess::MaxKinEnergy() const
0910 {
0911   return maxKinEnergy;
0912 }
0913 
0914 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0915 
0916 inline G4double G4VEnergyLossProcess::CrossSectionBiasingFactor() const
0917 {
0918   return biasFactor;
0919 }
0920 
0921 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0922 
0923 inline G4bool G4VEnergyLossProcess::TablesAreBuilt() const
0924 {
0925   return tablesAreBuilt;
0926 }
0927 
0928 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0929 
0930 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXTable() const
0931 {
0932   return theDEDXTable;
0933 }
0934 
0935 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0936 
0937 inline G4PhysicsTable* G4VEnergyLossProcess::DEDXunRestrictedTable() const
0938 {
0939   return theDEDXunRestrictedTable;
0940 }
0941 
0942 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0943 
0944 inline G4PhysicsTable* G4VEnergyLossProcess::IonisationTable() const
0945 {
0946   return theIonisationTable;
0947 }
0948 
0949 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0950 
0951 inline G4PhysicsTable* G4VEnergyLossProcess::CSDARangeTable() const
0952 {
0953   return theCSDARangeTable;
0954 }
0955 
0956 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0957 
0958 inline G4PhysicsTable* G4VEnergyLossProcess::RangeTableForLoss() const
0959 {
0960   return theRangeTableForLoss;
0961 }
0962 
0963 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0964 
0965 inline G4PhysicsTable* G4VEnergyLossProcess::InverseRangeTable() const
0966 {
0967   return theInverseRangeTable;
0968 }
0969 
0970 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0971 
0972 inline G4PhysicsTable* G4VEnergyLossProcess::LambdaTable() const
0973 {
0974   return theLambdaTable;
0975 }
0976 
0977 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0978 
0979 inline G4bool G4VEnergyLossProcess::UseBaseMaterial() const
0980 {
0981   return baseMat;
0982 }
0983 
0984 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0985 
0986 inline std::vector<G4double>* 
0987 G4VEnergyLossProcess::EnergyOfCrossSectionMax() const
0988 {
0989   return theEnergyOfCrossSectionMax;
0990 }
0991 
0992 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0993 
0994 inline std::vector<G4TwoPeaksXS*>* G4VEnergyLossProcess::TwoPeaksXS() const
0995 {
0996   return fXSpeaks;
0997 }
0998 
0999 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1000 
1001 inline std::size_t G4VEnergyLossProcess::NumberOfModels() const
1002 {
1003   return numberOfModels;
1004 }
1005 
1006 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1007 
1008 inline G4VEmModel* G4VEnergyLossProcess::EmModel(std::size_t index) const
1009 {
1010   return (index < emModels->size()) ? (*emModels)[index] : nullptr;
1011 }
1012 
1013 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1014 
1015 inline G4VEmModel* 
1016 G4VEnergyLossProcess::GetModelByIndex(std::size_t idx, G4bool ver) const
1017 {
1018   return modelManager->GetModel((G4int)idx, ver);
1019 }
1020 
1021 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
1022 
1023 #endif