Hi guys,
I was wondering if this piece of code is correct or if I’m missing something.
I have two root files and I retrieve an histogram from them.
Then, I want to save these two histos in a ROOT file with one tree and two branches. Each branch is an histogram.
To do this, I wrote this piece of code:
(histos are called h1 and h2)
//CREATE A TREE TO SAVE BOTH HISTOGRAMS//
//gROOT->cd();
TTree* tree = new TTree(“tree”,“final_tree”);
tree->Branch(“Beam spot_X”,&h1,“h1”);
tree->Branch(“Beam spot_Y”,&h2,“h2”);
Alternatively, do you know a more efficient way to draw the two histos one VS the other? My idea is to construct a tree and then:
“tree_name->Draw(“first branch:second branch>>histo(…)”)”).
Hi,
I am not sure to fully understand your question.
Do you want somehow create a 2D histogram (e.g. TH2D) from two 1D histograms (e.g TH1D)
If this is the case, it isn’t possible.
You could go from one 2D histogram to two 1D histograms, but not the other way.
Passing from 2D to 1D you lost informations that cannot be retrieved.
Look the post below, there is an example explaining why you could not do it