I am trying to read histogram from a root file. Here is my attempt:
const Char_t *directory="/home/haha/data.root";
But this gives a weird graph. I have also tried using the sprintf method to format string then put in as the argument of Get. But that does not work neither. Could anyone explain what happen?
In your example you do not produce a graph (no drawing). Can you provide an example we can run ?
I must have done something wrong before but now it works if I use
But I still don’t understand why the sprintf and TString::Format do not work (See the commented code). For these two method I can’t get the histogram and it gives a null pointer error at the line num11->Sumw2(). Thank you very much.
std::cout << "b = " << b << std::endl; // try it before and then afterwards
See methods’ descriptions: TString
The variable "directory " is wrong,you can change it in the code.
My program works now. But I forgor what I have changed. I guess I just made some silly mistake.
In ROOT,function “sprintf” is always used as another function TString::Form().For example,it always used as this:
Form("%s",location); //location is an object of TString instanced before.