I cannot read histogram of the file. I tried to repeat the tutorial code, but it does not work.
My histogram name is “LDJ”, which is stored in kq.root; I can browser it from root browser, but I cannot call it in macro.
I includes here two versions of code: one is my real code (test.C), and one is simple code (test2.C) that i tried to repeat the tutorial. Both of them did not give me the result. test2.C (416 Bytes) kq.root (3.8 KB) test.C (2.3 KB)
I used root 5.34.32 on window 7 64 bit.
Thank you,
Don’t write your own main() unless you really have to. You are missing an event loop; you want GUI interaction - all of that is provided if you run your code in ROOT, instead of building your own main().
(You’re missing a TApplication object; its Run() method creates an event loop.)
So the problem is that the TFile is destructed at the end of the function, and (good old ROOT behavior…) TH1 objects are owned by the TFile - i,e. the file destroys the histogram.
That now runs in example file, but crash in my code. Could you please explain me a little bit about SetDirectory, I think that problem come from the command.
If I try to
.L igg.C+
igg()
Then crash without any information.
If I try:
.L igg.C
igg()
this happens:
Error: illegal pointer to class object LDJ 0x0 1430 D:\OneDrive\Espace de travail\00 - Duy Tan 2017\Igg2\igg.C(338)
*** Interpreter error recovered ***
I see that the folder name where you execute your macro contains spaces and special characters like minus. Can you try to execute it in a folder without spaces and special characters ?