EDIT: SOLVED The problem was that the histogram I was trying to retrieve did not exist. TFile::Get() does actually get the right class and no cast is needed. Sorry!
I feel this is very very basic, but I cannot find the solution. In this small piece of code:
mystack=THStack("ratios_combined","combination of ratios for different isocuts") print "the name is ",mystack.GetName() # for isamp in ListOfSamples: filetoget=isamp.MainDir+isamp.RatioMergedFile print "file to get =", filetoget # readfile=TFile(filetoget,"READ") # hist=readfile.Get("fakeratio") # print "the class is ",hist.Class_Name() mystack.Add(hist) # readfile.Close()
I get the output:
the class is TObject TypeError: void THStack::Add(TH1* h, Option_t* option = "") => could not convert argument 1
It seems that THStack needs a TH1-inherited object. How can I make this happen? How can I make pyroot aware that “hist” is a TH1D ?