Retrieving TCutGs from array and applying to TH2

I am trying to retrieve TCutG objects from an array, draw a TH2 from a TTree with the cut applied, and save the drawn histograms in a new array.

For some reason, the normal method I would use in order to apply a cut to a histogram doesnt seem to work (i.e. draw, set name, and then use the TTree draw function with the option set to the name of the cut).

When I run the following loop:

(TCutG objects already defined and stored in a std::vector called ‘gates’)

(Trying to save created TH2 objects to an array called ‘sb2hists’)

  for(int l = 0;l<ngates;l++){

      TCutG* cut = (TCutG*)>Clone();





I get the following error messages:

Error in TTreeFormula::DefinedVariable: Found a TCutG without leaf information (mycut)
Error in TTreeFormula::Compile: Bad numerical expression : "mycut"
Error: Symbol slicehist is not defined in current scope plot_zed1_gate.cxx:1605:

Any ideas about what I’m doing wrong?

p.s. PRISMA_analysis is the TTree in this case