To define a vector<int> in pyroot one can do:

```
vec = ROOT.std.vector('int')()
```

Is it possible to use vectors with embedded pair in pyroot, e.g:

```
vector<pair<int, float>>
```

Thanks

To define a vector<int> in pyroot one can do:

```
vec = ROOT.std.vector('int')()
```

Is it possible to use vectors with embedded pair in pyroot, e.g:

```
vector<pair<int, float>>
```

Thanks

Why not?

```
>>> ROOT.std.vector('pair<int, int>')
<class 'ROOT.vector<pair<int,int> >'>
>>> ROOT.std.vector('pair<int, int>')()
<ROOT.vector<pair<int,int> > object at 0x5589910921c0>
>>> pvec = ROOT.std.vector('pair<int, int>')()
>>> pvec.push_back((1, 2))
>>> pvec[0]
<ROOT.pair<int,int> object at 0x558991d1f340>
>>> pvec[0].first
1
>>> pvec[0].second
2
>>> x, y = pvec[0]
>>> x, y
(1, 2)
```

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.