CMS 3D CMS Logo

CustomUIsession.cc
Go to the documentation of this file.
2 
4  G4UImanager* UI = G4UImanager::GetUIpointer();
5  UI->SetCoutDestination(this);
6 }
7 
9  G4UImanager* UI = G4UImanager::GetUIpointer();
10  UI->SetCoutDestination(nullptr);
11 }
12 
13 G4int CustomUIsession::ReceiveG4cout(const G4String& coutString) {
14  //std::cout << coutString << std::flush;
15  if (fout) {
16  (*fout) << trim(coutString) << "\n";
17  } else {
18  edm::LogVerbatim("G4cout") << trim(coutString);
19  }
20  return 0;
21 }
22 
23 G4int CustomUIsession::ReceiveG4cerr(const G4String& cerrString) {
24  //std::cerr << cerrString << std::flush;
25  edm::LogWarning("G4cerr") << trim(cerrString);
26  return 0;
27 }
28 
30  if (!str.empty() && str.back() == '\n')
31  return str.substr(0, str.length() - 1);
32  return str;
33 }
34 
35 void CustomUIsession::sendToFile(std::ofstream* ptr) {
36  if (ptr && !ptr->fail()) {
37  fout = ptr;
38  }
39 }
CustomUIsession::ReceiveG4cout
G4int ReceiveG4cout(const G4String &coutString) override
Definition: CustomUIsession.cc:13
CustomUIsession::trim
std::string trim(const std::string &str)
Definition: CustomUIsession.cc:29
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CustomUIsession::CustomUIsession
CustomUIsession()
Definition: CustomUIsession.cc:3
str
#define str(s)
Definition: TestProcessor.cc:53
CustomUIsession.h
CustomUIsession::~CustomUIsession
~CustomUIsession() override
Definition: CustomUIsession.cc:8
groupFilesInBlocks.fout
fout
Definition: groupFilesInBlocks.py:162
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
CustomUIsession::sendToFile
void sendToFile(std::ofstream *)
Definition: CustomUIsession.cc:35
CustomUIsession::ReceiveG4cerr
G4int ReceiveG4cerr(const G4String &cerrString) override
Definition: CustomUIsession.cc:23
CustomUIsession::fout
std::ofstream * fout
Definition: CustomUIsession.h:28