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");
virtual TObject * Get(const char *namecycle)
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::kUseGeneralPurpose, 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.