Home | News | Documentation | Download

Roofit: Puzzled by filling the graph in Windows Subsystem for Linux

Hello!

I am very puzzled about ploting with roofit in the windows subsystem for linux(WSL), there is always a white area which I cannot make it filled.
My code is

#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "TAxis.h"
#include "RooPlot.h"
using namespace RooFit;

void f1()
{
  // Create observables
  RooRealVar x("x", "x", -10, 10);
  // Create Gaussian
  RooRealVar sigma("sigma", "sigma", 5, 0.1, 10);
  RooRealVar mean("mean", "mean", 3, -10, 10);
  RooGaussian gauss("gauss", "gauss", x, mean, sigma);
  // Generate a sample of 100 events with sigma=3
  RooDataSet *data = gauss.generate(x, 1000);

  // Fit pdf to data
  gauss.fitTo(*data);

  // M a k e   p l o t   f r a m e s
  RooPlot *frame = x.frame(Name("xframe"), Title("Filled Curve / Blue Histo"), Bins(20));
  // D a t a   p l o t t i n g   s t y l e s
  data->plotOn(frame, MarkerColor(kBlue), LineColor(kBlue));

  // F u n c t i o n   p l o t t i n g   s t y l e s
  gauss.plotOn(frame, DrawOption("F"), FillColor(kOrange), LineColor(0), FillStyle(3344));
  TCanvas *c = new TCanvas("f107", "f107", 800, 800);
  frame->Draw();

}

When mean=-3,the result is no problem, but mean=3, the result is

I am puzzled for this result about the reason for the triangle area, maybe the question from

 // F u n c t i o n   p l o t t i n g   s t y l e s
  gauss.plotOn(frame, DrawOption("F"), FillColor(kOrange), LineColor(0), FillStyle(3344));
  TCanvas *c = new TCanvas("f107", "f107", 800, 800);
  frame->Draw();

,but I have changed the value, and no use. What’s more, my output looks no error

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

[#1] INFO:Minization -- RooMinimizer::optimizeConst: activating const optimization
 **********
 **    1 **SET PRINT           1
 **********
 **********
 **    2 **SET NOGRAD
 **********
 PARAMETER DEFINITIONS:
    NO.   NAME         VALUE      STEP SIZE      LIMITS
     1 mean        -3.00000e+00  2.00000e+00   -1.00000e+01  1.00000e+01
     2 sigma        5.00000e+00  9.90000e-01    1.00000e-01  1.00000e+01
 **********
 **    3 **SET ERR         0.5
 **********
 **********
 **    4 **SET PRINT           1
 **********
 **********
 **    5 **SET STR           1
 **********
 NOW USING STRATEGY  1: TRY TO BALANCE SPEED AGAINST RELIABILITY
 **********
 **    6 **MIGRAD        1000           1
 **********
 FIRST CALL TO USER FUNCTION AT NEW START POINT, WITH IFLAG=4.
 START MIGRAD MINIMIZATION.  STRATEGY  1.  CONVERGENCE WHEN EDM .LT. 1.00e-03
 FCN=2825.41 FROM MIGRAD    STATUS=INITIATE        8 CALLS           9 TOTAL
                     EDM= unknown      STRATEGY= 1      NO ERROR MATRIX
  EXT PARAMETER               CURRENT GUESS       STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  mean        -3.00000e+00   2.00000e+00   2.11716e-01  -7.90217e+01
   2  sigma        5.00000e+00   9.90000e-01   2.01369e-01  -4.00425e+01
                               ERR DEF= 0.5
 MIGRAD MINIMIZATION HAS CONVERGED.
 MIGRAD WILL VERIFY CONVERGENCE AND ERROR MATRIX.
 COVARIANCE MATRIX CALCULATED SUCCESSFULLY
 FCN=2824.05 FROM MIGRAD    STATUS=CONVERGED      38 CALLS          39 TOTAL
                     EDM=1.10538e-07    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                   STEP         FIRST
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE
   1  mean        -2.76714e+00   2.18379e-01   7.34220e-04  -8.64236e-03
   2  sigma        5.10682e+00   1.93674e-01   1.26581e-03   4.87329e-03
                               ERR DEF= 0.5
 EXTERNAL ERROR MATRIX.    NDIM=  25    NPAR=  2    ERR DEF=0.5
  4.770e-02 -2.009e-02
 -2.009e-02  3.753e-02
 PARAMETER  CORRELATION COEFFICIENTS
       NO.  GLOBAL      1      2
        1  0.47485   1.000 -0.475
        2  0.47485  -0.475  1.000
 **********
 **    7 **SET ERR         0.5
 **********
 **********
 **    8 **SET PRINT           1
 **********
 **********
 **    9 **HESSE        1000
 **********
 COVARIANCE MATRIX CALCULATED SUCCESSFULLY
 FCN=2824.05 FROM HESSE     STATUS=OK             10 CALLS          49 TOTAL
                     EDM=1.11281e-07    STRATEGY= 1      ERROR MATRIX ACCURATE
  EXT PARAMETER                                INTERNAL      INTERNAL
  NO.   NAME      VALUE            ERROR       STEP SIZE       VALUE
   1  mean        -2.76714e+00   2.18722e-01   1.46844e-04  -2.80372e-01
   2  sigma        5.10682e+00   1.93978e-01   5.06326e-05   1.14789e-02
                               ERR DEF= 0.5
 EXTERNAL ERROR MATRIX.    NDIM=  25    NPAR=  2    ERR DEF=0.5
  4.785e-02 -2.026e-02
 -2.026e-02  3.765e-02
 PARAMETER  CORRELATION COEFFICIENTS
       NO.  GLOBAL      1      2
        1  0.47740   1.000 -0.477
        2  0.47740  -0.477  1.000
[#1] INFO:Minization -- RooMinimizer::optimizeConst: deactivating const optimization

Maybe there is something wrong in WSL, I am new in WSL with Xming, and my ROOT is 6.20.

Thank you for you reply!!!

First, please read Posting code? Read this first!, then I think @StephanH will probably help you

Thank you! It looks better.

https://root.cern.ch/doc/master/rf107__plotstyles_8C.html
Maybe this tutorial is useful.

Hi,

I found the problem is only in Roofit but not ROOT, so I solved the problem by changing ROOT release6.20 into 6.16 .

The problem is that the polygon needs an additional point to be closed nicely, but that additional point needs to come last in the list of points. In your case, the points are drawn in this order, though:

46	10	37.1457
47	11	0
48	11	37.1457

Note that the polygon is closed down to the x-axis, but point 48 pulls it back up. The sorting algorithm that sorts the x values is probably unstable …

I fixed it by moving the last point by 1/1000 of the distance between points:

46	10	37.1457
47	11	37.1457
48	11.001	0

I will add this soon to ROOT, see the bug tracker here:
https://sft.its.cern.ch/jira/browse/ROOT-10931

That is clear, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.