WTI/Experiment Electronics/Data Processing: Go4

Previous tutorial 5  |    Go4   set_Par1.C   set_cHis1.C   |  Next tutorial 7

Tutorial 6

Macro execution in the Go4 framework

Macros are very useful for many purposes. We already have seen the setup.C macro called in our analysis class by
gROOT->ProcessLine("setup.C()");
But we can also execute macros interactively from the GUI:
  1. Execute macro in remote analysis
    Enter the macro command in the text field below the analysis terminal window. The macro command will be sent to the analysis and executed there. If the analysis is running, the command will be executed between two events. In the macro one has access to all registered objects of the analysis.
  2. Execute macro in GUI
    Use Settings->Show/hide in the menu to enable GUI command line. Enter the macro command in the GUI command line. The macro command will execute in the GUI environment. In the macro one has access to all objects of the browser.
Some macros are provided by Go4 in the directory $GO4SYS/macros. To avoid to type always the full path one can set default pathes. This is done in a file $HOME/.rootrc One can copy that file from $ROOTSYS/etc/system.rootrc. Search for a line
Unix.*.Root.MacroPath: .:$(ROOTSYS)/macros
and add the Go4 macro directory:
Unix.*.Root.MacroPath: .:$(GO4SYS)/macros:$(ROOTSYS)/macros

Saving conditions

Assume you have an analysis running from GUI and all conditions are set properly. To save these settings into an executable macro use macro savecond.C(name,prefix) in the execution line of the analysis terminal:
.x savecond.C("*","set")
It will produce one macro for each condition matching the name wildcard, e.g.: set_cHis1.C(flags,counters,reset) (we have only one condition cHis1). You can copy this output macro from above. This macro could be executed in the TSimProc.cxx constructor after we created the condition.
gROOT->ProcessLine(".x set_cHis1.C(1,0,1)");
The flags argument restores the flags, the counters the counters, and reset cleares the counters if 1.

Saving parameters

Assume you have an analysis running from GUI and all parameters are set properly. To save these settings into an executable macro use macro saveparam.C(name,prefix) in the execution line of the analysis terminal:
.x saveparam.C("*","set")
It will produce one macro for each parameter matching the name wildcard, e.g.: set_Par1.C (we have only one parameter Par1). You can copy this output macro from above. This macro could be executed in the TSimProc.cxx constructor after we created the parameter.
gROOT->ProcessLine(".x set_Par1.C()");
Using this method one can change parameters and conditions interactively, but store the settings independently of autosave files which are optional. The generated macros can be used as templates and might be modified directly. The settings in the analysis are always predictable.

Both macros can be used also in ROOT CINT to generate the macros from conditions and parameters in a file, i.e. autosave file. In this case add the file name as first argument.

> root
> root [0] .x saveparam.C("result.root","Par*","treeset")

Next tutorial


WTI Experiment Electronic Data Processing Group
Hans Essel , GSI Helmholtzzentrum für Schwerionenforschung mbH, GSI
Total 25965, last 2022 Jul 06 18:33
Last update: 2009 Nov 24 14:27