# How to read a 2D vector in root file

**URL:** <https://root-forum.cern.ch/t/how-to-read-a-2d-vector-in-root-file/15572>\
**Category:** ROOT\
**Created:** [January 31, 2013, 4:42pm UTC](https://root-forum.cern.ch/t/how-to-read-a-2d-vector-in-root-file/15572 "2013-01-31T16:42:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qipeng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/q/aeb1de/32.png) [@Qipeng](https://root-forum.cern.ch/u/Qipeng)\
**Post date:** [January 31, 2013, 4:42pm UTC](https://root-forum.cern.ch/t/how-to-read-a-2d-vector-in-root-file/15572/1 "2013-01-31T16:42:42Z")

</div>

Hi,

I have a skimmed D3PD root file and I just MakeClass to analyze the data.

In this root file I have some vector of float vector branches like:

```auto

```

The question is how to access these branches in the source file. I have tried two methods:

```auto
Float_t eta = trig_EF_trigmuonef_track_MS_eta->at(i).at(j);
```

and

```auto
vector<float> tmp;
tmp = trig_EF_trigmuonef_track_MS_eta->at(i);
Float_t eta = tmp[j];
```

It gives me the same error:  
Error: Can’t call vector\<vector\<float,allocator \>,allocator\<vector\<float,allocator \> \> \>::at(i) in current scope TagProbe.C:23:  
Possible candidates are…  
(in vector\<vector\<float,allocator \>,allocator\<vector\<float,allocator \> \> \>)  
\*\*\* Interpreter error recovered \*\*\*

I’d be really appreciated if someone knows how to access to these branches.

cheers,  
Qipeng

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [January 31, 2013, 4:53pm UTC](https://root-forum.cern.ch/t/how-to-read-a-2d-vector-in-root-file/15572/2 "2013-01-31T16:53:14Z")

</div>

In the beginning of your macro, try to add: ` if (!(gInterpreter->IsLoaded("vector")))
    gInterpreter->ProcessLine("#include <vector>");
  gSystem->Exec("rm -f AutoDict*vector*vector*float*");
  gInterpreter->GenerateDictionary("vector<vector<float> >", "vector");`  
For “std::vector\<std::vector \>” see [url][Storing 2D vector [--\> vector\<vector\<...\> \>] into a TTree](https://root-forum.cern.ch/t/storing-2d-vector-vector-vector-into-a-ttree/14331/2)  
For “std::vector\<std::vectorstd::string \>” see [url][Problem in getting the vector \< vector \<string\> \> branch](https://root-forum.cern.ch/t/problem-in-getting-the-vector-vector-string-branch/14608/4)

---

<div class="post-metadata">

**Author:** ![Qipeng](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/q/aeb1de/32.png) [@Qipeng](https://root-forum.cern.ch/u/Qipeng)\
**Post date:** [January 31, 2013, 6:05pm UTC](https://root-forum.cern.ch/t/how-to-read-a-2d-vector-in-root-file/15572/3 "2013-01-31T18:05:20Z")

</div>

Thanks very much!
