Message: problem with output dates to a file in exampleN03 Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None problem with output dates to a file in exampleN03 

Keywords: exampleN03
Forum: Installation and Configuration
Date: 18 Dec, 2007
From: Paul <Paul>

Hi. I have a problem with example 3. I need to save my measure results to a file. I have created a file "MySession.hh" and I have implemented like in exampleN03.cc. Unfortinately, I uses "simulation.mac" and what is more, it runs after the program has finished with CYGWIN console. How do you save your results to a file? What should I change in order to use simulation.mac?

File MySession.hh

#include "G4UIsession.hh"
#include "fstream"
#include "iostream"

using namespace std;

#ifndef MySession_H
#define MySession_H 1

 class MySession : public G4UIsession
 {
 public:
 ofstream logFile, logFile1;
   G4int ReceiveG4cout(G4String coutString);
 G4int ReceiveG4cerr(G4String cerrString);
  MySession()
 {
 logFile.open("results", ios::app);
 logFile1.open("errors", ios::app);
 }
 ~MySession()
 {
	logFile.close();
	logFile1.close();
 }

 };

 G4int MySession::ReceiveG4cout(G4String coutString)
 {
 logFile << coutString << flush;
 return 0;
 }

 G4int MySession::ReceiveG4cerr(G4String cerrString)
{
  logFile1 << cerrString << flush;
  return 0;
 }
#endif

In file exampleN03.cc I have [...] // Opening session for writing data to output file MySession * LoggedSession = new MySession; UI->SetCoutDestination(LoggedSession);

// commends to set output data UI->ApplyCommand("/run/verbose 0"); UI->ApplyCommand("/event/verbose 0"); UI->ApplyCommand("/tracking/verbose 0");

// starting a run
UI->ApplyCommand("/control/execute simulation.mac");
 LoggedSession->SessionStart();
delete LoggedSession;
[...]
Thank you for help
Paul

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 None: Re: problem with output dates to a file in exampleN03   (michel maire - 18 Dec, 2007)
3 None: Re: problem with output dates to a file in exampleN03   (John Allison - 18 Dec, 2007)
 Add Message Add Message
to: "problem with output dates to a file in exampleN03"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]