Belle II Software  release-08-01-10
tmemtest.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include "daq/dqm/DqmSharedMem.h"
10 
11 #include "TH1F.h"
12 #include "TMemFile.h"
13 #include "TObject.h"
14 
15 using namespace Belle2;
16 using namespace std;
17 
18 int main(int /*argc*/, char** /*argv*/)
19 {
20  DqmSharedMem* shm = new DqmSharedMem("testhisto", 2000000);
21  // TMemFile* file = new TMemFile ( "TestHisto", (char*)shm->ptr(), 2000000, "RECREATE", "", 0 );
22  TMemFile* file = new TMemFile("TestHisto", "RECREATE");
23  int cpysize = file->CopyTo(shm->ptr(), 500000);
24 
25  // TMapFile* file = TMapFile::Create("TestHisto", "RECREATE", 2000000);
26  // TFile* file = new TFile ( "testhist.root", "RECREATE" );
27  TH1F* h1 = new TH1F("testhisto", "testhisto", 100, 0.0, 100.0);
28  file->Write(0, TObject::kOverwrite);
29 
30  // file->Add(h1);
31  h1->Fill(5.0, 5.0);
32  // cpysize = file->CopyTo( shm->ptr(), 500000 );
33  // for (int i=0; i<10; i++ ) {
34  for (int i = 0; i < 100; i++) {
35  h1->Fill((float)i, (float)i);
36  sleep(1);
37  // file->Update();
38  // cpysize = file->CopyTo( shm.ptr(), 2000000 );
39  file->Write(0, TObject::kOverwrite);
40  shm->lock();
41  cpysize = file->CopyTo(shm->ptr(), 500000);
42  shm->unlock();
43  printf("Objects copied : cpysize = %d\n", cpysize);
44  }
45  // h1->Reset();
46  // }
47  cpysize = file->CopyTo(shm->ptr(), 500000);
48  file->ls();
49  file->Print();
50  file->Write();
51  file->Close();
52  return 0;
53 }
Abstract base class for different kinds of events.
int main(int argc, char **argv)
Run all tests.
Definition: test_main.cc:91