Hi Axel,
That is good to know. Actually my question was the reverse. Given a branch which is found to be a *vector<POD> by MakeClass(), can I instead call SetBranchAddress with a c-style array?
Thanks a lot,
e.
On 18 Jan 2011, at 10:24, Axel Naumann wrote:
> Hi, > > to clarify my reply: > > Given a branch containing a c-style array (POD* where POD is float, > double,...), you can call SetBranchAddress() passing a vector<POD>'s > first element's address (&v[0]), as long as the vector has sufficient > capacity and doesn't resize. I believe that's what the question really > was in the end. > > Cheers, Axel. > > Axel Naumann wrote on 01/17/2011 09:14 PM: >> Hi, >> >> That should work as long as the vector doesn't resize, as you already pointed out. And make sure you reserve enough capacity before calling SetBranchAddress(). >> >> Cheers, Axel >> >> "Erkcan Ozcan" <eo_at_hep.ucl.ac.uk> wrote: >>
>>>> Hello Erkcan, >>>> >>>> This is fine because there is not really a cast taking place. If you
>>>> >>>> vector<float> v; >>>> >>>> you can always safely reference the array of floats inside by doing
>>>> >>>> So it is safe as long as you deal correctly with the size of the
>>>> >>>> cheers ! >>>> >>>> John Idarraga >>>> >>>> On 01/16/2011 05:59 PM, Erkcan Ozcan wrote: >>>>> Dear ROOT experts, >>>>> >>>>> We have an ntuple that contains std::vectors of floats and ints.
>>>>> >>>>> vector<float> *pvx; >>>>> >>>>> We also have an old piece of code written before the ntuple format
>>>>> >>>>> float pvx[10]; >>>>> >>>>> And we were doing the following setbranch step: >>>>> >>>>> anltree->SetBranchAddress("pvx" ,&pvx); >>>>> >>>>> We have found out that the code seems to work on the new ntuples
>>>>> >>>>> Is this safe to do? I know normally it is not ok to cast an
>>>>> >>>>> Thanks a lot, >>>>> e. >>>>> >>>>> PS: I have had some problems when I sent this email the first time.
>>>>> PS2: We are using ROOT 5.26/00b. >>>>> >>>>> >>>>
>> >> >
-- In case they are not written explicitly, please be aware that my greetings and farewell are inherently implied in this email. V. Erkcan Ozcan Research Fellow University College London Dept. of Physics & AstronomyReceived on Tue Jan 18 2011 - 12:06:43 CET
This archive was generated by hypermail 2.2.0 : Tue Jan 18 2011 - 23:50:01 CET