_ROOT Version: 6.16/00
_Platform: Ubuntu 20.04 (WSL) Compiler: Not Provided
I have been trying to save some information that describes the content I am saving into a TFile. But, I do not found an explicit example.
I will an exact part of my problem. Filling the histograms can be splitter into two cases A, B; so I have tan histograms for each case. Either A, or B, are described by a variable that is not linked to any information you can retrieve from the class. These descriptors are counters, that I would use later to “Scale()” the TH1 objects. But, I need these counters to be saved into the TFile. I am using an additional ASCII file to store this metadata, but I found it inefficient.
How can I save this information into the TFile? These running variables can be of different types, but I am mostly interested in saving Int_t, Bool_t.
I’m not saying this is ideal (it’s far from it), but in principle you can store your Int_t in a special 1D histogram. Fill it once, and then do yourHistogram->GetMean().
The same goes for a Bool_t: make a 1D histogram with just two bins, -0.5 < x < 0.5 and 0.5 < x < 1.5, fill it with either 0 (false) or 1 (true), and then
Also search on this forum that question was already asked.
I really look for that, but I did not found the exact problem. I found something similar but did not work for me.
Moreover, I am pretty new with ROOT, so I am not sure what to do with the TObjString
This could work in the bool type case but is not feasible for the int type: some of them are in a too wide range, so probably exceed the max number of bins a TH1 can store
This could work in the bool type case but is not feasible for the int type: some of them are in a too wide range, so probably exceed the max number of bins a TH1 can store
In this case I guess you can fill a fixed bin (e.g., bin #1) with your value. And then get this value:
int myValue = 424242;
yourHistogram->Fill(1, myValue);
// write yourHistogram to the file, close the file
// now open your file in another program and read the value back:
const int myValue = static_cast<int>(yourHistogram->GetBinContent(1));