Compiling errors

Ok so I have a bit of code I’m running in compiler mode but I get a lot of errors, most of which I think are just cascaded down from previous ones and I think it is from the very first ones. They are illegal pointer errors. Here is the bit of code for which I am getting errors:

TTree oldTree = (TTree)a->Get(“ak3PFJetAnalyzer/t”);
TTree otherTree = (TTree)a->Get(“hiEvtAnalyzer/HiTree”);
TTree other1Tree=(TTree)a->Get(“hltanalysis/HltTree”);

and here are the errors:

Error: illegal pointer to class object a 0x0 402
Error: illegal pointer to class object a 0x0 402
Error: illegal pointer to class object a 0x0 402

I have #include “TTree.h” in the header so I don’t think that’s the problem.

I also get the same errors for later lines but I’m thinking once I know how to solve it once I can solve it again, so some help the first time would be greatly appreciated. Thanks in advance for reading and helping.

Zac

Hi,

It seems that your pointer “a” is 0x0. You probably haven’t created a TTree which the pointer “a” could point to.

cheers,
peter

Thanks for the reply Peter,

I have this which I believe to be a pointer:

TFile *a = TFile::Open("~/Documents/rootfiles/dimuonskim.root");

this is someone else’s code I’m using for a project but it’s not working for me and I’m trying to fix it. I’m totally new to coding and ROOT.
If that’s not what I need then how would I create this TTree so as to fix the problem?

Cheers,
Zac

Hi,

Is the file existing?

You might try doing your commands on the root cling interpreter. Load your file there and then check if the file and which are around in your ROOT directory with “.ls”.

cheers,
Peter