Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Gaudi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gaudi
Gaudi
Commits
cfba0cea
Commit
cfba0cea
authored
1 year ago
by
Sebastien Ponce
Browse files
Options
Downloads
Patches
Plain Diff
Fixed float comparisons in ParticlePropertySvc.cpp
parent
4ab43e5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1490
Fixed unsafe floating point comparisons
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
GaudiPartProp/src/ParticlePropertySvc.cpp
+15
-29
15 additions, 29 deletions
GaudiPartProp/src/ParticlePropertySvc.cpp
with
15 additions
and
29 deletions
GaudiPartProp/src/ParticlePropertySvc.cpp
+
15
−
29
View file @
cfba0cea
...
@@ -8,33 +8,29 @@
...
@@ -8,33 +8,29 @@
* granted to it by virtue of its status as an Intergovernmental Organization *
* granted to it by virtue of its status as an Intergovernmental Organization *
* or submit itself to any jurisdiction. *
* or submit itself to any jurisdiction. *
\***********************************************************************************/
\***********************************************************************************/
// ============================================================================
// Include files
// ============================================================================
// STD&STL
// ============================================================================
#include
"boost/algorithm/string/classification.hpp"
#include
"boost/algorithm/string/classification.hpp"
#include
"boost/algorithm/string/split.hpp"
#include
"boost/algorithm/string/split.hpp"
#include
"boost/algorithm/string/trim.hpp"
#include
"boost/algorithm/string/trim.hpp"
#include
<cctype>
#include
<cctype>
#include
<fstream>
#include
<fstream>
namespace
ba
=
boost
::
algorithm
;
namespace
ba
=
boost
::
algorithm
;
// ============================================================================
// GaudiKernel
// ============================================================================
#include
"GaudiKernel/IFileAccess.h"
#include
"GaudiKernel/IFileAccess.h"
#include
"GaudiKernel/ISvcLocator.h"
#include
"GaudiKernel/ISvcLocator.h"
#include
"GaudiKernel/MsgStream.h"
#include
"GaudiKernel/MsgStream.h"
#include
"GaudiKernel/ParticleProperty.h"
#include
"GaudiKernel/ParticleProperty.h"
#include
"GaudiKernel/PhysicalConstants.h"
#include
"GaudiKernel/PhysicalConstants.h"
#include
"GaudiKernel/System.h"
#include
"GaudiKernel/System.h"
// ============================================================================
// #include "GaudiKernel/ToStream.h"
// ============================================================================
// Local
// ============================================================================
#include
"ParticlePropertySvc.h"
#include
"ParticlePropertySvc.h"
// ============================================================================
namespace
{
// idea coming from The art of computer programming by Knuth
constexpr
bool
essentiallyEqual
(
double
const
a
,
double
const
b
)
{
return
std
::
abs
(
a
-
b
)
<=
std
::
min
(
std
::
abs
(
a
),
std
::
abs
(
b
)
)
*
std
::
numeric_limits
<
double
>::
epsilon
();
}
}
// namespace
namespace
Gaudi
{
namespace
Gaudi
{
/** Instantiation of a static factory class used by clients to create
/** Instantiation of a static factory class used by clients to create
* instances of this service
* instances of this service
...
@@ -370,13 +366,7 @@ namespace Gaudi {
...
@@ -370,13 +366,7 @@ namespace Gaudi {
//
//
return
StatusCode
::
SUCCESS
;
return
StatusCode
::
SUCCESS
;
}
}
// ============================================================================
// ============================================================================
#ifdef __ICC
// disable icc remark #1572: floating-point equality and inequality comparisons are unreliable
// The comparison are meant
# pragma warning( push )
# pragma warning( disable : 1572 )
#endif
bool
ParticlePropertySvc
::
diff
(
const
ParticleProperty
*
o
,
const
ParticleProperty
*
n
,
const
MSG
::
Level
l
)
const
{
bool
ParticlePropertySvc
::
diff
(
const
ParticleProperty
*
o
,
const
ParticleProperty
*
n
,
const
MSG
::
Level
l
)
const
{
//
//
if
(
o
==
n
)
{
return
false
;
}
if
(
o
==
n
)
{
return
false
;
}
...
@@ -405,15 +395,15 @@ namespace Gaudi {
...
@@ -405,15 +395,15 @@ namespace Gaudi {
result
=
true
;
result
=
true
;
log
<<
" PYID:"
<<
o
->
pythiaID
()
<<
"/"
<<
n
->
pythiaID
()
<<
"'"
;
log
<<
" PYID:"
<<
o
->
pythiaID
()
<<
"/"
<<
n
->
pythiaID
()
<<
"'"
;
}
}
if
(
o
->
charge
()
!=
n
->
charge
()
)
{
if
(
essentiallyEqual
(
o
->
charge
()
,
n
->
charge
()
)
)
{
result
=
true
;
result
=
true
;
log
<<
" Q:"
<<
o
->
charge
()
<<
"/"
<<
n
->
charge
()
<<
"'"
;
log
<<
" Q:"
<<
o
->
charge
()
<<
"/"
<<
n
->
charge
()
<<
"'"
;
}
}
if
(
o
->
mass
()
!=
n
->
mass
()
)
{
if
(
essentiallyEqual
(
o
->
mass
()
,
n
->
mass
()
)
)
{
result
=
true
;
result
=
true
;
log
<<
" M:"
<<
o
->
mass
()
<<
"/"
<<
n
->
mass
()
<<
"'"
;
log
<<
" M:"
<<
o
->
mass
()
<<
"/"
<<
n
->
mass
()
<<
"'"
;
}
}
if
(
o
->
lifetime
()
!=
n
->
lifetime
()
)
{
if
(
essentiallyEqual
(
o
->
lifetime
()
,
n
->
lifetime
()
)
)
{
result
=
true
;
result
=
true
;
log
<<
" T:"
<<
o
->
lifetime
()
<<
"/"
<<
n
->
lifetime
()
<<
"'"
;
log
<<
" T:"
<<
o
->
lifetime
()
<<
"/"
<<
n
->
lifetime
()
<<
"'"
;
}
}
...
@@ -421,7 +411,7 @@ namespace Gaudi {
...
@@ -421,7 +411,7 @@ namespace Gaudi {
result
=
true
;
result
=
true
;
log
<<
" EvtGen:"
<<
o
->
evtGenName
()
<<
"/"
<<
n
->
evtGenName
()
<<
"'"
;
log
<<
" EvtGen:"
<<
o
->
evtGenName
()
<<
"/"
<<
n
->
evtGenName
()
<<
"'"
;
}
}
if
(
o
->
maxWidth
()
!=
n
->
maxWidth
()
)
{
if
(
essentiallyEqual
(
o
->
maxWidth
()
,
n
->
maxWidth
()
)
)
{
result
=
true
;
result
=
true
;
log
<<
" WMAX:"
<<
o
->
maxWidth
()
<<
"/"
<<
n
->
maxWidth
()
<<
"'"
;
log
<<
" WMAX:"
<<
o
->
maxWidth
()
<<
"/"
<<
n
->
maxWidth
()
<<
"'"
;
}
}
...
@@ -430,10 +420,6 @@ namespace Gaudi {
...
@@ -430,10 +420,6 @@ namespace Gaudi {
return
result
;
return
result
;
}
}
}
// namespace Gaudi
}
// namespace Gaudi
#ifdef __ICC
// re-enable icc remark #1572
# pragma warning( pop )
#endif
// ============================================================================
// ============================================================================
// The END
// The END
// ============================================================================
// ============================================================================
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment