Logo ROOT  
Reference Guide
basic2.C File Reference

Detailed Description

View in nbviewer Open in SWAN Create can ntuple reading data from an ascii file. This macro is a variant of basic.C

void basic2() {
TString dir = gROOT->GetTutorialDir();
dir.Append("/tree/");
dir.ReplaceAll("/./","/");
TFile *f = new TFile("basic2.root","RECREATE");
TH1F *h1 = new TH1F("h1","x distribution",100,-4,4);
TTree *T = new TTree("ntuple","data from ascii file");
Long64_t nlines = T->ReadFile(Form("%sbasic.dat",dir.Data()),"x:y:z");
printf(" found %lld points\n",nlines);
T->Draw("x","z>2");
T->Write();
}
Author
Rene Brun

Definition in file basic2.C.

f
#define f(i)
Definition: RSha256.hxx:122
TString::Data
const char * Data() const
Definition: TString.h:369
Form
char * Form(const char *fmt,...)
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TTree
Definition: TTree.h:79
TString
Definition: TString.h:136
h1
TH1F * h1
Definition: legend1.C:5
TString::ReplaceAll
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:692
TString::Append
TString & Append(const char *cs)
Definition: TString.h:564
TFile
Definition: TFile.h:54
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:572
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:52
gROOT
#define gROOT
Definition: TROOT.h:406