I’m writing a script to deal with some histograms. In C++, I would have done something like
TH1F *histogram = (TH1F *)gDirectory->Get("LbCandidates_mass");
In Python, I can do
but if I try to execute histogram.Draw() I get
I’m not sure what this message means, but I assume the error comes about because the interpreter doesn’t know that histogram should be a TH1F instead of just a TObject. How can I tell it to coerce the type like I did in C++? Or is there some other way to do this?
check the histogram before calling. From the looks of it, it is NULL (i.e. the file does not contain the histogram asked for). In present day codes (i.e. not 4.00/08), you’d get a python exception “ReferenceError” when trying to use a null-pointer.
Again, please upgrade. This exercise in archeology is fun, but realize that it isn’t so much that this version of PyROOT that you’re using is old, it’s that it is the a prototype of PyROOT as released with ROOT for initial feedback. Even at the time it never had the claim of being usable: that wasn’t made until release 4.04 (which is only a little less ancient than 4.00/08).
Note that even if your institute refused to upgrade ROOT, you can still install a newer version in your own home directory: it does not need to reside in system directories such as /usr/local.
OK, I will look into that. Thanks for your patience Wim