Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,9 @@ void MCPLGen::init_weight_scale()
return;//not present (e.g. files from older McStas versions): use weights as stored
if ( !(nrays > 0.0) || !std::isfinite(nrays) ) {
if (nrays == -1.0)
printf("MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not"
" available (for instance due to an interrupted run of the application writing the file,"
" or because the file contains only a part of the particles of another file), so the weights"
" can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as"
" stored in the file.\n");
printf("MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which"
" means that the value is not available, so the weights can not be normalised. Set"
" normalise_by_initial_ray_count=false to use the weights as stored in the file.\n");
else
printf("MCPLGen ERROR - The input file has an invalid stat:sum:initial_ray_count value (%g),"
" so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,31 +81,6 @@ namespace ExprParser {
#endif
}

template<class TValue>
inline ExprEntityPtr ExprEntity<TValue>::optimisedVersion()
{
//todo: Can we move this to .cc and make sure implementations don't get copied to clients?
if (isConstant()) {
if (isConstantValue())
return 0;//we are already optimal
return makeobj<ExprEntityConstantValue<TValue>>(evaluate());
}
optimiseChildren();
auto p = specialOptimisedVersion();
if (p) {
for (int i =0; i<100000; ++i) {
_ensure_type<TValue>(p);
if (i==99999)
EXPRPARSER_THROW(LogicError,"non-converging optimisation loop");
ExprEntityPtr p_opt = p->optimisedVersion();
if (!p_opt)
break;
p = p_opt;
}
}
return p;
}

template<class TValue>
inline ExprEntityConstantValue<TValue>::ExprEntityConstantValue(TValue val)
: ExprEntity<TValue>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

namespace ExprParser {

template<class TValue>
ExprEntityPtr ExprEntity<TValue>::optimisedVersion()
{
if (isConstant()) {
if (isConstantValue())
return 0;//we are already optimal
return makeobj<ExprEntityConstantValue<TValue>>(evaluate());
}
optimiseChildren();
auto p = specialOptimisedVersion();
if (p) {
for (int i =0; i<100000; ++i) {
_ensure_type<TValue>(p);
if (i==99999)
EXPRPARSER_THROW(LogicError,"non-converging optimisation loop");
ExprEntityPtr p_opt = p->optimisedVersion();
if (!p_opt)
break;
p = p_opt;
}
}
return p;
}

template class ExprEntity<float_type>;
template class ExprEntity<int_type>;
template class ExprEntity<str_type>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
// sb_g4mcpltests_mkfile FILENAME NPARTICLES WEIGHT INITIAL_RAY_COUNT
//
//A value of "none" for INITIAL_RAY_COUNT means that the file does not get a
//stat:sum:initial_ray_count, while "notfinal" leaves the value at -1 (as when
//the application writing the file was interrupted).
//stat:sum:initial_ray_count, while "notfinal" leaves the value at -1 (i.e. not
//available).

#include "mcpl.h"
#include <cstdio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Output stat:sum:initial_geant4_weights = 10

==> File with initial_ray_count which is not finalised
MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not available (for instance due to an interrupted run of the application writing the file, or because the file contains only a part of the particles of another file), so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file.
MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which means that the value is not available, so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file.
(simulation failed as expected)

==> File with initial_ray_count which is not finalised, not normalised
Expand Down Expand Up @@ -144,5 +144,5 @@
Output stat:sum:initial_ray_count = <unavailable>

==> File where initial_ray_count is unavailable
MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value which is not available (for instance due to an interrupted run of the application writing the file, or because the file contains only a part of the particles of another file), so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file.
MCPLGen ERROR - The input file has a stat:sum:initial_ray_count value of -1, which means that the value is not available, so the weights can not be normalised. Set normalise_by_initial_ray_count=false to use the weights as stored in the file.
(simulation failed as expected)
Loading