Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:13

0001 #ifndef SimG4Core_CustomUIsessionToFile_H
0002 #define SimG4Core_CustomUIsessionToFile_H
0003 
0004 #include "SimG4Core/Geometry/interface/CustomUIsession.h"
0005 
0006 #include <fstream>
0007 
0008 /**
0009  * This class is intended for debugging of multithreaded simulation
0010  * when the amount of output is moderate to large. Output of Geant4 in
0011  * each thread is forwarded to a thread-specific file. Compared to
0012  * using MessageLogger, this way the synchronization is avoided.
0013  * Thread safety is ensured by
0014  * - each thread gets its own file name
0015  * - each thread gets its own std::ofstream object (as
0016  *   RunManagerMTWorker creates a CustomUIsessionToFile object
0017  *   separately for each thread).
0018  */
0019 class CustomUIsessionToFile : public CustomUIsession {
0020 public:
0021   CustomUIsessionToFile(const std::string& filePrefix, int threadId);
0022   ~CustomUIsessionToFile() override;
0023 
0024   G4int ReceiveG4cout(const G4String& coutString) override;
0025   G4int ReceiveG4cerr(const G4String& cerrString) override;
0026 
0027 private:
0028   std::ofstream m_output;
0029 };
0030 
0031 #endif