91 trsp->write((
char *) &time_index,
sizeof(EGS_Float));
183 m_trspFile->seekp(
sizeof(head_inctime) +
sizeof(
bool));
194 return (
m_buffer[tr]->getVertex(v));
215 const char *func_name =
"EGS_ParticleTrackContainer::readDataFile()";
216 ifstream *data =
new ifstream(filename, ios::binary);
217 if (!data || data->fail() || !data->good()) {
218 egsWarning(
"%s: Unable to open track space file '%s'! No tracks loaded\n",
219 func_name, filename);
224 data->seekg(
sizeof(head_inctime));
226 data->read((
char *)&incltime,
sizeof(
bool));
231 egsInformation(
"%s: Time indices are included in the data.\n", func_name);
234 egsInformation(
"%s: Time indices are not included in the data.\n", func_name);
238 int totalVertices = 0;
250 data->read((
char *)&nvertices,
sizeof(
int));
251 totalVertices += nvertices;
258 data->read((
char *)&time,
sizeof(EGS_Float));
260 for (
int j = 0; j < nvertices; j++) {
267 egsInformation(
"%s: Total Vertices : %d\n", func_name, totalVertices);
299 egsWarning(
" *** There are particles still being tracked. This"
300 " should never happen if this is the end of the simulation!");
310 void EGS_ParticleTrackContainer::tracksFileSort() {
317 const char *func_name =
"EGS_ParticleTrackContainer::tracksFileSort()";
319 ifstream *data =
new ifstream(trackfile, ios::binary);
325 string outstring = rawname+
"-sorted.ptracks";
326 const char *outname = outstring.c_str();
327 ofstream *sortout =
new ofstream(outname, ios::binary);
330 data->seekg(
sizeof(head_inctime));
332 data->read((
char *)&incltime,
sizeof(
bool));
334 int position = data->tellg();
337 egsWarning(
"%s: Warning: Attempted to sort ptracks file that does not contain time index.\n", func_name);
344 data->read((
char *)&totalTrackNum,
sizeof(
int));
345 egsInformation(
"%s: Sorting %d tracks from '%s' by time index ...\n", func_name, totalTrackNum, trackfile);
348 sortout->write(head_inctime,
sizeof(head_inctime));
349 sortout->write((
char *)&incltime,
sizeof(
bool));
351 sortout->write((
char *)&totalTrackNum,
sizeof(
int));
354 vector<pair<EGS_Float, int>> vect;
360 int position = data->tellg();
363 data->read((
char *)&nvertices,
sizeof(
int));
365 data->read((
char *)&time,
sizeof(EGS_Float));
366 vect.push_back(make_pair(time, position));
371 data->seekg(vertsize, ios_base::cur);
376 sort(vect.begin(), vect.end());
384 data->seekg(vect[i].second);
387 data->read((
char *)&nvertices,
sizeof(
int));
389 data->read((
char *)&time,
sizeof(EGS_Float));
392 sortout->write((
char *)&nvertices,
sizeof(
int));
394 sortout->write((
char *)&time,
sizeof(EGS_Float));
396 for (
int j = 0; j < nvertices; j++) {
407 int removal = remove(trackfile);
409 egsWarning(
"\nWarning: Failed to remove %s. Error code %d.\n", trackfile, errno);
410 egsWarning(
"Note that the sorted ptracks file will be left as a separate file, because your system seems to block file deletion: %s\n\n", outstring.c_str());
413 int renaming = rename(outname, trackfile);
415 egsWarning(
"Warning: Failed to rename %s to %s. Error code %d.\n", outname, trackfile, errno);
EGS_ParticleTrack::Vertex * getTrackVertex(int tr, int v)
Get the v vertex from the tr track.
string m_trspFilename
filename of output file
EGS_ParticleTrack ** m_buffer
the tracks array
void startNewTrack()
Start scoring a new track.
int m_nEvents
number of events scored
void reportResults(bool with_header=true)
Report results from the track scoring process so far.
int m_nTracks
number of tracks currently in memory
void updateHeader()
Update the output file's header.
int m_totalTracks
total number of tracks registered
int readDataFile(const char *filename)
Load particle data from the file called filename .
int m_bufferSize
max number of tracks in memory
ofstream * m_trspFile
the file to which data is output
void flushBuffer()
Write all track data to the file.
void addVertex(EGS_ParticleTrack::Vertex *x)
Add a vertex to the track currently being scorred.
A class representing a single track of a particle.
Vertex ** m_track
the array with the vertices
Vertex * getVertex(int v)
Gets vertex number v .
int m_nVertices
current number of vertices in track
void setParticleInfo(ParticleInfo *p)
Define the type of the particle being tracked.
void addVertex(Vertex *x)
Add additional point of interaction (Vertex) to the track.
void grow()
Resize the array containing the vertices.
int writeTrack(ofstream *trsp, bool incltime)
Write this track to a "track space" file.
void clearTrack()
Deallocate particle information and vertex data.
ParticleInfo * m_pInfo
type of the tracked particle
int m_size
current size of the vertex array
EGS_ParticleTrack class header file.
EGS_InfoFunction EGS_EXPORT egsInformation
Always use this function for reporting the progress of a simulation and any other type of information...
EGS_InfoFunction EGS_EXPORT egsWarning
Always use this function for reporting warnings.
Structure describing the particle being tracked.
Structure to store the data for each interaction along the track.