LDMX Software
G4Session.h
Go to the documentation of this file.
1
7#ifndef SIMCORE_G4SESSION_H_
8#define SIMCORE_G4SESSION_H_
9
10#include <fstream>
11#include <iostream>
12
13// Geant4
14#include "G4UIsession.hh"
15
16namespace simcore {
17
23class LoggedSession : public G4UIsession {
24 public:
30 LoggedSession(const std::string& coutFileName = "G4cout.log",
31 const std::string& cerrFileName = "G4cerr.log");
32
39
45 G4UIsession* SessionStart() { return nullptr; }
46
50 G4int ReceiveG4cout(const G4String& message);
51
55 G4int ReceiveG4cerr(const G4String& message);
56
57 private:
59 std::ofstream coutFile_;
60
62 std::ofstream cerrFile_;
63
64}; // LoggedSession
65
72class BatchSession : public G4UIsession {
73 public:
78
83
89 G4UIsession* SessionStart() { return nullptr; }
90
94 G4int ReceiveG4cout(const G4String&) { return 0; }
95
99 G4int ReceiveG4cerr(const G4String&) { return 0; }
100};
101
102} // namespace simcore
103
104#endif
Do nothing with G4cout and G4cerr messages.
Definition G4Session.h:72
G4int ReceiveG4cout(const G4String &)
Does nothing with input.
Definition G4Session.h:94
G4UIsession * SessionStart()
Required hook for Geant4.
Definition G4Session.h:89
~BatchSession()
Destructor.
Definition G4Session.h:82
BatchSession()
Constructor.
Definition G4Session.h:77
G4int ReceiveG4cerr(const G4String &)
Does nothing with input.
Definition G4Session.h:99
Log the output of Geant4 to files in current directory.
Definition G4Session.h:23
std::ofstream cerrFile_
cerr log file
Definition G4Session.h:62
~LoggedSession()
Destructor.
Definition G4Session.cxx:28
G4UIsession * SessionStart()
Required hook for Geant4.
Definition G4Session.h:45
G4int ReceiveG4cerr(const G4String &message)
Redirects cerr to file.
Definition G4Session.cxx:39
std::ofstream coutFile_
cout log file
Definition G4Session.h:59
G4int ReceiveG4cout(const G4String &message)
Redirects cout to file.
Definition G4Session.cxx:33