******************************************************************************
*Tree :T : test friend trees *
*Entries : 10000 : Total = 203762 bytes File Size = 94821 *
* : : Tree compression factor = 1.69 *
******************************************************************************
*Br 0 :Run : Run/I *
*Entries : 10000 : Total Size= 40698 bytes File Size = 265 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 120.75 *
*............................................................................*
*Br 1 :Event : Event/I *
*Entries : 10000 : Total Size= 40712 bytes File Size = 11231 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 2.85 *
*............................................................................*
*Br 2 :x : x/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 27116 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.18 *
*............................................................................*
*Br 3 :y : y/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 27035 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.18 *
*............................................................................*
*Br 4 :z : z/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 29174 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.10 *
*............................................................................*
******************************************************************************
*Tree :TF : test friend trees *
*Entries : 8460 : Total = 375780 bytes File Size = 128540 *
* : : Tree compression factor = 1.69 *
******************************************************************************
*Br 0 :Run : Run/I *
*Entries : 8460 : Total Size= 34463 bytes File Size = 374 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 90.84 *
*............................................................................*
*Br 1 :Event : Event/I *
*Entries : 8460 : Total Size= 34475 bytes File Size = 12152 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 2.80 *
*............................................................................*
*Br 2 :x : x/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 28849 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.18 *
*............................................................................*
*Br 3 :y : y/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 28757 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.18 *
*............................................................................*
*Br 4 :z : z/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 30674 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.11 *
*............................................................................*
nok = 8460, fentries=8460
void CreateParentTree() {
T->Branch("Run",&Run,"Run/I");
T->Branch(
"Event",&
Event,
"Event/I");
T->Branch("z",&z,"z/F");
for (
Int_t i=0;i<10000;i++) {
if (i < 5000) Run = 1;
else Run = 2;
T->Fill();
}
T->Print();
T->Write();
}
void CreateFriendTree() {
TFile *ff =
new TFile(
"treefriend.root",
"recreate");
TTree *TF =
T->CopyTree(
"z<10");
delete ff;
}
void CompareTrees() {
T->SetBranchAddress(
"Run",&Run);
T->SetBranchAddress(
"Event",&
Event);
T->SetBranchAddress(
"x",&
x);
T->SetBranchAddress(
"y",&
y);
T->SetBranchAddress(
"z",&z);
if (fRun == Run && fEvent==
Event &&
x==fx &&
y==fy &&z==fz) {
nok++;
} else {
if (i <100) printf(
"i=%lld, Run=%d, Event=%d, x=%g, y=%g, z=%g, : fRun=%d, fEvent=%d, fx=%g, fy=%g, fz=%g\n",i,Run,
Event,
x,
y,z,fRun,fEvent,fx,fy,fz);
}
}
}
printf(
"nok = %d, fentries=%lld\n",nok,TF->
GetEntries());
delete ff;
}
void DrawFriend() {
T->AddFriend(
"TF",
"treefriend.root");
}
void treefriend() {
CreateParentTree();
CreateFriendTree();
CompareTrees();
DrawFriend();
}
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
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.
This is the base class for the ROOT Random number generators.
A TTree represents a columnar dataset.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
virtual Int_t BuildIndex(const char *majorname, const char *minorname="0")
Build a Tree Index (default is TTreeIndex).
virtual Long64_t GetEntries() const
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
virtual Int_t GetEntryWithIndex(Int_t major, Int_t minor=0)
Read entry corresponding to major and minor number.
virtual void SetName(const char *name)
Change the name of this tree.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.