Logo ROOT  
Reference Guide
parallelMergeTest.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_net
3///
4/// \macro_code
5///
6/// \author
7
8#include "TMessage.h"
9#include "TBenchmark.h"
10#include "TSocket.h"
11#include "TH2.h"
12#include "TTree.h"
13#include "TFile.h"
14#include "TRandom.h"
15#include "TError.h"
16
17void parallelMergeTest(UInt_t nhist, UInt_t ndims = 1, UInt_t nbins = 100)
18{
19
20 gBenchmark->Start("parallelMergeTest");
21
22 TFile *file = TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
23
24 Float_t px, py;
25 TTree *tree = 0;
26 switch (ndims) {
27 case 1: {
28 for(UInt_t h = 0 ; h < nhist; ++h) {
29 new TH1F(TString::Format("hpx%d",h),"This is the px distribution",nbins,-4,4);
30 }
31 break;
32 }
33 case 2: {
34 for(UInt_t h = 0 ; h < nhist; ++h) {
35 new TH2F(TString::Format("hpxy%d",h),"py vs px",nbins,-4,4,nbins,-4,-4);
36 }
37 break;
38 }
39 case 99: {
40 tree = new TTree("tree","tree");
41 tree->SetAutoFlush(4000000);
42 tree->Branch("px",&px);
43 tree->Branch("py",&py);
44 }
45 }
46
47 // Fill histogram randomly
49 const int kUPDATE = 1000000;
50 for (int i = 0; i < 25000000; ) {
51// gRandom->Rannor(px,py);
52// if (idx%2 == 0)
53// hpx->Fill(px);
54// else
55// hpx->Fill(px,py);
56 if(tree) tree->Fill();
57 ++i;
58 if (i && (i%kUPDATE) == 0) {
59 file->Write();
60 }
61 }
62 file->Write();
63 delete file;
64
65 gBenchmark->Show("parallelMergeTest");
66}
#define h(i)
Definition: RSha256.hxx:106
unsigned int UInt_t
Definition: RtypesCore.h:42
float Float_t
Definition: RtypesCore.h:53
R__EXTERN TBenchmark * gBenchmark
Definition: TBenchmark.h:59
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
virtual void Start(const char *name)
Starts Benchmark with the specified name.
Definition: TBenchmark.cxx:174
virtual void Show(const char *name)
Stops Benchmark name and Prints results.
Definition: TBenchmark.cxx:157
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:48
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3923
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:251
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Definition: TRandom.cxx:597
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:2311
A TTree represents a columnar dataset.
Definition: TTree.h:72
Definition: file.py:1
Definition: tree.py:1