cmssw icon indicating copy to clipboard operation
cmssw copied to clipboard

TauWPThreshold uses exceptions in string parsing

Open makortel opened this issue 3 years ago • 5 comments

The deep_tau::TauWPThreshold constructor uses exceptions string parsing https://github.com/cms-sw/cmssw/blob/bae128ce493657abe49691256ff76a9a63a84c3a/RecoTauTag/RecoTau/src/DeepTauBase.cc#L19-L25

I encountered this exception being thrown many times (don't know how many because I gave up) when trying to catch a different exception, so the parse error does not seem to be as exceptional that exceptions would be justified (see https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideEdmExceptionUse#Exception_Handling, https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Re-throw https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Re-errors)

I'd suggest to parse the string in a way that does not use exceptions to signal an invalid value. E,g, std::from_chars() looks like a good candidate, but GCC (or libstdc++) implements it for floating point numbers only in version 11 (to which we'll hopefully switch to soon). An alternative could be std::strtod (from C) or std::istringstream (expensive).

makortel avatar Oct 05 '22 14:10 makortel

assign reconstruction

makortel avatar Oct 05 '22 14:10 makortel

New categories assigned: reconstruction

@mandrenguyen,@clacaputo you have been requested to review this Pull request/Issue and eventually sign? Thanks

cmsbuild avatar Oct 05 '22 14:10 cmsbuild

A new Issue was created by @makortel Matti Kortelainen.

@Dr15Jones, @perrotta, @dpiparo, @rappoccio, @makortel, @smuzaffar can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

cmsbuild avatar Oct 05 '22 14:10 cmsbuild

type tau

@cms-sw/tau-pog-l2

clacaputo avatar Oct 10 '22 15:10 clacaputo

Since parsing occurs only at the initialisation stage, I think std::istringstream is a best option for now. Once std::from_chars is available - we can switch to it.

kandrosov avatar Oct 11 '22 07:10 kandrosov