Writing simple types to TFile

Hello rooters,

I would like to make save one unsigned long or float or integer and other “simple” types to a TFile, and I wouldn’t like to create a structure for doing so, it should be just the single variable. Unfortunately, I can’t do that using the WriteObject template method, because it can only do that for objects that have a dictionary. I’ve searched a while, and couldn’t find many topics on this discussion, I’ve found this e-mail discussion:

root.cern.ch/root/roottalk/roottalk00/2319.html

but I don’t want to create an object for saving it. Is there a way for doing that?

Thanks in advance,
Werner.

[Writing simple variable in ROOT files

Hi Couet,

unfortunately this template is only available for double and float types. If I try to create it for other types, it leads to error of undefined references because the template declarations are on the .cxx file.

I am trying to use std::vector, but I am not being able to add the dictionary to my application using CMT.

Any other alternative?

Cheers,
Werner.

Ok, something that passed by my head: type conversion. But for the long types?

[quote=“wsfreund”]Hi Couet,

unfortunately this template is only available for double and float types. If I try to create it for other types, it leads to error of undefined references because the template declarations are on the .cxx file.

I am trying to use std::vector, but I am not being able to add the dictionary to my application using CMT.

Any other alternative?

Cheers,
Werner.[/quote]

I have asked our TFile expert to look at it.

Thanks, and sorry for going “out of standards”.

Hi,

For those you should consider using the TParameter class template, for example: root.cern.ch/root/html/TParameter_int_.html

It is always by default for double, float, int, long, Bool_t and Long64_t (long long). It can be instantiated for any time (you then need to also generate the dictionary for it).

Cheers,
Philippe.

1 Like