Hello,
being new to pyroot, I may still miss some concepts:
My problem is - how doI read a mmap file with TH1F histograms in it? They are created approximately like this:
TH1F *harray[7*8];
mmapfd3 = TMapFile::Create( "mmap.histo" ,"RECREATE" , 16*1024000 , "TH1F_16");
harray[0]=new TH1F( "hist0" ,"vme_histogram",8192,0,8192);
mmapfd3->Add( harray[0] );
mmapfd3->Update( );
I can read it approximately from C++ like this
TMapFile* mfile =TMapFile::Create("mmap.histo");
TMapRec *mr = mfile->GetFirst();
while (mfile->OrgAddress(mr)) {
TString classn=mr->GetClassName();
if ( strcmp(classn.Data(),"TH1F")==0){
TString name=mr->GetName();
TH1F *h =0;
h=(TH1F*)mfile->Get(name.Data(), h );
gROOT->cd();
TH1F *hc=(TH1F*)gDirectory->Get( name.Data() );
}
mr = mr->GetNext();
}
Can I read it from pyroot? That would really eased up my situation. I tried something, I can read mmap file in python, but I am lost with PyROOT:
#!/usr/bin/python3
import ROOT
import mmap
import contextlib
import time
import os
mmapfile="mmap.histo"
#---- i can work with mmap in pure python
if os.path.isfile( mmapfile ):
with open(mmapfile, "r+b") as f:
mm1 = mmap.mmap(f.fileno(), 0)# memory-map the file,size 0= whole
print("i... MMAP HISTO OPENED")
else:
quit()
# --- but i rather think I must use ROOT objects....
mm=ROOT.TMapFile.Create( mmapfile ) #???
ROOT.TMapRec.GetNext()
here I am stuck. I managed to receive an error:
Use rootn.exe or link application against "-lNew"```
When I want to open mmap from root, I must run `rootn.exe` by the way...
I hope that there is some way... thanks