This example writes a tree with objects of the class Event. 
It is a simplified version of $ROOTSYS/test/MainEvent.cxx to write the tree, and $ROOTSYS/test/eventb.C It shows:
- how to fill a Tree with an event class containing these data members: 
char           fType[20];
EventHeader    fEvtHdr;
An array of clone (identical) objects.
 
1-D histogram with a float per channel (see TH1 documentation)
 
 
- the difference in splitting or not splitting a branch
 
- how to read selected branches of the tree, and print the first entry with less than 587 tracks.
 
- how to browse and analyze the Tree via the TBrowser and TTreeViewer
 
This example can be run in many different ways:
- way1 using the Cling interpreter: 
 
- way2 using the Cling interpreter: 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
  
- way3 using ACLIC:  One can also run the write and read parts in two separate sessions. For example following one of the sessions above, one can start the session:  
 
 
#include "TFile.h"
#include "../test/Event.h"
 
{
 
  
  TFile f(
"tree4.root",
"RECREATE");
 
 
  
  TTree t4(
"t4",
"A Tree with Events");
 
 
  
 
  
  t4.Branch(
"event_split", &event,16000,99);
 
  t4.Branch(
"event_not_split", &event,16000,0);
 
 
  
  char etype[20];
 
  
    event->SetType(etype);
    event->SetHeader(
ev, 200, 960312, 
random);
 
    event->SetTemperature(
random+20.);
 
 
    }
 
    
      }
    }
 
    
 
    
 
    
    event->Clear();
  }
 
  
 
  
}
 
 
{
  
 
  
  
 
  
  
 
  
 
    
 
    
    if (event->GetNtrack() > 587)continue;
 
    
 
    
 
    
    event->Clear();
  }
 
  if (
gROOT->IsBatch()) 
return;
 
}
 
   Event::Reset(); 
   Event::Reset(); 
}
#define R__LOAD_LIBRARY(LIBRARY)
 
R__EXTERN TRandom * gRandom
 
A TTree is a list of TBranches.
 
Using a TBrowser one can browse all ROOT objects.
 
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
 
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
 
Double_t Rndm() override
Machine independent random number generator.
 
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
 
A TTree represents a columnar dataset.
 
 
- Author
 - Rene Brun 
 
Definition in file tree4.C.