# Std::vector\<float\> \*' to 'float', tree with vector entries to float values

**URL:** <https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415>\
**Category:** Newbie\
**Tags:** root\
**Created:** [September 19, 2023, 7:51pm UTC](https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415 "2023-09-19T19:51:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shreya14p](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/shreya14p/32/34541_2.png) [@shreya14p](https://root-forum.cern.ch/u/shreya14p)\
**Post date:** [September 19, 2023, 7:51pm UTC](https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415/1 "2023-09-19T19:51:39Z")

</div>

Is there a way to convert a tree with vector entries to float values? Basically, std::vector \*’ to ‘float’

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [September 19, 2023, 9:01pm UTC](https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415/2 "2023-09-19T21:01:53Z")

</div>

Dear @shreya14p ,

Let’s try to remove TTree from the equation for a second. Given any object of type `std::vector<float> *`, how would you convert it to a single `float`? Let me give the following small C++ snippet as an example

```cpp
int main(){
    std::vector<float> myfloats{1., 2., 3., 4., 5.};
    // To represent *exactly* your question, even though 
    // this is really not needed for the discussion
    std::vector<float> *myfloats_p{&myfloats};
    // How would you perform the conversion from vector to single float
    float my_float = ??
}

```

Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [September 20, 2023, 6:43am UTC](https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415/3 "2023-09-20T06:43:59Z")

</div>

Hi,

I propose not to branch the discussion in this thread and follow it here [Vector type in TMVAClassificationApplication - #3 by shreya14p](https://root-forum.cern.ch/t/vector-type-in-tmvaclassificationapplication/56413/3) .

Best,  
D

---

<div class="post-metadata">

**Author:** ![pcanal](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pcanal/32/12439_2.png) [@pcanal](https://root-forum.cern.ch/u/pcanal)\
**Post date:** [September 25, 2023, 5:43am UTC](https://root-forum.cern.ch/t/std-vector-float-to-float-tree-with-vector-entries-to-float-values/56415/4 "2023-09-25T05:43:17Z")

</div>

Closed on September 25, 2023, 5:43am UTC


