3D Histogram -> text file?

Hello !
I have a complicated question today. Is it possible to create a text file (.dat, .ascii, .txt) from a 3D histogram ?
Thank you for your help.

It depends what you mean by "text file "… ?

A file written in this way :

     x        y          z        weight
 3.56    4.32     2.45      0.152
 2.45    4.25     1.23      0.24

Do you understand what I mean ?


Yes I know this command but is this possible to write what I am printing (using a printf in my macro or using h->Print(“all”)) in a file ?

You should make a macro looping over the histogram bins. For each bin you get the info you need using the appropriate getters and you print it.

Yes I know how to do that but I am just able to print it on my window in this way. My objective is to have my datas written on a file in order to save them.

   FILE *f = fopen("outputfile.dat","w");
   for (int i=1; i<10; i++) fprintf(f,"%d %d %d\n",i,2*i,3*i);

Ok I will try this ! Thanks a lot for your help !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.