#include "TROOT.h" #include "TTree.h" #include "TFile.h" #include "TRandom.h" #include "TBranch.h" #include #include #include "mydict.h" int main(int argc, char **argv){ TROOT root("Root","The ROOT job"); //split=0 create a single branch corresponding to the object. //if split=1 the tree will be splitted in branches corresponding to each member of the object Int_t split = 0; Int_t bsize = 256000; //create a V4 V4 and particle objects MyClass *myc = new MyClass(); //output file TFile *f = new TFile("tree.root","recreate"); // Create a ROOT Tree and 3 superbranches TTree *tree = new TTree("T","An example of ROOT tree"); //tree->Branch("myclass","MyClass",&myc,bsize,split); tree->Bronch("myclass","MyClass",&myc,bsize,split); //Fill the objects fprintf(stderr,"Entering Loop\n"); for (Int_t i=0;i<1000;i++) { Float_t sigmat, sigmas; gRandom->Rannor(sigmat,sigmas); Float_t random = gRandom->Rndm(1); myc->SetX(i); myc->SetY(i+2); myc->SetZ(i*2); //fill the tree tree->Fill(); } //write stdout the tree structure tree->Print(); //write tree to the file tree->Write(); //close file f->Close(); return 0; }