ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
parallelMergeTest.C
Go to the documentation of this file.
1 #include "TMessage.h"
2 #include "TBenchmark.h"
3 #include "TSocket.h"
4 #include "TH2.h"
5 #include "TTree.h"
6 #include "TFile.h"
7 #include "TRandom.h"
8 #include "TError.h"
9 
10 void parallelMergeTest(UInt_t nhist, UInt_t ndims = 1, UInt_t nbins = 100)
11 {
12 
13  gBenchmark->Start("parallelMergeTest");
14 
15  TFile *file = TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
16 
17  Float_t px, py;
18  TTree *tree = 0;
19  switch (ndims) {
20  case 1: {
21  for(UInt_t h = 0 ; h < nhist; ++h) {
22  new TH1F(TString::Format("hpx%d",h),"This is the px distribution",nbins,-4,4);
23  }
24  break;
25  }
26  case 2: {
27  for(UInt_t h = 0 ; h < nhist; ++h) {
28  new TH2F(TString::Format("hpxy%d",h),"py vs px",nbins,-4,4,nbins,-4,-4);
29  }
30  break;
31  }
32  case 99: {
33  tree = new TTree("tree","tree");
34  tree->SetAutoFlush(4000000);
35  tree->Branch("px",&px);
36  tree->Branch("py",&py);
37  }
38  }
39 
40  // Fill histogram randomly
41  gRandom->SetSeed();
42  const int kUPDATE = 1000000;
43  for (int i = 0; i < 25000000; ) {
44 // gRandom->Rannor(px,py);
45 // if (idx%2 == 0)
46 // hpx->Fill(px);
47 // else
48 // hpx->Fill(px,py);
49  if(tree) tree->Fill();
50  ++i;
51  if (i && (i%kUPDATE) == 0) {
52  file->Write();
53  }
54  }
55  file->Write();
56  delete file;
57 
58  gBenchmark->Show("parallelMergeTest");
59 }
float Float_t
Definition: RtypesCore.h:53
void parallelMergeTest(UInt_t nhist, UInt_t ndims=1, UInt_t nbins=100)
virtual Int_t Fill()
Fill all branches.
Definition: TTree.cxx:4306
TH1 * h
Definition: legend2.C:5
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:155
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
int nbins[3]
Float_t py
Definition: hprod.C:33
virtual void SetSeed(UInt_t seed=0)
Set the random generator seed.
Definition: TRandom.cxx:568
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=1, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3851
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:172
virtual void SetAutoFlush(Long64_t autof=-30000000)
This function may be called at the start of a program to change the default value for fAutoFlush...
Definition: TTree.cxx:7382
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2321
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
Definition: TFile.cxx:2248
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:63
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
unsigned int UInt_t
Definition: RtypesCore.h:42
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
tuple tree
Definition: tree.py:24
tuple file
Definition: fildir.py:20
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
A TTree object has a header with a name and a title.
Definition: TTree.h:98