Read data (CERN staff) from an ascii file and create a root file with a Tree.
See also a variant in staff.C
TString filename =
"cernstaff.root";
FILE *fp = fopen(
Form(
"%scernstaff.dat",dir.
Data()),
"r");
if (getFile) {
if (hfile) return hfile;
}
if (hfile) return hfile;
}
}
printf("you must run the script in a directory with write access\n");
return 0;
}
tree->Branch(
"Category",&Category,
"Category/I");
tree->Branch(
"Flag",&Flag,
"Flag/i");
tree->Branch(
"Age",&Age,
"Age/I");
tree->Branch(
"Service",&Service,
"Service/I");
tree->Branch(
"Children",&Children,
"Children/I");
tree->Branch(
"Grade",&Grade,
"Grade/I");
tree->Branch(
"Hrweek",&Hrweek,
"Hrweek/I");
tree->Branch(
"Cost",&Cost,
"Cost/I");
tree->Branch(
"Division",Division,
"Division/C");
tree->Branch(
"Nation",Nation,
"Nation/C");
while (fgets(
line,80,fp)) {
sscanf(&
line[0],
"%d %d %d %d %d %d %d %d %d %s %s",
&Category,&Flag,&Age,&Service,&Children,&Grade,&
Step,&Hrweek,&Cost,Division,Nation);
}
if (print)
tree->Print();
fclose(fp);
delete hfile;
if (getFile) {
return hfile;
}
return 0;
}
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
A TTree represents a columnar dataset.
void Step(const gsl_rng *r, void *xp, double step_size)
- Author
- Rene Brun
Definition in file cernbuild.C.