Skip to content

Commit a0e2955

Browse files
authored
[Geom] Fix setting precision for matrix values in TGDMLWrite::CreateMatrixN (#20345)
Fixes #20342 Apply fFltPrecision setting to matrix value exports instead of using default C++ ostream precision (6 digits). Authored-by: Ahmed Bilal <ab459047@gmail.com>
1 parent a710e85 commit a0e2955

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

geom/gdml/src/TGDMLWrite.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ See that function for details.
164164
#include <ctime>
165165
#include <sstream>
166166

167-
168167
TGDMLWrite *TGDMLWrite::fgGDMLWrite = nullptr;
169168

170169
namespace {
@@ -2040,9 +2039,10 @@ XMLNodePointer_t TGDMLWrite::CreateMatrixN(TGDMLMatrix const *matrix)
20402039
XMLNodePointer_t mainN = fGdmlE->NewChild(nullptr, nullptr, "matrix", nullptr);
20412040
fGdmlE->NewAttr(mainN, nullptr, "name", matrix->GetName());
20422041
fGdmlE->NewAttr(mainN, nullptr, "coldim", TString::Format("%zu", cols));
2042+
const TString fltPrecision = TString::Format("%%.%dg", fFltPrecision);
20432043
for (size_t i = 0; i < rows; ++i) {
20442044
for (size_t j = 0; j < cols; ++j) {
2045-
vals << matrix->Get(i, j);
2045+
vals << TString::Format(fltPrecision.Data(), matrix->Get(i, j));
20462046
if (j < cols - 1)
20472047
vals << ' ';
20482048
}

0 commit comments

Comments
 (0)