This is a problem I noticed when trying to answer this question. Just consider the following toy example:
test = ParametricNDSolveValue[{x'[t] == 1, x[0] == a, WhenEvent[t == 1, Sow@a]},
x, {t, 0, 2}, a];
test@1; // Reap
(* {Null, {{a$224638}}} *)
This behavior becomes annoying when one wants to group the extracted value using the parameter a as a tag i.e. the 2nd argument of Sow.
How to understand this behavior? Is it possible to Sow the parameter value inside WhenEvent? If not, what's the best workaround for it?
test@1is executed, at some point aFunctionis constructed and it appears the argumenta$224638is rewritten in the standard way by adding$; namely the new argument isa$224638$. Thus the value ofafails to be injected intoSow[a$224638]. WRI might consider it a bug, if you report it. – Michael E2 Jan 12 '18 at 15:20