Hi Ville, Look at the documentation of TTree::Draw at: http://root.cern.ch/root/html/TTree.html#TTree:Draw and in particular at the section that says: How to obtain more info from TTree::Draw ======================================== Once TTree::Draw has been called, it is possible to access useful information still stored in the TTree object via the following functions: -GetSelectedRows() // return the number of entries accepted by the //selection expression. In case where no selection //was specified, returns the number of entries processed. -GetV1() //returns a pointer to the float array of V1 -GetV2() //returns a pointer to the float array of V2 -GetV3() //returns a pointer to the float array of V3 -GetW() //returns a pointer to the double array of Weights //where weight equal the result of the selection expression. where V1,V2,V3 correspond to the expressions in TTree::Draw("V1:V2:V3",selection); Example: Root > ntuple->Draw("py:px","pz>4"); Root > TGraph *gr = new TGraph(ntuple->GetSelectedRows(), ntuple->GetV2(), ntuple->GetV1()); Root > gr->Draw("ap"); //draw graph in current pad creates a TGraph object with a number of points corresponding to the number of entries selected by the expression "pz>4", the x points of the graph being the px values of the Tree and the y points the py values. Important note: By default TTree::Draw creates the arrays obtained with GetV1, GetV2, GetV3, GetW with a length corresponding to the parameter fEstimate. By default fEstimate=10000 and can be modified via TTree::SetEstimate. A possible recipee is to do tree->SetEstimate(tree->GetEntries()); You must call SetEstimate if the expected number of selected rows is greater than 10000. Rene Brun On Thu, 20 Jul 2000, Ville Axel Bergholm wrote: > > > Hi, > > I have an Ntuple NT with fields x, y, ex, ey containing (x,y) points > with errors. I want to create a TGraphErrors instance TGE using > these points. The easiest way to accomplish this seems to be > > Float_t *fp = NT->GetArgs(); > > then use fp and my knowledge of the NT structure to fill four > temporary float arrays (let's say tx, ty, tex, tey) with the correct data, > and finally to do > > TGraphErrors *TGE = new TGraphErrors(npoints, tx, ty, tex, tey); > > > Is there a better, more direct way? In other words, is there a way > to extract single Ntuple columns into arrays? > > > Please send a cc of the answer directly to my e-mail address (I don't > subscribe this mailing list). Thanks in advance! > > > Ville > > >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:30 MET