******************************************************************************
*Tree :T : test friend trees *
*Entries : 10000 : Total = 203762 bytes File Size = 100358 *
* : : 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 = 17635 *
*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 = 144998 *
* : : Tree compression factor = 1.59 *
******************************************************************************
*Br 0 :Run : Run/I *
*Entries : 8460 : Total Size= 34463 bytes File Size = 370 *
*Baskets : 2 : Basket Size= 32000 bytes Compression= 91.82 *
*............................................................................*
*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()
{
auto T =
new TTree(
"T",
"test friend trees");
T->Branch("Run", &Run, "Run/I");
T->Branch(
"Event", &
Event,
"Event/I");
T->Branch(
"x", &
x,
"x/F");
T->Branch(
"y", &
y,
"y/F");
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()
{
auto TF = T->CopyTree("z<10");
TF->SetName("TF");
TF->BuildIndex("Run", "Event");
TF->Write();
TF->Print();
delete ff;
}
void CompareTrees()
{
auto TF = ff->Get<
TTree>(
"TF");
T->SetBranchAddress(
"Event", &
Event);
T->SetBranchAddress(
"x", &
x);
T->SetBranchAddress(
"y", &
y);
T->SetBranchAddress("z", &z);
TF->SetBranchAddress("Run", &fRun);
TF->SetBranchAddress("Event", &fEvent);
TF->SetBranchAddress("x", &fx);
TF->SetBranchAddress("y", &fy);
TF->SetBranchAddress("z", &fz);
T->AddFriend(TF);
T->GetEntry(i);
if (fRun == Run && fEvent==
Event &&
x==fx &&
y==fy && z==fz) {
nok++;
} else {
if (TF->GetEntryWithIndex(Run,
Event) > 0) {
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()
{
}
void tree109_friend()
{
CreateParentTree();
CreateFriendTree();
CompareTrees();
DrawFriend();
}
int Int_t
Signed integer 4 bytes (int)
float Float_t
Float 4 bytes (float)
long long Long64_t
Portable signed long integer 8 bytes.
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
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 void Draw(Option_t *option="")
Default Draw method for all objects.
This is the base class for the ROOT Random number generators.
A TTree represents a columnar dataset.
virtual TFriendElement * AddFriend(const char *treename, const char *filename="")
Add a TFriendElement to the list of friends.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr, TClass *realClass, EDataType datatype, bool isptr, bool suppressMissingBranchError)