[ROOT] TTree Draw , missing axis label

From: Stefan Funk (Stefan.Funk@cern.ch)
Date: Mon Aug 04 2003 - 17:55:27 MEST


Hello All,
I would like to draw one thing against another from an ascii file. 
Therefore I wrote a little script that is included below. 
My problem is, that the TTree->Draw() does not label the axes and I have 
no idea how to label them (not the title but the numbers).

Thanks for your help

Stefan



#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include "Riostream.h"
#include <TFile.h>
#include <TH1F.h>
#include <TNtuple.h>

void reading(char infile[], Int_t nvals, 
	    char draw[]="x[0]:x[1]", char selection[]=""){

   // infile: ascii file to analyse
   // nvals: Number of columns in the file
   // draw:  Draw option for TTree->Draw()
   // selection: selection criterion for that
 
   std::ifstream in;
   in.open(infile);
   
   Float_t* x = new Float_t[nvals];
   Int_t nlines = 0;

   std::ostringstream o;
   o << "\"x[" << nvals << "]\"";
 
   TTree *tree = new TTree("tree","data from file");
   tree->Branch("x", x, o.str().c_str());

   while (1) {
     for(int i = 0; i < nvals; ++i )
       in >> x[i];

      if (!in.good()) break;
      tree->Fill();
      nlines++;
   }
   printf(" found %d points\n",nlines);

   in.close();
   tree->Draw(draw, selection, "hist", nlines, 0);

}



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET