Skip to content

Commit 319f4e4

Browse files
sawenzelnoferini
authored andcommitted
MCTrack: Calculate energy in double
in previous version, intermediate steps happened in float with a precision loss on the global result. Fixes another instance of the problem discussed here: https://its.cern.ch/jira/browse/ALIROOT-8233
1 parent e5a5e16 commit 319f4e4

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • DataFormats/simulation/include/SimulationDataFormat

DataFormats/simulation/include/SimulationDataFormat/MCTrack.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,10 @@ template <typename T>
298298
inline Double_t MCTrackT<T>::GetEnergy() const
299299
{
300300
const auto mass = GetMass();
301-
return std::sqrt(mass * mass + mStartVertexMomentumX * mStartVertexMomentumX +
302-
mStartVertexMomentumY * mStartVertexMomentumY + mStartVertexMomentumZ * mStartVertexMomentumZ);
301+
Double_t px = mStartVertexMomentumX;
302+
Double_t py = mStartVertexMomentumY;
303+
Double_t pz = mStartVertexMomentumZ;
304+
return std::sqrt(mass * mass + px * px + py * py + pz * pz);
303305
}
304306

305307
template <typename T>

0 commit comments

Comments
 (0)