<div dir="ltr">Carlos,<br><br>This line seems not right. <br>"RTPCTree ->SetBranchAddress("X", &X[ndim]);"<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 4, 2016 at 8:09 AM, Beni Zihlmann <span dir="ltr"><<a href="mailto:zihlmann@jlab.org" target="_blank">zihlmann@jlab.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I just realized:<br>
<br>
RTPCTree ->SetBranchAddress("X", &X[ndim]);<br>
<br>
try<br>
<br>
RTPCTree->SetBranchAddress("X", X);<br>
<br>
X is defined as array in the header file so X is already the pointer to the first<br>
element in the array.<span class="im HOEnZb"><br>
<br>
cheers,<br>
Beni<br>
<br>
<br>
On 05/03/2016 10:16 PM, Carlos Ayerbe wrote:<br>
</span><div class="HOEnZb"><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Dear JLab-rooters<br>
<br>
I need some help to understand what is the problem reading the variables from a root file through compiled code.<br>
<br>
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.<br>
<br>
<a href="https://drive.google.com/open?id=0BzMLOCd9ntumQWtha25aVHlicUk" rel="noreferrer" target="_blank">https://drive.google.com/open?id=0BzMLOCd9ntumQWtha25aVHlicUk</a><br>
<br>
The content of the rootfile is only space variables, the event number and the number of hits in such event.<br>
<br>
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.<br>
<br>
I compared this case with other examples I have and I don't see why this happen. Is because the use of the header?<br>
<br>
Thank you for your time<br>
<br>
Carlos Ayerbe<br>
_______________________________________________<br>
Root_list mailing list<br>
<a href="mailto:Root_list@jlab.org" target="_blank">Root_list@jlab.org</a><br>
<a href="https://mailman.jlab.org/mailman/listinfo/root_list" rel="noreferrer" target="_blank">https://mailman.jlab.org/mailman/listinfo/root_list</a><br>
</blockquote>
<br>
_______________________________________________<br>
Root_list mailing list<br>
<a href="mailto:Root_list@jlab.org" target="_blank">Root_list@jlab.org</a><br>
<a href="https://mailman.jlab.org/mailman/listinfo/root_list" rel="noreferrer" target="_blank">https://mailman.jlab.org/mailman/listinfo/root_list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">With Best Regards,<br>Jixie Zhang<br>757-269-7735 <br>_______________________________________________</div>
</div>