--- myst: substitutions: bloc1: python: 1-5,16-60,65-76,81-121 cpp: 3-6,12-41,46-51,56-96,105 bloc2: python: 83-98 cpp: 61-71 bloc3: python: 110-115 cpp: 85-90 bloc4: python: 117-121 cpp: 92-96 bloc5: python: 13-74 cpp: 16-77 --- (use_cases_macro_dataserver_pca_example)= # Macro "**dataserverPCAExample.{{extension}}**" ## Objective The goal of this macro is to show how to handle a PCA analysis. It is not much discussed here, as a large description of both methods and concepts is done in [](#dataserver_pca). ## Macro {{uranie}} {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/use_cases/" + language + "/dataserverPCAExample." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + "```" }} This first part of this macro is described in [](#dataserver_pca). We will focus here on the second part, where all the numerical results are dumped on screen. These results are stored in the {{ds}} for the points and in a dedicated ntuple for the variable that can be retrieved by calling the method `getVariableResultNtupleD`. In both cases, the results can be split into two kinds: - the quality of the representation: it is called *"cosca_X"* as it is a squared cosinus of the projection of the source under study (point or subject) on the X-th PC. - the contribution to axis: it is called *"contr_X"* as it is the contribution of the source under study (point or subject) to the definition of the X-th PC. We start by defining the list of variables that one might want to display {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/use_cases/" + language + "/dataserverPCAExample." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + "```" }} From there, once the variable ntuple is retrieved, one can dump both the quality and contribution coefficients for the variable, here the subjects (it leads to the second and third block in the output shown in [](#use_cases_macro_dataserver_pca_example_console)). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/use_cases/" + language + "/dataserverPCAExample." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + "```" }} Finally, one can do the same for the data points, with the same `Scan` method (which lead to the fourth and fifth block in the output shown in [](#use_cases_macro_dataserver_pca_example_console)). {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/use_cases/" + language + "/dataserverPCAExample." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + "```" }} (use_cases_macro_dataserver_pca_example_console)= ## Console {{ "```{literalinclude} " + parent_dir + "/roottest/build/uranie/doc/dataserver/use_cases/" + language + "/dataserverPCAExample.log" + "\n" + ":language: none\n" + ":name: console_dataserverPCAExample\n" + ":lines: " + bloc5[language] + "\n" + "```" }}