--- myst: substitutions: bloc: python: 1,4,15-16,20 cpp: 1-2,4,12-13 --- # Import data from a `TNtuple`/`TDSNtuple`/{{ttr}} From a {{ttr}} object (or any of its derived-object) contained in a {{root}}-file, it is possible to import data, with or without selection of a variable and addition of other ones through formula then deletions of patterns ensuring a criterion {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/data/" + language + "/draw_hsimple_scatterplot." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc[language] + "\n" + "```" }} **Description of data importation of a TTree from a {{root}} file** 1. Specification of the namespace. 2. Creation of a pointer *tds* to an object of type `TDataServer` without name and title. 3. Fill the {{tds}} with all branches contained in the tree *ntuple* that is contained in `hsimple.root`. Two new attributes are computed on the fly and a selection is applied on the patterns to be kept; 4. Plots scatterplot of the variable **py** versus the variable **px** In this case, *tds* is constructed from the `TTree` *ntuple* contained in the file `hsimple.root` where all initial variables are kept (__\*__ character). {numref}`fig_hsimplecontenu` shows the content of the *ntuple*. Two new variables are then added on top, defined by the equations "px\*py" and "py\*px" on both side of the "\*" string. A cut is finally done, to exclude all data that would satisfy the following equation $px^2 + py^2 < 2$ {{ "```{" "figure" "} " + parent_dir + "/usermanual/dataserver/figures/hsimplecontaint.png\n" ":align: center\n" ":name: fig_hsimplecontenu\n" + figure_scale + "\n" "\n" 'Content of the *ntuple* tree contained in "hsimple.root" file.\n' "```" }} The obtained graph is as follow: {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/dataserver/data/" + language + "/hsimple_scatterplot.png\n" ":align: center\n" ":name: dataserver_hsimple_scatterplot\n" + figure_scale + "\n" "\n" 'Data importation from a TNtuple\n' "```" }} ```{admonition} Summary: Loading data ( TNtupleD of {{root}} in a TFile) - `ntupleDataRead` (__const char \*__ file, __const char \*__ tree, __const char \*__ svar="\*", __const char \*__ cut="") Loads the data contained in the `TNtupleD tree` of file {{root}} `TFile file` by selecting/creating the list of variables `svar` (the variables are separated by the ":" character, and "\*" character means recalling all variables of the TNtupleD) and by deleting all patterns ensuring the criterion `cut`. ```