How can I make an elliptical cut in a TH2F programmatically (e.g. in my script, I want to make a cut where I know all of the parameters of the ellipse)? I figure that there’s some way to do it with TEllipse and TCutG, but I can’t figure it out.
Okay, great. Now, the harder question. Is there a way to use a TCutG when drawing from a tree? I would imaging something like…
TCutG myCut;
myCut.SetPoint(0,15.,32.);
…
TH2F *h = new TH2F(“h”,“h”,100,0,10,100,0,10);
myTree->Draw(“a:b>>h”,"[myCut]");
I’m trying to draw “a:b” into a 2D histogam from a tree, but only have the elements that exist in the ellipse defined by my TCutG be entered into the histogram.
Incidentally, I just realized that I could just run through a and b entry by entry, and if they are inside an ellipse of my definition, I can just fill a histo… e.g. in pseudo programming language:
val = ((a-a0)/s1)^2 + ((b-b0)/s2)^2
if val < c then fill histo
I was just hoping there was a cool way of doing this with TEllipse somehow.