Histogram producer script.
This script creates a memory mapped file and stores three histogram objects in it (a TH1F, a TH2F and a TProfile). It then fills, in an infinite loop (so use ctrl-c to stop this script), the three histogram objects with random numbers. Every 10 fills the objects are updated in shared memory. Use the hcons.C script to map this file and display the histograms.
{
"Demo memory mapped file with histograms");
hpx =
new TH1F(
"hpx",
"This is the px distribution",100,-4,4);
hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
hprof =
new TProfile(
"hprof",
"Profile of pz versus px",100,-4,4,0,20);
hpx->SetFillColor(48);
mfile->Print();
int ii = 0;
while (1) {
pz = px*px + py*py;
hpx->Fill(px);
hpxpy->Fill(px,py);
hprof->Fill(px,pz);
if (!(ii % 10)) {
mfile->Update();
if (!ii) mfile->ls();
}
ii++;
}
}
R__EXTERN TRandom * gRandom
1-D histogram with a float per channel (see TH1 documentation)
2-D histogram with a float per channel (see TH1 documentation)
static TMapFile * Create(const char *name, Option_t *option="READ", Int_t size=kDefaultMapSize, const char *title="")
Create a memory mapped file.
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
- Author
- Fons Rademakers
Definition in file hprod.C.