Belle II Software development
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 <unistd.h>
12
13#include "TH1F.h"
14#include "TMemFile.h"
15#include "TObject.h"
16
17using namespace Belle2;
18using namespace std;
19
20int main(int /*argc*/, char** /*argv*/)
21{
22 DqmSharedMem* shm = new DqmSharedMem("testhisto", 2000000);
23 // TMemFile* file = new TMemFile ( "TestHisto", (char*)shm->ptr(), 2000000, "RECREATE", "", 0 );
24 TMemFile* file = new TMemFile("TestHisto", "RECREATE");
25 file->CopyTo(shm->ptr(), 500000);
26
27 // TMapFile* file = TMapFile::Create("TestHisto", "RECREATE", 2000000);
28 // TFile* file = new TFile ( "testhist.root", "RECREATE" );
29 TH1F* h1 = new TH1F("testhisto", "testhisto", 100, 0.0, 100.0);
30 file->Write(0, TObject::kOverwrite);
31
32 // file->Add(h1);
33 h1->Fill(5.0, 5.0);
34 // cpysize = file->CopyTo( shm->ptr(), 500000 );
35 // for (int i=0; i<10; i++ ) {
36 for (int i = 0; i < 100; i++) {
37 h1->Fill((float)i, (float)i);
38 sleep(1);
39 // file->Update();
40 // cpysize = file->CopyTo( shm.ptr(), 2000000 );
41 file->Write(0, TObject::kOverwrite);
42 shm->lock();
43 int cpysize = file->CopyTo(shm->ptr(), 500000);
44 shm->unlock();
45 printf("Objects copied : cpysize = %d\n", cpysize);
46 }
47 // h1->Reset();
48 // }
49 file->CopyTo(shm->ptr(), 500000);
50 file->ls();
51 file->Print();
52 file->Write();
53 file->Close();
54 return 0;
55}
Abstract base class for different kinds of events.
STL namespace.