Message: Write data in binary file Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Write data in binary file 

Forum: Event and Track Management
Date: 08 Mar, 2017
From: A. Hod <A. Hod>

dear users,

in SteepingAction.cc I want to write the data (e.g. positions and other parameters) of the PostStep point in the output file. I can save these data as ASCII file but the file is huge (500 MB). Therefore, I want to write the data in a binary file.

I think doing so one can reduce the size of the file. How can I do it? Any help will be greatly appreciated! Thanks ...

Here is a part of my SteppingAction.cc which works.

..................

..................

..................

#include"iostream"
#include"fstream"
using namespace std;

ofstream outfile("mydata.dat");

....................

....................

....................

G4ThreeVector direction = track->GetMomentumDirection();

G4double ux1=direction.x();

G4double uy1=direction.y();

G4double uz1=direction.z();

G4double Energy = aStep->GetPostStepPoint()->GetKineticEnergy();

outfile<<(Event_No+1)<<'\t'<<x/nm<<'\t'<<'\t'<<y/nm<<'\t'<<z/nm<<"\t"<<ux/nm<<"\t"<<uy/nm<<"\t"<<uz/nm<<"\t"<< Energy/keV<<G4endl;

} }

Cheers

A.H.

 Add Message Add Message
to: "Write data in binary file"

 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 ]