File: circular.C

package info (click to toggle)
root-system 5.34.00-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 190,532 kB
  • sloc: cpp: 1,401,904; ansic: 217,182; xml: 25,899; sh: 19,215; fortran: 12,570; python: 7,311; makefile: 7,216; ruby: 553; csh: 317; objc: 88; perl: 85; sql: 14; tcl: 4
file content (27 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//  Example of a circular Tree
//  Circular Trees are interesting in online real time environments
//  to store the results of the last maxEntries events.
//  for more info, see TTree::SetCircular
// Author: Rene Brun
void circular() {
   gROOT->cd(); //make sure that the Tree is memory resident
   TTree *T = new TTree("T","test circular buffers");
   TRandom r;
   Float_t px,py,pz;
   Double_t random;
   UShort_t i;
   T->Branch("px",&px,"px/F");
   T->Branch("py",&py,"px/F");
   T->Branch("pz",&pz,"px/F");
   T->Branch("random",&random,"random/D");
   T->Branch("i",&i,"i/s");
   T->SetCircular(20000); //keep a maximum of 20000 entries in memory
   for (i = 0; i < 65000; i++) {
      r.Rannor(px,py);
      pz = px*px + py*py;
      random = r.Rndm();
      T->Fill();
   }
   T->Print();
}