Example to write & read a Tree built with a complex class inheritance tree. 
It demonstrates usage of inheritance and TClonesArrays This is simplified / stripped extract of an event structure which was used within the Marabou project.
To run this example, do: 
  
#ifndef CLONESA_EVENT_SECOND_RUN
 
{
   gROOT->ProcessLine(
TString(
".L ") + dir + 
"/clones_event.cxx+");
 
#define CLONESA_EVENT_SECOND_RUN yes
   gROOT->ProcessLine(
"tree131_clones_event(true)");
 
}
 
#else
 
{
   
   if ( 
gROOT->GetVersionInt() < 30503 ) {
 
      std::cout << "Works only with ROOT version >= 3.05/03" << std::endl;
      return;
   }
   if ( 
gROOT->GetVersionDate() < 20030406 ) {
 
      std::cout << "Works only with ROOT CVS version after 5. 4. 2003" << std::endl;
      return;
   }
 
   
   auto TTree("clones_event", "An example of a ROOT tree");
   event1, 8000, 99);
   event2, 8000, 99);
      std::cout << 
"event " << 
ev << std::endl;
 
      tree->Fill();
         ev);
   }
   tree->Write();
   tree->Print();
}
 
{
   
   auto TTree>("clones_event");
 
   event1);
   event2);
      ev);
      std::cout << 
"Pileup event1: " <<  
event1->GetPileup() << std::endl;
 
      std::cout << 
"Pileup event2: " <<  
event2->GetPileup() << std::endl;
 
      
   }
}
 
{
   
   
   
}
 
#endif
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
R__EXTERN TSystem * gSystem
 
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.
 
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
 
A TTree represents a columnar dataset.
 
- Author
 - The ROOT Team 
 
Definition in file tree131_clones_event.C.