Read data from an ascii file and create a root file with an histogram and an ntuple.
See a variant of this macro in tree102_basic.C.
void tree101_basic()
{
TH1F h1(
"h1",
"x distribution", 100, -4, 4);
TNtuple ntuple(
"ntuple",
"data from ascii file",
"x:y:z");
while (1) {
if (!in.good())
break;
if (nlines < 5)
printf(
"x = %+8.6f, y = %+8.6f, z = %+8.6f\n",
x,
y, z);
nlines++;
}
printf(" found %d points\n", nlines);
in.close();
}
int Int_t
Signed integer 4 bytes (int).
float Float_t
Float 4 bytes (float).
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a float per channel (see TH1 documentation)
A simple TTree restricted to a list of float variables only.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
- Author
- Rene Brun
Definition in file tree101_basic.C.