Hi all, I attach to this mail the file hprod.cxx which create a big share memory and put several TH1F in it. It compiles and works with ROOT 3.0 on Linux PC (Suse 7.0) but I cannot open the share memory in root interactively (segfault). Any idea? Many thanks in advance for any help Laurent Mirabito IPN Lyon // @(#)root/test:$Name: $:$Id: hsimple.cxx,v 1.2 2000/07/11 18:05:26 rdm Exp $ // Author: Rene Brun 19/08/96 //*-*-*-*-*-*-*Simple examples with histograms created/filled and saved*-*-*-* //*-* ======================================================== //*-* //*-* This program creates : //*-* - a one dimensional histogram //*-* - a two dimensional histogram //*-* - a profile histogram //*-* - an ntuple //*-* //*-* These objects are filled with some random numbers and saved on a file. //*-* //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* int hsimple(); #ifndef __CINT__ #include "TROOT.h" #include "TFile.h" #include "TH1.h" #include "TH2.h" #include "TProfile.h" #include "TMapFile.h" #include "TNtuple.h" #include "TRandom.h" int hproducer(); //______________________________________________________________________________ int main() { TROOT simple("simple","Test of histogramming and I/O"); return hproducer(); } #endif int hproducer() { // Create a new ROOT binary machine independent file. // Note that this file may contain any kind of ROOT objects, histograms, // pictures, graphics objects, detector geometries, tracks, events, etc.. // This file is now becoming the current directory. // TFile hfile("hsimple.root","RECREATE","Demo ROOT file with histograms"); TMapFile* mfile = TMapFile::Create("hsimple.map","RECREATE", 4000000, "Demo memory mapped file with histograms"); // Create some histograms, a profile histogram and an ntuple TH1F* hpx[100]; for (Int_t i=0;i<100;i++) { char cmd[100]; sprintf(cmd,"hpx%.2d",i); hpx[i] = new TH1F(cmd,"This is the px distribution",1000,-4,4); } TH2F *hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4); TProfile *hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20); mfile->Print(); // Fill histograms randomly Float_t px, py, pz; Int_t ii=0; while(1) { gRandom->Rannor(px,py); //px and py will be two gaussian random numbers pz = px*px + py*py; Float_t random = gRandom->Rndm(1); for (Int_t j=0;j<100;j++) hpx[j]->Fill(px); hpxpy->Fill(px,py); hprof->Fill(px,pz); if (!(ii % 10)) { mfile->Update(); // updates all objects in shared memory if (!ii) mfile->ls(); // print contents of mapped file after } // first update ii++; } // Save all objects in this file return 0; }
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET