--- myst: substitutions: geyser1: python: 19-20 cpp: 18-19 geyser2: python: 20-22,27 cpp : 14-16,21 bloc1: python: "5" cpp: "4" bloc2: python: "12" cpp: "13" bloc3: python: "15" cpp: "17" bloc4: python: 18-21 cpp: 21-24 bloc5: python: 24-29 cpp: 28-31 bloc6: python: 32-35 cpp: 35-38 dedent: python: ":dedent:\n" cpp: "" --- (dataserver_attribute_variable_information)= # List of variable information We will present in this section the list of information contained in a {{tattr}} of {{uranie}}. {{ "```{" "figure" "} " + parent_dir + "/usermanual/dataserver/figures/DiagramTAttributeAttributs.png\n" ":name: dataserver_diagram_tattribute_attributs\n" ":align: center\n" + figure_scale + "\n" "\n" "Attributes of TAttribute class\n" "```" }} **Name**: Variable name : It should be a *short* name as this information is needed to use this variable (mathematical expressions, graphics, scan, ...). **Title**: Variable title. : This information is only needed for graphical display. **Unit**: Variable units. : This information is only needed for graphical display. **Note**: Variable note. : description of the variable, this is not currently used. **Min, Max, Mean and Std**: Minimum, maximum, averaged and standard deviation values. : These information are now vectors and their usage is discussed in [](#dataserver_statistics_computing_elementary) **vquantile**: Vector of map containing value of the quantile computed using the key in argument. : These information are now stored in the attribute itself their usage is discussed in [](#dataserver_statistics_quantile_computation) **defaultValue**: Default value. : This default value will be considered either by the code launcher or during a parameter optimisation. In the case of a code launcher, this means either that the code failed to proceed or that the code did not return the value. At this level, there is no notion of **random variable**. Attributes are variables with a name, a label, a unit, a variation domain (bounded or belonging to R). Despite the large amount of possible combinations to instantiate a variable (name, name+label, name+boundary, name+label+boundary), only a small number of constructors are implemented. Some methods like **setTitle**, **setFileKey**, **setUnity** allow to precise the missing information. The four constructors currently implemented are the following: - Name: since this constructor only knows the name of the variable, the 3 piece of information title, label and key are strictly identical. This variable is not bounded. An example of use, already seen before, is: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc1[language] + "\n" + dedent[language] + "```" }} A random variable **"x"** (where px denotes a pointer to x) exists and it has its label also equal to x. Thus, if this variable is visualised on a graph, the default label will also be its title i.e **"x"**. - Name + title: constructor defined from the name and the title of the variable {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: 8-9\n" + dedent[language] + "```" }} A pointer **psdp** to a variable **"sdp"** is available with title being *#sigma_{#Delta P}*. The command **setUnity()** precises the unit. In this case, by default, the field *key* is identical to the field *name*. We will use the ability given by {{root}} to write LaTeX expressions in graphics to improve graphics rendering without weighing down the manipulation of variables: as a matter of fact, we can plot the histogram of the variable *sdp* by: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/draw_geyser_histogram_annoted." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + geyser1[language] + "\n" + "```" }} The result of this piece of code is shown in {numref}`dataserver_geyser_histogram_annoted`. {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/dataserver/attribute/" + language + "/geyser_1/geyser_histogram_annoted.png\n" ":align: center\n" ":name: dataserver_geyser_histogram_annoted\n" + figure_scale + "\n" "\n" "Graph of the variable `sdp`\n" "```" }} - Name + variation boundary: constructor defined by the name of the variable and the lower and upper boundaries. The two other pieces of information, label and key remain equal to the title. An example of use is {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc2[language] + "\n" + dedent[language] + "```" }} - Name + EType: constructor defined by the name of the variable and nature of the corresponding attribute . An example of use is {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc3[language] + "\n" + dedent[language] + "```" }} Setter methods allow to fill the other fields (title, key, etc ) generally by calling **set** and the name of the information to be modified (a restricted list of available methods being given below). For instance, the plot "x2:x1" of {{tds}} data *tdsGeyser* (whose data file `geyser.dat` can be found in the {{uranie}}-macros folder) can be considered again and we can replace the fields *title* and *unit* with new values by using **LaTeX** instructions. For instance, let us consider once again the graph of {{tds}} data tdsGeyser: {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/draw_geyser_scatterplot_labelled." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + geyser2[language] + "\n" + "```" }} The first line consists in retrieving the attribute pointer *x1*, while the others are self explanatory. This results in a new graph (scatterplot) of *x2* versus *x1* for the {{tds}} constructed from the *geyser* file with updated field title and unit values, shown in {numref}`dataserver_geyser_scatterplot_labelled`. {{ "```{" "figure" "} " + parent_dir + "/roottest/build/uranie/doc/dataserver/attribute/" + language + "/geyser_2/geyser_scatterplot_labelled.png\n" ":align: center\n" ":name: dataserver_geyser_scatterplot_labelled\n" + figure_scale + "\n" "\n" "Scatterplot `x2` versus `x1` for the `geyser` data with modification of fields `title` and `unit`\n" "```" }} Most of the information can be modified by "setter" methods. Here is a short list of the most relevant one starting with simple and already discussed attribute properties: - **setTitle**(TString *str*): assigns the character string *str* passed as argument to the field **title**; - **setUnity**(TString *str*: assigns the character string *str* passed as argument to the field **unity**; - **setNote**(TString *str*): assigns the character string *str* passed as argument to the field **note**; - **setUpperBound/setLowerBound/setDefaultValue**(double *val*): assigns or changes (if it already existed) respectively the upper, lower or default value for this attribute. - **setDataType**(EType *thetype* or TString *str*): changes the nature of the attribute given the enumerator value or a character chain (case insensitive). In the latter case, the enumerator is set to: - kReal: *str* = "double" or "real" or "d"; - kString: *str* = "string" or "s" - kVector: *str* = "vector" or "v" Given the new nature of attributes (meaning vectors and strings) a more generic method has been created to put default values to all type. The generic methods takes only one argument, a string containing values whatever the type. In cas of doubt, dedicated methods have also been created, with dedicated prototypes: - kReal: both `setDefault(TString value)` and `Bool_t setDefaultValue(Double_t val)` can be used as shown below {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc4[language] + "\n" + dedent[language] + "```" }} - kVector: both `setDefault(TString value)` and `setDefaultVectorvector &vec)` can be used as shown below {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc5[language] + "\n" + dedent[language] + "```" }} - kString: both `setDefault(TString value)` and `setDefaultString(TString val)` can be used as shown below {{ "```{literalinclude} " + parent_dir + "/roottest/uranie/doc/dataserver/attribute/" + language + "/variable_information." + extension + "\n" + ":language: " + language + "\n" + ":lines: " + bloc6[language] + "\n" + dedent[language] + "```" }} There are also important setters, used to connect attributes to {{ascii}} files. Most of the time, {{ascii}} files are indeed used to communicate with an external code and {{uranie}} must know in this case where to find the useful information for the corresponding attributes (either to write a new value that would be used as input to perform a calculation or to read the output of another computation). This is more carefully detailed in [](#launcher_external_code_input_output). - **setFileKey**(TString *sfile*, TString *skey*,TString *sformatToSubstitute*, TAttributeFileKey::EFileType *sFileType*): allows to specify for an attribute a file **sfile**, a key linked to this file **skey**, a writing format of the value of this key in the previous file **sformatToSubstitute**, and also the type of the file **sFileType**. This is heavily discussed in [](#launcher_module).