ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
circular.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_tree
3 ///
4 /// Example of a circular Tree
5 ///
6 /// Circular Trees are interesting in online real time environments
7 /// to store the results of the last maxEntries events.
8 /// for more info, see TTree::SetCircular.
9 /// Circular trees must be memory resident.
10 /// \macro_code
11 /// \author Rene Brun
12 void circular() {
13  auto T = new TTree("T","test circular buffers");
14  TRandom r;
15  Float_t px,py,pz;
17  UShort_t i;
18  T->Branch("px",&px,"px/F");
19  T->Branch("py",&py,"px/F");
20  T->Branch("pz",&pz,"px/F");
21  T->Branch("random",&random,"random/D");
22  T->Branch("i",&i,"i/s");
23  T->SetCircular(20000); //keep a maximum of 20000 entries in memory
24  for (i = 0; i < 65000; i++) {
25  r.Rannor(px,py);
26  pz = px*px + py*py;
27  random = r.Rndm();
28  T->Fill();
29  }
30  T->Print();
31 }
32 
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition: TRandom.cxx:460
Float_t pz
Definition: hprod.C:33
tuple random
Definition: hsimple.py:62
float Float_t
Definition: RtypesCore.h:53
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition: TRandom.cxx:512
unsigned short UShort_t
Definition: RtypesCore.h:36
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4306
Float_t py
Definition: hprod.C:33
TTree * T
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
Definition: TTree.cxx:6495
This is the base class for the ROOT Random number generators.
Definition: TRandom.h:29
ROOT::R::TRInterface & r
Definition: Object.C:4
double Double_t
Definition: RtypesCore.h:55
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
Definition: TTree.cxx:1623
Float_t px
Definition: hprod.C:33
virtual void SetCircular(Long64_t maxEntries)
Enable/Disable circularity for this tree.
Definition: TTree.cxx:7990
A TTree object has a header with a name and a title.
Definition: TTree.h:98