CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
CustomUIsessionToFile Class Reference

#include <CustomUIsessionToFile.h>

Inheritance diagram for CustomUIsessionToFile:
CustomUIsession

Public Member Functions

 CustomUIsessionToFile (const std::string &filePrefix, int threadId)
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
 ~CustomUIsessionToFile ()
 
- Public Member Functions inherited from CustomUIsession
 CustomUIsession ()
 
G4int ReceiveG4cerr (const G4String &cerrString) override
 
G4int ReceiveG4cout (const G4String &coutString) override
 
 ~CustomUIsession ()
 

Private Attributes

std::ofstream m_output
 

Additional Inherited Members

- Protected Member Functions inherited from CustomUIsession
std::string trim (const std::string &str)
 

Detailed Description

This class is intended for debugging of multithreaded simulation when the amount of output is moderate to large. Output of Geant4 in each thread is forwarded to a thread-specific file. Compared to using MessageLogger, this way the synchronization is avoided. Thread safety is ensured by

Definition at line 19 of file CustomUIsessionToFile.h.

Constructor & Destructor Documentation

CustomUIsessionToFile::CustomUIsessionToFile ( const std::string &  filePrefix,
int  threadId 
)

Definition at line 3 of file CustomUIsessionToFile.cc.

3  :
5  m_output(filePrefix+"_"+std::to_string(threadId)+".txt")
6 {}
CustomUIsessionToFile::~CustomUIsessionToFile ( )

Definition at line 8 of file CustomUIsessionToFile.cc.

8 {}

Member Function Documentation

G4int CustomUIsessionToFile::ReceiveG4cerr ( const G4String &  cerrString)
override

Definition at line 16 of file CustomUIsessionToFile.cc.

References m_output.

17 {
18  m_output << cerrString;
19  return 0;
20 }
G4int CustomUIsessionToFile::ReceiveG4cout ( const G4String &  coutString)
override

Definition at line 10 of file CustomUIsessionToFile.cc.

References m_output.

11 {
12  m_output << coutString;
13  return 0;
14 }

Member Data Documentation

std::ofstream CustomUIsessionToFile::m_output
private

Definition at line 31 of file CustomUIsessionToFile.h.

Referenced by ReceiveG4cerr(), and ReceiveG4cout().