# Macro "**relauncherFunctionFlowrateCJit.C**" ## Objective The goal of this macro is to show how to handle the C++-written function using a pointer to the function (and not the name as for the macro in [](#use_cases_macro_relauncher_cint)). This function has been presented, at least its equation (see {eq}`flowrate_function`) and would be interface through the `TCJitEval` class in the {{Relaun}} module. A special discussion will be held in the next few lines about the way the compilation is done. ## Macro {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.C" + "\n" + ":language: cpp\n" + "```" }} The very first part of the macro is slightly different from [](#use_cases_macro_relauncher_cint_macro) as it is now compulsory to write explicitly the include line for the pre-processors. The use of namespaces is declared along, but this time only because this is convenient not to recall these long names every time. {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.C" + "\n" + ":language: cpp\n" + ":lines: 1-11\n" + "```" }} The definition of the `flowrateModel` function is then made right before entering the main function. At this level a break is needed to explain the risen antagonism between the two possible compilation and the way to call them. This issue is entirely described by the following two lines: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.C" + "\n" + ":language: cpp\n" + ":lines: 27,28\n" + "```" }} Let's talk about the two cases: - ACLIC: one should remove the second line and put the first one instead (after commenting it out of course). The compilation is then done by calling: ```bash root -l relauncherFunctionFlowrateCJit.C+ ``` - PROS: this will give you the hand at the end of execution, leaving the display opened to handle plots for instance. - CONS: this will create several useless files and will need non-trivial manipulation if extra headers and libraries are needed. - Standalone: leaving the macro as it is, the compilation on Linux is done by writing a line such as: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.sh" + "\n" + ":language: bash\n" + ":lines: 3\n" + "```" }} An equivalent command on Windows would be: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.ps1" + "\n" + ":language: ps1\n" + ":lines: 18\n" + "```" }} - PROS: pure C++ compilation resulting in a single executable file (here *CJitTest*). It's easy to include more headers and libraries if your code needs them. - CONS: this will not leave the display opened, unless you do so through a `TApplication` ({{root}}-class). Whatever the chosen solution, the only difference with previous macro is the assessor creation: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/relauncher/use_cases/cpp/relauncherFunctionFlowrateCJit.C" + "\n" + ":language: cpp\n" + ":lines: 49\n" + "```" }} The rest it completely transparent and leads to the creation of the following plot. ## Graph {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/relauncher/use_cases/cpp/cjit/relauncherFunctionFlowrateCJit.png\n" ":align: center\n" ":name: usecases_relauncherFunctionFlowrateCJit\n" + figure_scale + "\n" "\n" "Representation of the output as a function of the first input with a colZ option\n" "```" }}