G4VUserPhysicsList.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // ------------------------------------------------------------
00031 //      GEANT 4 class header file 
00032 // Class Description:
00033 //      This class is an abstract class for
00034 //      constructing particles and processes.
00035 //      User must implement following three virtual methods
00036 //      in his/her own concrete class derived from this class. 
00037 //        G4VUserPhysicsList::ConstructParticle() 
00038 //           Construct particles
00039 //        G4VUserPhysicsList::ConstructProcess() 
00040 //           Construct procesess and register them to particles
00041 //
00042 // ------------------------------------------- 
00043 //      History
00044 //        first version                   09 Jan. 1998 by H.Kurashige 
00045 //        modified                        24 Jan. 1998 by H.Kurashige
00046 //          rename DumpCutValues/DumpCutValuesTable 
00047 //          change SetCuts method
00048 //          add    SetCutsWithDefault method
00049 //        modified                       06 June 1998 by H.Kurashige
00050 //          add    AddProcessManager
00051 //          add    BuildPhysicsTable
00052 //       modified                        29  June 1998 by H.Kurashige
00053 //          add    AddProcessManager
00054 //       modified                        05 Dec. 1998 by H.Kurashige
00055 //          add    ConstructAllParticles()
00056 //        modified                        14, Apr 1999 by H.Kurashige
00057 //          change BuildPhysicsTable as public
00058 //          removed ConstructAllParticles() and related methods  
00059 //          changed SetCuts method argument
00060 //       modified                           08, Nov 2000 by H.Kurashige
00061 //          added   Retrieve/StorePhysicsTable and related methods
00062 //       modified                           08, Mar 2001 by H.Kurashige
00063 //          added   binary mode for Retrieve/StorePhysicsTable
00064 //          added   RetrieveCutValues and related
00065 //          added   Set/ResetStoredInAscii() to switch on ascii mode 
00066 //                  for Retrieve/StorePhysicsTable
00067 //       modified for CUTS per REGION      10, Oct 2002 by H.Kurashige 
00068 //          removed following methods 
00069 //           void ReCalcCutValue() 
00070 //           void SetCutValueForOthers()
00071 //           void SetCutValueForOtherThan()     
00072 //           void ReCalcCutValueForOthers()
00073 //           virtual G4bool  StoreMaterialInfo()
00074 //           virtual G4bool  StoreCutValues()
00075 //           virtual G4bool  RetrieveCutValues()
00076 //           virtual G4bool  CheckForRetrievePhysicsTable()
00077 //           virtual G4bool  CheckMaterialInfo()
00078 //          added    void BuildPhysicsTable()    
00079 //       Added PhysicsListHelper           29 Apr. 2011 H.Kurashige
00080 //       Added default impelmentation of SetCuts 10 June 2011 H.Kurashige 
00081 //           SetCuts is not 'pure virtual' any more 
00082 // ------------------------------------------------------------
00083 #ifndef G4VUserPhysicsList_h
00084 #define G4VUserPhysicsList_h 1
00085 #include "globals.hh"
00086 #include "G4ios.hh"
00087 
00088 #include "G4ParticleTable.hh"
00089 #include "G4ParticleDefinition.hh" 
00090 #include "G4ProductionCutsTable.hh"
00091 
00092 class G4UserPhysicsListMessenger;
00093 class G4PhysicsListHelper;
00094 class G4VProcess;
00095 
00096 class G4VUserPhysicsList
00097 {
00098   public: 
00099     G4VUserPhysicsList();
00100     virtual ~G4VUserPhysicsList();
00101 
00102   // copy constructor and assignment operator
00103     G4VUserPhysicsList(const G4VUserPhysicsList&);
00104     G4VUserPhysicsList & operator=(const G4VUserPhysicsList&);
00105 
00106   public:  // with description
00107    // Each particle type will be instantiated
00108    // This method is invoked by the RunManger 
00109    virtual void ConstructParticle() = 0;
00110 
00111    // By calling the "Construct" method, 
00112    // process manager and processes are created. 
00113    void Construct();
00114  
00115    // Each physics process will be instantiated and
00116    // registered to the process manager of each particle type 
00117    // This method is invoked in Construct method 
00118    virtual void ConstructProcess() = 0;
00119 
00120   protected: // with description
00121    //  User must invoke this method in his ConstructProcess() 
00122    //  implementation in order to insures particle transportation.
00123    void AddTransportation();
00124 
00125    //Register a process to the particle type 
00126    // according to the ordering parameter table
00127    //  'true' is returned if the process is registerd successfully
00128    G4bool RegisterProcess(G4VProcess*            process,
00129                           G4ParticleDefinition*  particle);
00130 
00131   public:
00132    void UseCoupledTransportation(G4bool vl=true);
00133 
00135   public: // with description 
00136    //  "SetCuts" method sets a cut value for all particle types 
00137    //   in the particle table
00138    virtual void SetCuts(); 
00139 
00140   public:  // with description
00141    //  set/get the default cut value
00142    //  Calling SetDefaultCutValue causes re-calcuration of cut values
00143    //  and physics tables just before the next event loop
00144    void     SetDefaultCutValue(G4double newCutValue);
00145    G4double GetDefaultCutValue() const;
00146 
00148   public: // with description
00149     // Invoke BuildPhysicsTable for all processes for all particles
00150     // In case of "Retrieve" flag is ON, PhysicsTable will be
00151     // retrieved from files
00152     void BuildPhysicsTable();    
00153   
00154    // do PreparePhysicsTable for specified particle type
00155     void PreparePhysicsTable(G4ParticleDefinition* );    
00156 
00157    // do BuildPhysicsTable for specified particle type
00158     void BuildPhysicsTable(G4ParticleDefinition* );    
00159 
00160      // Store PhysicsTable together with both material and cut value 
00161     // information in files under the specified directory.
00162     //  (return true if files are sucessfully created)
00163     G4bool  StorePhysicsTable(const G4String& directory = ".");
00164  
00165     // Return true if "Retrieve" flag is ON. 
00166     // (i.e. PhysicsTable will be retrieved from files)
00167     G4bool  IsPhysicsTableRetrieved() const;
00168     G4bool  IsStoredInAscii() const;
00169 
00170     // Get directory path for physics table files.
00171     const G4String& GetPhysicsTableDirectory() const;
00172 
00173     // Set "Retrieve" flag
00174     // Directory path can be set together.
00175     // Null string (default) means directory is not changed 
00176     // from the current value 
00177     void    SetPhysicsTableRetrieved(const G4String& directory = "");
00178     void    SetStoredInAscii();
00179   
00180     // Reset "Retrieve" flag
00181     void    ResetPhysicsTableRetrieved();
00182     void    ResetStoredInAscii();
00183 
00185   public: // with description
00186     // Print out the List of registered particles types
00187     void DumpList() const;
00188 
00189   public: // with description
00190     // Request to print out information of cut values
00191     // Printing will be performed when all tables are made
00192     void DumpCutValuesTable(G4int flag =1);
00193 
00194     // The following method actually trigger the print-out requested
00195     // by the above method. This method must be invoked by RunManager
00196     // at the proper moment.
00197     void DumpCutValuesTableIfRequested();
00198 
00199   public: // with description
00200     void  SetVerboseLevel(G4int value);
00201     G4int GetVerboseLevel() const;
00202     // set/get controle flag for output message
00203     //  0: Silent
00204     //  1: Warning message
00205     //  2: More
00206 
00208   public: // with description
00209    //  "SetCutsWithDefault" method invokes default SetCuts method
00210    //   Note: Cut values will not be overwriten with this method 
00211    //   Using default SetCuts method is recommended
00212    //  (i.e You do not need to implement SetCuts method) 
00213    void SetCutsWithDefault();   
00214 
00215    // Following are utility methods for SetCuts
00216   
00217    // SetCutValue sets a cut value for a particle type for the default region
00218    void SetCutValue(G4double aCut, const G4String& pname); 
00219 
00220    // GetCutValue sets a cut value for a particle type for the default region
00221    G4double GetCutValue(const G4String& pname) const; 
00222 
00223    // SetCutValue sets a cut value for a particle type for a region
00224    void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname); 
00225 
00226    // Invoke SetCuts for specified particle for a region
00227    // If the pointer to the region is NULL, the default region is used
00228    // In case of "Retrieve" flag is ON, 
00229    // Cut values will be retrieved from files
00230    void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0);
00231   void SetParticleCuts( G4double cut, const G4String& particleName, G4Region* region=0);
00232 
00233    // Invoke SetCuts for all particles in a region
00234    void SetCutsForRegion(G4double aCut, const G4String& rname);
00235 
00236    // Following are utility methods are obsolete
00237    void ResetCuts();
00238 
00240   public:   
00241    // Get/SetApplyCuts gets/sets the flag for ApplyCuts
00242    void SetApplyCuts(G4bool value, const G4String& name); 
00243    G4bool GetApplyCuts(const G4String& name) const; 
00244 
00246   protected:  
00247     // do BuildPhysicsTable for make the integral schema
00248     void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition*  );   
00249 
00250 
00251   protected: 
00252     // Retrieve PhysicsTable from files for proccess belongng the particle.
00253     // Normal BuildPhysics procedure of processes will be invoked, 
00254     // if it fails (in case of Process's RetrievePhysicsTable returns false)
00255     virtual void  RetrievePhysicsTable(G4ParticleDefinition* ,  
00256                                        const G4String& directory, 
00257                                        G4bool          ascii = false);
00258 
00260   protected: 
00261     // adds new ProcessManager to all particles in the Particle Table
00262     //   this routine is used in Construct()
00263     void InitializeProcessManager();
00264 
00265   public: // with description
00266     // remove and delete ProcessManagers for all particles in tha Particle Table
00267     //    this routine is invoked from RunManager 
00268     void RemoveProcessManager();
00269 
00270   public: // with description
00271     // add process manager for particles created on-the-fly 
00272     void AddProcessManager(G4ParticleDefinition* newParticle,
00273                            G4ProcessManager*    newManager = 0 );
00274  
00276   public:
00277     // check consistencies of list of particles 
00278 
00279     void CheckParticleList();
00280 
00281     void DisableCheckParticleList();
00282  
00284   protected:
00285    // the particle table has the complete List of existing particle types
00286    G4ParticleTable* theParticleTable;
00287    G4ParticleTable::G4PTblDicIterator* theParticleIterator;
00288 
00289   protected: 
00290    // pointer to G4UserPhysicsListMessenger
00291    G4UserPhysicsListMessenger* theMessenger;
00292 
00293   protected:
00294    G4int verboseLevel;
00295 
00296   protected:
00297    // this is the default cut value for all particles
00298    G4double defaultCutValue;
00299   G4bool   isSetDefaultCutValue;
00300 
00301   protected:
00302    // pointer to ProductionCutsTable
00303    G4ProductionCutsTable* fCutsTable;
00304 
00305    // flag to determine physics table will be build from file or not
00306    G4bool fRetrievePhysicsTable;  
00307    G4bool fStoredInAscii;
00308  
00309    G4bool fIsCheckedForRetrievePhysicsTable;
00310    G4bool fIsRestoredCutValues;
00311 
00312    // directory name for physics table files 
00313    G4String directoryPhysicsTable;   
00314 
00315    // flag for displaying the range cuts & energy thresholds
00316    G4int fDisplayThreshold;
00317 
00318   // flag for Physics Table has been built 
00319    G4bool fIsPhysicsTableBuilt;
00320 
00321   // flag for CheckParticleList 
00322   G4bool fDisableCheckParticleList; 
00323 
00324   // PhysicsListHelper
00325   G4PhysicsListHelper* thePLHelper;
00326 
00327   private:
00328    enum { FixedStringLengthForStore = 32 }; 
00329 
00330 
00331 };
00332 
00333 inline void G4VUserPhysicsList::Construct()
00334 {
00335 #ifdef G4VERBOSE  
00336   if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl;  
00337 #endif
00338 
00339   InitializeProcessManager();
00340 
00341 #ifdef G4VERBOSE  
00342   if (verboseLevel >1) G4cout << "Construct processes " << G4endl;  
00343 #endif
00344   ConstructProcess();
00345 
00346 }
00347 
00348 inline G4double G4VUserPhysicsList::GetDefaultCutValue() const
00349 {
00350   return defaultCutValue;
00351 }
00352 
00353 
00354 inline  G4int G4VUserPhysicsList::GetVerboseLevel() const
00355 {
00356   return  verboseLevel;
00357 }
00358 
00359 inline  
00360  G4bool  G4VUserPhysicsList::IsPhysicsTableRetrieved() const
00361 {
00362   return fRetrievePhysicsTable;  
00363 }
00364 
00365 inline  
00366  G4bool  G4VUserPhysicsList::IsStoredInAscii() const
00367 {
00368   return fStoredInAscii;
00369 }
00370 
00371 inline 
00372   const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const
00373 {
00374   return directoryPhysicsTable;  
00375 }
00376 
00377 inline 
00378  void  G4VUserPhysicsList::SetStoredInAscii()
00379 {
00380   fStoredInAscii = true;
00381 }
00382     
00383     
00384 inline 
00385  void  G4VUserPhysicsList::ResetPhysicsTableRetrieved()
00386 {
00387   fRetrievePhysicsTable = false;
00388   fIsRestoredCutValues = false;
00389   fIsCheckedForRetrievePhysicsTable=false;
00390 }
00391 
00392 
00393 inline 
00394  void  G4VUserPhysicsList::ResetStoredInAscii()
00395 {
00396   fStoredInAscii = false;
00397 }
00398 
00399 inline
00400  void G4VUserPhysicsList::DisableCheckParticleList()
00401 {
00402   fDisableCheckParticleList = true;
00403 }
00404 
00405 #endif
00406 

Generated on Mon May 27 17:50:23 2013 for Geant4 by  doxygen 1.4.7