#include "TROOT.h" #include "TCanvas.h" #include "TFile.h" #include #include "TMapFile.h" int main() { TCanvas *c1; TMapFile *mfile; if(!TROOT::Initialized()) { static TROOT TestRoot("TestROOT","ROOT"); cout << " initialized ROOT" << endl; } const char *path = gROOT->GetPath(); bool batch = gROOT->IsBatch(); gROOT->SetBatch(kTRUE); mfile = TMapFile::Create("test.map","RECREATE",50000, "test memory mapped file"); gROOT->Cd(path); // create the graphic objects in batch mode c1 = new TCanvas("CMUDCanvas","CMUD plots",200,10,700,500); c1->Draw(); c1->Modified(); c1->Update(); gROOT->SetBatch(batch); gROOT->Cd(path); // add to the mapfile mfile->Add(c1); mfile->Update(); TFile *f = new TFile("test.root","RECREATE"); c1->Write(); gROOT->Cd(path);// return to old scope f->Close(); mfile->Close(); }