[Rivet] MathUtils median falls over empty vector

Andy Buckley andy.buckley at cern.ch
Wed Jul 20 08:58:40 BST 2016


On 19/07/16 23:10, Holger Schulz wrote:
> Hi,
>
> the Analysis ATLAS_2010_S8914702 calculates the median of a vector<double>
>
> and currently segfaults if the vector is empty.
>
>
> I don't know whether we should explicitly check the size of the vector or
> return 0 in the median function --- not sure if the median of an empty set
> is well defined though.
>
>
> What do you think?

Good spot. Thanks for adding protection to the analysis. If we add 
protection in the median itself, it would need to be either throwing an 
exception or returning a nan. Both of those would also need a check in 
the analysis code.

I'm going to make a few other tweaks to "utils" functions today, which 
tends to require a full rebuild since those headers are included 
everywhere. So I may as well do this at the same time... what approach 
do we prefer?

Andy

-- 
Dr Andy Buckley, Lecturer / Royal Society University Research Fellow
Particle Physics Expt Group, University of Glasgow


More information about the Rivet mailing list