Precisely speaking, I believe, tofit=0 means that the object named “EtvsMt” does not exist in the main directory of your file “ff”. If it exists in some kind of a subfolder, it will NOT be found by “ff.Get” (you need to find it “manually” yourself). See, for example, here: [url]Draw the 2-D histograms which in the subFolder
All your three variables (“ff”, “tofit” and “ppp”) are global variables and, according to the source code that you showed, they are initialized immediately when the “object code” gets loaded (that’s what “.L” does).
Ok, I understand, thanks for the explanation.
Anyhow, the histogram is present in the root file and I can execute the lines of the macro on the prompt
without errors.
Bye, Marianna.
Try to execute:
root [0] TFile ff(“testWm_et20_d0.root”);
root [1] ff.ls();
and see what exactly it says about the “EtvsMt”.
I’ve just noticed a bug in your code.
Replace:
TH1F ppp = (TH1F)(tofit->ProjectionY());
with:
TH1D *ppp = tofit->ProjectionY();
See http://root.cern.ch/root/html/TH2.html#TH2:ProjectionY for details.
Doing ff.ls() I get
KEY: TH2F EtvsMt;1
Also substituting with TH1D *ppp = tofit->ProjectionY();
I get this error:
Error: illegal pointer to class object tofit 0x0 1435 ttt.C:19
A precisation: I compile with .L ttt.C+
if I compile simpy .L ttt.C I get no error.
I have no idea what happens then.
The last thing you might try (though I don’t think it will help) is to replace:
TH2F* tofit=(TH2F*)ff.Get(“EtvsMt”);
with:
TH2F tofit=dynamic_cast<TH2F>(ff.Get(“EtvsMt”));
One more thing to try … “.L ttt.C++” (double “+”).
Next time, provide us with the [color=#800080]F[/color][color=#408040]U[/color][color=#FFBF00]L[/color][color=#00FFFF]L[/color] error message that you get. This will make it [color=#FF0000]M[/color][color=#FF4080]U[/color][color=#FFBF80]C[/color][color=#80FF00]H[/color] easier for people to help you.
A pitiful case, am I not?
Pepe Le Pew.