ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
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
mfile =
TMapFile::Create
(
"hsimple.map"
,
"RECREATE"
, 1000000,
22
"Demo memory mapped file with histograms"
);
23
24
// Create a 1d, a 2d and a profile histogram. These objects will
25
// be automatically added to the current directory, i.e. mfile.
26
hpx =
new
TH1F(
"hpx"
,
"This is the px distribution"
,100,-4,4);
27
hpxpy =
new
TH2F
(
"hpxpy"
,
"py vs px"
,40,-4,4,40,-4,4);
28
hprof =
new
TProfile
(
"hprof"
,
"Profile of pz versus px"
,100,-4,4,0,20);
29
30
// Set a fill color for the TH1F
31
hpx->SetFillColor(48);
32
33
// Print status of mapped file
34
mfile->Print();
35
36
// Endless loop filling histograms with random numbers
37
Float_t
px, py, pz;
38
int
ii = 0;
39
while
(1) {
40
gRandom
->Rannor(px,py);
41
pz = px*px + py*py;
42
hpx->Fill(px);
43
hpxpy->Fill(px,py);
44
hprof->Fill(px,pz);
45
if
(!(ii % 10)) {
46
mfile->Update();
// updates all objects in shared memory
47
if
(!ii) mfile->ls();
// print contents of mapped file after
48
}
// first update
49
ii++;
50
}
51
}
Float_t
float Float_t
Float 4 bytes (float).
Definition
RtypesCore.h:71
gROOT
#define gROOT
Definition
TROOT.h:417
gRandom
externTRandom * gRandom
Definition
TRandom.h:62
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:878
TH2F
2-D histogram with a float per channel (see TH1 documentation)
Definition
TH2.h:345
TMapFile::Create
static TMapFile * Create(const char *name, Option_t *option="READ", Int_t size=kDefaultMapSize, const char *title="")
Create a memory mapped file.
Definition
TMapFile.cxx:1171
TProfile
Profile Histogram.
Definition
TProfile.h:32
hist015_TH1_read_and_draw_uhi.hpx
hpx
Definition
hist015_TH1_read_and_draw_uhi.py:30
tutorials
legacy
net
hprod.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1