26 TString filename =
"cernstaff.root";
30 FILE *fp = fopen(
Form(
"%scernstaff.dat",dir.
Data()),
"r");
38 if (hfile)
return hfile;
43 if (hfile)
return hfile;
49 printf(
"you must run the script in a directory with write access\n");
54 tree->Branch(
"Category",&Category,
"Category/I");
55 tree->Branch(
"Flag",&Flag,
"Flag/i");
56 tree->Branch(
"Age",&Age,
"Age/I");
57 tree->Branch(
"Service",&Service,
"Service/I");
58 tree->Branch(
"Children",&Children,
"Children/I");
59 tree->Branch(
"Grade",&Grade,
"Grade/I");
60 tree->Branch(
"Step",&Step,
"Step/I");
61 tree->Branch(
"Hrweek",&Hrweek,
"Hrweek/I");
62 tree->Branch(
"Cost",&Cost,
"Cost/I");
63 tree->Branch(
"Division",Division,
"Division/C");
64 tree->Branch(
"Nation",Nation,
"Nation/C");
66 while (fgets(
line,80,fp)) {
67 sscanf(&
line[0],
"%d %d %d %d %d %d %d %d %d %s %s",
68 &Category,&Flag,&Age,&Service,&Children,&Grade,&Step,&Hrweek,&Cost,Division,Nation);
71 if (print)
tree->Print();
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)