Projection onto Y axis

Hi, I’m new to root, and I have a question regarding the 2D histogram - projection to the Y axis. I’ve opened a file and extracted the TH2D histogram that I want, projected and drew it onto the X axis as a TH1D histogram. What I want to do is to specify a range on the X axis, for example, from 53.5 to 66, and make a projection of that range onto the Y axis.
I’ve tried several example codes, but nothing seems to work. I was wondering can someone please give me some advice on how to do this. Thank you. :slight_smile:

Double_t firstx = 53.5, lastx = 66.0;
Int_t firstxbin = h2d->GetXaxis()->FindFixBin(firstx);
Int_t lastxbin = h2d->GetXaxis()->FindFixBin(lastx);
TH1D *hpy = h2d->ProjectionY("_py", firstxbin, lastxbin, "");

Thank you so much.