[Root_list] problem compiling

Beni Zihlmann zihlmann at jlab.org
Wed May 4 08:09:00 EDT 2016


I just realized:

RTPCTree ->SetBranchAddress("X", &X[ndim]);

try

RTPCTree->SetBranchAddress("X", X);

X is defined as array in the header file so X is already the pointer to 
the first
element in the array.

cheers,
Beni


On 05/03/2016 10:16 PM, Carlos Ayerbe wrote:
> Dear JLab-rooters
>
> I need some help to understand what is the problem reading the variables from a root file through compiled code.
>
> In the folder below is the code with the rootfile I'm using. In principle it compiles well, it runs without any apparent issue, but the values are incorrect.
>
> https://drive.google.com/open?id=0BzMLOCd9ntumQWtha25aVHlicUk
>
> The content of the rootfile is only space variables, the event number and the number of hits in such event.
>
> You can see with a simple scan or show the content of the rootfile, and the code skips the X value and writes to the Y value, and Y to Z. I started setting the definition of the branch variables in the header, but I found that makes the event values behave weird, so I set it as global variable. With the space variables (X, Y, Z), there is no easy solution and they are the ones making problems. They doesn't work properly in the header neither as global, but if I set them inside the function the code behaves even more weird. There is a loop where I get the entries, with the variables defined in the function (e.g. after the TTree declaration), the index enters the GetEntry method as normal, but after it the index goes crazy.
>
> I compared this case with other examples I have and I don't see why this happen. Is because the use of the header?
>
> Thank you for your time
>
> Carlos Ayerbe
> _______________________________________________
> Root_list mailing list
> Root_list at jlab.org
> https://mailman.jlab.org/mailman/listinfo/root_list



More information about the Root_list mailing list