Check sPlot which pass some sWeight criteria

Hi,

I have performed fit using sPlot technique and calculated the sWeights for signal and background components. There is a straightforward way in which I can plot the variable with sWeight_signal (signal weight). But, I want to plot the variable which pass some signal weight selection criteria. Here is my sample script,

 RooDataSet *data = new RooDataSet("data","data",RooArgSet(mbc,lid_l1));
 for(int i=0;i<tree->GetEntries();i++){
   tree->GetEntry(i);
   mbc.setVal(s_mbc);
   lid_l1.setVal(s_lid_l1);
   data->add(RooArgSet(mbc,lid_l1));
    }

 //perform fit
 RooFitResult * r = (RooFitResult*)model.fitTo(*data," ", RooFit::Save(),SumW2Error(kTRUE));
  r->Print("v");
 
  // Create the sPlot data from the fit to mass.
  RooStats::SPlot* sDataX = new RooStats::SPlot("sData","An SPlot", *data, &model, RooArgList(nsig,nbkg));
  cout << "Yield of signal is " << nsig.getVal() << " From sWeights it is " << sDataX->GetYieldFromSWeight("nsig") <<endl;
  cout << "Yield of continuum is " << nbkg.getVal() << "  From sWeights it is " << sDataX->GetYieldFromSWeight("nbkg") <<endl;

RooDataSet * dataw_sig = new RooDataSet(data->GetName(),data->GetTitle(),data,*data->get(),"nsig_sw") ;
  RooPlot* frame_sig = lid_l1.frame(Bins(101)) ;
  frame_sig->SetTitle("sPlot for signal");
  dataw_sig->plotOn(frame_sig, RooFit::DataError(RooAbsData::SumW2) ) ;

Here, I have performed fit in “mbc” with nsig and nbkg as the number of signal and background events, and calculated the sWeight for signal. The sWeight_signal are projected in another variable “lid_l1”. But, I want to see lid_l1 distribution which have sWeight_signal greater than 0.5. Is there a way to do so?

Hi @CS_p,
I think @StephanH could help you with your usecase.
Cheers,
Vincenzo

RooAbsData::plotOn() actually takes a Cut object, so you can plot data after a cut. It’s missing in the documentation at the moment, but I will fix that.
An example of applying a cut is here:
https://root.cern.ch/doc/master/rf310__sliceplot_8C.html

There, only the data with a specific category state is plotted.

Hi @StephanH,

Thank you for the feedback.

dataw_sig->plotOn(frame_sig, RooFit::DataError(RooAbsData::SumW2),Cut("nsig_sw >0.5")) ;

The above line, solved the problem.

1 Like

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