{	
	// load the shared library with the class definition
	// for Event.
 	gROOT->LoadMacro("$ROOTSYS/test/libEvent.so"); 

 	// Step1
	// create a TFile object, using RECREATE to 
	// overwrite if it exists 	
	TFile *hfile = new TFile("AFile.root","RECREATE","An Example ROOT file");

	// Step 2
	// create a TTree object with the name T, title : A ROOT tree, 
	// and the default buffer size of 64 MB
	TTree *tree = new TTree("T","A ROOT tree");
	
	// Step 3
	// create a branch object for the event object:
	event = new  Event();
	tree->Branch("EventBranch","Event",&event,64000,1);

	// Step 4
	// write a for loop to assigns values to create events and 
	// fill the tree with them.
	for (Int_t ev = 0; ev < 200; ev++) {
   	Float_t  sigmat, sigmas;
   	gRandom->Rannor(sigmat,sigmas);
   	Int_t   ntrack   = Int_t (600 + 600*sigmat/120.);
   	Float_t random   = gRandom->Rndm(1); 
   	event ->SetHeader      (ev, 200, 960312, random);
   	event ->SetNseg        (Int_t (6000+20*sigmas));
   	event ->SetNvertex     (1); 
   	event ->SetFlag(UInt_t (random +0.5));
   	event ->SetTemperature (random + 20.);
   	
		for (Int_t t = 0; t < ntrack; t++){
			event->AddTrack(random);
		} 
   	
		tree->Fill();   //fill the tree
   	
		event->GetTracks()->Clear();
	}

	// Step 5
	// write the file.
	hfile->Write();
}
	
	
	
	
		
