Uploaded image for project: 'ROOT'
  1. ROOT
  2. ROOT-8932

Impossible to plot multiple filled PDFs using RooFit::AddTo()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 6.20/00
    • Component/s: RooFit/RooStats
    • Labels:
      None
    • Environment:

      I use lxplus7 with ROOT 6.08.06

    • Development:

      Description

      Hi,

      I try to plot a simple two-component fit by accessing the constituent PDFs as follows:
      gx.plotOn(frame1,Normalization( n_phys_sig.getVal() , RooAbsReal::NumEvent ) ,
      RooFit::DrawOption("F") , RooFit::FillColor(46) , Name("gx_phys") , Invisible() ) ;
      px.plotOn(frame1,Normalization( n_phys_bg.getVal() , RooAbsReal::NumEvent ) ,
      RooFit::DrawOption("F") , RooFit::FillColor(46) , AddTo("gx_phys")) ;

      but there is a problem with the resulting image which only occurs with filled PDFs. In this case, the background PDF is filled incorrectly, with a line originating at the origin seeming to demarcate the wrongly unfilled area.

      What's wrong?

      Thanks,
      Dan

      You can reproduce the error using this small piece of code:

      using namespace RooFit ;

      void example()
      {
      // Create observables
      RooRealVar x("x","x",-8,8) ;

      // Construct signal pdf
      RooRealVar mean("mean","mean",0,-8,8) ;
      RooRealVar sigma("sigma","sigma",0.3,0.1,10) ;
      RooGaussian gx("gx","gx",x,mean,sigma) ;

      // Construct background pdf
      RooRealVar a0("a0","a0",-0.01,-1,1) ;
      RooRealVar a1("a1","a1",0.0004,-1,1) ;
      RooChebychev px("px","px",x,RooArgSet(a0,a1)) ;

      // Combine
      RooRealVar n_phys_sig("n_phys_sig","",20,0,1000) ;
      RooRealVar n_phys_bg("n_phys_bg","",100,0,1000) ;
      RooAddPdf model("model","model",RooArgList(gx,px),RooArgList(n_phys_sig,n_phys_bg)) ;

      // Generate events
      RooDataSet *data = model.generate(RooArgSet,1000) ;

      // Perform fit of model to data
      model.fitTo(*data) ;

      // Plot model and data
      RooPlot* frame1 = x.frame(Bins(30),Title("Physics sample")) ;
      data->plotOn(frame1) ;
      gx.plotOn(frame1,Normalization( n_phys_sig.getVal() , RooAbsReal::NumEvent ) ,
      RooFit::DrawOption("F") , RooFit::FillColor(46) , Name("gx_phys") , Invisible() ) ;
      px.plotOn(frame1,Normalization( n_phys_bg.getVal() , RooAbsReal::NumEvent ) ,
      RooFit::DrawOption("F") , RooFit::FillColor(46) , AddTo("gx_phys")) ;
      data->plotOn(frame1) ;
      TCanvas* c = new TCanvas() ;
      frame1->Draw() ;
      }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              shageboe Stephan Hageboeck
              Reporter:
              johndan Daniel Johnson
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: