Hi Topher, You have two possibilities: -using the return value of Ttree::Draw int nselected = tree->Draw(selection,selection,"goff"); -using TTreeFormula directly TTreeFormula select("select","selection,tree); then in your loop on tree entries, double r = select.Eval(entry_number); if (r==0) the selection is not true. Rene Brun Topher Cawlfield wrote: > > Hi, > > Does anyone know how I can (quickly and easily) get a count of events in > a TTree that pass a certain cut? One method is to make a histogram, use > TTree::Project to fill it, and then get the total bin contents from > TH1::GetStats. But this seems unnecessarily tedious and time-consuming, > creating (and later destroying) a histogram, and requires knowing of a > dummy variable to bin in. > > The reason for this is that I want to make a simple, general-purpose > utility for creating plots of quantities like yield and S/N for a > variety of cuts. One common way to assess yield and background is to > perform a fit. Simpler still, one could perform background subtraction > (such as sideband, wrong-sign, Monte Carlo, etc.). > > So, I thought I'd make a function that takes a baseline cut, an array of > experimental cuts, and an instance of a subclass of "Evaluator", and > makes a plot (one point per cut). Evaluator would be an abstract class > that defines a "getXY" virtual function that takes a cut and returns an > x, dx, y, and dy. X and Y would be, for example, S/N and yield. Then > I'd make a derived class, say "EvalSubtract", that you can hand a TTree, > signal cut, and background cut. The evaluation of signal (or > background) would simply be a count of events passing both the analysis > cuts and the signal (or background) cuts. Well, it sounded trivial to > me, until I ended up searching through the root docs for a TTree member > function that performed the count. No luck! > > I suppose one solution could be to write a counting TSelector and using > TTree::Process. But I don't know how to write the ProcessCut function > to evaluate a TCut, or whether or not this is the best way. > > Any ideas? > > Topher Cawlfield
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET