ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
hprod.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_net
3
/// Histogram producer script. This script creates a memory mapped
4
/// file and stores three histogram objects in it (a TH1F, a TH2F and a
5
/// TProfile). It then fills, in an infinite loop (so use ctrl-c to
6
/// stop this script), the three histogram objects with random numbers.
7
/// Every 10 fills the objects are updated in shared memory.
8
/// Use the hcons.C script to map this file and display the histograms.
9
///
10
/// \macro_code
11
///
12
/// \author Fons Rademakers
13
14
{
15
gROOT->Reset();
16
17
// Create a new memory mapped file. The memory mapped file can be
18
// opened in an other process on the same machine and the objects
19
// stored in it can be accessed.
20
21
TMapFile::SetMapAddress(0xb46a5000);
22
mfile = TMapFile::Create(
"hsimple.map"
,
"RECREATE"
, 1000000,
23
"Demo memory mapped file with histograms"
);
24
25
// Create a 1d, a 2d and a profile histogram. These objects will
26
// be automatically added to the current directory, i.e. mfile.
27
hpx =
new
TH1F(
"hpx"
,
"This is the px distribution"
,100,-4,4);
28
hpxpy =
new
TH2F(
"hpxpy"
,
"py vs px"
,40,-4,4,40,-4,4);
29
hprof =
new
TProfile(
"hprof"
,
"Profile of pz versus px"
,100,-4,4,0,20);
30
31
// Set a fill color for the TH1F
32
hpx->SetFillColor(48);
33
34
// Print status of mapped file
35
mfile->Print();
36
37
// Endless loop filling histograms with random numbers
38
Float_t px, py, pz;
39
int
ii = 0;
40
while
(1) {
41
gRandom->Rannor(px,py);
42
pz = px*px + py*py;
43
hpx->Fill(px);
44
hpxpy->Fill(px,py);
45
hprof->Fill(px,pz);
46
if
(!(ii % 10)) {
47
mfile->Update();
// updates all objects in shared memory
48
if
(!ii) mfile->ls();
// print contents of mapped file after
49
}
// first update
50
ii++;
51
}
52
}
tutorials
net
hprod.C
Generated on Tue May 5 2020 14:03:47 for ROOT by
1.8.5