Hi all,
I’m sure this has been covered but I had a search and couldn’t find a solution.
I want to create a graph from a tree I have already created, so this is the code I am currently running:
[code]void BCTF_graph()
{
TFile *f2011 = new TFile(“Bb2012.root”); //open file
TTree t2011 = (TTree)f2011->Get(“Bb2012”); //get tree
gROOT->SetStyle(“Plain”); //white background
gStyle->SetTitleBorderSize(0); //no box around the title
TPaveStats *stats; //define statistics box
Int_t n=100;
TCanvas *bunchedbeam = new TCanvas(“Bunched_Beam”,“BCTF40 Bunched Beam response”);
TGraph *BCTF40BB = new TGraph(100);
t2011->Draw(“vb>>BCTF40BB”);
BCTF40BB->Draw();
}[/code]
I can create this graph manually from tree viewer by just dragging “i” into x and “vb” into y, but I would prefer to be able to do it automatically.
Currently this code produce a histogram of frequency of values of “vb”. I want it to plot “vb” against “i”.
If anyone could shed some light or point me in the direction of a previous solution I’d be grateful.
Thanks!