How to save one single value in a TFile

Hello Rooters,

I’m trying for a while to safe one single value in a root file.
The root file contains already two TTrees and a couple of histograms

All this data is related to one assembly and one measurement.
Now I want to save the voltage with the measured data in the same file.

I thought about using a new TTree with only one entry but I was hoping there would be a more elegant way to do that.

Thanks for your help

Christian

Hi,

You can just write an object. See:
root.cern.ch/root/html/TFile.html#TFile:Write

Cheers,
Charles

Hi,
I would actually like to do the same.

Say, I have a
float somevalue;

and later in the code
somevalue = 2;

I cant do

TFile* hfile = new TFile(filename,“RECREATE”,“BeamMonitor”);
hfile->cd();
somevalue->Write();

Error: non class,struct,union object somevalue used with . or -> Bla.C:

So what’s the trick?

Thanks
Hendrik

It seems, one can use this:

root.cern.ch/root/html/TParameter_float_.html

works for me.

Hendrik

1 Like