Directory structure in map file.

From: Stanislav Terechtchenko (Stanislav.Terechtchenko@cern.ch)
Date: Sun Jun 06 1999 - 19:14:25 MEST


	Hi Rooters!
 Is it any way to create directory structure (with for example
histograms) inside the map file and navigate it with root browser?
It looks like it's not allowed by TMapFile.
 Look at this macro (slightly changed hprod.C example):

{
   // 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.
 
   gROOT->Reset();
 
   // Create a new memory mapped file. The memory mapped file can be
   // opened in an other process on the same machine and the objects
   // stored in it can be accessed.
 

   mfile = TMapFile::Create("hsimple.map","RECREATE", 100000,
                            "Demo memory mapped file with histograms");
 
   mfile->cd();

   gDirectory->mkdir("Dir1");
   gDirectory->cd("Dir1");
   hpx    = new TH1F("hpx","This is the px distribution",100,-4,4);

   gDirectory->mkdir("Dir2");
   gDirectory->cd("Dir2");
   hpxpy  = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);

   gDirectory->mkdir("Dir3");
   gDirectory->cd("Dir3");
   hprof  = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20);
 
   // Set a fill color for the TH1F
   hpx->SetFillColor(48);
 
   // Print status of mapped file
   mfile->Print();
 
   // Endless loop filling histograms with random numbers
   Float_t px, py, pz;
   int ii = 0;
//   while (1) {
   while(ii < 10000) {
      gRandom->Rannor(px,py);
      pz = px*px + py*py;
      hpx->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++;
   }
   TBrowser *tb = new TBrowser("tb","Browser");
}



------------------------------------------------------------------------------
   Stanislav Tereshenko
   Institute for High Energy Physics	        Protvino, Russia
   Multi-Muon Spectrometer Department
   e-mail:	                        tereshenko@mx.ihep.su
                                        sutasu@oea.ihep.su

   CERN, European Laboratory for Particle Physics, Geneve, Switzerland
   CMS experiment
   e-mail:				Stanislav.Terechtchenko@cern.ch
------------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:34 MET