[Root_list] problem compiling
Beni Zihlmann
zihlmann at jlab.org
Wed May 4 08:02:23 EDT 2016
Hi Carlos,
I do not see any immediate issues but I have some advice.
1) have all variables that are related to the same tree defined at the same
place, not scattered through the include file and main code. Some
of the
variables are global others (like Hit) are local.
2) RTPCTree->GetEntries() returns a Long64_t value not int
3) RTPCTree->GetEntry(a) takes a Long64_t variable not int
4) there is a white space between "RTPCTree" and "->" when setting the
Branch Address
5) all the stuff with "chain" you do not seem to use so I would remove them
maybe this helps.
I would expect that when you compile the code it should spit out lots of
warnings
not necessary errors.
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