RooFit: why FillStyle and FillColor don't work?

Hi,

I just want to fill the signal with the red color and follow what it says on:
http://root.cern.ch/root/html/RooAbsPdf.html#RooAbsPdf:plotOn

But it doesn’t work. My code is in the following, is there something wrong? I am using root 5.18.

And for the case of Minos, could we display the asymmetric errors with RooAbsPdf::paramOn?

Thank you very much.

[code]void testFill()
{
gSystem->Load(“libRooFit”);
using namespace RooFit;

RooRealVar *m = new RooRealVar( “m”, “invariant mass”, 5000, 5600, “MeV/c^{2}”);

RooArgSet* observables = new RooArgSet( *m );

/// sig mass
RooRealVar *SigMass = new RooRealVar(“M_{sig}”,“B mass”, 5279, 5000, 5600, “MeV/c^{2}” );
RooRealVar *SigMassRes = new RooRealVar("#sigma_{m}",“B mass resolution”, 25, 0., 60, “MeV/c^{2}”);
RooAbsPdf *SigMassPdf = new RooGaussian(“SigMassPdf”,“MassPDF of signal”,*m,*SigMass,*SigMassRes);

/// bkg mass
RooRealVar *BkgMassSlope = new RooRealVar(“Sl_{bkg}”,“Slope of mass bkg”, -9.7194e-05, -1.0, 1.0 );

RooAbsPdf *BkgMassPdf = new RooPolynomial(“BkgMassPdf”,“BkgMassPdf”,*m, *BkgMassSlope );

RooRealVar *FracSig = new RooRealVar(“f_{sig}”,“fraction of signal”, 0.11, 0, 1.0); //1.2802e-01

RooAbsPdf *MassPdf = new RooAddPdf(“MassPdf”,“mass pdf”,
RooArgList(*SigMassPdf,*BkgMassPdf),
RooArgList(*FracSig) );

BkgMassSlope->setError( 1.0e-8 ) ;

RooRandom::randomGenerator()->SetSeed(11111);

RooDataSet *toyData = MassPdf->generate(RooArgSet(*observables),Verbose(false),NumEvents( 3500 ));

MassPdf->fitTo(*toyData, Minos(true), Strategy(1),Save(true),Verbose(false) );

RooPlot *mframe = m->frame();
toyData->plotOn( mframe );
MassPdf->plotOn( mframe );
MassPdf->plotOn( mframe, Components(*SigMassPdf), FillStyle(3008), FillColor(2), VLines() );
MassPdf->paramOn( mframe, Layout(0.60,0.99,0.99) );

mframe->Draw();

}[/code]

Hi,

To show a filled curve you also need to have the curve (a TGraph inherited object) drawn with the “F” option

MassPdf->plotOn( mframe, Components(*SigMassPdf), FillStyle(3008), FillColor(2), VLines(), DrawOption(“F”) );

Concerning the asymmetric errors, you can modify what is shown by paramOn()
by adding a Format() command

// The Format(const char* what,…) has the following structure
//
// const char* what – Controls what is shown. “N” adds name, “E” adds error,
// “A” shows asymmetric error, “U” shows unit, “H” hides the value
// FixedPrecision(int n) – Controls precision, set fixed number of digits
// AutoPrecision(int n) – Controls precision. Number of shown digits is calculated from error
// + n specified additional digits (1 is sensible default)
//
// Example use: pdf.paramOn(frame, Label(“fit result”), Format(“NEU”,AutoPrecision(1)) ) ;
//

MassPdf->paramOn( mframe, Layout(0.60,0.99,0.99), Format(“NEAU”,AutoPrecision(1)));

Wouter

Hi Wouter (and Jibo :slight_smile:),

I was in trouble by the same feature of RooFit (adding the DrawOption(“F”)) to the plotOn command.

I suggest that it could be added to the FillColor and FillStyle doxygen.

Could it be ?

Thanks a lot Wouter.

Aurélien

Please report RooFit questions/problems to the “math and stats” thread

Rene

Hi Aurelien,

I’m working to make plotting filled shapes more intuitive for the next ROOT/RooFit release.

Wouter