ROOT to GDML format

Hello experts,

Help me please.

I use ROOT->GDML convertor for our geant4 simulation program.
My question is how to change format of output number of convered gdml file.

The line of root geometry:

TGeoMaterial *mat11 = new TGeoMaterial(“VACUUM”,1.008,1,1.0e-25);

is converted (by default) to gdml line:

</material>
<material name="VACUUM" Z="1.0">
  <D unit="g/cm3" value="0.000000"/>
  <atom unit="g/mole" value="1.008000"/>
</material>

Initial number 1.0e-25 is converted to 0.000000.

How I can change the output format of numbers of GDML file to scientific notation with determened precision?

With best wishes,
Vladimir Baranov.

I found the reason of this wrong conversion.

Source root files:

root_v5.34.19/geom/gdml/src/TGDMLWrite.cxx and
root_v5.34.19/geom/gdml/src/TGDMLParse.cxx

for converting to gdml format are used commands like that:

fGdmlE->NewAttr(atomN, 0, “unit”, unit);
fGdmlE->NewAttr(atomN, 0, “value”, TString::Format("%f", atom));

%f - Decimal floating point format converts 1.0e-25 to 0.000000.
%f format is the reason of wrong conversion.

I replace %f to %g (or %e ) in root source files
TGDMLWrite.cxx and TGDMLParse.cxx and recompile root.

After conversion with this new root I have the true gdml file:

<material name="VACUUM" Z="1">
  <D unit="g/cm3" value="1e-25"/>
  <atom unit="g/mole" value="1.008"/>
</material>

My be the other users will have ( have or had ) the same problems with
format of converted gdml files.

During my exercises I used %e (scientific notation) too but
%g (use the shortest representation) is better.

Dear Vladimir,
This issue is solved in v5-34-00-patches and master branches, where %f is being replaced by %.12g

Regards,
Andrei

In the “geom/gdml/src/TGDMLParse.cxx”, I find two places where “%.12f” is used.

Hi,
Yes, this gives better precision for some constants.

Best, Andrei

[quote=“agheata”]Dear Vladimir,
This issue is solved in v5-34-00-patches and master branches, where %f is being replaced by %.12g

Regards,
Andrei[/quote]

Dear Andrei,
I test new version of root for conversion to gdml format.
My conversion errors are disappeared.
Thank you, Andrei.
With best wishes,
Vladimir