Message: How to output position of primaries to .txt file at each step Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question How to output position of primaries to .txt file at each step 

Forum: Analysis
Date: 02 Aug, 2010
From: Nathan <Nathan>

I have in my stepping verbose file

std::ofstream out( "textfile.txt");
out << std::setw(5) << fTrack->GetCurrentStepNumber() << " "
		<< std::setw(6) << G4BestUnit(fTrack->GetPosition().x(),"Length")
		<< std::setw(6) << G4BestUnit(fTrack->GetPosition().y(),"Length")
		<< std::setw(6) << G4BestUnit(fTrack->GetPosition().z(),"Length")
		<< G4endl ;
out.close();

which outputs the position of the last step for the last tracked particle to a txt file. However I want to do this for every primary particle at every step or at least do it for the final step for every event. If I understand correctly I am just overwriting the same line in the txt file every time a step or event occurs. How can I make it so it doesnt overwrite it but makes a new line in the text file? If someone could help me with this I would appreciate it.

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

1 None: Re: How to output position of primaries to .txt file at each step   (John Allison - 03 Aug, 2010)
(_ Ok: Re: How to output position of primaries to .txt file at each step   (Nathan - 03 Aug, 2010)
 Add Message Add Message
to: "How to output position of primaries to .txt file at each step"

 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 ]