Root tutorial codes vs manual are different!

ROOT Version: 6.12
Platform: Not Provided
Compiler: Not Provided


the codes given in the tutorial manual and the actual codes doesn’t seem to match.

For example,

in section 12.2 A simple tree, there is a code staff.C which is given as

   // example of macro to read data from an ascii file and
   // create a root file with an histogram and a TTree

   // the structure to hold the variables for the branch

   struct staff_t {
      Int_t cat;
      Int_t division;
      Int_t flag;
      Int_t age;
      Int_t service;
      Int_t children;
      Int_t grade;
      Int_t step;
      Int_t nation;
      Int_t hrweek;
      Int_t cost;
   staff_t staff;
   // continued...
   // open the ASCII file
   FILE *fp = fopen("staff.dat","r");
   char line[81];
   // create a new ROOT file
   TFile *f = new TFile("staff.root","RECREATE");
   // create a TTree
   TTree *tree = new TTree("T","staff data from ascii file");
   // create one branch with all information from the stucture
   // fill the tree from the values in ASCII file
   while (fgets(&line,80,fp)) {
   // check what the tree looks like

however in the actual code located in “$ROOTSYS/tutorials/tree”, the code is given as

void staff() {
   auto f = TFile::Open("cernstaff.root");
   TTree *T = nullptr;
   if (gPad) gPad->Print("staff.C.png");

why are the codes different? where can I find the first code?
I also gave a look at the cernstaff.C code but it seems to be another different code…

please help, thanks!

The users’ guide is not updated with the same frequency as the main repository of ROOT. Please access the website if you would like to see the latest version of the code. For ROOT 6, you can look up the documentation here. You can see the same tutorial for the latest release of ROOT 5 here, which is more similar to the version you want. Cheers,

staff.C creates a plot of the data in cernstaff.root To create cernstaff.root , execute tutorial $ROOTSYS/tutorials/tree/cernbuild.C

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.