Dear root experts,
I have several root macros which I want to compile and run in root. I have made a bash script for it.
The simple example of the script is
Name:RunMacro_1_to_3.sh
and it contains following lines
To run it, I do in command prompt ./RunMacro_1_to_3.sh
It runs successfully but I want to include one more functionality. I want the script to quit root (.q) after
finishing first macro then call it again compile the second one, run the second one and so on.
My macro is simply doing some calculations and writing the results in a text file.
Dear Couet,
I try to use this method, it works, but in my macro I need to show an histogram and it didn’ see.
How can I show my histogram using a bash script?
Kind regards,
Daniele
Hi Daniele,
The “-b” option means “run in batch mode without graphics” (type root --help to see the options), so removing it will display your graphics. However, when root quits ("-q") any canvas will be closed too, so depending on your macro you may just see the graph quickly pop up and disappear. If you want to keep the canvas you can save it from within the macro, or maybe have your macro wait for some user input before finishing, to give you time to see the histogram.
Usually, in batch mode I just directly run the macros, something like root -l -q “mymacro.C(myarg)” or similar, without loading, compiling, etc, so I’m not really familiar with the way you are loading and running your code; as couet’s example looks similar, it should work, so your case could be a problem with your code (ShowCR_DOY_P.c).
A first question would be, do you see any graphics at all with that code when not using batch mode? try this: just go into root and run your macro from there and see if you get the graphics; if you don’t, the problem is something else in your code.
Do root -l ShowCR_DOY_P.c -e 'Show("CR distribution Selected Bin - Poisson Fit, 20180801-20181015", "213cr_507.dat");' instead. In heredoc approach, root exits when the Show function returns.