43void CreateParentTree() {
48 T->Branch(
"Run",&Run,
"Run/I");
49 T->Branch(
"Event",&
Event,
"Event/I");
50 T->Branch(
"x",&
x,
"x/F");
51 T->Branch(
"y",&
y,
"y/F");
52 T->Branch(
"z",&z,
"z/F");
54 for (
Int_t i=0;i<10000;i++) {
55 if (i < 5000) Run = 1;
67void CreateFriendTree() {
76 TFile *ff =
new TFile(
"treefriend.root",
"recreate");
77 TTree *TF =
T->CopyTree(
"z<10");
96 T->SetBranchAddress(
"Run",&Run);
97 T->SetBranchAddress(
"Event",&
Event);
98 T->SetBranchAddress(
"x",&
x);
99 T->SetBranchAddress(
"y",&
y);
100 T->SetBranchAddress(
"z",&z);
112 if (fRun == Run && fEvent==
Event &&
x==fx &&
y==
fy &&z==fz) {
116 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);
120 printf(
"nok = %d, fentries=%lld\n",nok,TF->
GetEntries());
133 T->AddFriend(
"TF",
"treefriend.root");
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 ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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.
void Print(Option_t *option="") const override
Print a summary of the tree contents.
virtual Int_t BuildIndex(const char *majorname, const char *minorname="0")
Build a Tree Index (default is TTreeIndex).
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.
void SetName(const char *name) override
Change the name of this tree.