Applying cuts after drawing a histogram

Hi all,

I think this is probably a really basic question, but my knowledge of coding in general is very shaky so I’m finding it hard to understand the documentation. I’ve been asked to ‘plot variable x in bins of variable y’. To do this I’ve put together a macro based on MakeClass, plotted a TH1F of variable x and now I want to plot specific ranges to display it in bins of variable y.

For example, if x is the number of tracks in a jet and y is the jet energy, I have a loop that determines the range of jet energy and finds the upper and lower limits of bins when the jet energy is split into 10 bins.

Given I know these limits, I’d like 10 plots of the number of tracks, each in one of the ranges I’ve found. I thought this should be doable by plotting the number of tracks, and then repeatedly applying axis->SetLimits(), GetXaxis->SetRangeUser or even just SetRange, but none of these do what I’d like. Should these commands work (i.e. it’s a problem with how I’m using them in my code) or is it likely I’ll need to try an entirely different approach?

Thanks for any help!

How about you fill a TH2D or TH2F (i.e. “y:x”) and then use some of the TH2::ProjectionX, TH2::ProjectionY, TH2::ProfileX and / or TH2::ProfileY methods.

See also the THistPainter Class Reference.