2.3.6. Pattern selection

It can be necessary during a study to apply filters on the patterns; i.e. to include or to exclude patterns depending on criterion. For example, to select the patterns with x1 lower than 3.0 and x2 lower than 55.0 from the geyser database, Uranie code is as follows:

    tdsGeyser->setSelect("( x1<3.0 ) & ( x2<55.)");
    tdsGeyser->draw("x2:x1");

The obtained figure is:

../../_images/geyser_scatterplot_selection.png

Figure 2.40 Graph with a selection definition

The result of the scan method applied on this TDataServer object yields:

************************************************
*    Row   *        x1 *        x2 * n__iter__ *
************************************************
*        1 *       1.8 *        54 *         2 *
*        8 *      1.95 *        51 *         9 *
*       10 *     1.833 *        54 *        11 *
*       13 *      1.75 *        47 *        14 *
*       15 *     2.167 *        52 *        16 *
...
*      268 *      2.15 *        46 *       269 *
*      270 *     1.817 *        46 *       271 *
************************************************
==> 53 selected entries

We have obtained 53 patterns among 278 respecting the given criterion without having to specify this criterion for the draw and scan calls. To get the same result, we could have executed the following command as well:

    tdsGeyser->draw("x2:x1", "( x1<3.0 ) && ( x2<55.)");
    //tdsGeyser->scan("*", "( x1<3.0 ) && ( x2<55.)");

However, in this case, we have to repeat the criterion for each command.

It is also possible to exclude patterns coming from TDataServer with the setCut method.

    tdsGeyser->setCut(TString("x1 >= 3."));
    tdsGeyser->draw("x2:x1");

The obtained figure is as follows:

../../_images/geyser_scatterplot_cut.png

Figure 2.41 Graph with a definition of Cut

It can be noticed in the title of Figure 2.41, that it simply corresponds to the opposite of criterion’s meaning with respect to the one given by the setCut method with the ! ( ) character. Thus, the setCut method consists in passing on the negation of the criterion to the setSelect command.

Finally, it is perfectly possible to delete the current filters with the methods clearSelect and clearCut, and retrieving the unfiltered results.

Tip

Every modifications of the ongoing selection (meaning doing a new selection or removing it) is now clearing automatically the vectors that contain statistical properties of attributes and the database of already computed quantiles. This is reminded with an information line shown below:

 <URANIE::INFO>  Selection is changing ==> clearing the TAttribute computed statistics and quantiles

Summary: Filters management regarding patterns

  • setSelect ( TString sselect)

    Patterns selection ensuring the criterion sselect

  • setCut ( TString scut)

    Excluding the patterns ensuring the criterion scut

  • clearSelect() / clearCut()

    Deletes the current filter.

Any modification of the selection is now clearing the vector of statistic (mean, std, min and max) introduced in List of variable information as well as the map containing quantiles. This is done in order to be sure that the method used to performed these estimation are called once again to take into account the change in selection. An informative message is displayed to remind this clearing.