Logo ROOT   6.18/05
Reference Guide
parallelMergeClient.C File Reference

Detailed Description

Client program which creates and fills 2 histograms and a TTree.

Every 1000000 fills the histograms and TTree is send to the server which displays the histogram.

To run this demo do the following:

#include "TMessage.h"
#include "TBenchmark.h"
#include "TSocket.h"
#include "TH2.h"
#include "TTree.h"
#include "TRandom.h"
#include "TError.h"
void parallelMergeClient()
{
gBenchmark->Start("treeClient");
TParallelMergingFile *file = (TParallelMergingFile*)TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
file->Write();
file->UploadAndReset(); // We do this early to get assigned an index.
UInt_t idx = file->fServerIdx; // This works on in ACLiC.
TH1 *hpx;
if (idx%2 == 0) {
// Create the histogram
hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
hpx->SetFillColor(48); // set nice fill-color
} else {
hpx = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
}
Float_t px, py;
TTree *tree = new TTree("tree","tree");
tree->SetAutoFlush(4000000);
tree->Branch("px",&px);
tree->Branch("py",&py);
// Fill histogram randomly
const int kUPDATE = 1000000;
for (int i = 0; i < 25000000; ) {
gRandom->Rannor(px,py);
if (idx%2 == 0)
hpx->Fill(px);
else
hpx->Fill(px,py);
tree->Fill();
++i;
if (i && (i%kUPDATE) == 0) {
file->Write();
}
}
file->Write();
delete file;
gBenchmark->Show("treeClient");
}
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 SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
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
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseGeneralPurpose, Int_t netopt=0)
Create / open a file.
Definition: TFile.cxx:3980
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:571
The TH1 histogram class.
Definition: TH1.h:56
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3258
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:248
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
Definition: TRandom.cxx:597
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:489
A TTree represents a columnar dataset.
Definition: TTree.h:71
Definition: file.py:1
Definition: tree.py:1
Authors
Fons Rademakers, Philippe Canal

Definition in file parallelMergeClient.C.