The documentation says that to save a histogram one must:
Example:
tree.Draw(“sqrt(x)>>hsqrt”,“y>0”)
will draw sqrt(x) and save the histogram as “hsqrt” in the current
directory. To retrieve it do:
TH1F hsqrt = (TH1F)gDirectory->Get(“hsqrt”);
but from the commandline a simple ttree->Draw(“branch”) draws the histogram I want.
My question is: is they’re any simple GetHistogram member function that will return a pointer to the histogram that would have otherwise been created by the Draw() command. (That is, is there a way without using the >> operator.) I know there is a TTree::GetHistogram function, but this method seems to be made for creating a histogram out of some general function.
My guess is that there is something I’m not understanding from the C++ that wont allow someone to do something like:
You create your own histo before TTree::Draw and let TTree::Draw fill it
TH1F *myh = new TH1F("myh","....);
tree.Draw("sqrt(x)>>myh","y<0>>myh","y<0",..)
TH1 *myh = gDirectory->Get("myh");
CASE 3
Use the default histogram named “htemp” created by TTree::Draw
tree.Draw("sqrt(x)","y<0",..)
The histogram exists only in the current pad and will be destroyed
by the next TTree::Draw command. It is not allocated to the current dir
TH1 *myh = (TH1*)gPad->GetPrimitive("htemp");
[quote]My guess is that there is something I’m not understanding from the C++ that wont allow someone to do something like:
TH1F *myhisto = mytree->GetHistogram(“mybranch”);
myhisto->Draw();
[/quote]
No, this would be quite bad, because next week somebody will request
mytree->GetHistogram("mybranch","some selection");
and the week after a request for