for (int i = 0; i<30000; i++) {
H1->Fill(Fun1(y),y);
}
H1->Draw();
The TTree::Draw() function is not intended for filling complicated
histograms, but quickly viewing a simple plot.
Cheers,
Andy
---Dirk Meier <Dirk.Meier@cern.ch> wrote:
>
>
>
> Hello,
>
> I want to draw a function TF1 which gets its arguments from a TTree.
>
> s.th like this:
>
> {
> TFile *f = new TFile("test.root"); // open file test.root
>
> TTree *t = (TTree*)f->Get("T"); // get the tree,
>
> TH1F *h1_1 = new TH1F("H1_1","H1_1",80,-0.1,1.1); // declare
histogramm
>
> T->Draw("x>>H1_1","y<1 && y>0","",30000); // Draw values from
> // tree into H1, x, y are floats in tree
>
>
> TF1 *fun1 = new TF1("Fun1","pol7",0,1); // decleare a function
>
> H1_1->Fit("Fun1","","",0,1); // do a fit to the
distribution of x
>
> // now I want to draw Fun1 as a function of y which is float in the
tree
>
> // s.th like T->Draw("Fun1(y):y","y<1 && y>0","",30000);
>
> }
>
>
> I believe TTreeFormula could help?
> Does anybody has an example on how to use TTreeFormula
>
>
> merci
>
> Dirk
>
>
>
>
==
Andrew Haas - haas@yahoo.com
University of Washingon Physics
Glast - D0
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com