EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
egs_track_scoring.h
Go to the documentation of this file.
1 /*
2 ###############################################################################
3 #
4 # EGSnrc egs++ particle track scoring object headers
5 # Copyright (C) 2015 National Research Council Canada
6 #
7 # This file is part of EGSnrc.
8 #
9 # EGSnrc is free software: you can redistribute it and/or modify it under
10 # the terms of the GNU Affero General Public License as published by the
11 # Free Software Foundation, either version 3 of the License, or (at your
12 # option) any later version.
13 #
14 # EGSnrc is distributed in the hope that it will be useful, but WITHOUT ANY
15 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
17 # more details.
18 #
19 # You should have received a copy of the GNU Affero General Public License
20 # along with EGSnrc. If not, see <http://www.gnu.org/licenses/>.
21 #
22 ###############################################################################
23 #
24 # Author: Iwan Kawrakow, 2009
25 #
26 # Contributors: Georgi Gerganov
27 #
28 ###############################################################################
29 */
30 
31 
37 #ifndef EGS_TRACK_SCORING_
38 #define EGS_TRACK_SCORING_
39 
40 #include "egs_ausgab_object.h"
41 #include "egs_application.h"
42 #include "egs_particle_track.h"
43 
44 #ifdef WIN32
45 
46  #ifdef BUILD_TRACK_SCORING_DLL
47  #define EGS_TRACK_SCORING_EXPORT __declspec(dllexport)
48  #else
49  #define EGS_TRACK_SCORING_EXPORT __declspec(dllimport)
50  #endif
51  #define EGS_TRACK_SCORING_LOCAL
52 
53 #else
54 
55  #ifdef HAVE_VISIBILITY
56  #define EGS_TRACK_SCORING_EXPORT __attribute__ ((visibility ("default")))
57  #define EGS_TRACK_SCORING_LOCAL __attribute__ ((visibility ("hidden")))
58  #else
59  #define EGS_TRACK_SCORING_EXPORT
60  #define EGS_TRACK_SCORING_LOCAL
61  #endif
62 
63 #endif
64 
94 class EGS_TRACK_SCORING_EXPORT EGS_TrackScoring : public EGS_AusgabObject {
95 
96 public:
97 
98  EGS_TrackScoring(const string &Name="", EGS_ObjectFactory *f = 0);
99 
100  ~EGS_TrackScoring();
101 
103  if (m_score) {
104  if (!m_didScore) {
105  m_didScore = true;
106  ++m_nScore;
107  }
108  int np = app->Np;
109  if (m_pts->isScoringParticle(np)) {
110  if (iarg == EGS_Application::AfterTransport) {
111  m_pts->addVertex(np,new EGS_ParticleTrack::Vertex(app->top_p.x,app->top_p.E));
112  }
113  else if (iarg != EGS_Application::BeforeTransport) {
114  m_pts->stopScoringParticle(np);
115  }
116  }
117  else if (iarg == EGS_Application::BeforeTransport) {
118  int q = app->top_p.q;
119  if ((q == 0 && m_score_photons) ||
120  (q == -1 && m_score_electrons) ||
121  (q == 1 && m_score_positrons)) {
122  m_pts->startNewTrack(np);
123  m_pts->setCurrentParticleInfo(new EGS_ParticleTrack::ParticleInfo(q));
124  m_pts->addVertex(np,new EGS_ParticleTrack::Vertex(app->top_p.x,app->top_p.E));
125  }
126  }
127  }
128  return 0;
129  };
130 
131  bool needsCall(EGS_Application::AusgabCall iarg) const {
132  return true;
133  };
134 
135  void setApplication(EGS_Application *App);
136 
137  void reportResults();
138 
139  void setCurrentCase(EGS_I64 ncase) {
140  if (ncase != m_lastCase) {
141  m_lastCase = ncase;
142  m_didScore = false;
143  }
144  if (ncase < m_start || ncase > m_stop) {
145  m_score = false;
146  }
147  else {
148  m_score = true;
149  }
150  };
151 
152  void setScorePhotons(bool score) {
153  m_score_photons = score;
154  };
155  void setScoreElectrons(bool score) {
156  m_score_electrons = score;
157  };
158  void setScorePositrons(bool score) {
159  m_score_positrons = score;
160  };
161  void setFirstEvent(EGS_I64 first) {
162  m_start = first;
163  };
164  void setLastEvent(EGS_I64 last) {
165  m_stop = last;
166  };
167  void setBufferSize(int size) {
168  m_bufSize = size;
169  };
170  void setFileNameExtra(const string &extra) {
171  m_fnExtra = extra;
172  };
173 
174 protected:
175 
177 
178  EGS_I64 m_start;
179  EGS_I64 m_stop;
180  EGS_I64 m_lastCase;
181  EGS_I64 m_nScore;
182 
183  int m_bufSize;
184 
185  bool m_score;
186  bool m_didScore;
187 
191 
192  string m_fnExtra;
193 
194 };
195 
196 #endif
bool m_score_positrons
Score positron tracks?
EGS_AusgabObject interface class header file.
bool m_score_photons
Score photon tracks?
virtual int processEvent(EGS_Application::AusgabCall iarg)=0
Process an ausgab call for event iarg.
bool m_didScore
Did the last event score tracks?
EGS_I64 m_lastCase
The event set via setCurrentCase()
AusgabCall
Possible calls to the user scoring function ausgab().
EGS_I64 m_start
Minimum event index for which to score tracks.
EGS_ParticleTrack class header file.
bool m_score
Should tracks be scored?
virtual bool needsCall(EGS_Application::AusgabCall iarg) const
Is the ausgab call iarg relevant for this object?
string m_fnExtra
String to append to output file name.
EGS_I64 m_nScore
Number of events for which tracks were scored.
virtual void reportResults()
Report results.
Structure describing the particle being tracked.
Structure to store the data for each interaction along the track.
An object factory.
A class that stores all the tracks in a simulation.
EGS_I64 m_stop
Maximum event index for which to score tracks.
A track scoring object: header.
int m_bufSize
The track container size.
virtual void setCurrentCase(EGS_I64 ncase)
Set the current event.
virtual void setApplication(EGS_Application *App)
Set the application this object belongs to.
EGS_Application class header file.
Base class for advanced EGSnrc C++ applications.
bool m_score_electrons
Score electron tracks?