13.2.12. Macro “dataserverComputeStatVector.C

13.2.12.1. Objective

This part shows the complete code used to produce the console display in Specific case of vectors.

13.2.12.2. Macro Uranie

    TDataServer *tdsop =new TDataServer("foo","poet");
    tdsop->fileDataRead("tdstest.dat");

    //Considering every element of a vector independent from the others
    tdsop->computeStatistic("x");
    TAttribute *px = tdsop->getAttribute("x");

    cout<<"min(x[0])= "<<px->getMinimum(0)<<";  max(x[0])= "<<px->getMaximum(0)
        <<";  mean(x[0])= "<<px->getMean(0)<<";  std(x[0])= "<<px->getStd(0)<<endl;
    cout<<"min(x[1])= "<<px->getMinimum(1)<<";  max(x[1])= "<<px->getMaximum(1)
        <<";  mean(x[1])= "<<px->getMean(1)<<";  std(x[1])= "<<px->getStd(1)<<endl;
    cout<<"min(x[2])= "<<px->getMinimum(2)<<";  max(x[2])= "<<px->getMaximum(2)
        <<";  mean(x[2])= "<<px->getMean(2)<<";  std(x[2])= "<<px->getStd(2)<<endl;
    cout<<"min(xtot)= "<<px->getMinimum(3)<<";  max(xtot)= "<<px->getMaximum(3)
        <<";  mean(xtot)= "<<px->getMean(3)<<";  std(xtot)= "<<px->getStd(3)<<endl;

    //Statistic for a single realisation of a vector, not considering other events
    tdsop->addAttribute("Min_x","Min$(x)");
    tdsop->addAttribute("Max_x","Max$(x)");
    tdsop->addAttribute("Mean_x","Sum$(x)/Length$(x)");

    tdsop->scan("x:Min_x:Max_x:Mean_x","","colsize=5 col=2:::6");

13.2.12.3. Console

This macro should result in this output in console, split in two parts, the first one being from Uranie’s method

min(x[0])= 1;  max(x[0])= 7;  mean(x[0])= 3;  std(x[0])= 3.4641
min(x[1])= 2;  max(x[1])= 8;  mean(x[1])= 4.66667;  std(x[1])= 3.05505
min(x[2])= 3;  max(x[2])= 9;  mean(x[2])= 6.66667;  std(x[2])= 3.21455
min(xtot)= 1;  max(xtot)= 9;  mean(xtot)= 4.77778;  std(xtot)= 3.23179

The second on the other hand results from ROOT’s methods (the second part of the code shown above):

*****************************************************
*    Row   * Instance *  x * Min_x * Max_x * Mean_x *
*****************************************************
*        0 *        0 *  1 *     1 *     3 *      2 *
*        0 *        1 *  2 *     1 *     3 *      2 *
*        0 *        2 *  3 *     1 *     3 *      2 *
*        1 *        0 *  7 *     7 *     9 *      8 *
*        1 *        1 *  8 *     7 *     9 *      8 *
*        1 *        2 *  9 *     7 *     9 *      8 *
*        2 *        0 *  1 *     1 *     8 * 4.3333 *
*        2 *        1 *  4 *     1 *     8 * 4.3333 *
*        2 *        2 *  8 *     1 *     8 * 4.3333 *
*****************************************************