Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58: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 // GEANT4 Class header file
0029 //
0030 //
0031 // File name:     G4LossTableManager
0032 //
0033 // Author:        Vladimir Ivanchenko on base of G4LossTables class
0034 //                and Maria Grazia Pia ideas
0035 //
0036 // Creation date: 03.01.2002
0037 //
0038 // Modifications by V.Ivanchenko  
0039 //
0040 // Class Description:
0041 //
0042 // A utility static class, responsable for the energy loss tables
0043 // for each particle
0044 //
0045 // Energy loss processes have to register their tables with this
0046 // class. The responsibility of creating and deleting the tables
0047 // remains with the energy loss classes.
0048 
0049 // -------------------------------------------------------------------
0050 //
0051 
0052 #ifndef G4LossTableManager_h
0053 #define G4LossTableManager_h 1
0054 
0055 #include <map>
0056 #include <vector>
0057 #include "globals.hh"
0058 #include "G4ThreadLocalSingleton.hh"
0059 #include "G4VEnergyLossProcess.hh"
0060 #include "G4EmParameters.hh"
0061 
0062 class G4PhysicsTable;
0063 class G4MaterialCutsCouple;
0064 class G4ParticleDefinition;
0065 class G4Region;
0066 class G4EmSaturation;
0067 class G4EmConfigurator;
0068 class G4ElectronIonPair;
0069 class G4NIELCalculator;
0070 class G4VMultipleScattering;
0071 class G4VEmProcess;
0072 class G4EmCorrections;
0073 class G4LossTableBuilder;
0074 class G4VAtomDeexcitation;
0075 class G4VSubCutProducer;
0076 
0077 class G4LossTableManager
0078 {
0079 
0080 friend class G4ThreadLocalSingleton<G4LossTableManager>;
0081 
0082 public:
0083 
0084   static G4LossTableManager* Instance();
0085 
0086   ~G4LossTableManager();
0087 
0088   //-------------------------------------------------
0089   // initialisation before a new run
0090   //-------------------------------------------------
0091 
0092   void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0093                            G4VEnergyLossProcess* p);
0094 
0095   void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0096                            G4VEmProcess* p);
0097 
0098   void PreparePhysicsTable(const G4ParticleDefinition* aParticle,
0099                            G4VMultipleScattering* p);
0100 
0101   void BuildPhysicsTable(const G4ParticleDefinition* aParticle);
0102 
0103   void BuildPhysicsTable(const G4ParticleDefinition* aParticle, 
0104                          G4VEnergyLossProcess* p);
0105 
0106   void LocalPhysicsTables(const G4ParticleDefinition* aParticle, 
0107                           G4VEnergyLossProcess* p);
0108  
0109   void DumpHtml();
0110 
0111   //-------------------------------------------------
0112   // Run time access to DEDX, range, energy for a given particle, 
0113   // energy, and G4MaterialCutsCouple
0114   //-------------------------------------------------
0115 
0116   inline G4double GetDEDX(
0117     const G4ParticleDefinition *aParticle,
0118     G4double kineticEnergy,
0119     const G4MaterialCutsCouple *couple);
0120 
0121   inline G4double GetRange(
0122     const G4ParticleDefinition *aParticle,
0123     G4double kineticEnergy,
0124     const G4MaterialCutsCouple *couple);
0125 
0126   inline G4double GetCSDARange(
0127     const G4ParticleDefinition *aParticle,
0128     G4double kineticEnergy,
0129     const G4MaterialCutsCouple *couple);
0130 
0131   inline G4double GetRangeFromRestricteDEDX(
0132     const G4ParticleDefinition *aParticle,
0133     G4double kineticEnergy,
0134     const G4MaterialCutsCouple *couple);
0135 
0136   inline G4double GetEnergy(
0137     const G4ParticleDefinition *aParticle,
0138     G4double range,
0139     const G4MaterialCutsCouple *couple);
0140 
0141   inline G4double GetDEDXDispersion(
0142     const G4MaterialCutsCouple *couple,
0143     const G4DynamicParticle* dp,
0144           G4double& length);
0145 
0146   //-------------------------------------------------
0147   // Methods to be called only at initialisation
0148   // and at the end of the job
0149   //-------------------------------------------------
0150 
0151   void Register(G4VEnergyLossProcess* p);
0152 
0153   void DeRegister(G4VEnergyLossProcess* p);
0154 
0155   void Register(G4VMultipleScattering* p);
0156 
0157   void DeRegister(G4VMultipleScattering* p);
0158 
0159   void Register(G4VEmProcess* p);
0160 
0161   void DeRegister(G4VEmProcess* p);
0162 
0163   void Register(G4VProcess* p);
0164 
0165   void DeRegister(G4VProcess* p);
0166 
0167   void Register(G4VEmModel* p);
0168 
0169   void DeRegister(G4VEmModel* p);
0170 
0171   void Register(G4VEmFluctuationModel* p);
0172 
0173   void DeRegister(G4VEmFluctuationModel* p);
0174 
0175   void RegisterExtraParticle(const G4ParticleDefinition* aParticle, 
0176                              G4VEnergyLossProcess* p);
0177 
0178   void SetVerbose(G4int val);
0179 
0180   void ResetParameters();
0181 
0182   void SetAtomDeexcitation(G4VAtomDeexcitation*);
0183 
0184   void SetSubCutProducer(G4VSubCutProducer*);
0185 
0186   void SetNIELCalculator(G4NIELCalculator*);
0187 
0188   //-------------------------------------------------
0189   // Access methods
0190   //-------------------------------------------------
0191 
0192   inline G4bool IsMaster() const;
0193 
0194   G4VEnergyLossProcess* GetEnergyLossProcess(const G4ParticleDefinition*);
0195  
0196   const std::vector<G4VEnergyLossProcess*>& GetEnergyLossProcessVector();
0197 
0198   const std::vector<G4VEmProcess*>& GetEmProcessVector();
0199 
0200   const std::vector<G4VMultipleScattering*>& GetMultipleScatteringVector();
0201 
0202   G4EmSaturation* EmSaturation();
0203 
0204   G4EmConfigurator* EmConfigurator();
0205 
0206   G4ElectronIonPair* ElectronIonPair();
0207 
0208   G4NIELCalculator* NIELCalculator();
0209 
0210   inline G4EmCorrections* EmCorrections();
0211 
0212   inline G4VAtomDeexcitation* AtomDeexcitation();
0213 
0214   inline G4VSubCutProducer* SubCutProducer();
0215 
0216   inline G4LossTableBuilder* GetTableBuilder();
0217 
0218   inline void SetGammaGeneralProcess(G4VEmProcess*); 
0219 
0220   inline G4VEmProcess* GetGammaGeneralProcess(); 
0221 
0222   inline void SetElectronGeneralProcess(G4VEmProcess*); 
0223 
0224   inline G4VEmProcess* GetElectronGeneralProcess(); 
0225 
0226   inline void SetPositronGeneralProcess(G4VEmProcess*); 
0227 
0228   inline G4VEmProcess* GetPositronGeneralProcess(); 
0229 
0230   G4LossTableManager(G4LossTableManager &) = delete;
0231   G4LossTableManager & operator=(const G4LossTableManager &right) = delete;
0232 
0233 private:
0234 
0235   //-------------------------------------------------
0236   // Private methods and members
0237   //-------------------------------------------------
0238 
0239   G4LossTableManager();
0240 
0241   void Clear();
0242 
0243   G4VEnergyLossProcess* BuildTables(const G4ParticleDefinition* aParticle);
0244 
0245   void CopyTables(const G4ParticleDefinition* aParticle, 
0246                   G4VEnergyLossProcess*);
0247 
0248   void ParticleHaveNoLoss(const G4ParticleDefinition* aParticle);
0249 
0250   void CopyDEDXTables();
0251 
0252   void PrintEWarning(G4String, G4double);
0253 
0254   static G4ThreadLocal G4LossTableManager* instance;
0255 
0256   typedef const G4ParticleDefinition* PD;
0257 
0258   // cache
0259   G4VEnergyLossProcess* currentLoss{nullptr};
0260   PD currentParticle{nullptr};
0261   PD theElectron;
0262   PD theGenericIon{nullptr};
0263   PD firstParticle{nullptr};
0264 
0265   G4LossTableBuilder* tableBuilder;
0266   G4EmCorrections* emCorrections;
0267   G4EmConfigurator* emConfigurator{nullptr};
0268   G4ElectronIonPair* emElectronIonPair{nullptr};
0269   G4NIELCalculator* nielCalculator{nullptr};
0270   G4VAtomDeexcitation* atomDeexcitation{nullptr};
0271   G4VSubCutProducer* subcutProducer{nullptr};
0272 
0273   G4EmParameters* theParameters;
0274   G4VEmProcess* gGeneral{nullptr};
0275   G4VEmProcess* eGeneral{nullptr};
0276   G4VEmProcess* pGeneral{nullptr};
0277 
0278   G4int verbose;
0279   G4int n_loss{0};
0280   G4int run{-1};
0281 
0282   G4bool all_tables_are_built{false};
0283   G4bool startInitialisation{false};
0284   G4bool isMaster{true};
0285 
0286   std::vector<G4VEnergyLossProcess*> loss_vector;
0287   std::vector<PD> part_vector;
0288   std::vector<PD> base_part_vector;
0289   std::vector<G4PhysicsTable*> dedx_vector;
0290   std::vector<G4PhysicsTable*> range_vector;
0291   std::vector<G4PhysicsTable*> inv_range_vector;
0292   std::vector<G4bool> tables_are_built;
0293   std::vector<G4bool> isActive;
0294   std::vector<G4VMultipleScattering*> msc_vector;
0295   std::vector<G4VEmProcess*> emp_vector;
0296   std::vector<G4VEmModel*> mod_vector;
0297   std::vector<G4VEmFluctuationModel*> fmod_vector;
0298   std::vector<G4VProcess*> p_vector;
0299 
0300   std::map<PD,G4VEnergyLossProcess*,std::less<PD> > loss_map;
0301 };
0302 
0303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0305 
0306 inline
0307 G4double G4LossTableManager::GetDEDX(const G4ParticleDefinition *aParticle,
0308                                      G4double kineticEnergy,
0309                                      const G4MaterialCutsCouple *couple)
0310 {
0311   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0312   return currentLoss ? currentLoss->GetDEDX(kineticEnergy, couple) : 0.0;
0313 }
0314 
0315 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0316 
0317 inline
0318 G4double G4LossTableManager::GetCSDARange(const G4ParticleDefinition *aParticle,
0319                                           G4double kineticEnergy,
0320                                           const G4MaterialCutsCouple *couple)
0321 {
0322   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0323   return currentLoss ? currentLoss->GetCSDARange(kineticEnergy, couple) : DBL_MAX;
0324 }
0325 
0326 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0327 
0328 inline
0329 G4double G4LossTableManager::GetRangeFromRestricteDEDX(
0330                              const G4ParticleDefinition *aParticle,
0331                              G4double kineticEnergy,
0332                              const G4MaterialCutsCouple *couple)
0333 {
0334   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0335   return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
0336 }
0337 
0338 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0339 
0340 inline
0341 G4double G4LossTableManager::GetRange(const G4ParticleDefinition *aParticle,
0342                                       G4double kineticEnergy,
0343                                       const G4MaterialCutsCouple *couple)
0344 {
0345   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0346   return currentLoss ? currentLoss->GetRange(kineticEnergy, couple) : DBL_MAX;
0347 }
0348 
0349 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0350 
0351 inline
0352 G4double G4LossTableManager::GetEnergy(const G4ParticleDefinition *aParticle,
0353                                        G4double range,
0354                                        const G4MaterialCutsCouple *couple)
0355 {
0356   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0357   return currentLoss ? currentLoss->GetKineticEnergy(range, couple) : 0.0;
0358 }
0359 
0360 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0361 
0362 inline
0363 G4double G4LossTableManager::GetDEDXDispersion(
0364                              const G4MaterialCutsCouple *couple,
0365                              const G4DynamicParticle* dp,
0366                              G4double& length)
0367 {
0368   const G4ParticleDefinition* aParticle = dp->GetParticleDefinition();
0369   if(aParticle != currentParticle) { GetEnergyLossProcess(aParticle); }
0370   return currentLoss ? currentLoss->GetDEDXDispersion(couple, dp, length) : 0.0;
0371 }
0372 
0373 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0374 
0375 inline G4bool G4LossTableManager::IsMaster() const
0376 {
0377   return isMaster;
0378 }
0379 
0380 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0381 
0382 inline G4EmCorrections* G4LossTableManager::EmCorrections() 
0383 {
0384   return emCorrections;
0385 }
0386 
0387 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0388 
0389 inline G4VAtomDeexcitation* G4LossTableManager::AtomDeexcitation()
0390 {
0391   return atomDeexcitation;
0392 }
0393 
0394 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0395 
0396 inline G4VSubCutProducer* G4LossTableManager::SubCutProducer()
0397 { 
0398   return subcutProducer;
0399 }
0400 
0401 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0402 
0403 inline G4LossTableBuilder* G4LossTableManager::GetTableBuilder()
0404 {
0405   return tableBuilder;
0406 }
0407 
0408 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0409 
0410 inline void G4LossTableManager::SetGammaGeneralProcess(G4VEmProcess* ptr)
0411 {
0412   gGeneral = ptr;
0413 } 
0414 
0415 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0416 
0417 inline G4VEmProcess* G4LossTableManager::GetGammaGeneralProcess()
0418 {
0419   return gGeneral;
0420 } 
0421 
0422 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0423 
0424 inline void G4LossTableManager::SetElectronGeneralProcess(G4VEmProcess* ptr)
0425 {
0426   eGeneral = ptr;
0427 } 
0428 
0429 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0430 
0431 inline G4VEmProcess* G4LossTableManager::GetElectronGeneralProcess()
0432 {
0433   return eGeneral;
0434 } 
0435 
0436 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0437 
0438 inline void G4LossTableManager::SetPositronGeneralProcess(G4VEmProcess* ptr)
0439 {
0440   pGeneral = ptr;
0441 } 
0442 
0443 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0444 
0445 inline G4VEmProcess* G4LossTableManager::GetPositronGeneralProcess()
0446 {
0447   return pGeneral;
0448 } 
0449 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0450 
0451 #endif