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*)gates.at(l)->Clone();
cut->SetName("mycut");
PRISMA_analysis->Draw("ic_energy_ab_de:ic_energy>>slicehist(4096,0,8192,4096,0,8192)","mycut","colz");
sb2hists.push_back(slicehist);
sb2hists.at(l)->SetMarkerColor(l);
}
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?