How to make transverse momentum intervals and how to do a certain operation in the transverse momentum intervals?

Hi @Highenergyman ,
and welcome to the ROOT forum! Please see Posting code? Read this first! for tips on code formatting on the forum.

You tagged the post as #rdataframe , so I would like to make sure, how does the rest of the code look like? How are you reading the input data?

We can help with ROOT and a bit of C++ but if you have to write a lot of C or C++ code you might want to start by getting familiar with the language.

About your actual question, I don’t see any logic in your code snippet that selects only the tracks that belong to a certain pt interval. Maybe the simplest way to do it is with a 2-dimensional histogram filled with phiRP in one dimension and with pt in the other, so you get a different “slice” of phiRP distribution for different slices in pt?

TH2D h("h", "h", nPtBins, minPt, maxPt, nPhiRPBins, phiRPmin, phiRPmax);
h.Fill(pt, phiRP);

Cheers,
Enrico