Documentation for std::vector (first google hit, my favorite c++ reference) [0].  In particular, std::vector::operator[] or the method std::vector::at() take an index argument and return the element stored at that index.  Both work for the PyROOT exposure of vector.  std::vector in C++ is much like the "list" type in python, and both have the [] operator for accessing an element at an index.

Some pseudocode:

print type(tree)
print type(tree.genP4)
print type(tree.genP4[0])
i = 5
print tree.genP4.at(i).pt()
print tree.genP4[i].pt()

indicesGlu = [i for i in range(len(tree.genP4)) if tree.genPdgId[i]==21]
print indicesGlu
#You probably want the last gluon listed, if any
iLastGluon = next(reversed(indicesGlu), None)
print iLastGluon

if iLastGluon!=None : gluplot.Fill(tree.genP4[iLastGluon].pt())

[0] http://www.cplusplus.com/reference/vector/vector/