With RDataFrame, you don’t iterate over the events explictly (this is hidden inside RDataFrame and done much more efficiently in C++). You proceed by applying per-event transformations to your dataset and finally obtaining some results from it.
In your code, you would construct an RDataFrame from your dataset, then for example define a new column pt from a function that does the per-event calculation you posted here. After that, you would call a Histo1D action on that column.