fmm
January 4, 2017, 4:17pm
1
Hello,
I’m trying to write/draw a TH2D to a .root file but I’m unable to do so. What I do with TH1D is something like:
[code]TFile *input_file = TFile::Open(“something.root”, “read”);
TTree input_tree = (TTree )input_file->Get(“tree”);
TFile *output = new TFile(“anything.root”, “RECREATE”);
TH1D *my_histogram = new TH1D(“my_histogram”, “histogram title”, 1000, 0, 1000);
input_tree->Draw(“my_variable>>my_histogram”);
output->Write();[/code]
For TH2D I was trying:
but it doesn’t work. Could you please be so kind as to point me in the right direction?
fmm
January 4, 2017, 4:47pm
3
Hello,
Thank you for the link. I read it and got the impression that the following should work:
It doesn’t work though. What am I doing wrong here?
input_tree->Draw(“my_variable:my_variable2>>my_histogram2”, “”, “colz”);
BTW. Do remember that it’s “Y:X” (and not “X:Y”).
fmm
January 4, 2017, 5:13pm
5
Thank you.
I had tried that before but it didn’t work. I finally figured what’s going on. I’m viewing the histograms using the TBrowser. For some reason, “colz” is not working there. I have to use “my_histogram->SetOption(“colz”);”…
Thank you again.
1 Like