ROOT logo

From $ROOTSYS/tutorials/net/parallelMergeTest.C

#include "TMessage.h"
#include "TBenchmark.h"
#include "TSocket.h"
#include "TH2.h"
#include "TTree.h"
#include "TFile.h"
#include "TRandom.h"
#include "TError.h"

void parallelMergeTest(UInt_t nhist, UInt_t ndims = 1, UInt_t nbins = 100) 
{
   
   gBenchmark->Start("parallelMergeTest");

   TFile *file = TFile::Open("mergedClient.root?pmerge=localhost:1095","RECREATE");
   
   Float_t px, py;
   TTree *tree = 0;
   switch (ndims) {
      case 1: {
         for(UInt_t h = 0 ; h < nhist; ++h) {
            new TH1F(TString::Format("hpx%d",h),"This is the px distribution",nbins,-4,4);
         }
         break;
      }
      case 2: {
         for(UInt_t h = 0 ; h < nhist; ++h) {
            new TH2F(TString::Format("hpxy%d",h),"py vs px",nbins,-4,4,nbins,-4,-4);
         }
         break;
      }
      case 99: {
         tree = new TTree("tree","tree");
         tree->SetAutoFlush(4000000);
         tree->Branch("px",&px);
         tree->Branch("py",&py);
      }
   }
         
   // Fill histogram randomly
   gRandom->SetSeed();
   const int kUPDATE = 1000000;
   for (int i = 0; i < 25000000; ) {
//      gRandom->Rannor(px,py);
//      if (idx%2 == 0)
//         hpx->Fill(px);
//      else
//         hpx->Fill(px,py);
      if(tree) tree->Fill();
      ++i;
      if (i && (i%kUPDATE) == 0) {
         file->Write();
      }
   }
   file->Write();
   delete file;

   gBenchmark->Show("parallelMergeTest");
}
 parallelMergeTest.C:1
 parallelMergeTest.C:2
 parallelMergeTest.C:3
 parallelMergeTest.C:4
 parallelMergeTest.C:5
 parallelMergeTest.C:6
 parallelMergeTest.C:7
 parallelMergeTest.C:8
 parallelMergeTest.C:9
 parallelMergeTest.C:10
 parallelMergeTest.C:11
 parallelMergeTest.C:12
 parallelMergeTest.C:13
 parallelMergeTest.C:14
 parallelMergeTest.C:15
 parallelMergeTest.C:16
 parallelMergeTest.C:17
 parallelMergeTest.C:18
 parallelMergeTest.C:19
 parallelMergeTest.C:20
 parallelMergeTest.C:21
 parallelMergeTest.C:22
 parallelMergeTest.C:23
 parallelMergeTest.C:24
 parallelMergeTest.C:25
 parallelMergeTest.C:26
 parallelMergeTest.C:27
 parallelMergeTest.C:28
 parallelMergeTest.C:29
 parallelMergeTest.C:30
 parallelMergeTest.C:31
 parallelMergeTest.C:32
 parallelMergeTest.C:33
 parallelMergeTest.C:34
 parallelMergeTest.C:35
 parallelMergeTest.C:36
 parallelMergeTest.C:37
 parallelMergeTest.C:38
 parallelMergeTest.C:39
 parallelMergeTest.C:40
 parallelMergeTest.C:41
 parallelMergeTest.C:42
 parallelMergeTest.C:43
 parallelMergeTest.C:44
 parallelMergeTest.C:45
 parallelMergeTest.C:46
 parallelMergeTest.C:47
 parallelMergeTest.C:48
 parallelMergeTest.C:49
 parallelMergeTest.C:50
 parallelMergeTest.C:51
 parallelMergeTest.C:52
 parallelMergeTest.C:53
 parallelMergeTest.C:54
 parallelMergeTest.C:55
 parallelMergeTest.C:56
 parallelMergeTest.C:57
 parallelMergeTest.C:58
 parallelMergeTest.C:59
 parallelMergeTest.C:60