Skip to content

Commit

Permalink
Fix a few egs++ compiler warnings and coding style
Browse files Browse the repository at this point in the history
Initialize variables and remove unused ones, to suppress egs++ compiler
warnings; adjust code style of c++ tutor applications with astyle. This
is just for tidiness and doesn't affect behaviour.
  • Loading branch information
rtownson authored and ftessier committed Dec 2, 2019
1 parent 3bbd658 commit ebffbdb
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ void EGS_PhspScoring::openPhspFile() const {
}
}
else if (oformat == 1) { //IAEA format
int rwmode;
int iaea_iostat;
iaea_id = 1; //numerical index indicating this is the 1st file associated with this object scored
//hard coded to 1
Expand Down Expand Up @@ -525,7 +524,7 @@ extern "C" {
int stype = 0; //default is to use scoring geom
int phspouttype;
int ptype;
int sdir;
int sdir=0;
int imuscore = 0;
float xyzconst[3];
bool xyzisconst[3] = {false, false, false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,7 @@ class EGS_PHSP_SCORING_EXPORT EGS_PhspScoring : public EGS_AusgabObject {
wt = p.w >= 0 ? p.wt : -p.wt;
};
};
mutable fstream phsp_file; //output file -- mutable so we can write to it during storeState
EGS_I64 count; //total no. of particles in file
EGS_I64 countg; //no. of photons in file
float emax; //max. k.e. of particles in phsp file
float emin; //min. k.e. of charged particles in file

bool score_mc; //set to true to score multiple crossers and their descendents

//variables specific to IAEA format
Expand All @@ -514,8 +510,13 @@ class EGS_PHSP_SCORING_EXPORT EGS_PhspScoring : public EGS_AusgabObject {
return (1 << 31);
}

int store_max; //max. no. of particles to store in p_stack
mutable int phsp_index; //index in p_stack array -- mutable so we can change it in storeState
int store_max; //max. no. of particles to store in p_stack
mutable fstream phsp_file; //output file -- mutable so we can write to it during storeState
EGS_I64 count; //total no. of particles in file
EGS_I64 countg; //no. of photons in file
float emin; //min. k.e. of charged particles in file
float emax; //max. k.e. of particles in phsp file
mutable bool first_flush; //first time writing to file in this run -- mutable so we can change it in storeState

bool is_restart; //true if this is a restart
Expand Down
23 changes: 16 additions & 7 deletions HEN_HOUSE/user_codes/tutor2pp/tutor2pp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ class APP_EXPORT Tutor2_Application : public EGS_SimpleApplication {
It is a good coding practice to deallocate memory when objects
go out of scope. That's what we do in the destructor of our application.
*/
~Tutor2_Application() { delete edep; };
~Tutor2_Application() {
delete edep;
};

/*! \brief Scoring.
Expand All @@ -101,9 +103,10 @@ class APP_EXPORT Tutor2_Application : public EGS_SimpleApplication {
(\em i.e., it goes from 1 to np)
*/
int ausgab(int iarg) {
if( iarg <= 4 ) {
if (iarg <= 4) {
//! Get the stack pointer and currect particle region index.
int np = the_stack->np - 1; int ir = the_stack->ir[np]-1;
int np = the_stack->np - 1;
int ir = the_stack->ir[np]-1;
/*! Per definition region index=0 corresponds to the outside,
regions 1...nreg to the nreg regions inside the geometry.
If the particle is outside, we say that it is 'reflected'
Expand All @@ -113,11 +116,15 @@ class APP_EXPORT Tutor2_Application : public EGS_SimpleApplication {
the particle is 'transmitted' and use region nreg+1 to score
its energy.
*/
if( ir == 0 && the_stack->w[np] > 0 ) ir = nreg+1;
if (ir == 0 && the_stack->w[np] > 0) {
ir = nreg+1;
}
/*! Now simply use the score method of the EGS_ScoringArray class
to record the energy deposited. */
edep->score(ir,the_epcont->edep*the_stack->wt[np]);
}

return 0;
};

/*! \brief Statistics
Expand All @@ -134,7 +141,9 @@ class APP_EXPORT Tutor2_Application : public EGS_SimpleApplication {
This is sufficient to get a history-by-history statistical analysis
for the deposited energy fractions.
*/
void startHistory(EGS_I64 icase) { edep->setHistory(icase); };
void startHistory(EGS_I64 icase) {
edep->setHistory(icase);
};


/*! Output of results.
Expand All @@ -158,8 +167,8 @@ class APP_EXPORT Tutor2_Application : public EGS_SimpleApplication {
double norm = ((double)last_case)/Etot;
egsInformation(" last case = %d Etot = %g\n",(int)last_case,Etot);
edep->reportResults(norm,
"Reflected/deposited/transmitted energy fraction",false,
" %d %9.5f +/- %9.5f %c\n");
"Reflected/deposited/transmitted energy fraction",false,
" %d %9.5f +/- %9.5f %c\n");
};

};
Expand Down
Loading

0 comments on commit ebffbdb

Please sign in to comment.