Dear experts,
After spending a lot of time trying to create a ration plot from my histograms and getting the following error:
Error in TRatioPlot::GetUpperRefObject: No upper ref object of TH1 or THStack type found
I decided to first go through the tutorial: ratioplot1.C (ROOT: tutorials/hist/ratioplot1.C File Reference).
However, I received the same error message.
Please let me know where I am going wrong.
As always, thank you for the help.
Hi @Wile_E_Coyote
Thank you for your quick response.
I am using RHEL 7.9 and my root version is 6.26/06.
I successfully ran “root -l ratioplot1.C” and I could see the plots. But when I try to implement ratio plots in a similar way for my other histograms, I get the error.
Hi @Wile_E_Coyote ,
I guessed I figured out what the problem was. After I saved the created canvases in a root file, I would close the file. If I comment out the command to close the file :
OutputRootFile->Close();
everything works as expected. However, my question now is how to close the file without any problems?
Thanks again
Hi @couet
How can I upload my file? can I just copy and paste it here?
It is really long (593 lines) and if I remove similar sections like other histograms then the problem seems to go away. However, I could not find the problem by removing the other histograms and parts of the code one by one and running it. It seems like it happens when I have many histograms and I try to save it to a root file and then close the file.
Please let me know how I can share it,
Thanks
A brief description about the code:
The code reads in two MC samples and creates several plots. Then, it normalizes the plots related to second MC sample. Using the two sets of plots , it creates ratio plots and saves to the file (which is located in a directory made by the code with the name of two samples). At the very end, it closes the file.
Thanks a lot for your help.
I run it as in the following:
.L CompareMCResults.cc++
MCResultComparator MCRC(“path to first MC”,“path to second MC”,“First Decay Mode”,“Second Decay Mode”)
MCRC.CompareMCResults()
@Wile_E_Coyote ,
I used DrawCopy() for histograms only, and also used “delete outputfile” instead of “outputfile->Close()” but I still get the same error:
Error in TRatioPlot::GetUpperRefObject: No upper ref object of TH1 or THStack type found
also immediately “segmentation violation”