TCutG for binning

Hello experts,

I have 9 bins defined(see picture). I want to know, How to use TCutG to define the histograms for each bin.(need to draw the missing massSq distributions for each bin)

I have defined my binning as a function.(int EffBin_pim) Attached the code. Is there a way to call this inside TCutG.

Could you please give me a clue?

int iBinEff_pim(double pp, double theta_p){
    // Make sure each case is exclusive
    if (theta_p>fE->Eval(pp)&&theta_p<fBW2->Eval(pp)&&pp<pMax){
        if (pp<pMin) {
            return 0;
        } else if (pp>pMin&&pp<pLimit){
            //central block with three theta bins
            fCut->SetParameter(0,upper);
            if (theta_p>fCut->Eval(pp)){
                // top two bins
                if (pp<pMid){
                    return 1;
                } else {
                    return 2;
                }
            } else {
                fCut->SetParameter(0,lower);
                if (theta_p>fCut->Eval(pp)){
                    // middle two bins
                    if (pp<pMid){
                        return 3;
                    } else {
                        return 4;
                    }
                }
                // Bottom two bins
                if (pp<pMid){
                    return 5;
                } else {
                    return 6;
                }
            }
        }
        if (pp<pMax) {
            // Two theta bins in maximal momentum bin
            fHiP->SetParameter(0,middle);
            if (theta_p>fHiP->Eval(pp)) {
                return 7;
            } else {
                return 8;
            }
        }
    }
    return -1;
}


Thank You
Dil

Hi,
@couet can maybe help you on this,

Best regards

Lorenzo

Seems to me you have much more. According to your plot.

Which area of the plot do you want to select with the cut ?
To use a TCutG when drawing a TH2 use the option:

“[cutg]” Draw only the sub-range selected by the TCutG named “cutg”.