Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:08

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 // Author: Jonathan Madsen (May 28st 2020)
0027 //
0028 // class description:
0029 //
0030 //     This is a class for mandatory control of GEANT4 kernel.
0031 //     This class implements Worker behavior in a MT application.
0032 //
0033 //     This class is constructed by G4TaskRunManager. If a user uses his/her own
0034 //     class instead of G4TaskRunManager, this class must be instantiated by
0035 //     him/herself at the very beginning of the application and must be deleted
0036 //     at the very end of the application. Also, following methods must be
0037 //     invoked in the proper order.
0038 //       DefineWorldVolume
0039 //       InitializePhysics
0040 //       RunInitialization
0041 //       RunTermination
0042 //
0043 //     User must provide his/her own classes derived from the following
0044 //     abstract class and register it to the RunManagerKernel.
0045 //        G4VUserPhysicsList - Particle types, Processes and Cuts
0046 //
0047 //     G4TaskRunManagerKernel does not have any eveny loop. Handling of events
0048 //     is managed by G4RunManager.
0049 //
0050 //     This class re-implements only the method that require special treatment
0051 //     to implement worker behavior
0052 
0053 #ifndef G4TaskRunManagerKernel_hh
0054 #define G4TaskRunManagerKernel_hh 1
0055 
0056 #include "G4RunManagerKernel.hh"
0057 #include "G4TaskRunManager.hh"
0058 #include "G4Threading.hh"
0059 
0060 #include "rundefs.hh"
0061 
0062 #include <vector>
0063 
0064 class G4WorkerThread;
0065 class G4WorkerTaskRunManager;
0066 
0067 class G4TaskRunManagerKernel : public G4RunManagerKernel
0068 {
0069   public:
0070     G4TaskRunManagerKernel();
0071     ~G4TaskRunManagerKernel() override = default;
0072 
0073   public:  // with descroption
0074     static G4WorkerThread* GetWorkerThread();
0075     // G4ThreadPool tasks
0076     static void InitializeWorker();
0077     static void ExecuteWorkerInit();
0078     static void ExecuteWorkerTask();
0079     static void TerminateWorkerRunEventLoop();
0080     static void TerminateWorker();
0081     static void TerminateWorkerRunEventLoop(G4WorkerTaskRunManager*);
0082     static void TerminateWorker(G4WorkerTaskRunManager*);
0083 
0084     static std::vector<G4String>& InitCommandStack();
0085 
0086     // Fill decay tables with particle definition pointers of
0087     // decay products. This method has to be invoked by
0088     // MTRunManager before event loop starts on workers.
0089     void SetUpDecayChannels();
0090 
0091     // This method should be invoked by G4TaskRunManager
0092     void BroadcastAbortRun(G4bool softAbort);
0093 
0094   protected:
0095     void SetupShadowProcess() const override;
0096     G4RUN_DLL static std::vector<G4String> initCmdStack;
0097 };
0098 
0099 #endif  // G4TaskRunManagerKernel_hh