******************************************************************************
*Tree :T : test friend trees *
*Entries : 10000 : Total = 203762 bytes File Size = 100357 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :Run : Run/I *
*Entries : 10000 : Total Size= 40698 bytes File Size = 262 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 122.13 *
*............................................................................*
*Br 1 :Event : Event/I *
*Entries : 10000 : Total Size= 40712 bytes File Size = 17634 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.81 *
*............................................................................*
*Br 2 :x : x/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 26767 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.20 *
*............................................................................*
*Br 3 :y : y/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 26662 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.20 *
*............................................................................*
*Br 4 :z : z/F *
*Entries : 10000 : Total Size= 40684 bytes File Size = 29032 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.10 *
*............................................................................*
******************************************************************************
*Tree :TF : test friend trees *
*Entries : 8460 : Total = 375780 bytes File Size = 144992 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :Run : Run/I *
*Entries : 8460 : Total Size= 34463 bytes File Size = 371 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 91.57 *
*............................................................................*
*Br 1 :Event : Event/I *
*Entries : 8460 : Total Size= 34475 bytes File Size = 18880 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.80 *
*............................................................................*
*Br 2 :x : x/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 28500 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.19 *
*............................................................................*
*Br 3 :y : y/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 28389 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 1.20 *
*............................................................................*
*Br 4 :z : z/F *
*Entries : 8460 : Total Size= 34451 bytes File Size = 30521 *
*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");
else Run = 2;
T->Fill();
}
T->Print();
T->Write();
}
void CreateFriendTree() {
TFile *ff =
new TFile(
"treefriend.root",
"recreate");
delete ff;
}
void CompareTrees() {
T->SetBranchAddress("Run",&Run);
T->SetBranchAddress(
"Event",&
Event);
T->SetBranchAddress(
"x",&
x);
T->SetBranchAddress(
"y",&
y);
T->SetBranchAddress("z",&z);
T->AddFriend(TF);
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");
T->Draw("x:TF.x");
}
void treefriend() {
CreateParentTree();
CreateFriendTree();
CompareTrees();
DrawFriend();
}
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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 TTree * CopyTree(const char *selection, Option_t *option="", Long64_t nentries=kMaxEntries, Long64_t firstentry=0)
Copy a tree with selection.
void Print(Option_t *option="") const override
Print a summary of the tree contents.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=nullptr)
Change branch address, dealing with clone trees properly.
virtual Long64_t GetEntries() const
virtual Int_t GetEntryWithIndex(Int_t major, Int_t minor=0)
Read entry corresponding to major and minor number.
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
Write this object to the current directory.
virtual Int_t BuildIndex(const char *majorname, const char *minorname="0", bool long64major=false, bool long64minor=false)
Build a Tree Index (default is TTreeIndex).
void SetName(const char *name) override
Change the name of this tree.