Error in accessing TTree branch

Hi,
I have a root file with TTree structure. The branches of this root file are various detectors (e.g AnnularS1,W1,SSSD etc) which contain other informations such as energy,strip number etc in its leaves. I wrote a macro to access the leaves of one of the detectors named W1 so that I can plot my required variables.
However on executing the macro I am getting the following errors

> use of undeclared identifier ‘W1’
t0->SetBranchAddress(“W1”,&W1);

I am attaching both the root file “7Bedp.root” and the macro “W1_theta.C”.

W1_theta.C (1.1 KB)

Bedp.root (2.8 MB)

Hi,

Where is your W1 varible defined?

Cheers, Bertrand.

Hi,
Actually I am a bit confused as there are a lot of files associated with W1 detector. I am attaching one of such file where W1 is a class. Tell me if it is useful to you in any way?

W1.hh (6.6 KB)

OK, thanks. Then you should do something like:

W1 *myW1 = 0;
t0->SetBranchAddress("W1", &myW1);

Cheers, Bertrand.

On using that I am getting the error

unknown type name ‘W1’
W1 *myW1=0;

Add #include "W1.hh" in your code…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.