Probably not a good idea to have the maximum range hard-coded.  What if there are not at least 14 gen particles?  It could easily happen.  If you want to loop over all gen particles by index, the best way is with

for i in range(len(tree.genPdgId)) :
   pass # do something with i