Example of a Tree where branches are variable length arrays A second Tree is created and filled in parallel.
Run this script with
In the function treer, the first Tree is open. The second Tree is declared friend of the first tree. TTree::Draw is called with variables from both Trees.
void tree3w() {
const Int_t kMaxTrack = 500;
TFile f(
"tree3.root",
"recreate");
t3->
Branch(
"ntrack",&ntrack,
"ntrack/I");
t3->
Branch(
"stat",stat,
"stat[ntrack]/I");
t3->
Branch(
"sign",sign,
"sign[ntrack]/I");
t3->
Branch(
"px",px,
"px[ntrack]/F");
t3->
Branch(
"py",py,
"py[ntrack]/F");
t3->
Branch(
"pz",pz,
"pz[ntrack]/F");
t3->
Branch(
"zv",zv,
"zv[ntrack]/F");
t3->
Branch(
"chi2",chi2,
"chi2[ntrack]/F");
TFile fr(
"tree3f.root",
"recreate");
t3f->
Branch(
"ntrack",&ntrack,
"ntrack/I");
t3f->
Branch(
"sumstat",&sumstat,
"sumstat/D");
for (
Int_t i=0;i<1000;i++) {
ntrack = nt;
sumstat = 0;
}
}
fr.cd();
}
void tree3r()
{
}
void tree3r2()
{
TPad *
p =
new TPad(
"p",
"p",0.6, 0.4, 0.98, 0.8);
}
void tree3()
{
tree3w();
tree3r();
tree3r2();
}
winID h TVirtualViewer3D TVirtualGLPainter p
R__EXTERN TRandom * gRandom
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
The most important graphics class in the ROOT system.
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Double_t Rndm() override
Machine independent random number generator.
A TTree represents a columnar dataset.
virtual Int_t Fill()
Fill all branches.
virtual TFriendElement * AddFriend(const char *treename, const char *filename="")
Add a TFriendElement to the list of friends.
void Draw(Option_t *opt) override
Default Draw method for all objects.
void Print(Option_t *option="") const override
Print a summary of the tree contents.
TBranch * Branch(const char *name, T *obj, Int_t bufsize=32000, Int_t splitlevel=99)
Add a new branch, and infer the data type from the type of obj being passed.
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) override
Write this object to the current directory.
Double_t Sqrt(Double_t x)
Returns the square root of x.
- Author
- Rene Brun
Definition in file tree3.C.