11 TFile *cernbuild(Int_t getFile=0, Int_t print=1) {
27 TString filename =
"cernstaff.root";
28 TString dir = gROOT->GetTutorialDir();
30 dir.ReplaceAll(
"/./",
"/");
31 FILE *fp = fopen(Form(
"%scernstaff.dat",dir.Data()),
"r");
37 if (!gSystem->AccessPathName(dir+
"cernstaff.root",kFileExists)) {
38 hfile = TFile::Open(dir+
"cernstaff.root");
39 if (hfile)
return hfile;
42 if (!gSystem->AccessPathName(
"cernstaff.root",kFileExists)) {
43 hfile = TFile::Open(
"cernstaff.root");
44 if (hfile)
return hfile;
49 if (gSystem->AccessPathName(
".",kWritePermission)) {
50 printf(
"you must run the script in a directory with write access\n");
53 hfile = TFile::Open(filename,
"RECREATE");
54 TTree *tree =
new TTree(
"T",
"CERN 1988 staff data");
55 tree->Branch(
"Category",&Category,
"Category/I");
56 tree->Branch(
"Flag",&Flag,
"Flag/i");
57 tree->Branch(
"Age",&Age,
"Age/I");
58 tree->Branch(
"Service",&Service,
"Service/I");
59 tree->Branch(
"Children",&Children,
"Children/I");
60 tree->Branch(
"Grade",&Grade,
"Grade/I");
61 tree->Branch(
"Step",&Step,
"Step/I");
62 tree->Branch(
"Hrweek",&Hrweek,
"Hrweek/I");
63 tree->Branch(
"Cost",&Cost,
"Cost/I");
64 tree->Branch(
"Division",Division,
"Division/C");
65 tree->Branch(
"Nation",Nation,
"Nation/C");
67 while (fgets(line,80,fp)) {
68 sscanf(&line[0],
"%d %d %d %d %d %d %d %d %d %s %s",
69 &Category,&Flag,&Age,&Service,&Children,&Grade,&Step,&Hrweek,&Cost,Division,Nation);
72 if (print) tree->Print();
79 hfile = TFile::Open(filename);