G4RunManagerKernel.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 // class description:
00032 //
00033 //     This is a class for mandatory control of GEANT4 kernel. 
00034 //     
00035 //     This class is constructed by G4RunManager. If a user uses his/her own
00036 //     class instead of G4RunManager, this class must be instantiated by
00037 //     him/herself at the very beginning of the application and must be deleted
00038 //     at the very end of the application. Also, following methods must be
00039 //     invoked in the proper order.
00040 //       DefineWorldVolume
00041 //       InitializePhysics
00042 //       RunInitialization
00043 //       RunTermination
00044 // 
00045 //     User must provide his/her own classes derived from the following
00046 //     abstract class and register it to the RunManagerKernel. 
00047 //        G4VUserPhysicsList - Particle types, Processes and Cuts
00048 // 
00049 //     G4RunManagerKernel does not have any eveny loop. Handling of events
00050 //     is managed by G4RunManager.
00051 //
00052 
00053 #ifndef G4RunManagerKernel_h
00054 #define G4RunManagerKernel_h 1
00055 
00056 class G4VUserPhysicsList;
00057 
00058 class G4VPhysicalVolume;
00059 class G4Region;
00060 class G4ExceptionHandler;
00061 class G4StackManager;
00062 class G4TrackingManager;
00063 class G4PrimaryTransformer;
00064 
00065 #include "globals.hh"
00066 #include "G4EventManager.hh"
00067 
00068 class G4RunManagerKernel
00069 {
00070   public: // with description
00071     static G4RunManagerKernel* GetRunManagerKernel();
00072     //  Static method which returns the singleton pointer of G4RunManagerKernel or
00073     // its derived class.
00074 
00075   private:
00076     static G4RunManagerKernel* fRunManagerKernel;
00077 
00078   public: // with description
00079     G4RunManagerKernel();
00080     virtual ~G4RunManagerKernel();
00081     //  The constructor and the destructor. The user must construct this class
00082     // object at the beginning of his/her main() and must delete it at the 
00083     // bottom of the main(), unless he/she used G4RunManager.
00084 
00085   public: // with description
00086     void DefineWorldVolume(G4VPhysicalVolume * worldVol,
00087                            G4bool topologyIsChanged=true);
00088     //  This method must be invoked if the geometry setup has been changed between
00089     // runs. The flag 'topologyIsChanged' will specify if the geometry topology is
00090     // different from the original one used in the previous run; if not, it must be
00091     // set to false, so that the original optimisation and navigation history is
00092     // preserved. This method is invoked also at initialisation.
00093 
00094     void SetPhysics(G4VUserPhysicsList* uPhys);
00095     //  This method must be invoked at least once by the user with a valid
00096     // concrete implementation of user physics list. 
00097 
00098     void InitializePhysics();
00099     //  This method must be invoked at least once by the user to build physics
00100     // processes.
00101 
00102     G4bool RunInitialization();
00103     //  Trigger geometry closing and physics table constructions.
00104     // It returns TRUE if all procedures went well.
00105 
00106     void RunTermination();
00107     //  Set the application state to G4State_Idle so that the user can modify
00108     // physics/geometry.
00109 
00110   private:
00111     void ResetNavigator();
00112     void BuildPhysicsTables();
00113     void CheckRegions();
00114 
00115   public: // with description
00116     void UpdateRegion();
00117     // Update region list. 
00118     // This method is mandatory before invoking following two dump methods.
00119     // At RunInitialization(), this method is automatically invoked, and thus
00120     // the user needs not invoke.
00121 
00122     void DumpRegion(const G4String& rname) const;
00123     // Dump information of a region.
00124 
00125     void DumpRegion(G4Region* region=0) const;
00126     // Dump information of a region.
00127     // If the pointer is NULL, all regions are shown.
00128 
00129   private:
00130     G4VUserPhysicsList * physicsList;
00131     G4VPhysicalVolume* currentWorld;
00132     G4bool geometryInitialized;
00133     G4bool physicsInitialized;
00134     G4bool geometryNeedsToBeClosed;
00135     G4bool geometryToBeOptimized;
00136     G4bool physicsNeedsToBeReBuilt;
00137     G4int verboseLevel;
00138     G4int numberOfParallelWorld;
00139 
00140     G4EventManager * eventManager;
00141     G4ExceptionHandler* defaultExceptionHandler;
00142     G4Region* defaultRegion;
00143     G4Region* defaultRegionForParallelWorld;
00144     G4String versionString;
00145 
00146   public: // with description
00147     inline void GeometryHasBeenModified()
00148     { geometryNeedsToBeClosed = true; }
00149     //  This method must be invoked (or equivalent UI commands can be used)
00150     // in case the user changes his/her detector geometry.
00151     // This method is automatically invoked from DefineWorldVolume() method.
00152 
00153     inline void PhysicsHasBeenModified()
00154     { physicsNeedsToBeReBuilt = true; }
00155     //  This method must be invoked in case the user changes his/her physics
00156     // process(es), e.g. (in)activate some processes. Once this method is
00157     // invoked, regardless of cuts are changed or not, BuildPhysicsTable()
00158     // of PhysicsList is invoked for refreshing all physics tables.
00159 
00160   public:
00161     inline G4EventManager* GetEventManager() const
00162     { return eventManager; }
00163     inline G4StackManager* GetStackManager() const
00164     { return eventManager->GetStackManager(); }
00165     inline G4TrackingManager* GetTrackingManager() const
00166     { return eventManager->GetTrackingManager(); }
00167     inline void SetPrimaryTransformer(G4PrimaryTransformer* pt)
00168     { eventManager->SetPrimaryTransformer(pt); }
00169     inline G4PrimaryTransformer* GetPrimaryTransformer() const
00170     { return eventManager->GetPrimaryTransformer(); }
00171 
00172     inline const G4String& GetVersionString() const
00173     { return versionString; }
00174 
00175     inline void SetVerboseLevel(G4int vl)
00176     { verboseLevel = vl; }
00177 
00178     inline void SetGeometryToBeOptimized(G4bool vl)
00179     { 
00180       if(geometryToBeOptimized != vl)
00181       {
00182         geometryToBeOptimized = vl;
00183         geometryNeedsToBeClosed = true;
00184       }
00185     }
00186 
00187     inline G4int GetNumberOfParallelWorld() const
00188     { return numberOfParallelWorld; }
00189     inline void SetNumberOfParallelWorld(G4int i)
00190     { numberOfParallelWorld = i; }
00191 
00192   private:
00193     void CheckRegularGeometry();
00194     G4bool ConfirmCoupledTransportation();
00195     void SetScoreSplitter();
00196 };
00197 
00198 #endif
00199 

Generated on Mon May 27 17:49:47 2013 for Geant4 by  doxygen 1.4.7