Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  24 Apr 2020, Pintaudi Giorgio, Forum, API to read MIDAS format file 
    Reply  24 Apr 2020, Stefan Ritt, Forum, API to read MIDAS format file 
       Reply  24 Apr 2020, Pintaudi Giorgio, Forum, API to read MIDAS format file 
          Reply  24 Apr 2020, Stefan Ritt, Forum, API to read MIDAS format file 
    Reply  25 Apr 2020, Konstantin Olchanski, Forum, API to read MIDAS format file 
       Reply  03 May 2020, Pintaudi Giorgio, Forum, API to read MIDAS format file 
          Reply  03 May 2020, Konstantin Olchanski, Forum, API to read MIDAS format file 
             Reply  04 May 2020, Pintaudi Giorgio, Forum, API to read MIDAS format file 
          Reply  03 May 2020, Stefan Ritt, Forum, API to read MIDAS format file ReferenceCardForMac.pdf
             Reply  26 May 2020, Pintaudi Giorgio, Forum, API to read MIDAS format file 
Message ID: 1901     Entry time: 03 May 2020     In reply to: 1884     Reply to this: 1902   1903
Author: Pintaudi Giorgio 
Topic: Forum 
Subject: API to read MIDAS format file 
> The format of .hst midas history files is pretty simple and mhdump.cxx is an easy to read 
> illustration on how to read it from basic principles (without going through the midas library, 
> which can be somewhat complicated). The newer "FILE" format for history is even simpler 
> to read because it is just fixed-record-size binary data prepended by a text header.
> 
> You can also use the mh2sql program to import history data into an sql database (mysql 
> and sqlite should work) or to convert .hst files to "FILE" format files. This works well
> for "archiving" history data, because the "FILE" format works better for looking at old data,
> and for looking at data in "months" or "years" timescale.
> 
> Back to your question, you can certainly use "mhdump" as is, using a pipe (popen()), or 
> you can package mhdump.cxx as a c++ class and use it in your application. If you go this 
> route, your contribution of such a c++ class back to midas would be very welcome.
> 
> You can also use mhist, but the mhist code cannot be trivially packaged as a c++ class
> to use in your application.
> 
> You can also suggest that we write an easier to use history utility, we are always open to 
> suggested improvements.
> 
> Let us know how it works out for you. Good luck!
> 
> K.O.

Dear Konstantin,
thank you very much for the wealth of information you provided.
I have thought about it and I see two options:

- One is to convert to SQL format and then use a SQLite library to import the data in my 
application.

- The other is to encapsulate the mhdump.cxx code into a C++ class, as you say.

I am leaning towards the first option for three reasons.
1. I have never used a SQLite database so it is a good learning opportunity for me.
2, The SQLite database format is very well known and widespread, so there are tons of tools to 
handle it
3. I have taken a look at the mhdump.cxx source code and I think it is a beautiful piece of code, 
but has a very "functional" taste with little encapsulation. Basically, all the fun is happening 
inside the readHstFile function and there is no trivial way to get the data out of it. I don't mean 
that it would be difficult to wrap it around a C++ class, but I feel that I can learn more by going 
the SQL way.

PS some time ago, I don't remember if you or Stefan, recommended CLion as C++ IDE. I have tried it 
(together with PyCharm) and I must admit that it is really good. It took me years to configure Emacs 
as a IDE, while it took me minutes to have much better results in CLion. Thank you very much for 
your recommendation.
ELOG V3.1.4-2e1708b5