Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Author: Jonathan Madsen (May 28st 2020)
0028 //
0029 // class description:
0030 //
0031 //  This is a class for run control in GEANT4 for multi-threaded runs
0032 //  It extends G4RunManager re-implementing multi-threaded behavior in
0033 //  key methods. See documentation for G4RunManager. User should never
0034 //  initialize instances of this class, that are usually handled by
0035 //  G4MTRunManager. There exists one instance of this class for each
0036 //  worker in a MT application.
0037 
0038 #ifndef G4WorkerTaskRunManager_h
0039 #define G4WorkerTaskRunManager_h 1
0040 
0041 #include "G4RNGHelper.hh"
0042 #include "G4RunManager.hh"
0043 #include "G4WorkerRunManager.hh"
0044 
0045 class G4WorkerThread;
0046 class G4WorkerTaskRunManagerKernel;
0047 
0048 class G4WorkerTaskRunManager : public G4WorkerRunManager
0049 {
0050   public:
0051     using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
0052     using G4StrVector = std::vector<G4String>;
0053 
0054   public:
0055     static G4WorkerTaskRunManager* GetWorkerRunManager();
0056     static G4WorkerTaskRunManagerKernel* GetWorkerRunManagerKernel();
0057     G4WorkerTaskRunManager() = default;
0058 
0059     // Modified for worker behavior
0060     void RunInitialization() override;
0061     void DoEventLoop(G4int n_event, const char* macroFile = nullptr, G4int n_select = -1) override;
0062     void ProcessOneEvent(G4int i_event) override;
0063     G4Event* GenerateEvent(G4int i_event) override;
0064     void RunTermination() override;
0065     void TerminateEventLoop() override;
0066     void DoWork() override;
0067     void RestoreRndmEachEvent(G4bool flag) override { readStatusFromFile = flag; }
0068 
0069     virtual void DoCleanup();
0070     virtual void ProcessUI();
0071     G4WorkerThread* GetWorkerThread() const { return workerContext; }
0072     G4StrVector GetCommandStack() const { return processedCommandStack; }
0073 
0074   protected:
0075     void StoreRNGStatus(const G4String& filenamePrefix) override;
0076 
0077   private:
0078     void SetupDefaultRNGEngine();
0079 
0080   private:
0081     G4StrVector processedCommandStack;
0082     std::unique_ptr<ProfilerConfig> workerRunProfiler;
0083 };
0084 
0085 #endif  // G4WorkerTaskRunManager_h