Home | News | Documentation | Download

C++ representation of histogram plotting

Dear ROOTers,

I am a total newbie and I would like your help please. I have a dataset which I successfully create a histogram for, cutting to the parameters I need and adding a Gaussian, however I do all these actions using the graphical interface. As a result, when I create a .c file I only find a graph and no code. How can I record everything that I am doing as code that can be run on a different computer? Never used C and I am not savvy with bins etc. I read the beginner’s guide but I still have trouble in translating my actions into code! I uploaded an example of one of the graphs I created. The code bit is empty so not sure how to save it as a macro.

Pi0attempt3

Thanks!


Please read tips for efficient and successful posting and posting code

ROOT Version: 6.22.06
Platform: Windows 10 Enterprise
Compiler: Not sure, I think I run it from source, as I only run root and it opens a ROOT session


If you save as a .C file you will get the objects present in the canvas but, for instance, if you performed a Fit you will not get the Fit command producing the gaussian curve. You will get the graph. I would recommend to do the fit with a command. Did you use the Fit panel ?

Hi couet, thanks for replying. Yes, I used the Fit panel. The panel was useful to play around with the sigma and see what I select on the graph in real time. Could you please give me an idea of the commands that I can use to do the fit with commands?

Hi @Andr0meda,

The command to fit histogram is simply TH1::Fit().

You can also look at the fit tutorials.

The ROOT online manual has also a fitting chapter..

And the ROOT primer has a section dealing with fitting.

Fantastic, thank you so much.